use of org.wso2.carbon.humantask.core.integration.HumanTaskWSDLLocator 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;
}
use of org.wso2.carbon.humantask.core.integration.HumanTaskWSDLLocator 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