Search in sources :

Example 11 with IllegalAccessFault

use of org.wso2.carbon.humantask.client.api.IllegalAccessFault in project carbon-business-process by wso2.

the class TaskOperationsImpl method deleteComment.

/**
 * Deletes the identified comment.
 * @param taskIdURI : task identifier
 * @param commentId : comment identifier
 * @throws IllegalStateFault
 * @throws IllegalOperationFault
 * @throws IllegalArgumentFault
 * @throws IllegalAccessFault
 */
public void deleteComment(final URI taskIdURI, final URI commentId) throws IllegalStateFault, IllegalOperationFault, IllegalArgumentFault, IllegalAccessFault {
    try {
        final Long taskId = validateTaskId(taskIdURI);
        HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getScheduler().execTransaction(new Callable<Object>() {

            public Object call() throws Exception {
                DeleteComment deleteComment = new DeleteComment(getCaller(), taskId, new Long(commentId.toString()));
                deleteComment.execute();
                return null;
            }
        });
    } catch (Exception ex) {
        handleException(ex);
    }
}
Also used : DeleteComment(org.wso2.carbon.humantask.core.engine.commands.DeleteComment) HumanTaskIllegalArgumentException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalArgumentException) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) HumanTaskIllegalStateException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalStateException) HumanTaskIllegalOperationException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalOperationException) UserStoreException(org.wso2.carbon.user.core.UserStoreException) HumanTaskException(org.wso2.carbon.humantask.core.engine.HumanTaskException) HumanTaskIllegalAccessException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)

Example 12 with IllegalAccessFault

use of org.wso2.carbon.humantask.client.api.IllegalAccessFault in project carbon-business-process by wso2.

the class TaskOperationsImpl method addAttachment.

/**
 * Add attachment to a task. Returns an identifier for the attachment.
 * @param taskIdentifier : task identifier
 * @param name : attachment name
 * @param accessType : access type
 * @param contentType : content type
 * @param attachment : attachment ID (String)
 * @return
 * @throws IllegalStateFault
 * @throws IllegalOperationFault
 * @throws IllegalArgumentFault
 * @throws IllegalAccessFault
 */
public boolean addAttachment(URI taskIdentifier, String name, String accessType, String contentType, Object attachment) throws IllegalStateFault, IllegalOperationFault, IllegalArgumentFault, IllegalAccessFault {
    final Long taskId = validateTaskId(taskIdentifier);
    final String attachmentID = (String) attachment;
    try {
        Boolean isAdded = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getScheduler().execTransaction(new Callable<Boolean>() {

            public Boolean call() throws Exception {
                HumanTaskEngine engine = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine();
                HumanTaskDAOConnection daoConn = engine.getDaoConnectionFactory().getConnection();
                TaskDAO taskDAO = daoConn.getTask(taskId);
                validateTaskTenant(taskDAO);
                try {
                    boolean isAdded = taskDAO.addAttachment(TransformerUtils.generateAttachmentDAOFromID(taskDAO, attachmentID));
                    if (!isAdded) {
                        throw new HumanTaskException("Attachment with id: " + attachmentID + "was not associated " + "task with id:" + taskId);
                    }
                    return isAdded;
                } catch (HumanTaskException ex) {
                    String errMsg = "getAttachmentInfos operation failed. Reason: ";
                    log.error(errMsg + ex.getLocalizedMessage(), ex);
                    throw ex;
                }
            }
        });
        return isAdded;
    } catch (Exception ex) {
        handleException(ex);
    }
    return false;
}
Also used : HumanTaskEngine(org.wso2.carbon.humantask.core.engine.HumanTaskEngine) TaskDAO(org.wso2.carbon.humantask.core.dao.TaskDAO) HumanTaskDAOConnection(org.wso2.carbon.humantask.core.dao.HumanTaskDAOConnection) HumanTaskIllegalArgumentException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalArgumentException) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) HumanTaskIllegalStateException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalStateException) HumanTaskIllegalOperationException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalOperationException) UserStoreException(org.wso2.carbon.user.core.UserStoreException) HumanTaskException(org.wso2.carbon.humantask.core.engine.HumanTaskException) HumanTaskIllegalAccessException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException) HumanTaskException(org.wso2.carbon.humantask.core.engine.HumanTaskException)

