Skip to content

Commit 1c27a67

Browse files
author
Burak Serdar
committed
add hasHooks()
1 parent a07035e commit 1c27a67

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

crud/src/main/java/com/redhat/lightblue/hooks/HookManager.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,23 @@ public void clear() {
130130
queuedHooks.clear();
131131
}
132132

133+
/**
134+
* Returns true if there are any hooks for this operation
135+
*/
136+
public boolean hasHooks(CRUDOperationContext ctx,CRUDOperation op) {
137+
EntityMetadata md = ctx.getEntityMetadata(ctx.getEntityName());
138+
List<Hook> mdHooks = md.getHooks().getHooks();
139+
for (Hook h : mdHooks) {
140+
switch (op) {
141+
case INSERT: if(h.isInsert()) return true;
142+
case UPDATE: if(h.isUpdate()) return true;
143+
case DELETE: if(h.isDelete()) return true;
144+
case FIND: if(h.isFind()) return true;
145+
}
146+
}
147+
return false;
148+
}
149+
133150
/**
134151
* Queues hooks for the operation represented by the operation context.
135152
*

0 commit comments

Comments
 (0)