Search in sources :

Example 6 with ProcessManagementException

use of org.wso2.carbon.bpel.stub.mgt.ProcessManagementException in project carbon-business-process by wso2.

the class ProcessManagementServiceSkeleton method fillPartnerLinks.

// private java.lang.String[] getServiceLocationForProcess(QName processId)
// throws ProcessManagementException {
// AxisConfiguration axisConf = getConfigContext().getAxisConfiguration();
// Map<String, AxisService> services = axisConf.getServices();
// ArrayList<String> serviceEPRs = new ArrayList<String>();
// 
// for (AxisService service : services.values()) {
// Parameter pIdParam = service.getParameter(BPELConstants.PROCESS_ID);
// if (pIdParam != null) {
// if (pIdParam.getValue().equals(processId)) {
// serviceEPRs.addAll(Arrays.asList(service.getEPRs()));
// }
// }
// }
// 
// if (serviceEPRs.size() > 0) {
// return serviceEPRs.toArray(new String[serviceEPRs.size()]);
// }
// 
// String errMsg = "Cannot find service for process: " + processId;
// log.error(errMsg);
// throw new ProcessManagementException(errMsg);
// }
private void fillPartnerLinks(ProcessInfoType pInfo, TDeployment.Process processInfo) throws ProcessManagementException {
    if (processInfo.getProvideList() != null) {
        EndpointReferencesType eprsType = new EndpointReferencesType();
        for (TProvide provide : processInfo.getProvideList()) {
            String plinkName = provide.getPartnerLink();
            TService service = provide.getService();
            /* NOTE:Service cannot be null for provider partner link*/
            if (service == null) {
                String errorMsg = "Error in <provide> element for process " + processInfo.getName() + " partnerlink" + plinkName + " did not identify an endpoint";
                log.error(errorMsg);
                throw new ProcessManagementException(errorMsg);
            }
            if (log.isDebugEnabled()) {
                log.debug("Processing <provide> element for process " + processInfo.getName() + ": partnerlink " + plinkName + " --> " + service.getName() + " : " + service.getPort());
            }
            QName serviceName = service.getName();
            EndpointRef_type0 eprType = new EndpointRef_type0();
            eprType.setPartnerLink(plinkName);
            eprType.setService(serviceName);
            ServiceLocation sLocation = new ServiceLocation();
            try {
                String url = Utils.getTryitURL(serviceName.getLocalPart(), getConfigContext());
                sLocation.addServiceLocation(url);
                String[] wsdls = Utils.getWsdlInformation(serviceName.getLocalPart(), getConfigContext().getAxisConfiguration());
                if (wsdls.length == 2) {
                    if (wsdls[0].endsWith("?wsdl")) {
                        sLocation.addServiceLocation(wsdls[0]);
                    } else {
                        sLocation.addServiceLocation(wsdls[1]);
                    }
                }
            } catch (AxisFault axisFault) {
                String errMsg = "Error while getting try-it url for the service: " + serviceName;
                log.error(errMsg, axisFault);
                throw new ProcessManagementException(errMsg, axisFault);
            }
            eprType.setServiceLocations(sLocation);
            eprsType.addEndpointRef(eprType);
        }
        pInfo.setEndpoints(eprsType);
    }
// if (processInfo.getInvokeList() != null) {
// for (TInvoke invoke : processInfo.getInvokeList()) {
// String plinkName = invoke.getPartnerLink();
// TService service = invoke.getService();
// /* NOTE:Service can be null for partner links*/
// if (service == null) {
// continue;
// }
// if (log.isDebugEnabled()) {
// log.debug("Processing <invoke> element for process " + processInfo.getName() + ": partnerlink" +
// plinkName + " -->" + service);
// }
// 
// QName serviceName = service.getName();
// }
// }
}
Also used : AxisFault(org.apache.axis2.AxisFault) QName(javax.xml.namespace.QName) ServiceLocation(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ServiceLocation) EndpointReferencesType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.EndpointReferencesType) EndpointRef_type0(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.EndpointRef_type0) TProvide(org.apache.ode.bpel.dd.TProvide) TService(org.apache.ode.bpel.dd.TService) ProcessManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.ProcessManagementException)

