use of org.apache.axis2.databinding.types.URI in project carbon-business-process by wso2.
the class TransformerUtils method transformToSimpleQueryRow.
// /**
// * @param matchingTasks :
// * @return :
// */
// public static TTaskSimpleQueryResultSet createSimpleQueryResultSet(
// List<TaskDAO> matchingTasks) {
//
// TTaskSimpleQueryResultSet resultSet = new TTaskSimpleQueryResultSet();
//
// for (TaskDAO matchingTask : matchingTasks) {
// resultSet.addRow(transformToSimpleQueryRow(matchingTask));
// }
//
// return resultSet;
// }
/**
* @param matchingTask :
* @return :
*/
public static TTaskSimpleQueryResultRow transformToSimpleQueryRow(TaskDAO matchingTask) {
TTaskSimpleQueryResultRow row = new TTaskSimpleQueryResultRow();
row.setName(QName.valueOf(matchingTask.getDefinitionName()));
row.setTaskType(matchingTask.getType().toString());
try {
row.setId(new URI(matchingTask.getId().toString()));
} catch (URI.MalformedURIException e) {
throw new HumanTaskRuntimeException("The task id :[" + matchingTask.getId() + "] is invalid", e);
}
Calendar createdTime = Calendar.getInstance();
createdTime.setTime(matchingTask.getCreatedOn());
row.setCreatedTime(createdTime);
// set the task priority.
TPriority priority = new TPriority();
priority.setTPriority(BigInteger.valueOf(matchingTask.getPriority()));
row.setPriority(priority);
// set the task status
TStatus taskStatus = new TStatus();
taskStatus.setTStatus(matchingTask.getStatus().toString());
row.setStatus(taskStatus);
row.setPresentationSubject((transformPresentationSubject(CommonTaskUtil.getDefaultPresentationSubject(matchingTask))));
row.setPresentationName(transformPresentationName(CommonTaskUtil.getDefaultPresentationName(matchingTask)));
return row;
}
use of org.apache.axis2.databinding.types.URI in project carbon-business-process by wso2.
the class HTQueryBuildHelperImpl method getTaskDataById.
/**
* @param taskId
* @return all the task details for the given taskID
* @throws IllegalAccessFault
* @throws IllegalArgumentFault
* @throws IllegalStateFault
* @throws IllegalOperationFault
* @throws URI.MalformedURIException
*/
public String[] getTaskDataById(String taskId) throws IllegalAccessFault, IllegalArgumentFault, IllegalStateFault, IllegalOperationFault, URI.MalformedURIException {
String[] output = { "" };
List<String> outputList = new ArrayList<>();
TaskDAO task;
URI uri = new URI(taskId);
try {
final Long validatedTaskId = validateTaskId(uri);
task = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getScheduler().execTransaction(new Callable<TaskDAO>() {
public TaskDAO call() throws Exception {
HumanTaskEngine engine = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine();
HumanTaskDAOConnection daoConn = engine.getDaoConnectionFactory().getConnection();
TaskDAO task = daoConn.getTask(validatedTaskId);
return task;
}
});
} catch (Exception ex) {
throw new IllegalAccessFault(ex);
}
GenericHumanRoleDAO.GenericHumanRoleType[] genericHumanRoleTypes = GenericHumanRoleDAO.GenericHumanRoleType.values();
MessageDAO inputMessageDAO = task.getInputMessage();
MessageDAO outputMessageDAO = task.getOutputMessage();
String description = task.getTaskDescription("text/plain");
String titleString = String.format("%1$-" + 25 + "s", "Task Name") + ":" + task.getName();
outputList.add(titleString);
for (int i = 0; i < genericHumanRoleTypes.length; i++) {
List<OrganizationalEntityDAO> organizationalEntityDAOs = CommonTaskUtil.getOrgEntitiesForRole(task, genericHumanRoleTypes[i]);
if (organizationalEntityDAOs.size() > 0) {
String taskDataString = String.format("%1$-" + 25 + "s", genericHumanRoleTypes[i]) + ":";
for (int j = 0; j < organizationalEntityDAOs.size(); j++) {
taskDataString = taskDataString + organizationalEntityDAOs.get(j).getName() + " [" + organizationalEntityDAOs.get(j).getOrgEntityType() + "] ";
}
outputList.add(taskDataString);
}
}
if (description != null) {
String taskDescriptionString = String.format("%1$-" + 25 + "s", "Task Description") + ":" + task.getTaskDescription("text/plain");
outputList.add(taskDescriptionString);
}
Element inputBodyData = inputMessageDAO.getBodyData();
if (inputBodyData != null) {
String inputMsgStr = String.format("%1$-" + 25 + "s", "Task Input") + ":" + "\n" + DOMUtils.domToString(inputBodyData);
outputList.add(inputMsgStr);
}
if (outputMessageDAO != null) {
Element outputBodyData = outputMessageDAO.getBodyData();
if (outputBodyData != null) {
String outputMessageStr = String.format("%1$-" + 25 + "s", "Task Output") + ":" + "\n" + DOMUtils.domToString(outputBodyData);
outputList.add(outputMessageStr);
}
}
output = new String[outputList.size()];
int i = 0;
for (Object o : outputList) {
output[i++] = o.toString();
}
return output;
}
use of org.apache.axis2.databinding.types.URI in project carbon-business-process by wso2.
the class HumanTaskClientAPIServiceClient method setTaskOutput.
public void setTaskOutput(URI taskId, String payLoad) throws RemoteException, IllegalStateFault, IllegalOperationFault, IllegalAccessFault, IllegalArgumentFault, XMLStreamException {
String errMsg = "Error occurred while performing setTaskOutput operation";
try {
String decodedPayload = HumanTaskUIUtil.decodeHTML(payLoad);
stub.setOutput(taskId, new NCName("message"), decodedPayload);
} catch (RemoteException e) {
log.error(errMsg, e);
throw e;
} catch (IllegalStateFault e) {
log.error(errMsg, e);
throw e;
} catch (IllegalOperationFault e) {
log.error(errMsg, e);
throw e;
} catch (IllegalArgumentFault e) {
log.error(errMsg, e);
throw e;
} catch (IllegalAccessFault e) {
log.error(errMsg, e);
throw e;
}
}
use of org.apache.axis2.databinding.types.URI in project carbon-business-process by wso2.
the class HumanTaskStore method createAxisServiceBuilder.
// Creates the AxisServiceBuilder object.
private WSDL11ToAxisServiceBuilder createAxisServiceBuilder(HumanTaskBaseConfiguration taskConfig, Definition wsdlDef) {
WSDL11ToAxisServiceBuilder serviceBuilder = new WSDL11ToAxisServiceBuilder(wsdlDef, taskConfig.getServiceName(), taskConfig.getPortName());
String wsdlBaseURI = wsdlDef.getDocumentBaseURI();
serviceBuilder.setBaseUri(wsdlBaseURI);
/*we don't need custom resolvers since registry takes care of it*/
serviceBuilder.setCustomResolver(new DefaultURIResolver());
URI wsdlBase = null;
try {
wsdlBase = new URI(convertToVaildURI(wsdlBaseURI));
} catch (Exception e) {
String error = "Error occurred while creating AxisServiceBuilder.";
log.error(error);
}
serviceBuilder.setCustomWSDLResolver(new HumanTaskWSDLLocator(wsdlBase));
serviceBuilder.setServerSide(true);
return serviceBuilder;
}
use of org.apache.axis2.databinding.types.URI in project carbon-business-process by wso2.
the class RegistrationService method registerOperation.
@Override
public RegisterResponseType registerOperation(URI uri, EndpointReferenceType endpointReferenceType, OMElement[] omElements) {
if (!CoordinationConfiguration.getInstance().isRegistrationServiceEnabled()) {
log.warn("Registration request is discarded. Registration service is disabled in this server");
return null;
}
if (log.isDebugEnabled()) {
log.debug("Registration request received.");
}
URI htIdentifierURI = null;
try {
htIdentifierURI = new URI(HT_COORDINATION_PROTOCOL);
} catch (URI.MalformedURIException e) {
log.error(e);
}
if (!htIdentifierURI.equals(uri)) {
String errorMsg = "Received an invalid Protocol identifier: " + uri.toString();
log.error(errorMsg);
return null;
}
String participantProtocolService = "";
if (endpointReferenceType != null && endpointReferenceType.getAddress() != null) {
participantProtocolService = endpointReferenceType.getAddress().toString();
} else {
String errorMsg = "Received an invalid Participant Protocol Service";
log.error(errorMsg);
}
String messageID = "";
boolean foundB4PMessageID = false;
if (omElements.length > 0) {
for (OMElement omElement : omElements) {
if (B4P_NAMESPACE.equals(omElement.getNamespace().getNamespaceURI()) && B4P_IDENTIFIER.equals(omElement.getLocalName())) {
messageID = omElement.getText();
foundB4PMessageID = true;
break;
}
}
}
if (!foundB4PMessageID) {
String errorMsg = "no B4P messageID received";
log.error(errorMsg);
return null;
}
if (log.isDebugEnabled()) {
log.debug("Adding message ID: " + messageID + "-> " + participantProtocolService);
}
// Persisting data.
try {
persistData(messageID, participantProtocolService);
} catch (Exception e) {
log.error("Error occurred during persisting data", e);
return null;
}
// Sending Dummy Response.
RegisterResponseType responseType = new RegisterResponseType();
EndpointReferenceType epr = new EndpointReferenceType();
AttributedURI attributedURI = new AttributedURI();
URI b4pProtocolHandlerURI;
try {
// Setting Dummy Address here.
b4pProtocolHandlerURI = new URI(getB4PProtocolHandlerURI());
attributedURI.setAnyURI(b4pProtocolHandlerURI);
} catch (URI.MalformedURIException e) {
log.error("Error occurred while generating b4p protocol handler uri", e);
return null;
}
epr.setAddress(attributedURI);
OMFactory omFactory = OMAbstractFactory.getOMFactory();
OMNamespace b4pOMNamespace = omFactory.createOMNamespace(B4P_NAMESPACE, B4P_PREFIX);
// Dummy Endpoint
responseType.setCoordinatorProtocolService(epr);
OMElement identifierElement = omFactory.createOMElement(B4P_IDENTIFIER, b4pOMNamespace);
identifierElement.addChild(omFactory.createOMText(identifierElement, messageID));
responseType.addExtraElement(identifierElement);
return responseType;
}
Aggregations