Search in sources :

Example 6 with FaultException

use of org.apache.ode.bpel.common.FaultException in project carbon-business-process by wso2.

the class PeopleActivity method extractStandardElementType.

/**
 * In a peopleActivity element there can be exist only one standard element. eg - Standard Elements are 1. task 2.
 * localTask 3. remoteTask 4. remoteNotification etc.
 * <p/>
 * This method verify there's only one standard element exist and return the type of that standard element
 *
 * @return
 */
private String extractStandardElementType(Element parentElement) throws FaultException {
    NodeList taskList = parentElement.getChildNodes();
    String elementType = null;
    int standardElementCounter = 0;
    for (int i = 0; i < taskList.getLength(); i++) {
        if (taskList.item(i).getNodeType() == Node.ELEMENT_NODE) {
            try {
                elementType = getTypeOfStandardElement(taskList.item(i));
                standardElementCounter++;
                if (standardElementCounter > 1) {
                    throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "There is exist more than one standard child elements in " + BPEL4PeopleConstants.PEOPLE_ACTIVITY);
                }
            } catch (FaultException e) {
            // Do nothing
            }
        }
    }
    if (elementType != null) {
        return elementType;
    } else {
        throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "There is no standard child elements defined in " + BPEL4PeopleConstants.PEOPLE_ACTIVITY);
    }
}
Also used : FaultException(org.apache.ode.bpel.common.FaultException) NodeList(org.w3c.dom.NodeList) WSDL11Endpoint(org.apache.ode.bpel.epr.WSDL11Endpoint) UnifiedEndpoint(org.wso2.carbon.unifiedendpoint.core.UnifiedEndpoint)

Example 7 with FaultException

use of org.apache.ode.bpel.common.FaultException in project carbon-business-process by wso2.

the class PeopleActivity method getUnifiedEndpoint.

public UnifiedEndpoint getUnifiedEndpoint() throws FaultException {
    int tenantId = B4PServiceComponent.getBPELServer().getMultiTenantProcessStore().getTenantId(processId);
    ProcessConfigurationImpl processConf = (ProcessConfigurationImpl) B4PServiceComponent.getBPELServer().getMultiTenantProcessStore().getTenantsProcessStore(tenantId).getProcessConfiguration(processId);
    EndpointConfiguration epConf = processConf.getEndpointConfiguration(new WSDL11Endpoint(serviceName, servicePort));
    try {
        return epConf.getUnifiedEndpoint();
    } catch (AxisFault axisFault) {
        throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "Error occurred while reading UnifiedEndpoint for service " + serviceName, axisFault);
    }
}
Also used : WSDL11Endpoint(org.apache.ode.bpel.epr.WSDL11Endpoint) AxisFault(org.apache.axis2.AxisFault) FaultException(org.apache.ode.bpel.common.FaultException) ProcessConfigurationImpl(org.wso2.carbon.bpel.core.ode.integration.store.ProcessConfigurationImpl) EndpointConfiguration(org.wso2.carbon.bpel.common.config.EndpointConfiguration) WSDL11Endpoint(org.apache.ode.bpel.epr.WSDL11Endpoint) UnifiedEndpoint(org.wso2.carbon.unifiedendpoint.core.UnifiedEndpoint)

Example 8 with FaultException

use of org.apache.ode.bpel.common.FaultException in project carbon-business-process by wso2.

the class PeopleActivity method getSoapFactory.

public SOAPFactory getSoapFactory() throws FaultException {
    Binding binding = getBinding();
    ExtensibilityElement bindingType = SOAPHelper.getBindingExtension(binding);
    if (!(bindingType instanceof SOAPBinding || bindingType instanceof SOAP12Binding || bindingType instanceof HTTPBinding)) {
        throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "Service binding is not supported for service " + serviceName + " and port " + getServicePort());
    }
    if (bindingType instanceof SOAPBinding) {
        return OMAbstractFactory.getSOAP11Factory();
    } else {
        return OMAbstractFactory.getSOAP12Factory();
    }
}
Also used : HTTPBinding(javax.wsdl.extensions.http.HTTPBinding) SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) Binding(javax.wsdl.Binding) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) FaultException(org.apache.ode.bpel.common.FaultException) SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) HTTPBinding(javax.wsdl.extensions.http.HTTPBinding)

Example 9 with FaultException

use of org.apache.ode.bpel.common.FaultException in project carbon-business-process by wso2.

the class PeopleActivity method processStandardElement.

/**
 * Determine what the standard element is and process it
 *
 * @param peopleActivityElement
 * @throws FaultException
 */
