?? wfcmd.java
字號:
/* * Copyright (c) 2005, John Mettraux, OpenWFE.org * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * . Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * . Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * . Neither the name of the "OpenWFE" nor the names of its contributors may be * used to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * $Id: WfCmd.java,v 1.11 2005/05/17 16:41:02 jmettraux Exp $ */package openwfe.org.wlshell;import java.io.BufferedReader;import java.io.InputStreamReader;import java.rmi.Naming;import java.util.Date;import java.util.Iterator;import java.util.List;import javax.security.auth.Subject;import openwfe.org.shell.CmdHandler;import openwfe.org.rmi.session.WorkSessionServer;import openwfe.org.engine.workitem.Attribute;import openwfe.org.engine.workitem.HistoryItem;import openwfe.org.engine.workitem.InFlowWorkItem;import openwfe.org.engine.workitem.LaunchItem;import openwfe.org.engine.workitem.LongAttribute;import openwfe.org.engine.workitem.StringAttribute;import openwfe.org.engine.workitem.StringMapAttribute;import openwfe.org.engine.expressions.FlowExpressionId;import openwfe.org.worklist.Header;import openwfe.org.worklist.Launchable;import openwfe.org.worklist.WorkSession;/** * An RMI shell for tinkering with a worklist * * <p><font size=2>CVS Info : * <br>$Author: jmettraux $ * <br>$Date: 2005/05/17 16:41:02 $ * <br>$Id: WfCmd.java,v 1.11 2005/05/17 16:41:02 jmettraux Exp $ </font> * * @author Peter Mayne * @author jmettraux@openwfe.org */public class WfCmd{ public final static String BANNER = "\n" + WfCmd.class.getName() + "\nBy Peter Mayne\n$Id: WfCmd.java,v 1.11 2005/05/17 16:41:02 jmettraux Exp $\n"; // The default maximum number of workitems that will be displayed. // final static int DEFAULT_LIMIT = 1000; private String url; private WorkSession session; private String prompt; private String language = null; private BufferedReader reader; public WfCmd(String url, WorkSession session, BufferedReader reader) { this.url = url; this.session = session; prompt = url + "> "; this.reader = reader; } public void help_count() { System.out.println("count [<storeName>]"); System.out.println(" Returns the count of workitems in the store. If you don't provide a"); System.out.println(" storeName, it will be set to 'default'."); } /** * Display the number of workflow items in a store. * * @param args * @return * @throws Exception */ public Boolean do_count(String[] args) throws Exception { String storeName = "default"; if (args.length > 0) { storeName = args[0]; } System.out.print("WorkItems in store '" + storeName + "': "); int count = session.countWorkItems(storeName); System.out.println(count); return CmdHandler.DO_NOT_EXIT; } public void help_display() { System.out.println("display <store> <workflow item id>"); System.out.println(" Display the specified workflow item."); } /** * Show a workflow item. * * @param args * @return * @throws Exception */ public Boolean do_display (final String[] args) throws Exception { if (args.length!=2) { System.out.println("Required parameters not specified"); return CmdHandler.DO_NOT_EXIT; } String storeName = args[0]; String id = args [1]; Header header = getHeader(session, storeName, id); if (header!=null) { FlowExpressionId fei = header.getExpressionId(); InFlowWorkItem wi = session.get(storeName, fei); displayWorkItem(header, wi); } else { System.out.println("No such work item."); } return CmdHandler.DO_NOT_EXIT; } public void help_edit() { System.out.println("edit <store> <workflow item id>"); System.out.println(" Edit the specified workflow item."); } /** * Edit a workflow item. * * @param args * @return * @throws Exception */ public Boolean do_edit (String[] args) throws Exception { if(args.length!=2) { System.out.println("Required parameters not specified"); return CmdHandler.DO_NOT_EXIT; } String storeName = args[0]; String id = args[1]; Header header = getHeader(session, storeName, id); // Start a new workitem editor. // new WfCmdEdit(session, storeName, header, reader).run(); return CmdHandler.DO_NOT_EXIT; } public void help_headers () { System.out.println("headers [<storeName> [<limit>]]"); System.out.println(" Returns headers of the workitem in a given store (defaults to"); System.out.println(" store 'default'). The 'limit' parameters defaults to " + DEFAULT_LIMIT + " and allows you"); System.out.println(" to specify how may headers you want to receive at max."); } public Boolean do_headers (String[] args) throws Exception { String storeName = "default"; int limit = DEFAULT_LIMIT; String sLimit = null; if (args.length > 0) { storeName = args[0]; } if (args.length > 1) { sLimit = args[1]; } if (sLimit != null) { try { limit = Integer.parseInt(sLimit); } catch (NumberFormatException nfe) { System.out.println("Cannot read '" + sLimit + "': setting limit to " + limit); } } List headers = session.getHeaders(storeName, limit); // Display the headers. // System.out.println(); final Iterator it = headers.iterator(); while (it.hasNext()) { final Header header = (Header)it.next(); final StringMapAttribute sma = header.getAttributes(); System.out.println("Workflow " + sma.get(Header.WF_DEFINITION_NAME) + " " + sma.get(Header.WF_DEFINITION_REVISION) + " : " + sma.get(Header.WF_INSTANCE_ID)); StringAttribute subject = (StringAttribute)sma.get(Header.SUBJECT); System.out.println("\"" + (subject!=null ? subject.toString() : "") + "\""); System.out.println("Dispatch time : " + sma.get(Header.DISPATCH_TIME)); System.out.println("Last modified : " + header.getLastModified()); System.out.println("Participant : " + sma.get(Header.PARTICIPANT_NAME)); System.out.println("."); System.out.println("headers 'en vrac' :"); final java.util.Iterator jt = sma.stringKeySet().iterator(); while (jt.hasNext()) { final String key = (String)jt.next(); System.out.println(" * '"+key+"': '"+sma.get(key)+"'"); } if (header.isLocked()) System.out.println("Locked"); System.out.println(); } return CmdHandler.DO_NOT_EXIT; } public void help_launch() { System.out.println("launch <url>"); // | flow <name> <version>"); System.out.println(" Launch the specified workflow.");// System.out.println(" Specify the URL of the workflow."); //, or its name and version."); } public Boolean do_launch(String[] args) { if(args.length!=1) { System.out.println("Incorrect parameters specified"); return CmdHandler.DO_NOT_EXIT; } String url = args[0]; try { Launchable launch = null; LaunchItem li = null; for(Iterator it = session.getLaunchables().iterator(); it.hasNext();) { launch = (Launchable)it.next(); if(launch.getUrl().equalsIgnoreCase(url)) { li = launch.getLaunchItem(); break; } } if(li!=null) { // Add the subject. // System.out.print("Subject: "); String line = null; try { line = reader.readLine().trim(); } catch(Exception e)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -