use of org.wso2.carbon.registry.core.exceptions.RegistryException 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.registry.core.exceptions.RegistryException in project carbon-business-process by wso2.
the class HumanTaskPackageRepository method addLatestArchiveToRegistryCollection.
/**
* Add latest human task package zip to the registry
*
* @param deploymentUnitDAO
* @param humanTaskFile
* @throws RegistryException
* @throws HumanTaskStoreException
*/
private void addLatestArchiveToRegistryCollection(DeploymentUnitDAO deploymentUnitDAO, File humanTaskFile) throws HumanTaskStoreException, RegistryException {
FileInputStream fileInputStream = null;
try {
Resource latestHumanTaskArchive = configRegistry.newResource();
fileInputStream = new FileInputStream(humanTaskFile);
latestHumanTaskArchive.setContent(fileInputStream);
configRegistry.put(HumanTaskPackageRepositoryUtils.getHumanTaskPackageArchiveResourcePath(deploymentUnitDAO.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.registry.core.exceptions.RegistryException in project carbon-business-process by wso2.
the class BPELDeployer method init.
public void init(ConfigurationContext configurationContext) {
Integer tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
log.info("Initializing BPEL Deployer for tenant " + tenantId + ".");
File bpelRepo = null;
try {
BPELDeployerServiceComponent.getTenantRegistryLoader().loadTenantRegistry(tenantId);
bpelRepo = createBPELRepository(configurationContext);
} catch (DeploymentException e) {
log.warn("BPEL repository creation failed.", e);
} catch (RegistryException e) {
log.warn("Initialization of tenant process store failed for tenant: " + tenantId + " This can cause issues in deployment of BPEL packages.", e);
}
BPELServer bpsServer = BPELDeployerServiceComponent.getBPELServer();
tenantProcessStore = bpsServer.getMultiTenantProcessStore().createProcessStoreForTenant(configurationContext);
tenantProcessStore.setBpelArchiveRepo(bpelRepo);
configurationContext.setProperty(HTTPConstants.MULTITHREAD_HTTP_CONNECTION_MANAGER, bpsServer.getHttpConnectionManager());
try {
tenantProcessStore.init();
} catch (Exception re) {
log.warn("Initialization of tenant process store failed for tenant: " + tenantId + " This can cause issues in deployment of BPEL packages.", re);
}
}
use of org.wso2.carbon.registry.core.exceptions.RegistryException in project carbon-business-process by wso2.
the class BPMNDeploymentService method getLatestChecksum.
/**
* Get the checksum of latest deployment for given deployment name
*
* @param deploymentName
* @return
* @throws BPSFault
*/
public String getLatestChecksum(String deploymentName) throws BPSFault {
try {
Integer tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
RegistryService registryService = BPMNServerHolder.getInstance().getRegistryService();
Registry tenantRegistry = registryService.getConfigSystemRegistry(tenantId);
String deploymentRegistryPath = BPMNConstants.BPMN_REGISTRY_PATH + BPMNConstants.REGISTRY_PATH_SEPARATOR + deploymentName;
if (tenantRegistry.resourceExists(deploymentRegistryPath)) {
Resource deploymentEntry = tenantRegistry.get(deploymentRegistryPath);
return deploymentEntry.getProperty(BPMNConstants.LATEST_CHECKSUM_PROPERTY);
} else {
return null;
}
} catch (RegistryException e) {
String msg = "Error while accessing registry to get latest checksum for package : " + deploymentName;
throw new BPSFault(msg, e);
}
}
use of org.wso2.carbon.registry.core.exceptions.RegistryException in project carbon-business-process by wso2.
the class TenantRepository method undeploy.
/**
* Undeploys a BPMN package.
* This may be called by the BPMN deployer, when a BPMN package is deleted from the deployment folder or by admin services
*
* @param deploymentName package name to be undeployed
* @param force forceful deletion of package
*/
// public void undeploy(String deploymentName, boolean force) {
//
// DeploymentMetaDataModel deploymentMetaDataModel;
// SqlSession sqlSession = null;
// try {
// // Remove the deployment from the tenant's registry
// deploymentMetaDataModel = activitiDAO
// .selectTenantAwareDeploymentModel(tenantId.toString(), deploymentName);
//
// if ((deploymentMetaDataModel == null) && !force) {
// String msg = "Deployment: " + deploymentName + " does not exist.";
// log.warn(msg);
// return;
// }
//
// ProcessEngineImpl engine = (ProcessEngineImpl) BPMNServerHolder.getInstance().getEngine();
//
// DbSqlSessionFactory dbSqlSessionFactory =
// (DbSqlSessionFactory) engine.getProcessEngineConfiguration().
// getSessionFactories().get(DbSqlSession.class);
//
// SqlSessionFactory sqlSessionFactory = dbSqlSessionFactory.getSqlSessionFactory();
// sqlSession = sqlSessionFactory.openSession();
// DeploymentMapper deploymentMapper = sqlSession.getMapper(DeploymentMapper.class);
// int rowCount = deploymentMapper.deleteDeploymentMetaData(deploymentMetaDataModel);
//
// if (log.isDebugEnabled()) {
// log.debug("Total row count deleted=" + rowCount);
// }
//
// // Remove the deployment archive from the tenant's deployment folder
// File deploymentArchive = new File(repoFolder, deploymentName + ".bar");
// FileUtils.deleteQuietly(deploymentArchive);
//
// // Delete all versions of this package from the Activiti engine.
// RepositoryService repositoryService = engine.getRepositoryService();
// List<Deployment> deployments = repositoryService.createDeploymentQuery().deploymentTenantId(tenantId.toString()).
// deploymentName(deploymentName).list();
// for (Deployment deployment : deployments) {
// repositoryService.deleteDeployment(deployment.getId());
// }
//
// //commit metadata
// sqlSession.commit();
// } finally {
// if (sqlSession != null) {
// sqlSession.close();
// }
// }
//
// }
public void undeploy(String deploymentName, boolean force) throws BPSFault {
try {
// Remove the deployment from the tenant's registry
RegistryService registryService = BPMNServerHolder.getInstance().getRegistryService();
Registry tenantRegistry = registryService.getConfigSystemRegistry(tenantId);
String deploymentRegistryPath = BPMNConstants.BPMN_REGISTRY_PATH + BPMNConstants.REGISTRY_PATH_SEPARATOR + deploymentName;
if (!tenantRegistry.resourceExists(deploymentRegistryPath) && !force) {
String msg = "Deployment: " + deploymentName + " does not exist.";
log.warn(msg);
return;
}
tenantRegistry.delete(deploymentRegistryPath);
// Remove the deployment archive from the tenant's deployment folder
File deploymentArchive = new File(repoFolder, deploymentName + ".bar");
FileUtils.deleteQuietly(deploymentArchive);
// Delete all versions of this package from the Activiti engine.
ProcessEngine engine = BPMNServerHolder.getInstance().getEngine();
RepositoryService repositoryService = engine.getRepositoryService();
List<Deployment> deployments = repositoryService.createDeploymentQuery().deploymentTenantId(tenantId.toString()).deploymentName(deploymentName).list();
for (Deployment deployment : deployments) {
repositoryService.deleteDeployment(deployment.getId(), true);
}
} catch (RegistryException e) {
String msg = "Failed to undeploy BPMN deployment: " + deploymentName + " for tenant: " + tenantId;
log.error(msg, e);
throw new BPSFault(msg, e);
}
}
Aggregations