use of org.wso2.carbon.user.api.Tenant in project carbon-business-process by wso2.
the class HumanTaskAppDeployer method undeployArtifacts.
/**
* Check the artifact type and if it is a HumanTask, delete the file from the HumanTask
* deployment hot folder
*
* @param carbonApp - CarbonApplication instance to check for HumanTask artifacts
* @param axisConfig - - axisConfig of the current tenant
*/
public void undeployArtifacts(CarbonApplication carbonApp, AxisConfiguration axisConfig) {
List<Artifact.Dependency> artifacts = carbonApp.getAppConfig().getApplicationArtifact().getDependencies();
// loop through all dependencies
for (Artifact.Dependency dep : artifacts) {
Deployer deployer;
Artifact artifact = dep.getArtifact();
if (artifact == null) {
continue;
}
if (HUMANTASK_TYPE.equals(artifact.getType())) {
deployer = AppDeployerUtils.getArtifactDeployer(axisConfig, HUMANTASK_DIR, "zip");
} else {
continue;
}
List<CappFile> files = artifact.getFiles();
if (files.size() != 1) {
log.error("A HumanTask artifact must have a single file. But " + files.size() + " files found.");
continue;
}
if (deployer != null && AppDeployerConstants.DEPLOYMENT_STATUS_DEPLOYED.equals(artifact.getDeploymentStatus())) {
String fileName = artifact.getFiles().get(0).getName();
String artifactPath = artifact.getExtractedPath() + File.separator + fileName;
try {
deployer.undeploy(artifactPath);
artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_PENDING);
} catch (DeploymentException e) {
artifact.setDeploymentStatus(AppDeployerConstants.DEPLOYMENT_STATUS_FAILED);
log.error("Error occured while trying to un deploy : " + artifact.getName());
}
}
}
}
use of org.wso2.carbon.user.api.Tenant in project carbon-business-process by wso2.
the class InstanceManagementServiceSkeleton method isOperationIsValidForTheCurrentTenant.
/**
* Check whether the instance belongs to the current tenant. If not, don't allow any operations.
*
* @param iid instance id
* @throws IllegalAccessException if instance doesn't belong to the current tenant
* @throws ProcessingException if there a error getting instance data
* @throws InstanceManagementException if the processId does not exist
*/
private void isOperationIsValidForTheCurrentTenant(final long iid) throws IllegalAccessException, ProcessingException, InstanceManagementException {
QName processId = getProcess(iid);
TenantProcessStoreImpl processStore = getTenantProcessForCurrentSession();
if (processId != null) {
if (!processStore.containsProcess(processId)) {
log.error("Trying to invoke a illegal operation. Instance ID:" + iid);
throw new IllegalAccessException("Operation is not permitted.");
}
} else {
throw new InstanceManagementException("Process instance for instance ID " + iid + " does not exist");
}
}
use of org.wso2.carbon.user.api.Tenant in project carbon-business-process by wso2.
the class TenantProcessStoreImpl method init.
public void init() throws Exception {
bpelDURepo = new File(parentProcessStore.getLocalDeploymentUnitRepo(), tenantId.toString());
if (!bpelDURepo.exists() && !bpelDURepo.mkdirs()) {
log.warn("Cannot create tenant " + tenantId + " BPEL deployment unit repository.");
}
repository = new BPELPackageRepository(tenantConfigRegistry, bpelDURepo, bpelArchiveRepo);
repository.init();
}
use of org.wso2.carbon.user.api.Tenant in project carbon-business-process by wso2.
the class TenantProcessStoreImpl method findBPELPackageInFileSystem.
private File findBPELPackageInFileSystem(DeploymentUnitDAO dudao) {
String duName = dudao.getName();
// Done: Fix the logic to handle registry
log.info("Looking for BPEL package in file system for deployment unit " + duName);
File bpelDUDirectory = new File(bpelDURepo, duName);
if (bpelDUDirectory.exists()) {
return bpelDUDirectory;
} else {
String registryCollectionPath = dudao.getDeploymentUnitDir();
try {
if (tenantConfigRegistry.resourceExists(registryCollectionPath)) {
if (!bpelDUDirectory.exists() && !bpelDUDirectory.mkdirs()) {
String errMsg = "Error creating BPEL deployment unit repository for " + "tenant " + tenantId;
log.error(errMsg);
log.error("Failed to load BPEL deployment unit " + duName + " due to above error.");
throw new BPELDeploymentException(errMsg);
}
boolean deployedOnCarbon310 = false;
// Check whether the registry repo is of type carbon 3.1.0
if (tenantConfigRegistry.resourceExists(registryCollectionPath + RegistryConstants.PATH_SEPARATOR + duName)) {
registryCollectionPath += RegistryConstants.PATH_SEPARATOR + duName;
deployedOnCarbon310 = true;
if (log.isDebugEnabled()) {
log.debug("Found a carbon 3.1.0 compatible deployment unit at " + registryCollectionPath);
}
}
RegistryClientUtils.exportFromRegistry(bpelDUDirectory, registryCollectionPath, tenantConfigRegistry);
if (deployedOnCarbon310) {
if (log.isDebugEnabled()) {
log.debug("Recompiling the carbon 3.1.0 compatible deployment unit at " + bpelDUDirectory);
}
// Re-compiling to get rid of binary compatibility issues.
DeploymentUnitDir du = new DeploymentUnitDir(bpelDUDirectory);
for (File file : du.allFiles()) {
if (file.getAbsolutePath().endsWith(".cbp") && !file.delete()) {
log.warn("Unable to delete " + file);
}
}
du.compile();
}
return bpelDUDirectory;
} else {
String errMsg = "Expected resource: " + registryCollectionPath + " not found in the registry";
log.error(errMsg);
throw new BPELDeploymentException(errMsg);
}
} catch (RegistryException re) {
String errMsg = "Error while exporting deployment unit: " + duName + " to file system from the registry.";
log.error(errMsg, re);
throw new BPELDeploymentException(errMsg, re);
}
}
}
use of org.wso2.carbon.user.api.Tenant in project carbon-business-process by wso2.
the class BPELProcessStateChangedCommand method execute.
@Override
public void execute(ConfigurationContext configurationContext) throws ClusteringFault {
if (log.isDebugEnabled()) {
log.debug("New state changed command received. Process: " + pid + " New state: " + processState + " Tenant: " + tenantId);
}
ProcessStoreImpl parentProcessStore = (ProcessStoreImpl) configurationContext.getAxisConfiguration().getParameter(BPELConstants.PARAM_PARENT_PROCESS_STORE).getValue();
TenantProcessStore tenantProcessStore = parentProcessStore.getTenantsProcessStore(tenantId);
tenantProcessStore.handleBPELProcessStateChangedNotification(pid, processState);
}
Aggregations