Package org.enhydra.shark.api.client.wfservice

Examples of org.enhydra.shark.api.client.wfservice.ExecutionAdministration


                    throw new ContainerException(e);
                }
            }
        }
        // re-eval current assignments
        ExecutionAdministration exAdmin = SharkContainer.getAdminInterface().getExecutionAdministration();
        try {
            //exAdmin.connect(adminUser.getString("userLoginId"), SharkContainer.adminPass, null, null);
            exAdmin.connect(adminUser.getString("userLoginId"), adminUser.getString("currentPassword"), null, null);
            // this won't work with encrypted passwords: exAdmin.connect(adminUser.getString("userLoginId"), adminUser.getString("currentPassword"), null, null);
            exAdmin.reevaluateAssignments();
            exAdmin.disconnect();
        } catch (ConnectFailed e) {
            String errMsg = "Shark Connection error (if it is a password wrong error, check the admin-pass property in the container config file, probably ofbiz-containers.xml): " + e.toString();
            throw new ContainerException(errMsg, e);
        } catch (NotConnected e) {
            throw new ContainerException(e);
View Full Code Here


        } catch (GenericEntityException e) {
            Debug.logError(e, module);
        }
        if (userLogin != null) {
            AdminInterface admin = SharkContainer.getAdminInterface();
            ExecutionAdministration exAdmin = admin.getExecutionAdministration();
            boolean connected = true;
            try {
                exAdmin.connect(userLogin.getString("userLoginId"), userLogin.getString("currentPassword"), null, null);
            } catch (BaseException e) {
                Debug.logError(e, module);
                connected = false;
            } catch (ConnectFailed e) {
                Debug.logError(e, module);
                connected = false;
            }

            if (connected) {
                performers = new ArrayList(performerIds.size());
                Iterator i = performerIds.iterator();
                try {
                    while (i.hasNext()) {
                        String processId = (String) i.next();
                        exAdmin.getProcess(processId);
                    }
                } catch (Exception e) {
                    Debug.logError(e, module);
                    performers = null;
                } finally {
                    try {
                        exAdmin.disconnect();
                    } catch (BaseException e) {
                        Debug.logError(e, module);
                    } catch (NotConnected e) {
                        Debug.logError(e, module);
                    }
View Full Code Here

                    throw new ContainerException(e);
                }
            }
        }
        // re-eval current assignments
        ExecutionAdministration exAdmin = SharkContainer.getAdminInterface().getExecutionAdministration();
        try {
            //exAdmin.connect(adminUser.getString("userLoginId"), SharkContainer.adminPass, null, null);
            exAdmin.connect(adminUser.getString("userLoginId"), adminUser.getString("currentPassword"), null, null);
            // this won't work with encrypted passwords: exAdmin.connect(adminUser.getString("userLoginId"), adminUser.getString("currentPassword"), null, null);
            exAdmin.reevaluateAssignments();
            exAdmin.disconnect();
        } catch (ConnectFailed e) {
            String errMsg = "Shark Connection error (if it is a password wrong error, check the admin-pass property in the container config file, probably ofbiz-containers.xml): " + e.toString();
            throw new ContainerException(errMsg, e);
        } catch (NotConnected e) {
            throw new ContainerException(e);
View Full Code Here

        if (userLogin == null) {
            userLogin = SharkContainer.getAdminUser();
        }

        AdminInterface admin = SharkContainer.getAdminInterface();
        ExecutionAdministration exec = admin.getExecutionAdministration();

        boolean beganTrans = false;
        boolean hasError = false;
        Transaction trans = null;

        try {
            beganTrans = TransactionUtil.begin();
            if (!beganTrans) {
                trans = TransactionUtil.suspend();
                beganTrans = TransactionUtil.begin();
            }

            try {
                // connect to admin API
                try {
                    exec.connect(userLogin.getString("userLoginId"), userLogin.getString("currentPassword"), null, null);
                } catch (BaseException e) {
                    throw new GenericServiceException(e);
                } catch (ConnectFailed e) {
                    throw new GenericServiceException(e);
                }

                try {
                    // create the requester
                    WfRequester req = new SimpleRequester(userLogin, model, waiter);
                    WfProcessMgr mgr = null;
                    String location = this.getLocation(model);
                    String version = null;

                    // locate packageId::version
                    if (location.indexOf("::") != -1) {
                        List splitList = StringUtil.split(location, "::");
                        location = (String) splitList.get(0);
                        version = (String) splitList.get(1);
                    }

                    // obtain the process manager
                    try {
                        if (version == null) {
                            mgr = exec.getProcessMgr(location, model.invoke);
                        } else {
                            mgr = exec.getProcessMgr(location, version, model.invoke);
                        }
                    } catch (BaseException e) {
                        throw new GenericServiceException(e);
                    } catch (NotConnected e) {
                        throw new GenericServiceException(e);
                    }

                    // make sure the manager exists
                    if (mgr == null) {
                        throw new GenericServiceException("Unable to obtain Process Manager for : " + this.getLocation(model) + " / " + model.invoke);
                    }

                    // create the process instance
                    WfProcess proc = null;
                    try {
                        proc = mgr.create_process(req);
                    } catch (BaseException e) {
                        throw new GenericServiceException(e);
                    } catch (NotEnabled e) {
                        throw new GenericServiceException(e);
                    } catch (InvalidRequester e) {
                        throw new GenericServiceException(e);
                    } catch (RequesterRequired e) {
                        throw new GenericServiceException(e);
                    }

                    Map contextSig = null;
                    try {
                        contextSig = mgr.context_signature();
                    } catch (BaseException e) {
                        throw new GenericServiceException(e);
                    }

                    if (contextSig != null) {
                        Iterator sigKeys = contextSig.keySet().iterator();
                        Map formalParams = new HashMap();
                        while (sigKeys.hasNext()) {
                            String key = (String) sigKeys.next();
                            formalParams.put(key, context.get(key));
                        }

                        // set the initial WRD
                        try {
                            proc.set_process_context(formalParams);
                        } catch (BaseException e) {
                            throw new GenericServiceException(e);
                        } catch (InvalidData e) {
                            throw new GenericServiceException(e);
                        } catch (UpdateNotAllowed e) {
                            throw new GenericServiceException(e);
                        }
                    }

                    // start the process
                    try {
                        proc.start();
                    } catch (BaseException e) {
                        throw new GenericServiceException(e);
                    } catch (CannotStart e) {
                        throw new GenericServiceException(e);
                    } catch (AlreadyRunning e) {
                        throw new GenericServiceException(e);
                    }
                } catch (GenericServiceException e) {
                    throw e;
                } finally {
                    // disconnect from admin API
                    try {
                        exec.disconnect();
                    } catch (NotConnected e) {
                        throw new GenericServiceException(e);
                    } catch (BaseException e) {
                        throw new GenericServiceException(e);
                    }
View Full Code Here

        } catch (GenericEntityException e) {
            Debug.logError(e, module);
        }
        if (userLogin != null) {
            AdminInterface admin = SharkContainer.getAdminInterface();
            ExecutionAdministration exAdmin = admin.getExecutionAdministration();
            boolean connected = true;
            try {
                exAdmin.connect(userLogin.getString("userLoginId"), userLogin.getString("currentPassword"), null, null);
            } catch (BaseException e) {
                Debug.logError(e, module);
                connected = false;
            } catch (ConnectFailed e) {
                Debug.logError(e, module);
                connected = false;
            }

            if (connected) {
                performers = new ArrayList(performerIds.size());
                Iterator i = performerIds.iterator();
                try {
                    while (i.hasNext()) {
                        String processId = (String) i.next();
                        exAdmin.getProcess(processId);
                    }
                } catch (Exception e) {
                    Debug.logError(e, module);
                    performers = null;
                } finally {
                    try {
                        exAdmin.disconnect();
                    } catch (BaseException e) {
                        Debug.logError(e, module);
                    } catch (NotConnected e) {
                        Debug.logError(e, module);
                    }
View Full Code Here

        if (userLogin == null) {
            userLogin = SharkContainer.getAdminUser();
        }

        AdminInterface admin = SharkContainer.getAdminInterface();
        ExecutionAdministration exec = admin.getExecutionAdministration();

        boolean beganTrans = false;
        boolean hasError = false;
        Transaction trans = null;

        try {
            beganTrans = TransactionUtil.begin();
            if (!beganTrans) {
                trans = TransactionUtil.suspend();
                beganTrans = TransactionUtil.begin();
            }

            try {
                // connect to admin API
                try {
                    exec.connect(userLogin.getString("userLoginId"), userLogin.getString("currentPassword"), null, null);
                } catch (BaseException e) {
                    throw new GenericServiceException(e);
                } catch (ConnectFailed e) {
                    throw new GenericServiceException(e);
                }

                try {
                    // create the requester
                    WfRequester req = new SimpleRequester(userLogin, model, waiter);
                    WfProcessMgr mgr = null;
                    String location = this.getLocation(model);
                    String version = null;

                    // locate packageId::version
                    if (location.indexOf("::") != -1) {
                        List splitList = StringUtil.split(location, "::");
                        location = (String) splitList.get(0);
                        version = (String) splitList.get(1);
                    }

                    // obtain the process manager
                    try {
                        if (version == null) {
                            mgr = exec.getProcessMgr(location, model.invoke);
                        } else {
                            mgr = exec.getProcessMgr(location, version, model.invoke);
                        }
                    } catch (BaseException e) {
                        throw new GenericServiceException(e);
                    } catch (NotConnected e) {
                        throw new GenericServiceException(e);
                    }

                    // make sure the manager exists
                    if (mgr == null) {
                        throw new GenericServiceException("Unable to obtain Process Manager for : " + this.getLocation(model) + " / " + model.invoke);
                    }

                    // create the process instance
                    WfProcess proc = null;
                    try {
                        proc = mgr.create_process(req);
                    } catch (BaseException e) {
                        throw new GenericServiceException(e);
                    } catch (NotEnabled e) {
                        throw new GenericServiceException(e);
                    } catch (InvalidRequester e) {
                        throw new GenericServiceException(e);
                    } catch (RequesterRequired e) {
                        throw new GenericServiceException(e);
                    }

                    Map contextSig = null;
                    try {
                        contextSig = mgr.context_signature();
                    } catch (BaseException e) {
                        throw new GenericServiceException(e);
                    }

                    if (contextSig != null) {
                        Iterator sigKeys = contextSig.keySet().iterator();
                        Map formalParams = new HashMap();
                        while (sigKeys.hasNext()) {
                            String key = (String) sigKeys.next();
                            formalParams.put(key, context.get(key));
                        }

                        // set the initial WRD
                        try {
                            proc.set_process_context(formalParams);
                        } catch (BaseException e) {
                            throw new GenericServiceException(e);
                        } catch (InvalidData e) {
                            throw new GenericServiceException(e);
                        } catch (UpdateNotAllowed e) {
                            throw new GenericServiceException(e);
                        }
                    }

                    // start the process
                    try {
                        proc.start();
                    } catch (BaseException e) {
                        throw new GenericServiceException(e);
                    } catch (CannotStart e) {
                        throw new GenericServiceException(e);
                    } catch (AlreadyRunning e) {
                        throw new GenericServiceException(e);
                    }
                } catch (GenericServiceException e) {
                    throw e;
                } finally {
                    // disconnect from admin API
                    try {
                        exec.disconnect();
                    } catch (NotConnected e) {
                        throw new GenericServiceException(e);
                    } catch (BaseException e) {
                        throw new GenericServiceException(e);
                    }
View Full Code Here

                    throw new ContainerException(e);
                }
            }
        }
        // re-eval current assignments
        ExecutionAdministration exAdmin = SharkContainer.getAdminInterface().getExecutionAdministration();
        try {
            //exAdmin.connect(adminUser.getString("userLoginId"), SharkContainer.adminPass, null, null);
            exAdmin.connect(adminUser.getString("userLoginId"), adminUser.getString("currentPassword"), null, null);
            // this won't work with encrypted passwords: exAdmin.connect(adminUser.getString("userLoginId"), adminUser.getString("currentPassword"), null, null);
            exAdmin.reevaluateAssignments();
            exAdmin.disconnect();
        } catch (ConnectFailed e) {
            String errMsg = "Shark Connection error (if it is a password wrong error, check the admin-pass property in the container config file, probably ofbiz-containers.xml): " + e.toString();
            throw new ContainerException(errMsg, e);
        } catch (NotConnected e) {
            throw new ContainerException(e);
View Full Code Here

        } catch (GenericEntityException e) {
            Debug.logError(e, module);
        }
        if (userLogin != null) {
            AdminInterface admin = SharkContainer.getAdminInterface();
            ExecutionAdministration exAdmin = admin.getExecutionAdministration();
            boolean connected = true;
            try {
                exAdmin.connect(userLogin.getString("userLoginId"), userLogin.getString("currentPassword"), null, null);
            } catch (BaseException e) {
                Debug.logError(e, module);
                connected = false;
            } catch (ConnectFailed e) {
                Debug.logError(e, module);
                connected = false;
            }

            if (connected) {
                performers = new ArrayList(performerIds.size());
                Iterator i = performerIds.iterator();
                try {
                    while (i.hasNext()) {
                        String processId = (String) i.next();
                        exAdmin.getProcess(processId);
                    }
                } catch (Exception e) {
                    Debug.logError(e, module);
                    performers = null;
                } finally {
                    try {
                        exAdmin.disconnect();
                    } catch (BaseException e) {
                        Debug.logError(e, module);
                    } catch (NotConnected e) {
                        Debug.logError(e, module);
                    }
View Full Code Here

            sc = connect();

            // delete process instances
            LogUtil.info(getClass().getName(), "Deleting running processes for " + packageId + " version " + version);
            Shark shark = Shark.getInstance();
            ExecutionAdministration ea = shark.getExecutionAdministration();
            WAPI wapi = shark.getWAPIConnection();
            WfProcessIterator wpi = sc.get_iterator_process();
            ProcessFilterBuilder fb = shark.getProcessFilterBuilder();
            WMSessionHandle sessionHandle = sc.getSessionHandle();
            WMFilter filter1 = fb.addPackageIdEquals(sessionHandle, packageId);
            WMFilter filter2 = fb.addVersionEquals(sessionHandle, version);
            WMFilter filter = fb.and(sessionHandle, filter1, filter2);
            wpi.set_query_expression(fb.toIteratorExpression(sessionHandle, filter));
            WfProcess[] procs = wpi.get_next_n_sequence(0);
            for (int i = 0; i < procs.length; i++) {
                String instanceId = procs[i].key();
                try {
                    if (procs[i].state().startsWith(SharkConstants.STATEPREFIX_OPEN)) {
                        wapi.terminateProcessInstance(sessionHandle, instanceId);
                        LogUtil.info(getClass().getName(), " -- Terminated open process " + instanceId);
                    }
                    ea.deleteProcesses(sessionHandle, new String[]{instanceId});
                    LogUtil.info(getClass().getName(), " -- Deleted process " + instanceId);
                } catch (Exception e) {
                    LogUtil.info(getClass().getName(), " -- Could not delete process " + instanceId + ": " + e.toString());
                }
            }
View Full Code Here

            sc = connect();

            // delete process instances
            LogUtil.info(getClass().getName(), "Deleting all running processes for " + packageId);
            Shark shark = Shark.getInstance();
            ExecutionAdministration ea = shark.getExecutionAdministration();
            WMSessionHandle sessionHandle = sc.getSessionHandle();
            PackageAdministration pa = getSharkPackageAdmin(sessionHandle);
            WAPI wapi = shark.getWAPIConnection();
            WfProcessIterator wpi = sc.get_iterator_process();
            ProcessFilterBuilder fb = shark.getProcessFilterBuilder();
            WMFilter filter = fb.addPackageIdEquals(sessionHandle, packageId);
            wpi.set_query_expression(fb.toIteratorExpression(sessionHandle, filter));
            WfProcess[] procs = wpi.get_next_n_sequence(0);
            for (int i = 0; i < procs.length; i++) {
                String instanceId = procs[i].key();
                if (procs[i].state().startsWith(SharkConstants.STATEPREFIX_OPEN)) {
                    wapi.terminateProcessInstance(sessionHandle, instanceId);
                    LogUtil.info(getClass().getName(), " -- Terminated open process " + instanceId);
                }
                ea.deleteProcesses(sessionHandle, new String[]{instanceId});
                LogUtil.info(getClass().getName(), " -- Deleted process " + instanceId);
            }

            // unload
            pa.closeAllPackagesForId(sessionHandle, packageId);
View Full Code Here

TOP

Related Classes of org.enhydra.shark.api.client.wfservice.ExecutionAdministration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.