use of org.wso2.carbon.bpmn.core.internal.mapper.DeploymentMapper 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);
}
}
use of org.wso2.carbon.bpmn.core.internal.mapper.DeploymentMapper in project carbon-business-process by wso2.
the class ActivitiDAO method selectTenantAwareDeploymentModel.
/**
* invokes the DeploymentMapper.selectMetaData for a given tenant id and package name
*
* @param tenantID tenant id
* @param bpmnPackageName package name
* @return DeploymentMetaDataModel object
*/
public DeploymentMetaDataModel selectTenantAwareDeploymentModel(final String tenantID, final String bpmnPackageName) {
CustomSqlExecution<DeploymentMapper, DeploymentMetaDataModel> customSqlExecution = new AbstractCustomSqlExecution<DeploymentMapper, DeploymentMetaDataModel>(DeploymentMapper.class) {
public DeploymentMetaDataModel execute(DeploymentMapper deploymentMapper) {
return deploymentMapper.selectMetaData(tenantID, bpmnPackageName);
}
};
DeploymentMetaDataModel deploymentMetaDataModel = managementService.executeCustomSql(customSqlExecution);
if (log.isDebugEnabled()) {
if (deploymentMetaDataModel != null) {
log.debug("DeploymentDataModel exists when selecting models=" + deploymentMetaDataModel.getId());
} else {
log.debug("DeploymentDataModel null when selecting models");
}
}
return deploymentMetaDataModel;
}
Aggregations