Example 13 with IllegalAccessFault

use of org.wso2.carbon.humantask.client.api.IllegalAccessFault in project carbon-business-process by wso2.

the class TaskOperationsImpl method deleteOutput.

/**
 * Deletes the output data of the task.
 * @param taskIdURI : task identifier
 * @throws IllegalStateFault
 * @throws IllegalOperationFault
 * @throws IllegalArgumentFault
 * @throws IllegalAccessFault
 */
public void deleteOutput(final URI taskIdURI) throws IllegalStateFault, IllegalOperationFault, IllegalArgumentFault, IllegalAccessFault {
    try {
        final Long taskId = validateTaskId(taskIdURI);
        HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getScheduler().execTransaction(new Callable<Object>() {

            public Object call() throws Exception {
                DeleteOutput deleteOutput = new DeleteOutput(getCaller(), taskId);
                deleteOutput.execute();
                return null;
            }
        });
    } catch (Exception ex) {
        handleException(ex);
    }
}
Also used : DeleteOutput(org.wso2.carbon.humantask.core.engine.commands.DeleteOutput) HumanTaskIllegalArgumentException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalArgumentException) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) HumanTaskIllegalStateException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalStateException) HumanTaskIllegalOperationException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalOperationException) UserStoreException(org.wso2.carbon.user.core.UserStoreException) HumanTaskException(org.wso2.carbon.humantask.core.engine.HumanTaskException) HumanTaskIllegalAccessException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)

Example 14 with IllegalAccessFault

use of org.wso2.carbon.humantask.client.api.IllegalAccessFault in project carbon-business-process by wso2.

the class HTRenderingApiImpl method getRenderingInputElements.

/**
 * @param taskIdentifier : interested task identifier
 * @return set of input renderings wrapped within InputType
 * @throws IllegalArgumentFault : error occured while retrieving renderings from task definition
 * @throws IOException          If an error occurred while reading from the input source
 * @throws SAXException         If the content in the input source is invalid
 */
private InputType getRenderingInputElements(URI taskIdentifier) throws IllegalArgumentFault, IOException, SAXException, IllegalOperationFault, IllegalAccessFault, IllegalStateFault, XPathExpressionException {
    // TODO Chaching : check cache against task id for input renderings
    QName renderingType = new QName(htRenderingNS, "input", "wso2");
    String inputRenderings = (String) taskOps.getRendering(taskIdentifier, renderingType);
    // Create input element
    InputType renderingInputs = null;
    // check availability of input renderings
    if (inputRenderings != null && inputRenderings.length() > 0) {
        // parse input renderings
        Element inputRenderingsElement = DOMUtils.stringToDOM(inputRenderings);
        // retrieve input elements
        NodeList inputElementList = inputRenderingsElement.getElementsByTagNameNS(htRenderingNS, "element");
        Element taskInputMsgElement = DOMUtils.stringToDOM((String) taskOps.getInput(taskIdentifier, null));
        if (inputElementList != null && inputElementList.getLength() > 0) {
            // hold number of input element
            int inputElementNum = inputElementList.getLength();
            InputElementType[] inputElements = new InputElementType[inputElementNum];
            for (int i = 0; i < inputElementNum; i++) {
                Element tempElement = (Element) inputElementList.item(i);
                String label = tempElement.getElementsByTagNameNS(htRenderingNS, "label").item(0).getTextContent();
                String value = tempElement.getElementsByTagNameNS(htRenderingNS, "value").item(0).getTextContent();
                // if the value starts with '/' then considered as an xpath and evaluate over received Input Message
                if (value.startsWith("/") && taskInputMsgElement != null) {
                    // value represents xpath. evaluate against the input message
                    String xpathValue = evaluateXPath(value, taskInputMsgElement, inputRenderingsElement.getOwnerDocument());
                    if (xpathValue != null) {
                        value = xpathValue;
                    }
                }
                inputElements[i] = new InputElementType();
                inputElements[i].setLabel(label);
                inputElements[i].setValue(value);
            }
            renderingInputs = new InputType();
            renderingInputs.setElement(inputElements);
        // TODO cache renderingInputs against task instance id
        }
    }
    return renderingInputs;
}
Also used : InputElementType(org.wso2.carbon.humantask.rendering.api.InputElementType) InputType(org.wso2.carbon.humantask.rendering.api.InputType) QName(javax.xml.namespace.QName) Element(org.w3c.dom.Element) NodeList(org.w3c.dom.NodeList)