Example 7 with ProcessManagementException

use of org.wso2.carbon.bpel.stub.mgt.ProcessManagementException in project carbon-business-process by wso2.

the class ProcessManagementServiceSkeleton method fillProcessInfo.

/**
 * Fill in the <code>ProcessInfo</code> element of the transfer object.
 *
 * @param info               destination XMLBean
 * @param pconf              process configuration object (from store)
 * @param custom             used to customize the quantity of information produced in the
 *                           info
 * @param tenantProcessStore Tenant's Process store
 * @throws ProcessManagementException If an error occurred while filling process information
 */
private void fillProcessInfo(ProcessInfoType info, ProcessConf pconf, ProcessInfoCustomizer custom, TenantProcessStoreImpl tenantProcessStore) throws ProcessManagementException {
    if (pconf == null) {
        String errMsg = "Process configuration cannot be null.";
        log.error(errMsg);
        throw new ProcessManagementException(errMsg);
    }
    info.setPid(pconf.getProcessId().toString());
    // Active process may be retired at the same time
    if (pconf.getState() == ProcessState.RETIRED) {
        info.setStatus(ProcessStatus.RETIRED);
        info.setOlderVersion(AdminServiceUtils.isOlderVersion(pconf, tenantProcessStore));
    } else if (pconf.getState() == ProcessState.DISABLED) {
        info.setStatus(ProcessStatus.DISABLED);
        info.setOlderVersion(0);
    } else {
        info.setStatus(ProcessStatus.ACTIVE);
        info.setOlderVersion(0);
    }
    info.setVersion(pconf.getVersion());
    DefinitionInfo defInfo = new DefinitionInfo();
    defInfo.setProcessName(pconf.getType());
    BpelDefinition bpelDefinition = new BpelDefinition();
    bpelDefinition.setExtraElement(getProcessDefinition(pconf));
    defInfo.setDefinition(bpelDefinition);
    info.setDefinitionInfo(defInfo);
    DeploymentInfo depInfo = new DeploymentInfo();
    depInfo.setPackageName(pconf.getPackage());
    depInfo.setDocument(pconf.getBpelDocument());
    depInfo.setDeployDate(AdminServiceUtils.toCalendar(pconf.getDeployDate()));
    // TODO: Need to fix this by adding info to process conf.
    depInfo.setDeployer(org.wso2.carbon.bpel.core.BPELConstants.BPEL_DEPLOYER_NAME);
    info.setDeploymentInfo(depInfo);
    if (custom.includeInstanceSummary()) {
        InstanceSummary instanceSummary = new InstanceSummary();
        addInstanceSummaryEntry(instanceSummary, pconf, InstanceStatus.ACTIVE);
        addInstanceSummaryEntry(instanceSummary, pconf, InstanceStatus.COMPLETED);
        addInstanceSummaryEntry(instanceSummary, pconf, InstanceStatus.FAILED);
        addInstanceSummaryEntry(instanceSummary, pconf, InstanceStatus.SUSPENDED);
        addInstanceSummaryEntry(instanceSummary, pconf, InstanceStatus.TERMINATED);
        addFailuresToInstanceSummary(instanceSummary, pconf);
        info.setInstanceSummary(instanceSummary);
    }
    if (custom.includeProcessProperties()) {
        ProcessProperties processProps = new ProcessProperties();
        for (Map.Entry<QName, Node> propEntry : pconf.getProcessProperties().entrySet()) {
            QName key = propEntry.getKey();
            if (key != null) {
                Property_type0 prop = new Property_type0();
                prop.setName(new QName(key.getNamespaceURI(), key.getLocalPart()));
                OMFactory omFac = OMAbstractFactory.getOMFactory();
                OMElement propEle = omFac.createOMElement("PropertyValue", null);
                propEle.setText(propEntry.getValue().getNodeValue());
                prop.addExtraElement(propEle);
                processProps.addProperty(prop);
            }
        }
        info.setProperties(processProps);
    }
    fillPartnerLinks(info, ((ProcessConfigurationImpl) pconf).getProcessDeploymentInfo());
}
Also used : DefinitionInfo(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.DefinitionInfo) BpelDefinition(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.BpelDefinition) QName(javax.xml.namespace.QName) Node(org.w3c.dom.Node) OMElement(org.apache.axiom.om.OMElement) InstanceSummary(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.InstanceSummary) Property_type0(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.Property_type0) ProcessProperty_type0(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ProcessProperty_type0) ProcessProperties(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.ProcessProperties) ProcessManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.ProcessManagementException) OMFactory(org.apache.axiom.om.OMFactory) DeploymentInfo(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.DeploymentInfo) Map(java.util.Map)

