Search in sources :

Example 16 with URI

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;
}
Also used : Calendar(java.util.Calendar) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException) URI(org.apache.axis2.databinding.types.URI)

Example 17 with URI

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;
}
Also used : IllegalAccessFault(org.wso2.carbon.humantask.client.api.IllegalAccessFault) HumanTaskEngine(org.wso2.carbon.humantask.core.engine.HumanTaskEngine) Element(org.w3c.dom.Element) URI(org.apache.axis2.databinding.types.URI) Callable(java.util.concurrent.Callable)

Example 18 with URI

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;
    }
}
Also used : RemoteException(java.rmi.RemoteException) NCName(org.apache.axis2.databinding.types.NCName)

Example 19 with URI

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;
}
Also used : HumanTaskWSDLLocator(org.wso2.carbon.humantask.core.integration.HumanTaskWSDLLocator) DefaultURIResolver(org.apache.ws.commons.schema.resolver.DefaultURIResolver) WSDL11ToAxisServiceBuilder(org.apache.axis2.description.WSDL11ToAxisServiceBuilder) URI(java.net.URI) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) HumanTaskDeploymentException(org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)

Example 20 with URI

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;
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) AttributedURI(org.wso2.carbon.bpel.skeleton.b4p.coordination.addressing.AttributedURI) OMNamespace(org.apache.axiom.om.OMNamespace) RegisterResponseType(org.wso2.carbon.bpel.skeleton.b4p.coordination.RegisterResponseType) EndpointReferenceType(org.wso2.carbon.bpel.skeleton.b4p.coordination.addressing.EndpointReferenceType) OMElement(org.apache.axiom.om.OMElement) AttributedURI(org.wso2.carbon.bpel.skeleton.b4p.coordination.addressing.AttributedURI) URI(org.apache.axis2.databinding.types.URI)

Aggregations

AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)16 SynapseConfiguration (org.apache.synapse.config.SynapseConfiguration)15 OMElement (org.apache.axiom.om.OMElement)13 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)13 Parameter (org.apache.axis2.description.Parameter)11 SynapseEnvironment (org.apache.synapse.core.SynapseEnvironment)10 URI (java.net.URI)9 Axis2SynapseEnvironment (org.apache.synapse.core.axis2.Axis2SynapseEnvironment)9 Test (org.junit.Test)9 EndpointReference (org.apache.axis2.addressing.EndpointReference)8 URI (org.apache.axis2.databinding.types.URI)7 IOException (java.io.IOException)5 SynapseException (org.apache.synapse.SynapseException)5 MalformedURLException (java.net.MalformedURLException)4 Calendar (java.util.Calendar)4 HumanTaskRuntimeException (org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)4 InputStream (java.io.InputStream)3 URISyntaxException (java.net.URISyntaxException)3 URL (java.net.URL)3 HashMap (java.util.HashMap)3