Модераторы: LSD, AntonSaburov
  

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> Intalio Не могу claim, revoke и complete task, Не могу claim, revoke и complete task 
:(
    Опции темы
Hopeless
Дата 14.10.2009, 16:25 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 43
Регистрация: 12.7.2006

Репутация: нет
Всего: нет



Код

package main;

import java.io.StringWriter;
import java.net.URI;
import java.security.SecureRandom;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;

import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.ode.axis2.BindingContextImpl;
import org.apache.ode.axis2.ODEServer;
import org.apache.ode.axis2.service.ServiceClientUtil;
import org.apache.ode.bpel.engine.BpelServerImpl;
import org.apache.ode.bpel.engine.ProcessAndInstanceManagementImpl;
import org.apache.ode.bpel.iapi.BindingContext;
import org.apache.ode.bpel.iapi.BpelServer;
import org.apache.ode.bpel.iapi.ProcessStore;
import org.apache.ode.bpel.pmapi.ProcessInfoListDocument;
import org.apache.ode.bpel.pmapi.TProcessInfoList;
import org.apache.ode.store.ProcessStoreImpl;
import org.intalio.tempo.security.Property;
import org.intalio.tempo.security.authentication.AuthenticationConstants;
import org.intalio.tempo.security.util.PropertyUtils;
import org.intalio.tempo.security.ws.TokenClient;
import org.intalio.tempo.workflow.task.Notification;
import org.intalio.tempo.workflow.task.PATask;
import org.intalio.tempo.workflow.task.PIPATask;
import org.intalio.tempo.workflow.task.Task;
import org.intalio.tempo.workflow.task.xml.XmlTooling;
import org.intalio.tempo.workflow.tms.ITaskManagementService;
import org.intalio.tempo.workflow.tms.client.RemoteTMSClient;
import org.intalio.tempo.workflow.tms.client.RemoteTMSFactory;
import org.intalio.tempo.workflow.tms.server.ITMSServer;
import org.intalio.tempo.workflow.tms.server.TMSRequestProcessor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;

import freemarker.cache.ClassTemplateLoader;
import freemarker.cache.TemplateLoader;
import freemarker.template.Configuration;
import freemarker.template.DefaultObjectWrapper;
import freemarker.template.Template;

public class Test {

    private static final String TMS_REMOTE_URL = "http://localhost:8080/axis2/services/TaskManagementServices";

    static final Logger _log = LoggerFactory.getLogger(Test.class);

    static final String TOKEN_SERVICE = "http://localhost:8080/axis2/services/TokenService";
    static final String TMS_SERVICE = "http://localhost:8080/axis2/services/TaskManagementServices";
    static final String TASK_MANAGEMENT_PROCESS = "http://localhost:8080/ode/processes/completeTask";
    static final String TASK_MANAGEMENT_PROCESS_WORKFLOW = "http://localhost:8080/fds/workflow/xform";

    static final XmlTooling xmlTooling = new XmlTooling();
    static Configuration cfg;
    static final int SLEEP_TIME = 5000;
    static final int MICRO_SLEEP_TIME = 400;

    private static final SecureRandom SECURE_RANDOM = new SecureRandom();
    private static final String TOKEN = "VE9LRU4mJnVzZXI9PWludGFsaW9cYWRtaW4mJmlzc3VlZD09MTE5NzQ0ODYzNjIzNSYmcm9sZXM9PWludGFsaW9ccHJvY2Vzc2FkbWluaXN0cmF0b3IsZXhhbXBsZXNcZW1wbG95ZWUsaW50YWxpb1xwcm9jZXNzbWFuYWdlcixleGFtcGxlc1xtYW5hZ2VyJiZmdWxsTmFtZT09QWRtaW5pbmlzdHJhdG9yJiZlbWFpbD09YWRtaW5AZXhhbXBsZS5jb20mJm5vbmNlPT0tMjM1OTg5Mzc4MzQ0MDg3MTE5MCYmdGltZXN0YW1wPT0xMTk3NDQ4NjM2MjM2JiZkaWdlc3Q9PXdLNzJnTXhDWDhzS2ZoM29oOFJwcGVjYlV1ND0mJiYmVE9LRU4=";
    private static String task1ID;

    private static EntityManager em;
    private static EntityManagerFactory factory;
    private static EntityTransaction jpa;

    public static void main(String[] args) throws Exception {
        
        ITaskManagementService tms = new RemoteTMSFactory(
                TMS_REMOTE_URL, TOKEN).getService();
        Task[] tasks = tms.getTaskList();
        
        Document input1 = Utils.createXMLDocument("/oderInit.xml");
        task1ID = nextRandom();
        PATask task1 = new PATask(task1ID, new URI("http://localhost/1"), "processID", "urn:completeSOAPAction", input1);
        task1.getUserOwners().add("examples\\ewilliams");
        tms.create(task1);

        TemplateLoader loader = new ClassTemplateLoader(Test.class, "/");
        cfg = new Configuration();
        cfg.setTemplateLoader(loader);
        cfg.setObjectWrapper(new DefaultObjectWrapper());

        // We'll use those parameters for login
        String paramUser = "examples\\ewilliams";
        String paramPassword = "password";

        // We'll use those parameters for initiating the process
        HashMap<String, Object> pipa = new HashMap<String, Object>();
        pipa.put("Product_count", 200);
        pipa.put("Product_id", 4);
        pipa.put("Customer_id", 2);

        // We'll use those parameters to complete the task
        HashMap complete = new HashMap();
        complete.put("continue", "true");

        // Standard absence request
        runOderRequest(paramUser, paramPassword, pipa, complete);
    }

    private static void runOderRequest(String paramUser, String paramPassword,
            HashMap pipa, HashMap complete) throws Exception {
        _log.info("Instanciate token service client");
        TokenClient client = new TokenClient(TOKEN_SERVICE);

        _log.info("We are trying to authenticate as user:" + paramUser
                + " with password:" + paramPassword);
        String token = client.authenticateUser(paramUser, paramPassword);
        _log
                .info("We have gained a token from the token service. We can use it to call authenticated tempo services");
        Property[] props = client.getTokenProperties(token);
        String user = (String) PropertyUtils.getProperty(props,
                AuthenticationConstants.PROPERTY_USER).getValue();
        _log
                .info("Decrypting the token properties. We have successfully logged in as:"
                        + user);

        _log.info("Instanciate tms service client");
        RemoteTMSClient tms = new RemoteTMSClient(TMS_SERVICE, token);

        _log
                .info("get the pipa corresponding to the absence request, by making a query on our available tasks");
        Task[] ts = tms
                .getAvailableTasks("PIPATask",
                        "T._description like '%initForm-init request process Oder/diagram%'");

        String pipaID = ts[0].getID();
        _log
                .info("We have found the task to instanciate the process. This task has the following ID:"
                        + pipaID);
        tms.init(pipaID, xmlTooling.parseXML(pipa(pipa)));
        _log.info("wait for the task to be initiated. Hopefully 2s is enough");
        Thread.sleep(SLEEP_TIME);

        _log.info("get our full activity task list");
        Task[] paList = tms.getAvailableTasks("PATask",
                "ORDER BY T._creationDate DESC");
        _log.info("get the id of the activity task");
        String id = paList[0].getID();
        _log.info("We're about to start using PATask with id:" + id);

        _log
                .info("We cannot get input and output of a task on a get task list call (see WSDL)");
        _log
                .info("Let's call TMS again to get the full input and output data of this PATask");
        PATask task = (PATask) tms.getTask(id);
        _log.info("" + "\nChecking the task metadata..."
                + "\nThe task has been created on:" + task.getCreationDate()
                + "\nIt has the following description:" + task.getDescription()
                + "\nIt is attached to the process with id:"
                + task.getProcessID()
                + "\nIt is attached to the following form:"
                + task.getFormURLAsString() + "\nIt is in the following state:"
                + task.getState() + "\nIt has the following input:\n"
                + task.getInputAsXmlString()
                + "\nIt can be assigned to the following roles:"
                + task.getRoleOwners()
                + "\nIt can be assigned to the following users:"
                + task.getUserOwners());

         _log.info("Let's claim the task: no one else can access this task apart from user:"
         + user);
         sendSoapToTMP(claim(token, id, user), "claimTask");
        _log.info("Let's revoke the task:every one can access this task again");
        sendSoapToTMP(revoke(token, id), "revokeTask");    
        _log.info("Call setoutput from TMS Client");
        tms.setOutput(id, createOutputMessage(complete));
        _log.info("Check the output we've just set");
        String outputAsXmlString = ((PATask) tms.getTask(id))
                .getOutputAsXmlString();
        _log.info(outputAsXmlString);
        _log.info("complete the PA task with some output");
        sendSoapToTMP(complete(token, id, complete), "completeTask");

        _log.info("sleep again to wait for the notification");
        Thread.sleep(SLEEP_TIME);
        Task[] ts2 = tms.getAvailableTasks("Notification",
                "ORDER BY T._creationDate DESC");
        String notificationId = ts2[0].getID();
        _log
                .info("We want to retrieve some more data on the notification with id:"
                        + notificationId);
        Notification notification = (Notification) tms.getTask(notificationId);

        _log.info("The notification has the following:" + "\nInput:"
                + xmlTooling.serializeXML(notification.getInput())
                + "\nCreation Date:" + notification.getCreationDate()
                + "\nAttached Form:" + notification.getFormURLAsString()
                + "\nDescription:" + notification.getDescription());

        _log.info("Dismiss this notification");
        tms.complete(notificationId);
    }

    private static String nextRandom() {
        return String.valueOf(((Integer) SECURE_RANDOM.nextInt(100000000)));
    }

    private static String pipa(HashMap pipa) throws Exception {
        return templateMe("oderInit.ftl", pipa);
    }

    private static String templateMe(String template, Map params)
            throws Exception {
        Template temp = cfg.getTemplate(template);
        StringWriter writer = new StringWriter();
        temp.process(params, writer);
        return writer.toString();
    }

    private static Document createOutputMessage(HashMap complete)
            throws Exception {
        return new XmlTooling().parseXML(templateMe("setoutputOder.ftl",
                complete));
    }

    private static String reassign(String token, String taskId, String user)
            throws Exception {
        HashMap<String, String> escalate = new HashMap<String, String>();
        escalate.put("taskId", taskId);
        escalate.put("token", token);
        escalate.put("user", user);
        return templateMe("escalate.ftl", escalate);
    }

    /**
     * Generate a complete request. This also adds some output to the task.
     */
    private static String complete(String token, String taskId, HashMap complete)
            throws Exception {
        complete.put("taskId", taskId);
        complete.put("token", token);
        complete.put("user", "niko");
        return templateMe("completeOder.ftl", complete);
    }

    /**
     * Generate a revoke request
     */
    private static String revoke(String token, String taskId) throws Exception {
        HashMap<String, String> root = new HashMap<String, String>();
        root.put("taskId", taskId);
        root.put("token", token);
        return templateMe("revoke.ftl", root);
    }

    /**
     * Generate a claim request, for the given user
     */
    private static String claim(String token, String taskId, String user)
            throws Exception {
        HashMap<String, String> root = new HashMap<String, String>();
        root.put("taskId", taskId);
        root.put("user", user);
        root.put("token", token);
        return templateMe("claim.ftl", root);
    }

    private static void sendSoapToTMP(String request, String soapAction)
            throws Exception {
        sendSoapTo(request, soapAction, TASK_MANAGEMENT_PROCESS);
    }

    /**
     * Generic http method to send a soap request
     */
    private static void sendSoapTo(String request, String soapAction,
            String endpoint) throws Exception {
        ServiceClient serviceClient = new ServiceClient();
        OMFactory factory = OMAbstractFactory.getOMFactory();
        Options options = new Options();
        options.setTo(new EndpointReference(endpoint));
        serviceClient.setOptions(options);
        options.setAction(soapAction);
        OMElement response = serviceClient.sendReceive(xmlTooling
                .convertDOMToOM(xmlTooling.parseXML(request), factory));
        _log.info(MessageFormat.format("Answer from endpoint {0}: {1}",
                endpoint, response.toString()));
    }

    private static void persist(Object o) throws Exception {
        jpa.begin();
        em.persist(o);
        jpa.commit();
        // this is to prevent caching at the entity manager level
        em.clear();
    }

}


Intalio console:
Код

12:06:47,252 INFO  [Catalina] Initialization processed in 546 ms
Starting Derby Network server on localhost:1527
14 ???????В 2009 12:06:47 bitronix.tm.integration.tomcat55.BTMLifecycleListener lifecycleEvent
INFO: Starting Bitronix Transaction Manager
12:07:13,737 WARN  [JmxUtils] Found more than one MBeanServer instance. Returning first from list.
12:08:00,737 INFO  [HostConfig] Deploying web application archive drools-server-5.0.1.war
14 ???????В 2009 12:08:02 com.sun.xml.ws.transport.http.servlet.WSServletContextListener contextInitialized
INFO: WSSERVLET12: JAX-WS context listener initializing
14 ???????В 2009 12:08:04 com.sun.xml.ws.transport.http.servlet.WSServletDelegate <init>
INFO: WSSERVLET14: JAX-WS servlet initializing
12:08:05,612 INFO  [Catalina] Server startup in 78360 ms
13:07:07,362 ERROR [ODEService] Timeout or execution error when waiting for response to MEX {MyRoleMex#7241729 [Client e753c8c4-0367-453e-ad0
b-3adbe64714a8-1] calling {http://www.intalio.com/bpms/workflow/ib4p_20051115}UIFWService.claimTask(...)} java.util.concurrent.TimeoutExcepti
on: Message exchange org.apache.ode.bpel.engine.MyRoleMessageExchangeImpl$ResponseFuture@1a537e7 timed out(120000 ms) when waiting for a resp
onse!
java.util.concurrent.TimeoutException: Message exchange org.apache.ode.bpel.engine.MyRoleMessageExchangeImpl$ResponseFuture@1a537e7 timed out
(120000 ms) when waiting for a response!
        at org.apache.ode.bpel.engine.MyRoleMessageExchangeImpl$ResponseFuture.get(MyRoleMessageExchangeImpl.java:240)
        at org.apache.ode.axis2.ODEService.onAxisMessageExchange(ODEService.java:165)
        at org.apache.ode.axis2.hooks.ODEMessageReceiver.invokeBusinessLogic(ODEMessageReceiver.java:69)
        at org.apache.ode.axis2.hooks.ODEMessageReceiver.invokeBusinessLogic(ODEMessageReceiver.java:52)
        at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:114)
        at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:173)
        at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:167)
        at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:142)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
        at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
        at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
        at java.lang.Thread.run(Thread.java:619)