Example 8 with ProcessManagementException

use of org.wso2.carbon.bpel.stub.mgt.ProcessManagementException in project carbon-business-process by wso2.

the class ProcessManagementServiceSkeleton method updateDeployInfo.

/*When a user modifies deploy info table they are updated in this method
    *
    * @param processDeployDetailsList
    *
    */
public void updateDeployInfo(ProcessDeployDetailsList_type0 processDeployDetailsListType) throws ProcessManagementException {
    final QName processId = processDeployDetailsListType.getProcessName();
    try {
        TenantProcessStoreImpl tenantProcessStore = AdminServiceUtils.getTenantProcessStore();
        ProcessConfigurationImpl processConf = (ProcessConfigurationImpl) tenantProcessStore.getProcessConfiguration(processId);
        final boolean oldIsInmemory = processConf.isTransient();
        final boolean newIsInmemory = processDeployDetailsListType.getIsInMemory();
        processConf.setState(getProcessState(processDeployDetailsListType));
        processConf.setIsTransient(newIsInmemory);
        processConf.setProcessEventsList(processDeployDetailsListType.getProcessEventsList());
        processConf.setGenerateType(processDeployDetailsListType.getProcessEventsList());
        processConf.setProcessCleanupConfImpl(processDeployDetailsListType.getCleanUpList());
        if (tenantProcessStore.getBPELPackageRepository() != null) {
            tenantProcessStore.getBPELPackageRepository().createPropertiesForUpdatedDeploymentInfo(processConf);
        }
        bpelServer.getODEBPELServer().getContexts().scheduler.execTransaction(new java.util.concurrent.Callable<Boolean>() {

            public Boolean call() throws Exception {
                ProcessDAO processDAO;
                ProcessDAO newProcessDAO;
                if (oldIsInmemory & !newIsInmemory) {
                    processDAO = bpelServer.getODEBPELServer().getContexts().getInMemDao().getConnection().getProcess(processId);
                    if (bpelServer.getODEBPELServer().getContexts().dao.getConnection().getProcess(processId) == null) {
                        newProcessDAO = bpelServer.getODEBPELServer().getContexts().dao.getConnection().createProcess(processDAO.getProcessId(), processDAO.getType(), processDAO.getGuid(), processDAO.getVersion());
                        Set<String> correlatorsSet = processDAO.getCorrelatorsSet();
                        for (String correlator : correlatorsSet) {
                            newProcessDAO.addCorrelator(correlator);
                        }
                    }
                } else if (!oldIsInmemory & newIsInmemory) {
                    QName pId = processId;
                    processDAO = bpelServer.getODEBPELServer().getContexts().dao.getConnection().getProcess(pId);
                    if (bpelServer.getODEBPELServer().getContexts().getInMemDao().getConnection().getProcess(pId) == null) {
                        newProcessDAO = bpelServer.getODEBPELServer().getContexts().getInMemDao().getConnection().createProcess(processDAO.getProcessId(), processDAO.getType(), processDAO.getGuid(), processDAO.getVersion());
                        Set<String> correlatorsSet = processDAO.getCorrelatorsSet();
                        for (String correlator : correlatorsSet) {
                            newProcessDAO.addCorrelator(correlator);
                        }
                    }
                }
                return true;
            }
        });
    } catch (Exception e) {
        String errMsg = "Error occurred while updating deployment info for: " + processId;
        log.error(errMsg, e);
        throw new ProcessManagementException(errMsg, e);
    }
}
Also used : Set(java.util.Set) QName(javax.xml.namespace.QName) ProcessConfigurationImpl(org.wso2.carbon.bpel.core.ode.integration.store.ProcessConfigurationImpl) TenantProcessStoreImpl(org.wso2.carbon.bpel.core.ode.integration.store.TenantProcessStoreImpl) 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) ProcessManagementException(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.ProcessManagementException) ProcessDAO(org.apache.ode.bpel.dao.ProcessDAO)