private void processStandardElement(Element peopleActivityElement) throws FaultException {
    try {
        String elementType = extractStandardElementType(peopleActivityElement);
        if (elementType.equals(BPEL4PeopleConstants.PEOPLE_ACTIVITY_REMOTE_TASK)) {
            Node node = peopleActivityElement.getElementsByTagNameNS(BPEL4PeopleConstants.B4P_NAMESPACE, BPEL4PeopleConstants.PEOPLE_ACTIVITY_REMOTE_TASK).item(0);
            if (node == null) {
                throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "Namespace for element:" + elementType + " is not " + BPEL4PeopleConstants.B4P_NAMESPACE);
            }
            parseRemoteTask(node);
        } else if (elementType.equals(BPEL4PeopleConstants.PEOPLE_ACTIVITY_REMOTE_NOTIFICATION)) {
            Node node = peopleActivityElement.getElementsByTagNameNS(BPEL4PeopleConstants.B4P_NAMESPACE, BPEL4PeopleConstants.PEOPLE_ACTIVITY_REMOTE_NOTIFICATION).item(0);
            if (node == null) {
                throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "Namespace for element:" + elementType + " is not " + BPEL4PeopleConstants.B4P_NAMESPACE);
            }
            parseRemoteNotification(node);
        } else if (elementType.equals(BPEL4PeopleConstants.PEOPLE_ACTIVITY_LOCAL_NOTIFICATION)) {
            Node node = peopleActivityElement.getElementsByTagNameNS(BPEL4PeopleConstants.B4P_NAMESPACE, BPEL4PeopleConstants.PEOPLE_ACTIVITY_LOCAL_NOTIFICATION).item(0);
            if (node == null) {
                throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "Namespace for element:" + elementType + " is not " + BPEL4PeopleConstants.B4P_NAMESPACE);
            }
            parseLocalNotification(node);
        } else if (elementType.equals(BPEL4PeopleConstants.PEOPLE_ACTIVITY_LOCAL_TASK)) {
            Node node = peopleActivityElement.getElementsByTagNameNS(BPEL4PeopleConstants.B4P_NAMESPACE, BPEL4PeopleConstants.PEOPLE_ACTIVITY_LOCAL_TASK).item(0);
            if (node == null) {
                throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "Namespace for element:" + elementType + " is not " + BPEL4PeopleConstants.B4P_NAMESPACE);
            }
            parseLocalTask(node);
        }
    } catch (FaultException fex) {
        throw fex;
    }
}
Also used : FaultException(org.apache.ode.bpel.common.FaultException) Node(org.w3c.dom.Node)

Example 10 with FaultException

use of org.apache.ode.bpel.common.FaultException in project carbon-business-process by wso2.

the class SOAPHelper method parseResponseFeedback.

public static String parseResponseFeedback(org.apache.axiom.soap.SOAPBody soapBody) throws FaultException {
    /*  Sample feedback response
        *   <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
            <soapenv:Body><part><axis2ns3:correlation xmlns:axis2ns3="http://wso2.org/humantask/feedback">
            <axis2ns3:taskid>10001</axis2ns3:taskid></axis2ns3:correlation></part></soapenv:Body></soapenv:Envelope>
        * */
    Iterator<OMElement> srcParts = soapBody.getChildElements();
    if (srcParts.hasNext()) {
        OMElement srcPart = srcParts.next();
        if (!srcPart.getQName().equals(new QName(null, "part"))) {
            throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "Unexpected element in SOAP body: " + srcPart.toString());
        }
        OMElement hifb = srcPart.getFirstChildWithName(new QName(BPEL4PeopleConstants.B4P_NAMESPACE, BPEL4PeopleConstants.B4P_CORRELATION_HEADER));
        if (hifb == null) {
            throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "Unexpected element in SOAP body: " + srcPart.toString());
        }
        OMElement taskIDele = hifb.getFirstChildWithName(new QName(BPEL4PeopleConstants.B4P_NAMESPACE, BPEL4PeopleConstants.B4P_CORRELATION_HEADER_ATTRIBUTE));
        if (taskIDele == null) {
            throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "Unexpected element in SOAP body: " + srcPart.toString());
        }
        return taskIDele.getText();
    // Document doc = DOMUtils.newDocument();
    // Element destPart = doc.createElementNS(null, "part");
    // destPart.appendChild(doc.importNode(OMUtils.toDOM(srcPart), true));
    // message.setPart("part", destPart);
    }
    throw new FaultException(BPEL4PeopleConstants.B4P_FAULT, "TaskID not found in the feedback message");
}
Also used : FaultException(org.apache.ode.bpel.common.FaultException) QName(javax.xml.namespace.QName) OMElement(org.apache.axiom.om.OMElement)

Aggregations

FaultException (org.apache.ode.bpel.common.FaultException)10 QName (javax.xml.namespace.QName)3 WSDL11Endpoint (org.apache.ode.bpel.epr.WSDL11Endpoint)3 UnifiedEndpoint (org.wso2.carbon.unifiedendpoint.core.UnifiedEndpoint)3 Binding (javax.wsdl.Binding)2 Port (javax.wsdl.Port)2 Service (javax.wsdl.Service)2 HTTPBinding (javax.wsdl.extensions.http.HTTPBinding)2 SOAPBinding (javax.wsdl.extensions.soap.SOAPBinding)2 SOAP12Binding (javax.wsdl.extensions.soap12.SOAP12Binding)2 AxisFault (org.apache.axis2.AxisFault)2 Node (org.w3c.dom.Node)2 NodeList (org.w3c.dom.NodeList)2 SOAPAddressImpl (com.ibm.wsdl.extensions.soap.SOAPAddressImpl)1 SocketException (java.net.SocketException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 UUID (java.util.UUID)1 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)1 OMElement (org.apache.axiom.om.OMElement)1