Example 15 with IllegalAccessFault

use of org.wso2.carbon.humantask.client.api.IllegalAccessFault in project carbon-business-process by wso2.

the class TaskOperationsImpl method stop.

/**
 * Cancel/stop the processing of the task. The task returns to the Reserved state.
 *
 * @param taskId : task identifier
 * @throws IllegalStateFault
 * @throws IllegalOperationFault
 * @throws IllegalArgumentFault
 * @throws IllegalAccessFault
 */
public void stop(final URI taskId) throws IllegalStateFault, IllegalOperationFault, IllegalArgumentFault, IllegalAccessFault {
    try {
        validateTaskId(taskId);
        HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getScheduler().execTransaction(new Callable<Object>() {

            public Object call() throws Exception {
                HumanTaskCommand stop = new Stop(getCaller(), new Long(taskId.toString()));
                stop.execute();
                return null;
            }
        });
    } catch (Exception ex) {
        handleException(ex);
    }
}
Also used : Stop(org.wso2.carbon.humantask.core.engine.commands.Stop) HumanTaskCommand(org.wso2.carbon.humantask.core.engine.HumanTaskCommand) HumanTaskIllegalArgumentException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalArgumentException) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) HumanTaskIllegalStateException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalStateException) HumanTaskIllegalOperationException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalOperationException) UserStoreException(org.wso2.carbon.user.core.UserStoreException) HumanTaskException(org.wso2.carbon.humantask.core.engine.HumanTaskException) HumanTaskIllegalAccessException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)

Aggregations

HumanTaskException (org.wso2.carbon.humantask.core.engine.HumanTaskException)23 HumanTaskIllegalAccessException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException)23 HumanTaskIllegalArgumentException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalArgumentException)23 HumanTaskIllegalOperationException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalOperationException)23 HumanTaskIllegalStateException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalStateException)23 HumanTaskRuntimeException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)23 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)23 UserStoreException (org.wso2.carbon.user.core.UserStoreException)23 Element (org.w3c.dom.Element)8 HumanTaskCommand (org.wso2.carbon.humantask.core.engine.HumanTaskCommand)5 HumanTaskEngine (org.wso2.carbon.humantask.core.engine.HumanTaskEngine)4 HumanTaskDAOConnection (org.wso2.carbon.humantask.core.dao.HumanTaskDAOConnection)3 TaskDAO (org.wso2.carbon.humantask.core.dao.TaskDAO)3 QName (javax.xml.namespace.QName)2 URI (org.apache.axis2.databinding.types.URI)2 NodeList (org.w3c.dom.NodeList)2 IllegalAccessFault (org.wso2.carbon.humantask.client.api.IllegalAccessFault)2 Complete (org.wso2.carbon.humantask.core.engine.commands.Complete)2 Start (org.wso2.carbon.humantask.core.engine.commands.Start)2 Callable (java.util.concurrent.Callable)1