Example 9 with ProcessManagementException

use of org.wso2.carbon.bpel.stub.mgt.ProcessManagementException in project carbon-business-process by wso2.

the class PNGGenarateServlet method processRequest.

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
 *
 * @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(PNGGenarateServlet.class);
    HttpSession session = request.getSession(true);
    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;
    ProcessManagementServiceClient client;
    SVGInterface svg;
    String svgStr;
    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/png"
        response.setContentType("image/png");
        // Create an instance of ServletOutputStream to write the output
        ServletOutputStream sos = response.getOutputStream();
        // Convert the image as a byte array of a PNG
        byte[] pngBytes = svg.toPNGBytes();
        // stream to write binary data into the response
        sos.write(pngBytes);
        sos.flush();
        sos.close();
    } catch (ProcessManagementException e) {
        log.error("PNG Generation Error", e);
    }
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) Log(org.apache.commons.logging.Log) BPELImpl(org.wso2.carbon.bpel.ui.bpel2svg.impl.BPELImpl) ServletOutputStream(javax.servlet.ServletOutputStream) 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 10 with ProcessManagementException

use of org.wso2.carbon.bpel.stub.mgt.ProcessManagementException in project carbon-business-process by wso2.

the class ProcessManagementServiceSkeleton method addFailuresToInstanceSummary.

private void addFailuresToInstanceSummary(final InstanceSummary instSum, ProcessConf pconf) throws ProcessManagementException {
    final FailuresInfo failureInfo = new FailuresInfo();
    String queryStatus = InstanceFilter.StatusKeys.valueOf(TInstanceStatus.ACTIVE.toString()).toString().toLowerCase();
    final InstanceFilter instanceFilter = new InstanceFilter("status=" + queryStatus + " pid=" + pconf.getProcessId());
    dbexec(new BpelDatabase.Callable<Void>() {

        public Void run(BpelDAOConnection conn) throws Exception {
            Date lastFailureDt = null;
            int failureInstances = 0;
            for (ProcessInstanceDAO instance : conn.instanceQuery(instanceFilter)) {
                int count = instance.getActivityFailureCount();
                if (count > 0) {
                    ++failureInstances;
                    Date failureDt = instance.getActivityFailureDateTime();
                    if (lastFailureDt == null || lastFailureDt.before(failureDt)) {
                        lastFailureDt = failureDt;
                    }
                }
            }
            if (failureInstances > 0) {
                failureInfo.setCount(failureInstances);
                failureInfo.setFailureDate(AdminServiceUtils.toCalendar(lastFailureDt));
                instSum.setFailures(failureInfo);
            }
            return null;
        }
    });
}
Also used : InstanceFilter(org.apache.ode.bpel.common.InstanceFilter) ProcessInstanceDAO(org.apache.ode.bpel.dao.ProcessInstanceDAO) BpelDatabase(org.apache.ode.bpel.engine.BpelDatabase) BpelDAOConnection(org.apache.ode.bpel.dao.BpelDAOConnection) FailuresInfo(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.FailuresInfo) 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) Date(java.util.Date)

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