use of org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException in project carbon-business-process by wso2.
the class HumanTaskStore method createCallBackService.
private void createCallBackService(TaskConfiguration taskConf) throws HumanTaskDeploymentException {
EndpointConfiguration endpointConfig = taskConf.getEndpointConfiguration(taskConf.getCallbackServiceName().getLocalPart(), taskConf.getCallbackPortName());
CallBackServiceImpl callbackService = new CallBackServiceImpl(tenantId, taskConf.getCallbackServiceName(), taskConf.getCallbackPortName(), taskConf.getName(), taskConf.getResponseWSDL(), taskConf.getResponseOperation(), endpointConfig);
taskConf.setCallBackService(callbackService);
}
use of org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException in project carbon-business-process by wso2.
the class HumanTaskStore method deploy.
/**
* This will simply deploy the new task and will not perform removal of existing tasks, which should be done prior to
* deploying this task
* @param humanTaskDU
* @return List of task configuration Qnames deployed
* @throws HumanTaskDeploymentException
*/
public List<QName> deploy(HumanTaskDeploymentUnit humanTaskDU) throws HumanTaskDeploymentException {
List<QName> taskConfigsInPackage = new ArrayList<QName>();
TTask[] tasks = humanTaskDU.getTasks();
List<HumanTaskBaseConfiguration> configurations = new ArrayList<HumanTaskBaseConfiguration>();
if (tasks != null) {
for (TTask task : tasks) {
QName taskQName = new QName(humanTaskDU.getNamespace(), task.getName());
if (log.isDebugEnabled()) {
log.debug(" Adding task " + task.getName() + "to task configuration");
}
TaskConfiguration taskConf = new TaskConfiguration(task, humanTaskDU.getTaskServiceInfo(taskQName), humanTaskDU.getHumanInteractionsDefinition(), humanTaskDU.getWSDLs(), humanTaskDU.getNamespace(), humanTaskDU.getName(), getTenantAxisConfig(), humanTaskDU.getPackageName(), humanTaskDU.getVersion(), humanTaskDU.getHumanTaskDefinitionFile());
taskConf.setPackageStatus(humanTaskDU.getTaskPackageStatus());
configurations.add(taskConf);
if (!taskConf.isErroneous()) {
createCallBackService(taskConf);
if (taskConf.getPackageStatus() == TaskPackageStatus.ACTIVE) {
deploy(taskConf);
// activeTaskConfigurationQNameMap.put(taskQName, taskConf.getName());
}
}
}
}
TNotification[] notifications = humanTaskDU.getNotifications();
if (notifications != null) {
for (TNotification notification : notifications) {
QName notificationQName = new QName(humanTaskDU.getNamespace(), notification.getName());
NotificationConfiguration notificationConf = new NotificationConfiguration(notification, humanTaskDU.getNotificationServiceInfo(notificationQName), humanTaskDU.getHumanInteractionsDefinition(), humanTaskDU.getWSDLs(), humanTaskDU.getNamespace(), humanTaskDU.getName(), getTenantAxisConfig(), humanTaskDU.getPackageName(), humanTaskDU.getVersion(), humanTaskDU.getHumanTaskDefinitionFile());
notificationConf.setPackageStatus(humanTaskDU.getTaskPackageStatus());
configurations.add(notificationConf);
if (!notificationConf.isErroneous()) {
// Deploy the axis2 service only for the active version of the task/notification
if (notificationConf.getPackageStatus() == TaskPackageStatus.ACTIVE) {
deploy(notificationConf);
// activeTaskConfigurationQNameMap.put(notificationQName, notificationConf.getName());
}
}
}
}
// condition if a service name is deployed with same name outside of this task package
for (HumanTaskBaseConfiguration configuration : configurations) {
taskConfigurations.add(configuration);
taskBaseConfigurationHashMap.put(configuration.getName(), configuration);
taskConfigsInPackage.add(configuration.getName());
if (configuration.getPackageStatus() == TaskPackageStatus.ACTIVE) {
activeTaskConfigurationQNameMap.put(configuration.getDefinitionName(), configuration.getName());
}
}
for (TNotification inlineNotification : humanTaskDU.getInlineNotifications()) {
QName notificationQName = new QName(humanTaskDU.getNamespace(), inlineNotification.getName());
NotificationConfiguration notificationConf = new NotificationConfiguration(inlineNotification, humanTaskDU.getNotificationServiceInfo(notificationQName), humanTaskDU.getHumanInteractionsDefinition(), humanTaskDU.getWSDLs(), humanTaskDU.getNamespace(), humanTaskDU.getName(), getTenantAxisConfig(), humanTaskDU.getPackageName(), humanTaskDU.getVersion(), humanTaskDU.getHumanTaskDefinitionFile());
notificationConf.setPackageStatus(humanTaskDU.getTaskPackageStatus());
taskConfigurations.add(notificationConf);
taskConfigsInPackage.add(notificationConf.getName());
taskBaseConfigurationHashMap.put(notificationConf.getName(), notificationConf);
if (notificationConf.getPackageStatus() == TaskPackageStatus.ACTIVE) {
activeTaskConfigurationQNameMap.put(notificationQName, notificationConf.getName());
}
}
taskConfigurationsInTaskPackage.put(humanTaskDU.getName(), taskConfigsInPackage);
return taskConfigsInPackage;
}
use of org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException in project carbon-business-process by wso2.
the class NotificationConfiguration method initEndpointConfigs.
private void initEndpointConfigs() throws HumanTaskDeploymentException {
TPublish.Service service = notificationDeploymentConfiguration.getPublish().getService();
OMElement serviceEle;
serviceEle = HumanTaskStoreUtils.getOMElement(service.toString());
EndpointConfiguration endpointConfig = HumanTaskStoreUtils.getEndpointConfig(serviceEle);
if (endpointConfig != null) {
endpointConfig.setServiceName(service.getName().getLocalPart());
endpointConfig.setServicePort(service.getPort());
endpointConfig.setServiceNS(service.getName().getNamespaceURI());
endpointConfig.setBasePath(getHumanTaskDefinitionFile().getParentFile().getAbsolutePath());
endpointConfig.setServiceDescriptionLocation(service.getServiceDescriptionReference());
addEndpointConfiguration(endpointConfig);
}
}
use of org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException in project carbon-business-process by wso2.
the class HumanTaskStore method createNewDeploymentUnit.
/**
* Creates a new deployment unit from the given information
* @param humanTaskFile
* @param tenantId
* @param version
* @param md5sum
* @return
* @throws HumanTaskDeploymentException
*/
public HumanTaskDeploymentUnit createNewDeploymentUnit(File humanTaskFile, int tenantId, long version, String md5sum) throws HumanTaskDeploymentException {
try {
ArchiveBasedHumanTaskDeploymentUnitBuilder builder = new ArchiveBasedHumanTaskDeploymentUnitBuilder(humanTaskFile, tenantId, version, md5sum);
HumanTaskDeploymentUnit newHumanTaskDeploymentUnit = builder.createNewHumanTaskDeploymentUnit();
return newHumanTaskDeploymentUnit;
} catch (HumanTaskDeploymentException deploymentException) {
if (log.isDebugEnabled()) {
log.debug("humanTask:" + humanTaskFile.getName() + " deployment failed, removing the extracted human task directory.");
}
String versionedName = FilenameUtils.removeExtension(humanTaskFile.getName()) + HumanTaskConstants.VERSION_SEPARATOR + version;
deleteHumanTaskPackageFromRepo(versionedName);
throw deploymentException;
}
}
use of org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException in project carbon-business-process by wso2.
the class HumanTaskStore method findHumanTaskPackageInFileSystem.
/**
* This method provides the extracted human task package location in file system.
* If human task package does not exist in file system then package will be exported from registry.
* If human task package does not exist in registry then package will be imported to registry from file system.
* If registry and file location don't have extracted human task package content then exception will be thrown
*
* @param dudao
* @return File
* @throws HumanTaskDeploymentException
*/
private File findHumanTaskPackageInFileSystem(DeploymentUnitDAO dudao, File archiveFile) throws Exception {
String duName = dudao.getName();
log.info("Looking for HumanTask package in file system for deployment unit " + duName);
File humanTaskDUDirectory = new File(humanTaskDeploymentRepo, duName);
String registryCollectionPath = HumanTaskPackageRepositoryUtils.getResourcePathForHumanTaskPackageContent(dudao.getPackageName(), dudao.getName());
try {
if (humanTaskDUDirectory.exists()) {
if (!tenantConfigRegistry.resourceExists(registryCollectionPath)) {
// Import human task package content to registry from file system
repository.restoreHumanTaskPackageContentInRegistry(dudao, archiveFile);
}
return humanTaskDUDirectory;
} else {
if (tenantConfigRegistry.resourceExists(registryCollectionPath)) {
if (!humanTaskDUDirectory.exists() && !humanTaskDUDirectory.mkdirs()) {
String errMsg = "Error creating HumanTask deployment unit repository for " + "tenant " + tenantId;
log.error(errMsg);
log.error("Failed to load HumanTask deployment unit " + duName + " due to above error.");
throw new HumanTaskDeploymentException(errMsg);
}
// Export human task package content from registry to file system
RegistryClientUtils.exportFromRegistry(humanTaskDUDirectory, registryCollectionPath, tenantConfigRegistry);
return humanTaskDUDirectory;
} else {
String errMsg = "Expected resource: " + registryCollectionPath + " not found in the registry";
log.error(errMsg);
throw new HumanTaskDeploymentException(errMsg);
}
}
} catch (RegistryException re) {
String errMsg = "Error while exporting deployment unit: " + duName + " to file system from the " + "registry.";
log.error(errMsg, re);
throw new HumanTaskDeploymentException(errMsg, re);
}
}
Aggregations