Это сообщение отредактировал(а) Hopeless - 14.10.2009, 16:32

Присоединённый файл ( Кол-во скачиваний: 2 )
Присоединённый файл  Oder.zip 133,09 Kb
PM MAIL   Вверх
Hopeless
Дата 15.10.2009, 17:56 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 43
Регистрация: 12.7.2006

Репутация: нет
Всего: нет



Когда я даже инициализирую процесс в Wev Service Explorer через TaskManadgerService то получаю ошибку в задаче "Request Available Produst Number" процесса:





Код

 Fault info  

Namespace:     http://docs.oasis-open.org/wsbpel/2.0/process/executable

Name:     selectionFailure

Explanation:     R-Value expression "{OXPath10Expression $initForm1InitProcessRequestMsg.root/initForm1:taskOutput/initForm1:output/initForm1:Product_id}" did not select any nodes.

Line number:     293

Aiid:     111







Инициализирую так:

 
Код

Endpoints  http://localhost:8080/axis2/services/TaskManagementServices.TaskManagementServicesSOAP/  

 Body 

  initRequest    

    taskId  string      

  input    

    ::inputinitRequest::0::0::2::0::0::1     

<output>         

            <request>                 

                <Product_count>333</Product_count>                 

                <Product_id>4</Product_id>                 

                <Customer_id>2</Customer_id>         

            </request>

        </output>  

 

 

 

 

