⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 restworksession.java

📁 一个工作流设计及定义的系统,可以直接与数据库结合进行系统工作流程的定义及应用.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            // ignore        }        java.util.List feis = this.session.findFlowInstance(storeName, wfid);        reply(key, getCoder().encodeIdsAsXml(feis));    }    public void do_getworkitem        (final SelectionKey key, final String firstLine, final byte[] request)    throws         Exception    {        final String storeName = extractStoreName(request);        InFlowWorkItem item = null;        if (firstLine.startsWith("GET "))        {            String sid = RestUtils.extractFromLine(firstLine, "id");            item = this.session.get(storeName, sid);        }        else        {            final org.jdom.Element reqElt = parseBody(key, request);            //log.debug            //    ("getWorkItem() : request body >\n"+            //     openwfe.org.Utils.toString(reqElt, "ISO-8859-1"));            final FlowExpressionId itemId =                 getCoder().decodeFlowExpressionId(reqElt);            item = this.session.get(storeName, itemId);        }        // debug        //openwfe.org.Utils.dump        //    ("rest_4_",         //     item.getAttributes().sget("field")        //      .getBytes(openwfe.org.Utils.getEncoding()));        reply(key, getCoder().encodeAsXml(item));    }    public void do_getandlockworkitem        (final SelectionKey key, final String firstLine, final byte[] request)    throws         Exception    {        final String storeName = extractStoreName(request);        InFlowWorkItem item = null;        try        {            if (firstLine.startsWith("GET "))            {                String sid = RestUtils.extractFromLine(firstLine, "id");                item = this.session.getAndLock(storeName, sid);            }            else            {                final org.jdom.Element reqElt = parseBody(key, request);                final FlowExpressionId fei =                     getCoder().decodeFlowExpressionId(reqElt);                item = this.session.getAndLock(storeName, fei);            }        }        catch (final Exception e)        {            log.debug("do_getandlockworkitem() trouble", e);            rethrowAsHttpException(404, e);        }        reply(key, getCoder().encodeAsXml(item));    }    public void do_releaseworkitem        (final SelectionKey key, final String firstLine, final byte[] request)    throws         Exception    {        final String storeName = extractStoreName(request);        final org.jdom.Element reqElt =             parseBody(key, request);        final InFlowWorkItem item = (InFlowWorkItem)getCoder().decode            (reqElt, null, null);        try        {            this.session.release(storeName, item);        }        catch (final Exception e)        {            rethrowAsHttpException(403, e);        }        reply(key, new org.jdom.Element("ok"));    }    public void do_saveworkitem        (final SelectionKey key, final String firstLine, final byte[] request)    throws         Exception    {        String storeName = extractStoreName(request);        org.jdom.Element reqElt =             parseBody(key, request);        InFlowWorkItem item =             (InFlowWorkItem)getCoder().decode(reqElt, null, null);        this.session.save(storeName, item);        reply(key, new org.jdom.Element("ok"));    }    public void do_forwardworkitem        (final SelectionKey key, final String firstLine, final byte[] request)    throws         Exception    {        String storeName = extractStoreName(request);        org.jdom.Element reqElt =             parseBody(key, request);        InFlowWorkItem item =             (InFlowWorkItem)getCoder().decode(reqElt, null, null);        this.session.forward(storeName, item);        reply(key, new org.jdom.Element("ok"));    }    protected org.jdom.Element encodeLaunchables         (final java.util.List launchables)    {        org.jdom.Element eLs = new org.jdom.Element(E_LAUNCHABLES);        java.util.Iterator it = launchables.iterator();        while (it.hasNext())        {            Launchable l = (Launchable)it.next();            org.jdom.Element e = new org.jdom.Element(E_LAUNCHABLE);            e.setAttribute(A_ENGINE_ID, l.getEngineId());            e.setAttribute(A_URL, l.getUrl());            eLs.addContent(e);        }        return eLs;    }    public void do_listlaunchables        (final SelectionKey key, final String firstLine, final byte[] request)    throws         Exception    {        reply(key, encodeLaunchables(this.session.getLaunchables()));    }    public void do_launchflow        (final SelectionKey key, final String firstLine, final byte[] request)    throws         Exception    {        String engineId = RestUtils.extractFromLine            (RestService.createBufferedReader(request).readLine(),              "engineid");        org.jdom.Element reqElt =             parseBody(key, request);        LaunchItem item =             (LaunchItem)getCoder().decode(reqElt, null, null);        //log.debug        //    ("do_launchflow() field is >"+item.getAttributes().sget("field")+        //     "<");        final String flowId = this.session.launch(engineId, item);        org.jdom.Element eReply = new org.jdom.Element("ok");        eReply.setAttribute("flow-id", flowId);        reply(key, eReply);    }    public void do_delegate        (final SelectionKey key, final String firstLine, final byte[] request)    throws         Exception    {        //String firstLine =         //    RestService.createBufferedReader(request).readLine();        String storeName =             extractStoreName(firstLine);        String targetStore =             RestUtils.extractFromLine(firstLine, "targetstore");        String targetParticipant =             RestUtils.extractFromLine(firstLine, "targetparticipant");        org.jdom.Element reqElt =             parseBody(key, request);        InFlowWorkItem item =             (InFlowWorkItem)getCoder().decode(reqElt, null, null);        if (targetStore != null)        {            this.session.delegate                (storeName, item, targetStore);        }        else if (targetParticipant != null)        {            this.session.delegateToParticipant                (storeName, item, targetParticipant);        }        else        {            throw new WorkListException                ("'targetstore' or 'targetparticipant' required");        }        reply(key, new org.jdom.Element("ok"));    }    public XmlWorkItemAndHeaderCoder getCoder ()    {        return this.coder;    }    //    // STATIC METHODS    protected static String extractStoreName (byte[] request)        throws Exception    {        return extractStoreName            (RestService.createBufferedReader(request).readLine());    }    protected static String extractStoreName (String line)        throws java.net.MalformedURLException    {        int i = line.indexOf("/worklist/");        if (i < 0)        {            throw new java.net.MalformedURLException                ("No storeName in >"+line+"<");        }        line = line.substring(i+10);        i = line.indexOf("?");        if (i < 0)        {            throw new java.net.MalformedURLException                ("Invalid storeName in >"+line+"<");        }        line = line.substring(0, i);        //log.debug("storeName seems to be >"+line+"<");        return line;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -