use of org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException in project carbon-business-process by wso2.
the class HumanTaskStore method reloadExistingTaskVersions.
/**
* Reload existing task versions for a given deployment unit
* @param existingDeploymentUnitsForPackage
* @param archiveFile
* @param md5sum
* @throws HumanTaskDeploymentException
*/
public void reloadExistingTaskVersions(List<DeploymentUnitDAO> existingDeploymentUnitsForPackage, File archiveFile, String md5sum, boolean isMasterServer) throws Exception {
// deployment units list should not be null, having a safety check anyway
if (existingDeploymentUnitsForPackage == null) {
return;
}
if (log.isDebugEnabled()) {
log.debug("Reloading existing task versions for human task archive [ " + archiveFile.getName() + "]");
}
for (DeploymentUnitDAO dao : existingDeploymentUnitsForPackage) {
if (!isMasterServer) {
// We need to avoid deployment of already loaded packages
String versionedName = dao.getName();
List<QName> qNames = taskConfigurationsInTaskPackage.get(versionedName);
if (qNames != null && qNames.size() > 0) {
// This dao is already loaded
if (log.isDebugEnabled()) {
log.debug("This is already loaded package, skipping " + versionedName);
}
continue;
}
}
try {
File taskDirectory = findHumanTaskPackageInFileSystem(dao, archiveFile);
ArchiveBasedHumanTaskDeploymentUnitBuilder deploymentUnitBuilder = null;
if (log.isDebugEnabled()) {
log.debug("Loading task : " + dao.getName());
}
if (taskDirectory.exists()) {
// This is an existing task configuration
deploymentUnitBuilder = new ArchiveBasedHumanTaskDeploymentUnitBuilder(taskDirectory, tenantId, dao.getVersion(), dao.getPackageName(), dao.getChecksum());
} else if (dao.getStatus() == TaskPackageStatus.ACTIVE) {
// This node is a salve node and task is being reloaded or new version has been deployed on master
deploymentUnitBuilder = new ArchiveBasedHumanTaskDeploymentUnitBuilder(archiveFile, tenantId, dao.getVersion(), md5sum);
} else {
String errMsg = "Error loading task. Cannot find the task directory for retired task " + dao.getName();
log.error(errMsg);
throw new HumanTaskDeploymentException(errMsg);
}
// Check whether this is a new version deployment on a slave node
if (!isMasterServer && dao.getStatus() == TaskPackageStatus.ACTIVE) {
String currentDeployedVersion = loadedPackages.get(dao.getPackageName());
if (currentDeployedVersion != null && currentDeployedVersion.equals(dao.getName()) == false) {
// This is a new version on the salve node , retire the existing version
retireTaskPackageConfigurations(currentDeployedVersion);
}
}
HumanTaskDeploymentUnit taskDeploymentUnit = deploymentUnitBuilder.createNewHumanTaskDeploymentUnit();
taskDeploymentUnit.setTaskPackageStatus(dao.getStatus());
deploy(taskDeploymentUnit);
if (dao.getStatus() == TaskPackageStatus.ACTIVE) {
// Add the active package to the loaded packages
loadedPackages.put(dao.getPackageName(), dao.getName());
}
} catch (HumanTaskDeploymentException e) {
String errMsg = "Error loading the task configuration ";
log.error(errMsg, e);
throw e;
}
}
}
use of org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException in project carbon-business-process by wso2.
the class HumanTaskStore method validateServiceCreationForTaskConfig.
/**
* When wsdl errors are there in the package, we use a dummy service creation step to validate all required parts
* are available in the wsdl
* @param taskConfig Task configuration object for this task package
* @throws HumanTaskDeploymentException HumanTaskDeployment Exception is thrown when an error happens
*/
private void validateServiceCreationForTaskConfig(HumanTaskBaseConfiguration taskConfig) throws HumanTaskDeploymentException {
try {
WSDL11ToAxisServiceBuilder serviceBuilder = createAxisServiceBuilder(taskConfig, taskConfig.getWSDL());
serviceBuilder.populateService();
} catch (AxisFault e) {
String errorMsg = "Error validating wsdl " + e.getMessage();
throw new HumanTaskDeploymentException(errorMsg, e);
}
}
use of org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException in project carbon-business-process by wso2.
the class HumanTaskStore method validateTaskConfig.
/**
* Performance a test deployment of the task in order to avoid deployment issues due to invalid task packages
* @param humanTaskDU
* @return
* @throws HumanTaskDeploymentException
*/
public void validateTaskConfig(HumanTaskDeploymentUnit humanTaskDU) throws HumanTaskDeploymentException, AxisFault {
boolean validateTask = HumanTaskServiceComponent.getHumanTaskServer().getServerConfig().getEnableTaskValidationBeforeDeployment();
if (validateTask) {
TTask[] tasks = humanTaskDU.getTasks();
if (tasks != null) {
for (TTask task : tasks) {
QName taskQName = new QName(humanTaskDU.getNamespace(), task.getName());
TaskConfiguration taskConf = new TaskConfiguration(task, humanTaskDU.getTaskServiceInfo(taskQName), humanTaskDU.getHumanInteractionsDefinition(), humanTaskDU.getWSDLs(), humanTaskDU.getNamespace(), humanTaskDU.getName(), getTenantAxisConfig(), humanTaskDU.getPackageName(), humanTaskDU.getVersion(), humanTaskDU.getHumanTaskDefinitionFile());
if (taskConf.isErroneous()) {
throw new HumanTaskDeploymentException(taskConf.getDeploymentError());
}
validateServiceCreationForTaskConfig(taskConf);
}
}
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());
if (notificationConf.isErroneous()) {
throw new HumanTaskDeploymentException(notificationConf.getDeploymentError());
}
validateServiceCreationForTaskConfig(notificationConf);
}
}
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());
if (notificationConf.isErroneous()) {
throw new HumanTaskDeploymentException(notificationConf.getDeploymentError());
}
validateServiceCreationForTaskConfig(notificationConf);
}
}
return;
}
use of org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException in project carbon-business-process by wso2.
the class TaskConfiguration method initEndpointConfigs.
private void initEndpointConfigs() throws HumanTaskDeploymentException {
if (taskDeploymentConfiguration == null) {
throw new HumanTaskDeploymentException("Cannot find task deployment configuration.");
}
if (taskDeploymentConfiguration.getPublish() == null || taskDeploymentConfiguration.getPublish().getService() == null) {
throw new HumanTaskDeploymentException("Cannot find publish element in the htconfig.xml file.");
}
TPublish.Service service = taskDeploymentConfiguration.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);
}
if (taskDeploymentConfiguration.getCallback() == null || taskDeploymentConfiguration.getCallback().getService() == null) {
throw new HumanTaskDeploymentException("Cannot find callback element in the htconfig.xml file.");
}
TCallback.Service cbService = taskDeploymentConfiguration.getCallback().getService();
serviceEle = HumanTaskStoreUtils.getOMElement(cbService.toString());
endpointConfig = HumanTaskStoreUtils.getEndpointConfig(serviceEle);
if (endpointConfig != null) {
endpointConfig.setServiceName(cbService.getName().getLocalPart());
endpointConfig.setServicePort(cbService.getPort());
endpointConfig.setServiceNS(cbService.getName().getNamespaceURI());
endpointConfig.setBasePath(getHumanTaskDefinitionFile().getParentFile().getAbsolutePath());
endpointConfig.setServiceDescriptionLocation(cbService.getServiceDescriptionReference());
addEndpointConfiguration(endpointConfig);
}
}
use of org.wso2.carbon.humantask.core.deployment.HumanTaskDeploymentException in project carbon-business-process by wso2.
the class HumanTaskStore method deploy.
private void deploy(HumanTaskBaseConfiguration taskConfig) throws HumanTaskDeploymentException {
if (taskConfig != null) {
/**
* Creating AxisService for HI
*/
if (log.isDebugEnabled()) {
log.debug("Deploying task " + taskConfig.getName());
}
AxisService axisService;
Definition wsdlDef = taskConfig.getWSDL();
if (taskConfig instanceof TaskConfiguration) {
// to get the task id as response
wsdlDef.getPortType(taskConfig.getPortType()).getOperation(taskConfig.getOperation(), null, null).setStyle(OperationType.REQUEST_RESPONSE);
} else {
// ONE_WAY no feed back for NOTIFICATIONS
wsdlDef.getPortType(taskConfig.getPortType()).getOperation(taskConfig.getOperation(), null, null).setStyle(OperationType.ONE_WAY);
}
WSDL11ToAxisServiceBuilder serviceBuilder = createAxisServiceBuilder(taskConfig, wsdlDef);
try {
axisService = createAxisService(serviceBuilder, taskConfig);
ServiceConfigurationUtil.configureService(axisService, taskConfig.getEndpointConfiguration(taskConfig.getServiceName().getLocalPart(), taskConfig.getPortName()), getConfigContext());
ArrayList<AxisService> serviceList = new ArrayList<AxisService>();
serviceList.add(axisService);
DeploymentEngine.addServiceGroup(createServiceGroupForService(axisService), serviceList, null, null, getTenantAxisConfig());
if (log.isDebugEnabled()) {
log.debug(" Published axis2 service " + axisService.getName() + " for task " + taskConfig.getName());
}
} catch (AxisFault axisFault) {
String errMsg = "Error populating the service";
log.error(errMsg);
throw new HumanTaskDeploymentException(errMsg, axisFault);
}
}
}
Aggregations