Search in sources :

Example 1 with ProcessManagementException

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);
}
Also used : Resource(org.wso2.carbon.registry.core.Resource)

Example 2 with ProcessManagementException

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();
    }
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) Log(org.apache.commons.logging.Log) ServletOutputStream(javax.servlet.ServletOutputStream) BPELImpl(org.wso2.carbon.bpel.ui.bpel2svg.impl.BPELImpl) HttpSession(javax.servlet.http.HttpSession) ServletConfig(javax.servlet.ServletConfig) ProcessManagementServiceClient(org.wso2.carbon.bpel.ui.clients.ProcessManagementServiceClient) OMElement(org.apache.axiom.om.OMElement) ProcessManagementException(org.wso2.carbon.bpel.stub.mgt.ProcessManagementException) SVGImpl(org.wso2.carbon.bpel.ui.bpel2svg.impl.SVGImpl)

Example 3 with ProcessManagementException

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;
}
Also used : ProcessConf(org.apache.ode.bpel.iapi.ProcessConf) ProcessFilter(org.apache.ode.bpel.common.ProcessFilter) PaginatedProcessInfoList(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.PaginatedProcessInfoList) TenantProcessStoreImpl(org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl)

Example 4 with ProcessManagementException

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);
}
Also used : InstanceFilter(org.apache.ode.bpel.common.InstanceFilter) Instances_type0(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.Instances_type0) BpelDatabase(org.apache.ode.bpel.engine.BpelDatabase) BpelDAOConnection(org.apache.ode.bpel.dao.BpelDAOConnection) XMLStreamException(javax.xml.stream.XMLStreamException) ParseException(java.text.ParseException) ProcessManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.ProcessManagementException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException)

Example 5 with ProcessManagementException

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()]);
}
Also used : QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) TenantProcessStoreImpl(org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl)

Aggregations

ProcessManagementException (org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.ProcessManagementException)7 QName (javax.xml.namespace.QName)5 FileNotFoundException (java.io.FileNotFoundException)4 IOException (java.io.IOException)4 ParseException (java.text.ParseException)4 XMLStreamException (javax.xml.stream.XMLStreamException)4 OMElement (org.apache.axiom.om.OMElement)4 TenantProcessStoreImpl (org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl)4 ProcessConf (org.apache.ode.bpel.iapi.ProcessConf)3 Date (java.util.Date)2 Map (java.util.Map)2 ServletConfig (javax.servlet.ServletConfig)2 ServletOutputStream (javax.servlet.ServletOutputStream)2 HttpSession (javax.servlet.http.HttpSession)2 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)2 Log (org.apache.commons.logging.Log)2 InstanceFilter (org.apache.ode.bpel.common.InstanceFilter)2 BpelDAOConnection (org.apache.ode.bpel.dao.BpelDAOConnection)2 BpelDatabase (org.apache.ode.bpel.engine.BpelDatabase)2 ProcessConfigurationImpl (org.wso2.carbon.bpel.core.ode.integration.store.ProcessConfigurationImpl)2