use of org.wso2.carbon.bpel.skeleton.b4p.coordination.addressing.EndpointReferenceType 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