use of org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentUnit 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.HumanTaskDeploymentUnit in project carbon-business-process by wso2.
the class HumanTaskPackageRepository method addLatestArchiveToRegistryCollection.
/**
* Add latest human task package zip to the registry
*
* @param humanTaskDeploymentUnit
* @param humanTaskFile
* @throws HumanTaskStoreException
* @throws RegistryException
*/
private void addLatestArchiveToRegistryCollection(HumanTaskDeploymentUnit humanTaskDeploymentUnit, File humanTaskFile) throws HumanTaskStoreException, RegistryException {
FileInputStream fileInputStream = null;
try {
Resource latestHumanTaskArchive = configRegistry.newResource();
fileInputStream = new FileInputStream(humanTaskFile);
latestHumanTaskArchive.setContent(fileInputStream);
configRegistry.put(HumanTaskPackageRepositoryUtils.getHumanTaskPackageArchiveResourcePath(humanTaskDeploymentUnit.getPackageName()), latestHumanTaskArchive);
} catch (FileNotFoundException ex) {
String errMsg = "HumanTask package zip file couldn't found on given location " + humanTaskFile.getAbsolutePath();
throw new HumanTaskStoreException(errMsg, ex);
} catch (RegistryException ex) {
String errMsg = "Exception occurred while adding latest archive to registry collection";
throw new RegistryException(errMsg, ex);
} finally {
if (fileInputStream != null) {
try {
fileInputStream.close();
} catch (IOException e) {
log.warn("Cannot close file input stream.", e);
}
}
}
}
use of org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentUnit in project carbon-business-process by wso2.
the class HumanTaskPackageRepository method createHumanTaskPackageParentCollectionWithProperties.
/**
* Create parent collection to persisting human task package information. For example, if you deploy
* a human task archive called 'ClaimsApprovalTask.zip', we store information of that package in collection
* named 'ClaimsApprovalTask'. This will be the root for 'ClaimsApprovalTask' human task package information and
* there will several versions of this human task package in this registry collection which relates
* to the versions deployed in human task engine.
*
* @param humanTaskDeploymentUnit containing information on current deployment
* @throws RegistryException when there is a error accessing registry
*/
private void createHumanTaskPackageParentCollectionWithProperties(HumanTaskDeploymentUnit humanTaskDeploymentUnit) throws RegistryException {
Collection humanPackage = configRegistry.newCollection();
humanPackage.setProperty(HumanTaskConstants.HUMANTASK_PACKAGE_PROP_LATEST_CHECKSUM, humanTaskDeploymentUnit.getMd5sum());
if (log.isDebugEnabled()) {
log.debug(humanTaskDeploymentUnit.getPackageName() + " updating checksum: " + humanTaskDeploymentUnit.getMd5sum() + " in registry");
}
humanPackage.setProperty(HumanTaskConstants.HUMANTASK_PACKAGE_PROP_STATUS, String.valueOf(humanTaskDeploymentUnit.getTaskPackageStatus()));
humanPackage.setProperty(HumanTaskConstants.HUMANTASK_PACKAGE_PROP_LATEST_VERSION, Long.toString(humanTaskDeploymentUnit.getVersion()));
configRegistry.put(HumanTaskPackageRepositoryUtils.getResourcePathForHumanTaskPackage(humanTaskDeploymentUnit), humanPackage);
}
use of org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentUnit in project carbon-business-process by wso2.
the class HumanTaskDAOConnectionImpl method createDeploymentUnitDAO.
public DeploymentUnitDAO createDeploymentUnitDAO(HumanTaskDeploymentUnit deploymentUnit, int tenantId) {
String taskRelativePath = "repository" + File.separator + HumanTaskConstants.HUMANTASK_REPO_DIRECTORY + File.separator + tenantId + File.separator + deploymentUnit.getName();
DeploymentUnitDAO deploymentUnitDAO = new DeploymentUnit();
deploymentUnitDAO.setVersion(deploymentUnit.getVersion());
deploymentUnitDAO.setName(deploymentUnit.getName());
deploymentUnitDAO.setPackageName(deploymentUnit.getPackageName());
deploymentUnitDAO.setStatus(TaskPackageStatus.ACTIVE);
deploymentUnitDAO.setChecksum(deploymentUnit.getMd5sum());
deploymentUnitDAO.setDeploymentUnitDir(taskRelativePath);
deploymentUnitDAO.setDeployDate(new Date());
deploymentUnitDAO.setTenantId(tenantId);
entityManager.persist(deploymentUnitDAO);
return deploymentUnitDAO;
}
use of org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentUnit 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;
}
}
Aggregations