use of org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException in project carbon-business-process by wso2.
the class CallBackServiceImpl method inferBindingInformation.
private void inferBindingInformation(Definition wsdlDefinition) throws HumanTaskDeploymentException {
Service serviceDef = wsdlDefinition.getService(serviceName);
if (serviceDef == null) {
throw new HumanTaskDeploymentException("Service element not found for callback service wsdl: " + serviceName);
}
Port port = serviceDef.getPort(portName);
if (port == null) {
throw new HumanTaskDeploymentException("Port: " + portName + " not found for Service: " + serviceName + " in the callback service wsdl");
}
binding = port.getBinding();
if (binding == null) {
throw new HumanTaskDeploymentException("Binding not found for port: " + portName + " and Service: " + serviceName + " in the callback service wsdl");
}
}
use of org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException in project carbon-business-process by wso2.
the class ArchiveBasedHumanTaskDeploymentUnitBuilder method buildWSDLs.
@Override
public void buildWSDLs() throws HumanTaskDeploymentException {
HashSet<Definition> tmpWsdlDefinitions = new HashSet<>();
URI baseUri = humantaskDir.toURI();
for (File file : FileUtils.directoryEntriesInPath(humantaskDir, wsdlFilter)) {
try {
URI uri = baseUri.relativize(file.toURI());
if (!uri.isAbsolute()) {
File f = new File(baseUri.getPath() + File.separator + uri.getPath());
URI abUri = f.toURI();
if (abUri.isAbsolute()) {
uri = abUri;
}
}
WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
reader.setFeature(HumanTaskConstants.JAVAX_WSDL_VERBOSE_MODE_KEY, false);
reader.setFeature("javax.wsdl.importDocuments", true);
Definition definition = reader.readWSDL(new HumanTaskWSDLLocator(uri));
if (definition != null) {
tmpWsdlDefinitions.add(definition);
}
} catch (WSDLException e) {
log.error("Error processing wsdl " + file.getName());
throw new HumanTaskDeploymentException(" Error processing wsdl ", e);
} catch (URISyntaxException e) {
log.error("Invalid uri in reading wsdl ", e);
throw new HumanTaskDeploymentException(" Invalid uri in reading wsdl ", e);
}
}
// Optimizing WSDLs imports. Using HashSet to avoid duplicate entices.
HashSet<Definition> optimizedDefinitions = new HashSet<>();
HTDeploymentConfigDocument htDeploymentConfigDocument = getHTDeploymentConfigDocument();
// Iterating Tasks.
THTDeploymentConfig.Task[] taskArray = htDeploymentConfigDocument.getHTDeploymentConfig().getTaskArray();
if (taskArray != null) {
for (THTDeploymentConfig.Task task : taskArray) {
QName taskService = task.getPublish().getService().getName();
Definition taskServiceDefinition = getDefinition(taskService, tmpWsdlDefinitions);
if (log.isDebugEnabled()) {
log.debug("Optimizing WSDL import for Task : " + task.getName());
}
if (taskServiceDefinition != null) {
optimizedDefinitions.add(taskServiceDefinition);
if (log.isDebugEnabled()) {
log.debug("Added WSDL for Task : " + task.getName() + ", Service : " + taskService + ", Imported/Total definition : " + optimizedDefinitions.size() + "/" + tmpWsdlDefinitions.size());
}
} else {
log.warn("Can't find valid WSDL definition for Task" + task.getName() + ", Service: " + taskService);
}
QName callbackService = task.getCallback().getService().getName();
Definition callbackServiceDefinition = getDefinition(callbackService, tmpWsdlDefinitions);
if (callbackServiceDefinition != null) {
optimizedDefinitions.add(callbackServiceDefinition);
if (log.isDebugEnabled()) {
log.debug("Added WSDL for Task : " + task.getName() + ", Callback Service : " + callbackService + ", Imported/Total definition : " + optimizedDefinitions.size() + "/" + tmpWsdlDefinitions.size());
}
} else {
log.warn("Can't find valid WSDL definition for Task : " + task.getName() + ", Callback Service" + callbackService);
}
}
}
// Iterating Notifications.
THTDeploymentConfig.Notification[] notificationsArray = htDeploymentConfigDocument.getHTDeploymentConfig().getNotificationArray();
if (notificationsArray != null) {
for (THTDeploymentConfig.Notification notification : notificationsArray) {
QName notificationService = notification.getPublish().getService().getName();
Definition notificationServiceDefinition = getDefinition(notificationService, tmpWsdlDefinitions);
if (notificationServiceDefinition != null) {
optimizedDefinitions.add(notificationServiceDefinition);
if (log.isDebugEnabled()) {
log.debug("Added WSDL for Task : " + notification.getName() + ", Callback Service : " + notificationService + ", Imported/Total definition : " + optimizedDefinitions.size() + "/" + tmpWsdlDefinitions.size());
}
} else {
log.warn("Can't find valid WSDL definition for Notification " + notification.getName() + ", Service: " + notificationService);
}
}
}
// Converting HashSet to ArrayList.
wsdlDefinitions = new ArrayList<>(optimizedDefinitions);
if (log.isDebugEnabled()) {
log.debug("Optimized Imported/Total definition : " + wsdlDefinitions.size() + "/" + tmpWsdlDefinitions.size());
}
}
Aggregations