use of org.wso2.carbon.humantask.core.dao.DeploymentUnitDAO 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.humantask.core.dao.DeploymentUnitDAO in project carbon-business-process by wso2.
the class HumanTaskPackageRepository method createHumanTaskPackageParentCollectionWithProperties.
/**
* Create parent collection for human task package using DeploymentUnitDAO
*
* @param deploymentUnitDAO
* @throws RegistryException
*/
private void createHumanTaskPackageParentCollectionWithProperties(DeploymentUnitDAO deploymentUnitDAO) throws RegistryException {
Collection humanPackage = configRegistry.newCollection();
humanPackage.setProperty(HumanTaskConstants.HUMANTASK_PACKAGE_PROP_LATEST_CHECKSUM, deploymentUnitDAO.getChecksum());
if (log.isDebugEnabled()) {
log.debug(deploymentUnitDAO.getPackageName() + " updating checksum: " + deploymentUnitDAO.getChecksum() + " in registry");
}
humanPackage.setProperty(HumanTaskConstants.HUMANTASK_PACKAGE_PROP_STATUS, String.valueOf(deploymentUnitDAO.getStatus()));
humanPackage.setProperty(HumanTaskConstants.HUMANTASK_PACKAGE_PROP_LATEST_VERSION, Long.toString(deploymentUnitDAO.getVersion()));
configRegistry.put(HumanTaskPackageRepositoryUtils.getResourcePathForHumanTaskPackage(deploymentUnitDAO), humanPackage);
}
use of org.wso2.carbon.humantask.core.dao.DeploymentUnitDAO 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.humantask.core.dao.DeploymentUnitDAO 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.dao.DeploymentUnitDAO in project carbon-business-process by wso2.
the class HumanTaskDAOConnectionImpl method getDeploymentUnitByName.
public DeploymentUnitDAO getDeploymentUnitByName(int tenantId, String packageName) {
Query q = entityManager.createQuery("select hu from org.wso2.carbon.humantask.core.dao.jpa.openjpa.model" + ".DeploymentUnit hu WHERE hu.status=?1 and hu.tenantId=?2 and hu.packageName=?3");
q.setParameter(1, TaskPackageStatus.ACTIVE);
q.setParameter(2, tenantId);
q.setParameter(3, packageName);
List<DeploymentUnit> resultList = q.getResultList();
DeploymentUnit deploymentUnit = null;
if (resultList.size() != 0) {
deploymentUnit = resultList.get(0);
}
return deploymentUnit;
}
Aggregations