use of org.wso2.carbon.humantask.client.api.IllegalArgumentFault 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);
}
}
use of org.wso2.carbon.humantask.client.api.IllegalArgumentFault 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;
}
use of org.wso2.carbon.humantask.client.api.IllegalArgumentFault 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);
}
}
use of org.wso2.carbon.humantask.client.api.IllegalArgumentFault in project carbon-business-process by wso2.
the class HTRenderingApiImpl method setTaskOutput.
public SetTaskOutputResponse setTaskOutput(URI taskIdentifier, SetOutputValuesType values) throws SetTaskOutputFaultException {
// Retrieve task information
TaskDAO htTaskDAO;
try {
htTaskDAO = getTaskDAO(taskIdentifier);
} catch (Exception e) {
log.error("Error occurred while retrieving task data", e);
throw new SetTaskOutputFaultException(e);
}
QName taskName = QName.valueOf(htTaskDAO.getName());
// Check hash map for output message template
Element outputMsgTemplate = outputTemplates.get(taskName);
if (outputMsgTemplate == null) {
try {
// generate output message template
int tenantID = CarbonContext.getThreadLocalCarbonContext().getTenantId();
HumanTaskBaseConfiguration htConf = HumanTaskServiceComponent.getHumanTaskServer().getTaskStoreManager().getHumanTaskStore(tenantID).getTaskConfiguration(taskName);
TaskConfiguration taskConf = (TaskConfiguration) htConf;
// retrieve response binding
Service callbackService = (Service) taskConf.getResponseWSDL().getServices().get(taskConf.getCallbackServiceName());
Port callbackPort = (Port) callbackService.getPorts().get(taskConf.getCallbackPortName());
String callbackBinding = callbackPort.getBinding().getQName().getLocalPart();
outputMsgTemplate = createSoapTemplate(taskConf.getResponseWSDL().getDocumentBaseURI(), taskConf.getResponsePortType().getLocalPart(), taskConf.getResponseOperation(), callbackBinding);
} catch (Exception e) {
log.error("Error occurred while output message template generation", e);
throw new SetTaskOutputFaultException("Unable to generate output message", e);
}
// add to the template HashMap
if (outputMsgTemplate != null) {
outputTemplates.put(taskName, outputMsgTemplate);
} else {
log.error("Unable to create output message template");
throw new SetTaskOutputFaultException("Unable to generate output message");
}
}
// update template with new values
try {
// TODO improve this section with caching
QName renderingType = new QName(htRenderingNS, "output", "wso2");
String outputRenderings = (String) taskOps.getRendering(taskIdentifier, renderingType);
SetOutputvalueType[] valueSet = values.getValue();
if (outputRenderings != null && valueSet.length > 0) {
Element outputRenderingsElement = DOMUtils.stringToDOM(outputRenderings);
// update elements in the template to create output xml
for (int i = 0; i < valueSet.length; i++) {
Element outElement = getOutputElementById(valueSet[i].getId(), outputRenderingsElement);
if (outElement != null) {
outputMsgTemplate = updateXmlByXpath(outputMsgTemplate, outElement.getElementsByTagNameNS(htRenderingNS, "xpath").item(0).getTextContent(), valueSet[i].getString(), outputRenderingsElement.getOwnerDocument());
}
}
} else {
log.error("Retrieving output renderings failed");
throw new SetTaskOutputFaultException("Retrieving output renderings failed");
}
// TODO what is this NCName?
taskOps.setOutput(taskIdentifier, new NCName("message"), DOMUtils.domToString(outputMsgTemplate));
} catch (IllegalArgumentFault illegalArgumentFault) {
// Error occurred while retrieving HT renderings and set output message
throw new SetTaskOutputFaultException(illegalArgumentFault);
} catch (SAXException e) {
log.error("Error occured while parsing output renderings", e);
throw new SetTaskOutputFaultException("Response message generation failed");
} catch (XPathExpressionException e) {
// Error occured while updating elements in the template to create output xml
log.error("XPath evaluation failed", e);
throw new SetTaskOutputFaultException("Internal Error Occurred");
} catch (Exception e) {
// Error occurred while updating template with new values
log.error("Error occurred while updating template with new values", e);
throw new SetTaskOutputFaultException("Internal Error Occurred");
}
SetTaskOutputResponse response = new SetTaskOutputResponse();
response.setSuccess(true);
return response;
}
use of org.wso2.carbon.humantask.client.api.IllegalArgumentFault 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;
}
Aggregations