participantToken  
VE9LRU4mJnVzZXI9PWV4YW1wbGVzXGV3aWxsaWFtcyYmaXNzdWVkPT0xMjU1NTk2NTExODgyJiZyb2xlcz09ZXhhbXBsZXNcbWFuYWdlcixleGFtcGxlc1xlbXBsb3llZSYmZnVsbE5hbWU9PUVtaWx5IFdpbGxpYW1zJiZlbWFpbD09ZXdpbGxpYW1zQGV4YW1wbGVzLmludGFsaW8uY29tJiZub25jZT09MjQyNjk1MDI1MDYyOTQxMT
Q5NyYmdGltZXN0YW1wPT0xMjU1NTk2NTExODgyJiZkaWdlc3Q9PTc4bUJyUGVhVFNjc0JaMTR6d2drNjg2MkVCZz0mJiYmVE9LRU4




PM MAIL   Вверх
  
Ответ в темуСоздание новой темы Создание опроса
Правила форума "Java"
LSD   AntonSaburov
powerOn   tux
  • Прежде, чем задать вопрос, прочтите это!
  • Книги по Java собираются здесь.
  • Документация и ресурсы по Java находятся здесь.
  • Используйте теги [code=java][/code] для подсветки кода. Используйтe чекбокс "транслит", если у Вас нет русских шрифтов.
  • Помечайте свой вопрос как решённый, если на него получен ответ. Ссылка "Пометить как решённый" находится над первым постом.
  • Действия модераторов можно обсудить здесь.
  • FAQ раздела лежит здесь.

Если Вам помогли, и атмосфера форума Вам понравилась, то заходите к нам чаще! С уважением, LSD, AntonSaburov, powerOn, tux.

 
1 Пользователей читают эту тему (1 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | Java EE (J2EE) и Spring | Следующая тема »


 




[ Время генерации скрипта: 0.0950 ]   [ Использовано запросов: 21 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.