use of org.wso2.carbon.bpel.stub.mgt.ProcessManagementException in project carbon-business-process by wso2.
the class BPELPackageRepository method createPropertiesForUpdatedDeploymentInfo.
/**
* Creates new properties for the details of updated deployment descriptor information
* for a process in the package location of the registry
*
* @param processConfiguration - Process's configuration details after updated
* @throws RegistryException on registry rollback error case, we'll init the cause to the
* original exception we got when accessing registry
* @throws IOException if file access error occurred during MD5 checksum generation
* @throws NoSuchAlgorithmException when there is a error during MD5 generation
* @throws ProcessManagementException
*/
public void createPropertiesForUpdatedDeploymentInfo(ProcessConfigurationImpl processConfiguration) throws RegistryException, IOException, NoSuchAlgorithmException, ProcessManagementException {
String versionlessPackageName = BPELPackageRepositoryUtils.getVersionlessPackageName(processConfiguration.getPackage());
String packageLocation = BPELPackageRepositoryUtils.getResourcePathForDeployInfoUpdatedBPELPackage(processConfiguration.getPackage(), versionlessPackageName);
Resource bpelPackage = configRegistry.get(packageLocation);
bpelPackage.setProperty(BPELConstants.BPEL_INSTANCE_CLEANUP_FAILURE + processConfiguration.getProcessId(), BPELPackageRepositoryUtils.getBPELPackageFailureCleanUpsAsString(processConfiguration.getCleanupCategories(false)));
bpelPackage.setProperty(BPELConstants.BPEL_INSTANCE_CLEANUP_SUCCESS + processConfiguration.getProcessId(), BPELPackageRepositoryUtils.getBPELPackageSuccessCleanUpsInList(processConfiguration.getCleanupCategories(true)));
bpelPackage.setProperty(BPELConstants.BPEL_PROCESS_EVENT_GENERATE + processConfiguration.getProcessId(), BPELPackageRepositoryUtils.getBPELPackageProcessGenerateType(processConfiguration.getGenerateType()));
bpelPackage.setProperty(BPELConstants.BPEL_PROCESS_EVENTS + processConfiguration.getProcessId(), BPELPackageRepositoryUtils.getBPELPackageProcessEventsInList(processConfiguration.getEvents()));
bpelPackage.setProperty(BPELConstants.BPEL_PROCESS_INMEMORY + processConfiguration.getProcessId(), String.valueOf(processConfiguration.isTransient()));
bpelPackage.setProperty(BPELConstants.BPEL_PROCESS_STATE + processConfiguration.getProcessId(), processConfiguration.getState().name());
// ScopeLevelEnabledEvents list of a process in a bpel package
List<String> scopeEvents;
scopeEvents = BPELPackageRepositoryUtils.getBPELPackageScopeEventsInList(processConfiguration.getEvents());
if (!scopeEvents.isEmpty()) {
for (int k = 0; k < scopeEvents.size(); k++) {
bpelPackage.setProperty(BPELConstants.BPEL_PROCESS_SCOPE_EVENT + (k + 1) + processConfiguration.getProcessId(), scopeEvents.get(k));
}
}
configRegistry.put(packageLocation, bpelPackage);
}
use of org.wso2.carbon.bpel.stub.mgt.ProcessManagementException in project carbon-business-process by wso2.
the class SVGGenerateServlet method processRequest.
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* Handles the HTTP process request which creates the SVG graph for a bpel process
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Log log = LogFactory.getLog(SVGGenerateServlet.class);
HttpSession session = request.getSession(true);
// Get the bpel process id
String pid = CharacterEncoder.getSafeText(request.getParameter("pid"));
ServletConfig config = getServletConfig();
String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(), session);
ConfigurationContext configContext = (ConfigurationContext) config.getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
String processDef = null;
ProcessManagementServiceClient client = null;
SVGInterface svg = null;
String svgStr = null;
ServletOutputStream sos = null;
sos = response.getOutputStream();
try {
client = new ProcessManagementServiceClient(cookie, backendServerURL, configContext, request.getLocale());
// Gets the bpel process definition needed to create the SVG from the processId
processDef = client.getProcessInfo(QName.valueOf(pid)).getDefinitionInfo().getDefinition().getExtraElement().toString();
BPELInterface bpel = new BPELImpl();
// Converts the bpel process definition to an omElement which is how the AXIS2 Object Model (AXIOM)
// represents an XML document
OMElement bpelStr = bpel.load(processDef);
/**
* Process the OmElement containing the bpel process definition
* Process the subactivites of the bpel process by iterating through the omElement
*/
bpel.processBpelString(bpelStr);
// Create a new instance of the LayoutManager for the bpel process
LayoutManager layoutManager = BPEL2SVGFactory.getInstance().getLayoutManager();
// Set the layout of the SVG to vertical
layoutManager.setVerticalLayout(true);
// Get the root activity i.e. the Process Activity
layoutManager.layoutSVG(bpel.getRootActivity());
svg = new SVGImpl();
// Set the root activity of the SVG i.e. the Process Activity
svg.setRootActivity(bpel.getRootActivity());
// Set the content type of the HTTP response as "image/svg+xml"
response.setContentType("image/svg+xml");
// Get the SVG graph created for the process as a SVG string
svgStr = svg.generateSVGString();
// Checks whether the SVG string generated contains a value
if (svgStr != null) {
// stream to write binary data into the response
sos.write(svgStr.getBytes(Charset.defaultCharset()));
sos.flush();
sos.close();
}
} catch (ProcessManagementException e) {
log.error("SVG Generation Error", e);
String errorSVG = "<svg version=\"1.1\"\n" + " xmlns=\"http://www.w3.org/2000/svg\"><text y=\"50\">Could not display SVG</text></svg>";
sos.write(errorSVG.getBytes(Charset.defaultCharset()));
sos.flush();
sos.close();
}
}
use of org.wso2.carbon.bpel.stub.mgt.ProcessManagementException in project carbon-business-process by wso2.
the class ProcessManagementServiceSkeleton method getPaginatedProcessList.
public PaginatedProcessInfoList getPaginatedProcessList(String processListFilter, String processListOrderByKey, int page) throws ProcessManagementException {
int tPage = page;
PaginatedProcessInfoList processList = new PaginatedProcessInfoList();
TenantProcessStoreImpl tenantProcessStore = AdminServiceUtils.getTenantProcessStore();
if (tPage < 0 || tPage == Integer.MAX_VALUE) {
tPage = 0;
}
Integer itemsPerPage = 10;
Integer startIndexForCurrentPage = tPage * itemsPerPage;
Integer endIndexForCurrentPage = (tPage + 1) * itemsPerPage;
final ProcessFilter processFilter = new ProcessFilter(processListFilter, processListOrderByKey);
Collection<ProcessConf> processListForCurrentPage = processQuery(processFilter, tenantProcessStore);
Integer processListSize = processListForCurrentPage.size();
Integer pages = (int) Math.ceil((double) processListSize / itemsPerPage);
processList.setPages(pages);
ProcessConf[] processConfigurations = processListForCurrentPage.toArray(new ProcessConf[processListSize]);
for (int i = startIndexForCurrentPage; (i < endIndexForCurrentPage && i < processListSize); i++) {
processList.addProcessInfo(AdminServiceUtils.createLimitedProcessInfoObject(processConfigurations[i]));
}
return processList;
}
use of org.wso2.carbon.bpel.stub.mgt.ProcessManagementException in project carbon-business-process by wso2.
the class ProcessManagementServiceSkeleton method addInstanceSummaryEntry.
private void addInstanceSummaryEntry(InstanceSummary instSum, ProcessConf pconf, InstanceStatus state) throws ProcessManagementException {
Instances_type0 instances = new Instances_type0();
instances.setState(state);
String queryStatus = InstanceFilter.StatusKeys.valueOf(state.toString()).toString().toLowerCase();
final InstanceFilter instanceFilter = new InstanceFilter("status=" + queryStatus + " pid=" + pconf.getProcessId());
int count = dbexec(new BpelDatabase.Callable<Integer>() {
public Integer run(BpelDAOConnection conn) throws Exception {
return conn.instanceCount(instanceFilter).intValue();
}
});
instances.setCount(count);
instSum.addInstances(instances);
}
use of org.wso2.carbon.bpel.stub.mgt.ProcessManagementException in project carbon-business-process by wso2.
the class ProcessManagementServiceSkeleton method getAllProcesses.
public java.lang.String[] getAllProcesses(String getAllProcesses) throws ProcessManagementException {
TenantProcessStoreImpl tenantProcessStore = AdminServiceUtils.getTenantProcessStore();
Set<QName> processIds = tenantProcessStore.getProcessConfigMap().keySet();
List<String> pids = new ArrayList<String>();
for (QName pid : processIds) {
pids.add(pid.toString());
}
return pids.toArray(new String[pids.size()]);
}
Aggregations