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);
}
}
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);
}
}
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();
}
}
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;
}
}
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");
}
Aggregations