use of org.wso2.carbon.registry.core.Collection in project carbon-business-process by wso2.
the class BpelUIUtil method setFailureTypeCleanups.
private static String[] setFailureTypeCleanups(ProcessDeployDetailsList_type0 processDeployDetailsListType) {
List<String> failureCategories = null;
if (processDeployDetailsListType.getCleanUpList() != null && processDeployDetailsListType.getCleanUpList().getCleanUp() != null) {
failureCategories = new ArrayList<String>();
CleanUpType[] cleanUpTypes = processDeployDetailsListType.getCleanUpList().getCleanUp();
for (CleanUpType cleanUpType : cleanUpTypes) {
if (cleanUpType.getOn().getValue().equalsIgnoreCase("failure") && cleanUpType.getCategoryList() != null) {
CategoryListType categoryList = cleanUpType.getCategoryList();
if (categoryList.getCategory() != null) {
Category_type1[] categories = categoryList.getCategory();
for (Category_type1 categoryType1 : categories) {
failureCategories.add(categoryType1.getValue());
}
}
}
}
}
// Collection to array
String[] failureList = new String[0];
if (failureCategories != null) {
failureList = failureCategories.toArray(new String[failureCategories.size()]);
}
return failureList;
}
use of org.wso2.carbon.registry.core.Collection in project carbon-business-process by wso2.
the class BpelUIUtil method setSuccessTypeCleanups.
private static String[] setSuccessTypeCleanups(ProcessDeployDetailsList_type0 processDeployDetailsListType) {
List<String> successCategories = null;
if (processDeployDetailsListType.getCleanUpList() != null && processDeployDetailsListType.getCleanUpList().getCleanUp() != null) {
successCategories = new ArrayList<String>();
CleanUpType[] cleanUpTypes = processDeployDetailsListType.getCleanUpList().getCleanUp();
for (CleanUpType cleanUpType : cleanUpTypes) {
if (cleanUpType.getOn().getValue().equalsIgnoreCase("success") && cleanUpType.getCategoryList() != null) {
CategoryListType categoryList = cleanUpType.getCategoryList();
if (categoryList.getCategory() != null) {
Category_type1[] categories = categoryList.getCategory();
for (Category_type1 categoryType1 : categories) {
successCategories.add(categoryType1.getValue());
}
}
}
}
}
// Collection to array
String[] successList = new String[0];
if (successCategories != null) {
successList = successCategories.toArray(new String[successCategories.size()]);
}
return successList;
}
use of org.wso2.carbon.registry.core.Collection in project carbon-business-process by wso2.
the class WorkflowTaskService method deleteAllLocalTaskVariables.
@DELETE
@Path("/{taskId}/variables")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response deleteAllLocalTaskVariables(@PathParam("taskId") String taskId) {
TaskService taskService = BPMNOSGIService.getTaskService();
Task task = getTaskFromRequest(taskId);
Collection<String> currentVariables = taskService.getVariablesLocal(task.getId()).keySet();
taskService.removeVariablesLocal(task.getId(), currentVariables);
return Response.ok().status(Response.Status.NO_CONTENT).build();
}
use of org.wso2.carbon.registry.core.Collection in project carbon-business-process by wso2.
the class TenantRepository method fixDeployments.
/**
* Information about BPMN deployments are recorded in 3 places:
* Activiti database, Registry and the file system (deployment folder).
* If information about a particular deployment is not recorded in all these 3 places, BPS may not work correctly.
* Therefore, this method checks whether deployments are recorded in all these places and undeploys packages, if
* they are missing in few places in an inconsistent way.
* <p/>
* As there are 3 places, there are 8 ways a package can be placed. These cases are handled as follows:
* (1) Whenever a package is not in the deployment folder, it is undeploye (this covers 4 combinations).
* (2) If a package is in all 3 places, it is a proper deployment and it is left untouched.
* (3) If a package is only in the deployment folder, it is a new deployment. This will be handled by the deployer.
* (4) If a package is in the deployment folder AND it is in either registry or Activiti DB (but not both), then it is an inconsistent deployment. This will be undeployed.
*/
// public void fixDeployments() {
//
// // get all deployments in the deployment folder
// List<String> fileArchiveNames = new ArrayList<String>();
// File[] fileDeployments = repoFolder.listFiles();
// if (fileDeployments != null) {
// for (File fileDeployment : fileDeployments) {
// String deploymentName = FilenameUtils.getBaseName(fileDeployment.getName());
// fileArchiveNames.add(deploymentName);
// }
// } else {
// log.error("File deployments returned null for tenant" + tenantId);
// }
//
//
// // get all deployments in the Activiti DB
// List<String> activitiDeploymentNames = new ArrayList<String>();
// ProcessEngine engine = BPMNServerHolder.getInstance().getEngine();
// RepositoryService repositoryService = engine.getRepositoryService();
// List<Deployment> tenantDeployments =
// repositoryService.createDeploymentQuery().deploymentTenantId(tenantId.toString())
// .list();
// for (Deployment deployment : tenantDeployments) {
// String deploymentName = deployment.getName();
// activitiDeploymentNames.add(deploymentName);
// }
//
// // get all deployments in the registry
// List<String> metaDataDeploymentNames = new ArrayList<String>();
// List<DeploymentMetaDataModel> deploymentMetaDataModelList =
// activitiDAO.selectAllDeploymentModel();
//
// int deploymentMetaDataModelListSize = deploymentMetaDataModelList.size();
//
// for (int i = 0; i < deploymentMetaDataModelListSize; i++) {
// DeploymentMetaDataModel deploymentMetaDataModel =
// deploymentMetaDataModelList.get(i);
//
// if (deploymentMetaDataModel != null) {
// String deploymentMetadataName = deploymentMetaDataModel.getPackageName();
// metaDataDeploymentNames.add(deploymentMetadataName);
// }
// }
//
// // construct the union of all deployments
// Set<String> allDeploymentNames = new HashSet<String>();
// allDeploymentNames.addAll(fileArchiveNames);
// allDeploymentNames.addAll(activitiDeploymentNames);
// allDeploymentNames.addAll(metaDataDeploymentNames);
//
// for (String deploymentName : allDeploymentNames) {
//
// if (!(fileArchiveNames.contains(deploymentName))) {
// if (log.isDebugEnabled()) {
// log.debug(deploymentName +
// " has been removed from the deployment folder. Undeploying the package...");
// }
// undeploy(deploymentName, true);
// } else {
// if (activitiDeploymentNames.contains(deploymentName) &&
// !metaDataDeploymentNames.contains(deploymentName)) {
// if (log.isDebugEnabled()) {
// log.debug(deploymentName +
// " is missing in the registry. Undeploying the package to avoid inconsistencies...");
// }
// undeploy(deploymentName, true);
// }
//
// if (!activitiDeploymentNames.contains(deploymentName) &&
// metaDataDeploymentNames.contains(deploymentName)) {
// if (log.isDebugEnabled()) {
// log.debug(deploymentName +
// " is missing in the BPS database. Undeploying the package to avoid inconsistencies...");
// }
// undeploy(deploymentName, true);
// }
// }
// }
// }
public void fixDeployments() throws BPSFault {
// get all deployments in the deployment folder
List<String> fileArchiveNames = new ArrayList<String>();
File[] fileDeployments = repoFolder.listFiles();
for (File fileDeployment : fileDeployments) {
String deploymentName = FilenameUtils.getBaseName(fileDeployment.getName());
fileArchiveNames.add(deploymentName);
}
// get all deployments in the Activiti DB
List<String> activitiDeploymentNames = new ArrayList<String>();
ProcessEngine engine = BPMNServerHolder.getInstance().getEngine();
RepositoryService repositoryService = engine.getRepositoryService();
List<Deployment> tenantDeployments = repositoryService.createDeploymentQuery().deploymentTenantId(tenantId.toString()).list();
for (Deployment deployment : tenantDeployments) {
String deploymentName = deployment.getName();
activitiDeploymentNames.add(deploymentName);
}
// get all deployments in the registry
List<String> registryDeploymentNames = new ArrayList<String>();
try {
RegistryService registryService = BPMNServerHolder.getInstance().getRegistryService();
Registry tenantRegistry = registryService.getConfigSystemRegistry(tenantId);
String deploymentRegistryPath = BPMNConstants.BPMN_REGISTRY_PATH;
if (tenantRegistry.resourceExists(deploymentRegistryPath)) {
Collection registryDeployments = (Collection) tenantRegistry.get(deploymentRegistryPath);
String[] deploymentPaths = registryDeployments.getChildren();
for (String deploymentPath : deploymentPaths) {
String deploymentName = deploymentPath.substring(deploymentPath.lastIndexOf("/") + 1, deploymentPath.length());
registryDeploymentNames.add(deploymentName);
}
}
} catch (RegistryException e) {
String msg = "Failed to obtain BPMN deployments from the Registry.";
log.error(msg, e);
throw new BPSFault(msg, e);
}
// construct the union of all deployments
Set<String> allDeploymentNames = new HashSet<String>();
allDeploymentNames.addAll(fileArchiveNames);
allDeploymentNames.addAll(activitiDeploymentNames);
allDeploymentNames.addAll(registryDeploymentNames);
for (String deploymentName : allDeploymentNames) {
try {
if (!(fileArchiveNames.contains(deploymentName))) {
if (log.isDebugEnabled()) {
log.debug(deploymentName + " has been removed from the deployment folder. Undeploying the package...");
}
undeploy(deploymentName, true);
} else {
if (activitiDeploymentNames.contains(deploymentName) && !registryDeploymentNames.contains(deploymentName)) {
if (log.isDebugEnabled()) {
log.debug(deploymentName + " is missing in the registry. Undeploying the package to avoid inconsistencies...");
}
undeploy(deploymentName, true);
}
if (!activitiDeploymentNames.contains(deploymentName) && registryDeploymentNames.contains(deploymentName)) {
if (log.isDebugEnabled()) {
log.debug(deploymentName + " is missing in the BPS database. Undeploying the package to avoid inconsistencies...");
}
undeploy(deploymentName, true);
}
}
} catch (BPSFault e) {
String msg = "Failed undeploy inconsistent deployment: " + deploymentName;
log.error(msg, e);
throw new BPSFault(msg, e);
}
}
}
use of org.wso2.carbon.registry.core.Collection in project carbon-business-process by wso2.
the class InstanceManagementServiceSkeleton method getPaginatedInstanceList.
/**
* Get paginated instance list
*
* @param filter Instance tFilter
* @param order The field on which to be ordered
* @param limit The maximum number of instances to be fetched
* @param page The page number
* @return Instances that are filtered through "tFilter", ordered by "order" that fits into
* 'page'th page
* @throws InstanceManagementException When an error occurs
*/
public PaginatedInstanceList getPaginatedInstanceList(String filter, final String order, final int limit, final int page) throws InstanceManagementException {
String tFilter = filter;
final PaginatedInstanceList instanceList = new PaginatedInstanceList();
Integer tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
TenantProcessStoreImpl tenantProcessStore = (TenantProcessStoreImpl) bpelServer.getMultiTenantProcessStore().getTenantsProcessStore(tenantId);
if (tenantProcessStore.getProcessConfigMap().size() <= 0) {
instanceList.setPages(0);
return instanceList;
}
if (!tFilter.contains(" pid=")) {
tFilter = tFilter + getTenantsProcessList(tenantProcessStore.getProcessConfigMap().keySet());
}
if (log.isDebugEnabled()) {
log.debug("Instance Filter:" + tFilter);
}
final InstanceFilter instanceFilter = new InstanceFilter(tFilter, order, limit);
try {
BpelDatabase bpelDb = bpelServer.getODEBPELServer().getBpelDb();
bpelDb.exec(new BpelDatabase.Callable<Object>() {
public Object run(BpelDAOConnection conn) throws InstanceManagementException {
Collection<ProcessInstanceDAO> instances = conn.instanceQuery(instanceFilter);
int pageNum = page;
if (pageNum < 0 || pageNum == Integer.MAX_VALUE) {
pageNum = 0;
}
int startIndexOfCurrentPage = pageNum * BPELConstants.ITEMS_PER_PAGE;
int endIndexOfCurrentPage = (pageNum + 1) * BPELConstants.ITEMS_PER_PAGE;
int instanceListSize = instances.size();
int pages = (int) Math.ceil((double) instanceListSize / BPELConstants.ITEMS_PER_PAGE);
instanceList.setPages(pages);
ProcessInstanceDAO[] instanceArray = instances.toArray(new ProcessInstanceDAO[instanceListSize]);
for (int i = startIndexOfCurrentPage; (i < endIndexOfCurrentPage && i < instanceListSize); i++) {
instanceList.addInstance(createLimitedInstanceInfoObject(instanceArray[i]));
}
return null;
}
});
} catch (Exception e) {
String errMsg = "Error querying instances from database. Instance Filter:" + instanceFilter.toString();
log.error(errMsg, e);
throw new InstanceManagementException(errMsg, e);
}
return instanceList;
}
Aggregations