| | |
| | | import org.opends.messages.Message; |
| | | import org.opends.server.admin.std.server.WorkflowElementCfg; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.SearchOperationBasis; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.Operation; |
| | | import org.opends.server.types.SearchResultReference; |
| | | import org.opends.server.types.CanceledOperationException; |
| | | |
| | | |
| | |
| | | private static Object registeredWorkflowElementsLock = new Object(); |
| | | |
| | | |
| | | // The original operation basis which has invoked the workflow. |
| | | // This original operation basis is only useful for the search |
| | | // operation, for the returned entry and returned reference to be |
| | | // processed before they are sent back to the client application. |
| | | private Operation originalOperationBasis = null; |
| | | |
| | | |
| | | // The parent of the workflow element (null if the workflow element is |
| | | // the root of the processing tree). |
| | | private WorkflowElement<?> parent = null; |
| | |
| | | |
| | | |
| | | /** |
| | | * Set the original operation basis which has invoked the workflow. |
| | | * |
| | | * @param operation the operation basis which has invoked the workflow |
| | | */ |
| | | protected void setOriginalOperationBasis(Operation operation) |
| | | { |
| | | this.originalOperationBasis = operation; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Set the parent of the current workflow element. |
| | | * |
| | | * @param parent the parent of the workflow element |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Used as a callback for workflow elements to indicate that the provided |
| | | * entry matches the search criteria and that additional processing should |
| | | * be performed to potentially send it back to the client. |
| | | * |
| | | * @param entry The entry that matches the search criteria and should be |
| | | * sent to the client. |
| | | * @param controls The set of controls to include with the entry (may be |
| | | * <CODE>null</CODE> if none are needed). |
| | | * |
| | | * @return <CODE>true</CODE> if the caller should continue processing the |
| | | * search request and sending additional entries and references, or |
| | | * <CODE>false</CODE> if not for some reason (e.g., the size limit |
| | | * has been reached or the search has been abandoned). |
| | | */ |
| | | public boolean returnEntry( |
| | | Entry entry, |
| | | List<Control> controls) |
| | | { |
| | | boolean result; |
| | | |
| | | // If the workflow element has a parent then send the entry |
| | | // to the parent, otherwise send the entry to the operation |
| | | // basis. The operation basis will be in charge of sending |
| | | // the entry to the client application. |
| | | if (parent == null) |
| | | { |
| | | SearchOperationBasis searchOperationBasis = |
| | | (SearchOperationBasis) originalOperationBasis; |
| | | result = searchOperationBasis.returnEntry(entry, controls); |
| | | } |
| | | else |
| | | { |
| | | result = parent.returnEntry(entry, controls); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Used as a callback for workflow elements to indicate that the provided |
| | | * search reference was encountered during processing and that additional |
| | | * processing should be performed to potentially send it back to the client. |
| | | * |
| | | * @param reference The search reference to send to the client. |
| | | * @param dn The DN related to the specified search reference. |
| | | * |
| | | * @return <CODE>true</CODE> if the caller should continue processing the |
| | | * search request and sending additional entries and references , or |
| | | * <CODE>false</CODE> if not for some reason (e.g., the size limit |
| | | * has been reached or the search has been abandoned). |
| | | */ |
| | | public boolean returnReference( |
| | | DN dn, |
| | | SearchResultReference reference) |
| | | { |
| | | boolean result; |
| | | |
| | | // If the workflow element has a parent then send the reference |
| | | // to the parent, otherwise send the reference to the operation |
| | | // basis. The operation basis will be in charge of sending |
| | | // the reference to the client application. |
| | | if (parent == null) |
| | | { |
| | | SearchOperationBasis searchOperationBasis = |
| | | (SearchOperationBasis) originalOperationBasis; |
| | | result = searchOperationBasis.returnReference(dn, reference); |
| | | } |
| | | else |
| | | { |
| | | result = parent.returnReference(dn, reference); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | } |
| | | |