provisionr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From as...@apache.org
Subject [20/21] PROVISIONR-20. Change groupId from com.axemblr.provisionr to org.apache.provisionr
Date Mon, 01 Apr 2013 08:52:43 GMT
http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/activiti/commands/src/main/java/org/activiti/karaf/commands/StartActivitiCommand.java
----------------------------------------------------------------------
diff --git a/activiti/commands/src/main/java/org/activiti/karaf/commands/StartActivitiCommand.java b/activiti/commands/src/main/java/org/activiti/karaf/commands/StartActivitiCommand.java
deleted file mode 100644
index 00b437a..0000000
--- a/activiti/commands/src/main/java/org/activiti/karaf/commands/StartActivitiCommand.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2012 Cisco Systems
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.activiti.karaf.commands;
-
-import org.activiti.engine.ProcessEngine;
-import org.activiti.engine.RuntimeService;
-import org.activiti.engine.runtime.ProcessInstance;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-
-/**
- * @author Srinivasan Chikkala
- */
-@Command(scope = "activiti", name = "start",
-    description = "Starts the Activiti process instance from a deployed process definition")
-public class StartActivitiCommand extends ActivitiCommand {
-
-    @Argument(index = 0, name = "definitionID", required = true, multiValued = false,
-        description = "Activiti Process definition ID to start an instance of it.")
-    private String definitionID;
-
-    @Override
-    protected Object doExecute() throws Exception {
-        ProcessEngine pe = this.getProcessEngine();
-        if (pe == null) {
-            out().println("Process Engine NOT Found!");
-            return null;
-        }
-
-        RuntimeService rt = pe.getRuntimeService();
-        if (definitionID != null) {
-            ProcessInstance pi = rt.startProcessInstanceById(definitionID);
-            out().printf("Process instance %s Started\n", pi.getProcessInstanceId());
-        }
-
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/activiti/commands/src/main/java/org/activiti/karaf/commands/UndeployActivitiCommand.java
----------------------------------------------------------------------
diff --git a/activiti/commands/src/main/java/org/activiti/karaf/commands/UndeployActivitiCommand.java b/activiti/commands/src/main/java/org/activiti/karaf/commands/UndeployActivitiCommand.java
deleted file mode 100644
index 19f7b6f..0000000
--- a/activiti/commands/src/main/java/org/activiti/karaf/commands/UndeployActivitiCommand.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2012 Cisco Systems
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.activiti.karaf.commands;
-
-import java.util.List;
-import org.activiti.engine.ProcessEngine;
-import org.activiti.engine.RepositoryService;
-import org.activiti.engine.repository.Deployment;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
-import org.apache.felix.gogo.commands.Option;
-
-/**
- * @author Srinivasan Chikkala
- */
-@Command(scope = "activiti", name = "undeploy", description = "Undeploys the Activiti Deployments " +
-    "(Process definition, images, bar files etc")
-public class UndeployActivitiCommand extends ActivitiCommand {
-
-    @Argument(index = 0, name = "deploymentIDs", description = "Deployment IDs of the Activiti deployments " +
-        "for undeploying", required = false, multiValued = true)
-    private String[] deploymentIDs;
-
-    @Option(name = "-a", aliases = "--all", description = "Undeploys all Activiti deployments ")
-    private boolean undeployAll;
-
-    @Option(name = "-c", aliases = "--cascade", description = "Deletes the given deployment and cascade deletion to " +
-        "process instances, history process instances and jobs.")
-    private boolean cascade;
-
-
-    @Override
-    protected Object doExecute() throws Exception {
-        ProcessEngine engine = this.getProcessEngine();
-        if (engine == null) {
-            out().println("Process Engine NOT Found!");
-            return null;
-        }
-
-        RepositoryService repo = engine.getRepositoryService();
-
-        if (this.deploymentIDs != null && this.deploymentIDs.length > 0) {
-            for (String deploymentID : this.deploymentIDs) {
-                repo.deleteDeployment(deploymentID, this.cascade);
-                out().printf("Undeployed %s \n", deploymentID);
-            }
-            return null;
-        }
-
-        if (!undeployAll) {
-            out().println("Activiti Deployment IDs required or use the command with -a or --all " +
-                "option for all undeployments");
-            return null;
-        } else {
-            out().println("Undeploying all Activiti deployments...");
-            List<Deployment> depList = repo.createDeploymentQuery().orderByDeploymenTime().asc().list();
-            for (Deployment dep : depList) {
-                String deploymentID = dep.getId();
-                repo.deleteDeployment(deploymentID, this.cascade);
-                out().printf("Undeployed %s \n", deploymentID);
-            }
-        }
-
-        return null;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/activiti/commands/src/main/java/org/activiti/karaf/commands/handlers/AbstractActivitiPrintHandler.java
----------------------------------------------------------------------
diff --git a/activiti/commands/src/main/java/org/activiti/karaf/commands/handlers/AbstractActivitiPrintHandler.java b/activiti/commands/src/main/java/org/activiti/karaf/commands/handlers/AbstractActivitiPrintHandler.java
deleted file mode 100644
index 352b8f2..0000000
--- a/activiti/commands/src/main/java/org/activiti/karaf/commands/handlers/AbstractActivitiPrintHandler.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright 2012 Cisco Systems
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.activiti.karaf.commands.handlers;
-
-import java.io.PrintWriter;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import org.activiti.engine.ActivitiException;
-import org.activiti.engine.ProcessEngine;
-import org.activiti.engine.history.HistoricActivityInstance;
-import org.activiti.engine.history.HistoricDetail;
-import org.activiti.engine.history.HistoricProcessInstance;
-import org.activiti.engine.history.HistoricVariableUpdate;
-import org.activiti.karaf.commands.util.Commands;
-
-/**
- * Abstract class that provides most of the implementation required to print process variable using
- * print handler.
- *
- * @author Srinivasan Chikkala
- * @see DefaultActivitiPrintHandler
- */
-public abstract class AbstractActivitiPrintHandler implements ActivitiPrintHandler {
-
-    public static final String PROCESS_DEFINITION_PROP = "bpm.process.definition";
-    public static final String PROCESS_VARS_PROP = "bpm.process.variables";
-
-    private static final Logger LOG = Logger.getLogger(AbstractActivitiPrintHandler.class.getName());
-
-    private boolean verbose;
-    private boolean quiet;
-    private ProcessEngine processEngine;
-
-    public boolean isQuiet() {
-        return quiet;
-    }
-
-    public void setQuiet(boolean quiet) {
-        this.quiet = quiet;
-    }
-
-    public boolean isVerbose() {
-        return verbose;
-    }
-
-    public void setVerbose(boolean verbose) {
-        this.verbose = verbose;
-    }
-
-    public ProcessEngine getProcessEngine() {
-        return processEngine;
-    }
-
-    public void setProcessEngine(ProcessEngine processEngine) {
-        this.processEngine = processEngine;
-    }
-
-    /**
-     * Extended class can implement this method to print the variable specific information.
-     */
-    protected abstract void printVariable(PrintWriter out, String varName, Object varValue);
-
-    protected void printVariable(PrintWriter out, HistoricVariableUpdate var) {
-
-        LinkedHashMap<String, String> nvMap = new LinkedHashMap<String, String>();
-        // nvMap.put("Variable Type", var.getVariableTypeName());
-        if (this.isVerbose()) {
-            nvMap.put("Variable ID", var.getId());
-            nvMap.put("Revision", "" + var.getRevision());
-            nvMap.put("Updated Time", Commands.UTIL.formatDate(var.getTime()));
-        }
-        nvMap.put("Variable Name", var.getVariableName());
-        Object value = var.getValue();
-        String simpleValue = Commands.UTIL.valueOf(value);
-        if (simpleValue != null) {
-            nvMap.put("Value", simpleValue);
-        } else {
-            nvMap.put("Value", "");
-        }
-        Commands.UTIL.printNameValues(out, nvMap);
-
-        if (simpleValue == null) {
-            // print the value in a json serialization format.
-            printVariable(out, var.getVariableName(), value);
-        }
-        out.println();
-    }
-
-    protected void printVariables(PrintWriter out, Map<String, HistoricVariableUpdate> vars) {
-        for (HistoricVariableUpdate var : vars.values()) {
-            printVariable(out, var);
-        }
-    }
-
-    protected void printVariables(PrintWriter out, List<HistoricDetail> varList) {
-        Map<String, HistoricVariableUpdate> varMap = new TreeMap<String, HistoricVariableUpdate>();
-        // filter revisions
-        for (HistoricDetail detail : varList) {
-            HistoricVariableUpdate varDetail = (HistoricVariableUpdate) detail;
-            String varName = varDetail.getVariableName();
-            // expects the varList is sorted in a descending order of time.
-            if (!varMap.containsKey(varName)) {
-                varMap.put(varName, varDetail);
-            } else {
-                LOG.info("#### " + varName + " has multiple updates!!! "
-                    + Commands.UTIL.formatDate(varDetail.getTime()) + " Revision= "
-                    + varDetail.getRevision());
-            }
-        }
-        printVariables(out, varMap);
-    }
-
-    @Override
-    public void printInstanceData(PrintWriter out, boolean verbose, boolean quite, HistoricProcessInstance hpi) {
-        this.setVerbose(verbose);
-        this.setQuiet(quite);
-
-        List<HistoricDetail> varList = null;
-        try {
-            varList = this.processEngine.getHistoryService().createHistoricDetailQuery()
-                .variableUpdates().processInstanceId(hpi.getId()).orderByTime().desc().list();
-        } catch (ActivitiException ex) {
-            // silent about the error. and log it.
-            LOG.log(Level.INFO, "Error in getting process variables. " + ex.getMessage(), ex);
-        }
-        if (varList != null && varList.size() > 0) {
-            out.println("-------- Instance Variables ");
-            printVariables(out, varList);
-        } else {
-            LOG.info("------ No Instance Variables! for " + hpi.getId());
-        }
-    }
-
-    @Override
-    public void printActivityData(PrintWriter out, boolean verbose, boolean quite,
-                                  HistoricActivityInstance actInst) {
-        this.setVerbose(verbose);
-        this.setQuiet(quite);
-        if (quite) {
-            // don't print activity variable update per activity
-            return;
-        }
-        List<HistoricDetail> varList = null;
-        try {
-            varList = this.processEngine.getHistoryService().createHistoricDetailQuery()
-                .variableUpdates().activityInstanceId(actInst.getId()).orderByTime().desc().list();
-        } catch (ActivitiException ex) {
-            //silent about the error. and log it.
-            LOG.log(Level.INFO, "Error in getting process variables. " + ex.getMessage(), ex);
-        }
-
-        if (varList != null && varList.size() > 0) {
-            out.println("-------- Task Variables");
-            printVariables(out, varList);
-        } else {
-            LOG.info("------ No Task Variables! for " + actInst.getActivityId());
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/activiti/commands/src/main/java/org/activiti/karaf/commands/handlers/ActivitiPrintHandler.java
----------------------------------------------------------------------
diff --git a/activiti/commands/src/main/java/org/activiti/karaf/commands/handlers/ActivitiPrintHandler.java b/activiti/commands/src/main/java/org/activiti/karaf/commands/handlers/ActivitiPrintHandler.java
deleted file mode 100644
index d5ff680..0000000
--- a/activiti/commands/src/main/java/org/activiti/karaf/commands/handlers/ActivitiPrintHandler.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2012 Cisco Systems
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.activiti.karaf.commands.handlers;
-
-import java.io.PrintWriter;
-import org.activiti.engine.history.HistoricActivityInstance;
-import org.activiti.engine.history.HistoricProcessInstance;
-
-/**
- * Service interface whose implementations can handle process variables printing as part of bpm:info cmd.
- * service providers can register implementation of this interface as a OSGi service which the bpm:info cmd
- * can lookup and use to print a bpmn process specific variable information.
- * <p/>
- * Each OSGi service registered can have the following set of properties
- * process-definition=<process-definition-id> - which handles all process instances variable printing for this
- * process definition.
- * process-var-name=<name-of-the-var> - which handles all process instances that contains this variable name
- * useful when you want to handles any process definitions that contains this variable.
- *
- * @author Srinivasan Chikkala
- */
-public interface ActivitiPrintHandler {
-
-    /**
-     * Print instance level Activiti process variable data
-     */
-    void printInstanceData(PrintWriter out, boolean verbose, boolean quiet, HistoricProcessInstance hpi);
-
-    /**
-     * Print activity level Activiti process variable data
-     */
-    void printActivityData(PrintWriter out, boolean verbose, boolean quiet, HistoricActivityInstance actInst);
-}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/activiti/commands/src/main/java/org/activiti/karaf/commands/handlers/DefaultActivitiPrintHandler.java
----------------------------------------------------------------------
diff --git a/activiti/commands/src/main/java/org/activiti/karaf/commands/handlers/DefaultActivitiPrintHandler.java b/activiti/commands/src/main/java/org/activiti/karaf/commands/handlers/DefaultActivitiPrintHandler.java
deleted file mode 100644
index 82c7897..0000000
--- a/activiti/commands/src/main/java/org/activiti/karaf/commands/handlers/DefaultActivitiPrintHandler.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2012 Cisco Systems
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.activiti.karaf.commands.handlers;
-
-import java.io.PrintWriter;
-import java.io.StringReader;
-import java.lang.reflect.Modifier;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import org.activiti.karaf.commands.util.Commands;
-
-/**
- * Default implementation of the process variable print handler.
- *
- * @author Srinivasan Chikkala
- */
-public class DefaultActivitiPrintHandler extends AbstractActivitiPrintHandler {
-
-    private static final Logger LOG = Logger.getLogger(DefaultActivitiPrintHandler.class.getName());
-
-    protected void printVariable(PrintWriter out, String varName, Object varValue) {
-        Gson gson = new GsonBuilder()
-            .setPrettyPrinting()
-            .serializeNulls()
-            .excludeFieldsWithModifiers(Modifier.STATIC, Modifier.TRANSIENT, Modifier.VOLATILE)
-            .create();
-
-        LOG.info("Printing var " + varName);
-        String jsonText = null;
-        try {
-            jsonText = gson.toJson(varValue);
-        } catch (Exception ex) {
-            jsonText = "{\n  " + varValue + "\n}"; // use default toString object            
-            LOG.log(Level.SEVERE, "Serializing Activiti Variable. " + ex.getMessage(), ex);
-        }
-
-        Commands.UTIL.printText(out, new StringReader(jsonText), " ");
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/activiti/commands/src/main/java/org/activiti/karaf/commands/util/Commands.java
----------------------------------------------------------------------
diff --git a/activiti/commands/src/main/java/org/activiti/karaf/commands/util/Commands.java b/activiti/commands/src/main/java/org/activiti/karaf/commands/util/Commands.java
deleted file mode 100644
index 6ed8283..0000000
--- a/activiti/commands/src/main/java/org/activiti/karaf/commands/util/Commands.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2012 Cisco Systems
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.activiti.karaf.commands.util;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.Reader;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Map;
-import java.util.TimeZone;
-
-/**
- * This class provides common utils for commands processing
- *
- * @author Srinivasan Chikkala
- */
-public class Commands {
-
-    public static final Commands UTIL = new Commands();
-
-    public void printNameValues(PrintWriter out, Map<String, String> nvMap) {
-        String fmt = "  %-16.16s %-20.60s\n";
-        for (String key : nvMap.keySet()) {
-            String value = nvMap.get(key);
-            out.printf(fmt, key + ":", value);
-        }
-    }
-
-    public String formatDate(Date date) {
-        String dateTxt = "--";
-        if (date != null) {
-            dateTxt = DateFormat.getDateTimeInstance().format(date);
-        }
-        return dateTxt;
-    }
-
-    public String formatDuration(Long duration) {
-        String dTxt = "--";
-        if (duration != null) {
-            SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss:SSS");
-            format.setTimeZone(TimeZone.getTimeZone("GMT"));
-            dTxt = format.format(new Date(duration));
-        }
-        return dTxt;
-    }
-
-    public void printText(PrintWriter out, Reader txtReader, String tabSpace) {
-        BufferedReader in = new BufferedReader(txtReader);
-        String line = null;
-        try {
-            while ((line = in.readLine()) != null) {
-                out.printf("  %-16.16s %s\n", tabSpace, line);
-            }
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Convert a simple object to string.
-     *
-     * @param obj object .
-     * @return string if the object is simple. else return null.
-     */
-    public String valueOf(Object obj) {
-        String value = null;
-        if (obj == null) {
-            value = "NULL";
-        } else if (obj.getClass().isPrimitive()
-            || obj.getClass().isEnum()
-            || obj instanceof java.lang.String) {
-            value = obj.toString();
-        } else if (obj instanceof Date) {
-            value = formatDate((Date) obj);
-        } else {
-            value = null;
-        }
-        return value;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/activiti/commands/src/main/java/org/activiti/karaf/commands/util/TextTable.java
----------------------------------------------------------------------
diff --git a/activiti/commands/src/main/java/org/activiti/karaf/commands/util/TextTable.java b/activiti/commands/src/main/java/org/activiti/karaf/commands/util/TextTable.java
deleted file mode 100644
index 00be544..0000000
--- a/activiti/commands/src/main/java/org/activiti/karaf/commands/util/TextTable.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2012 Cisco Systems
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.activiti.karaf.commands.util;
-
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Srinivasan Chikkala
- */
-public class TextTable {
-
-    private static final int DEFAULT_WIDTH = 3;
-    private int col;
-
-    private List<String> columnHeaders;
-    private List<Integer> columnWidths;
-    private List<List<String>> rows;
-
-    public TextTable(int col) {
-        this.col = col;
-        this.columnHeaders = new ArrayList<String>();
-        this.columnWidths = new ArrayList<Integer>();
-        this.rows = new ArrayList<List<String>>();
-    }
-
-    public void addHeaders(String... headers) {
-        for (String header : headers) {
-            this.columnHeaders.add(header);
-            this.columnWidths.add(DEFAULT_WIDTH);
-        }
-    }
-
-    public void addRow(String... colValues) {
-        List<String> row = new ArrayList<String>();
-        rows.add(row);
-        if (colValues != null && colValues.length > this.col) {
-            throw new IllegalArgumentException("Number of Column values passed are more than the tables " +
-                "column cound " + this.col);
-        }
-        for (int i = 0; i < this.col; ++i) {
-            String colValue = "";
-            if ((i < colValues.length) && (colValues[i] != null)) {
-                colValue = colValues[i];
-                Integer colWidth = this.columnWidths.get(i);
-                if (colWidth < colValue.length()) {
-                    this.columnWidths.set(i, colValue.length());
-                }
-            }
-            row.add(colValue);
-        }
-    }
-
-    public void print(PrintStream stremaOut) {
-        PrintWriter out = new PrintWriter(stremaOut, true);
-        print(out);
-    }
-
-    public void print(PrintWriter out) {
-        StringBuilder hdrFmtBuff = new StringBuilder();
-        StringBuilder rowFmtBuff = new StringBuilder();
-        // " %-20.20s   %-20.20s [%-20.20s]\n";
-        // "[%-20.20s] [%-20.20s] [%-20.20s]\n";
-        for (Integer width : this.columnWidths) {
-            hdrFmtBuff.append(" %-").append(width).append(".").append(width).append("s ");
-            rowFmtBuff.append("[%-").append(width).append(".").append(width).append("s]");
-        }
-        hdrFmtBuff.append("\n");
-        rowFmtBuff.append("\n");
-        String hdrFmt = hdrFmtBuff.toString();
-        String rowFmt = rowFmtBuff.toString();
-
-        out.printf(hdrFmt, this.columnHeaders.toArray());
-        for (List<String> row : this.rows) {
-            out.printf(rowFmt, row.toArray());
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/ActivitiCommand.java
----------------------------------------------------------------------
diff --git a/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/ActivitiCommand.java b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/ActivitiCommand.java
new file mode 100644
index 0000000..a9adc40
--- /dev/null
+++ b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/ActivitiCommand.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2012 Cisco Systems
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.provisionr.activiti.karaf.commands;
+
+import java.io.PrintWriter;
+import org.activiti.engine.ProcessEngine;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+
+/**
+ * Base class for implementing Activiti Karaf commands
+ *
+ * @author Srinivasan Chikkala
+ */
+public abstract class ActivitiCommand extends OsgiCommandSupport {
+
+    /**
+     * By default write normal messages to stdout
+     */
+    private PrintWriter out = new PrintWriter(System.out, true);
+
+    /**
+     * By default write error messages to stderr
+     */
+    private PrintWriter err = new PrintWriter(System.err, true);
+
+    private ProcessEngine processEngine;
+
+    public ProcessEngine getProcessEngine() {
+        return processEngine;
+    }
+
+    public void setProcessEngine(ProcessEngine processEngine) {
+        this.processEngine = processEngine;
+    }
+
+    public PrintWriter out() {
+        return out;
+    }
+
+    public void setOut(PrintWriter out) {
+        this.out = out;
+    }
+
+    public PrintWriter err() {
+        return err;
+    }
+
+    public void setErr(PrintWriter err) {
+        this.err = err;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/AddGroupCommand.java
----------------------------------------------------------------------
diff --git a/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/AddGroupCommand.java b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/AddGroupCommand.java
new file mode 100644
index 0000000..f4b4a08
--- /dev/null
+++ b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/AddGroupCommand.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2012 S.C. Axemblr Software Solutions S.R.L
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.provisionr.activiti.karaf.commands;
+
+import com.google.common.annotations.VisibleForTesting;
+import static com.google.common.base.Preconditions.checkNotNull;
+import org.activiti.engine.IdentityService;
+import org.activiti.engine.identity.Group;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.felix.gogo.commands.Option;
+
+@Command(scope = "activiti", name = "add-group", description = "Create new user group")
+public class AddGroupCommand extends ActivitiCommand {
+
+    @Option(name = "-i", aliases = "--id", description = "Group ID", required = true)
+    private String id;
+
+    @Option(name = "-n", aliases = "--name", description = "Group Name", required = true)
+    private String name;
+
+    @Option(name = "-t", aliases = "--type", description = "Group Type")
+    private String type = "security-role";
+
+    @Override
+    protected Object doExecute() throws Exception {
+        IdentityService identityService = getProcessEngine().getIdentityService();
+
+        Group group = identityService.newGroup(id);
+        group.setName(name);
+        group.setType(type);
+        identityService.saveGroup(group);
+
+        return null;
+    }
+
+    @VisibleForTesting
+    void setId(String id) {
+        this.id = checkNotNull(id, "id is null");
+    }
+
+    @VisibleForTesting
+    void setName(String name) {
+        this.name = checkNotNull(name, "name is null");
+    }
+
+    @VisibleForTesting
+    void setType(String type) {
+        this.type = checkNotNull(type, "type is null");
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/AddUserCommand.java
----------------------------------------------------------------------
diff --git a/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/AddUserCommand.java b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/AddUserCommand.java
new file mode 100644
index 0000000..e94d54c
--- /dev/null
+++ b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/AddUserCommand.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2012 S.C. Axemblr Software Solutions S.R.L
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.provisionr.activiti.karaf.commands;
+
+import org.activiti.engine.IdentityService;
+import org.activiti.engine.identity.User;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.felix.gogo.commands.Option;
+
+@Command(scope = "activiti", name = "add-user", description = "Create a new Activiti user")
+public class AddUserCommand extends ActivitiCommand {
+
+    @Option(name = "-i", aliases = "--id", description = "User ID", required = true)
+    private String id;
+
+    @Option(name = "-p", aliases = "--password", description = "User password", required = true)
+    private String password;
+
+    @Option(name = "-g", aliases = "--group", description = "Group ID", required = true)
+    private String groupId;
+
+    @Option(name = "-e", aliases = "--email", description = "User email")
+    private String email = "";
+
+    @Override
+    protected Object doExecute() throws Exception {
+        if (getProcessEngine() == null) {
+            throw new NullPointerException("Please configure a processEngine instance for this command");
+        }
+        IdentityService identityService = getProcessEngine().getIdentityService();
+
+        User user = identityService.newUser(id);
+        user.setEmail(password);
+        identityService.saveUser(user);
+
+        identityService.createMembership(id, groupId);
+
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/CleanHistoryActivitiCommand.java
----------------------------------------------------------------------
diff --git a/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/CleanHistoryActivitiCommand.java b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/CleanHistoryActivitiCommand.java
new file mode 100644
index 0000000..59bcfc6
--- /dev/null
+++ b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/CleanHistoryActivitiCommand.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright 2012 Cisco Systems
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.provisionr.activiti.karaf.commands;
+
+import java.util.List;
+import org.activiti.engine.HistoryService;
+import org.activiti.engine.ProcessEngine;
+import org.activiti.engine.history.HistoricProcessInstance;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.felix.gogo.commands.Option;
+
+/**
+ * @author Srinivasan Chikkala
+ */
+@Command(scope = "activiti", name = "clean-history", description = "Removes history of the Activiti process instances")
+public class CleanHistoryActivitiCommand extends ActivitiCommand {
+
+    @Argument(index = 0, name = "instanceIDs", description = "Instance IDs to remove from history",
+        required = false, multiValued = true)
+    private String[] instanceIDs;
+
+    @Option(name = "-a", aliases = "--all", description = "Remove all Activiti Processes from history")
+    private boolean cleanAll;
+
+    @Option(name = "-pd", aliases = "--definitions", required = false, multiValued = true,
+        description = "Removes history of process instances started from the definitions")
+    private String[] definitionIDs;
+
+    @Override
+    protected Object doExecute() throws Exception {
+        ProcessEngine engine = this.getProcessEngine();
+        if (engine == null) {
+            out().println("Process Engine NOT Found!");
+            return null;
+        }
+        HistoryService historyService = engine.getHistoryService();
+
+        // order of priority if instnaceIDs or definitionIDs and all on the list
+        // process instnaceID and exist or process definitionIDs and exit or process all 
+        // TODO figure out how to add mutually exclusive options - instanceIDs | definitions | all
+
+        if (this.instanceIDs != null && this.instanceIDs.length > 0) {
+            this.cleanProcessInstanceHistory(historyService, this.instanceIDs);
+            return null;
+        }
+
+        if (this.definitionIDs != null && this.definitionIDs.length > 0) {
+            this.cleanProcessDefinitionHistory(historyService, this.definitionIDs);
+            return null;
+        }
+
+        // clean all history
+        if (!cleanAll) {
+            out().println("Process instance IDs required or use the command with -a " +
+                "or --all option to clean all history");
+            return null;
+        } else {
+            cleanAllHistory(historyService);
+        }
+
+        return null;
+    }
+
+    private void cleanAllHistory(HistoryService hs) {
+        out().println("Cleaning History of All Process Instances...");
+        List<HistoricProcessInstance> hpiList = hs.createHistoricProcessInstanceQuery()
+            .orderByProcessDefinitionId().asc().list();
+        if (hpiList == null || hpiList.size() == 0) {
+            out().println("No Process History found! ");
+            return;
+        }
+        for (HistoricProcessInstance hpi : hpiList) {
+            String processId = hpi.getId();
+            hs.deleteHistoricProcessInstance(hpi.getId());
+            out().printf("History removed for process instance %s \n", processId);
+        }
+    }
+
+    private void cleanProcessInstanceHistory(HistoryService hs, String... instances) {
+        for (String instanceId : instances) {
+            // query and if exists delete.
+            HistoricProcessInstance hpi = hs.createHistoricProcessInstanceQuery()
+                .processInstanceId(instanceId).singleResult();
+            if (hpi != null) {
+                hs.deleteHistoricProcessInstance(hpi.getId());
+                out().printf("History removed for process instance %s \n", hpi.getId());
+            } else {
+                out().printf("No History found for process instance %s \n", instanceId);
+            }
+        }
+    }
+
+    private void cleanProcessDefinitionHistory(HistoryService hs, String... definitions) {
+
+        for (String definitionId : definitions) {
+            List<HistoricProcessInstance> hpiList = hs.createHistoricProcessInstanceQuery()
+                .processDefinitionId(definitionId)
+                .orderByProcessDefinitionId().asc().list();
+            if (hpiList == null || hpiList.size() == 0) {
+                out().printf("No History found for process definition %s \n", definitionId);
+                break;
+            }
+            for (HistoricProcessInstance hpi : hpiList) {
+                String processId = hpi.getId();
+                hs.deleteHistoricProcessInstance(hpi.getId());
+                out().printf("History removed for process instance %s with definition %s\n", processId,
+                    definitionId);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/DeleteGroupCommand.java
----------------------------------------------------------------------
diff --git a/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/DeleteGroupCommand.java b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/DeleteGroupCommand.java
new file mode 100644
index 0000000..950f433
--- /dev/null
+++ b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/DeleteGroupCommand.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2012 S.C. Axemblr Software Solutions S.R.L
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.provisionr.activiti.karaf.commands;
+
+import org.apache.felix.gogo.commands.Command;
+import org.apache.felix.gogo.commands.Option;
+
+@Command(scope = "activiti", name = "delete-group", description = "Delete Group")
+public class DeleteGroupCommand extends ActivitiCommand {
+
+    @Option(name = "-i", aliases = "--id", description = "Group ID", required = true)
+    private String id;
+
+    @Override
+    protected Object doExecute() throws Exception {
+        getProcessEngine().getIdentityService().deleteGroup(id);
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/DeleteUserCommand.java
----------------------------------------------------------------------
diff --git a/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/DeleteUserCommand.java b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/DeleteUserCommand.java
new file mode 100644
index 0000000..1171572
--- /dev/null
+++ b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/DeleteUserCommand.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2012 S.C. Axemblr Software Solutions S.R.L
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.provisionr.activiti.karaf.commands;
+
+import org.activiti.engine.IdentityService;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.felix.gogo.commands.Option;
+
+@Command(scope = "activiti", name = "delete-user", description = "Delete existing Activiti user")
+public class DeleteUserCommand extends ActivitiCommand {
+
+    @Option(name = "--id", description = "User ID")
+    private String id;
+
+    @Override
+    protected Object doExecute() throws Exception {
+        if (getProcessEngine() == null) {
+            throw new NullPointerException("Please configure a processEngine instance for this command");
+        }
+        IdentityService identityService = getProcessEngine().getIdentityService();
+        identityService.deleteUser(id);
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/InfoActivitiCommand.java
----------------------------------------------------------------------
diff --git a/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/InfoActivitiCommand.java b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/InfoActivitiCommand.java
new file mode 100644
index 0000000..3a0b357
--- /dev/null
+++ b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/InfoActivitiCommand.java
@@ -0,0 +1,249 @@
+/*
+ * Copyright 2012 Cisco Systems
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.provisionr.activiti.karaf.commands;
+
+import java.io.PrintWriter;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.activiti.engine.HistoryService;
+import org.activiti.engine.ProcessEngine;
+import org.activiti.engine.RepositoryService;
+import org.activiti.engine.RuntimeService;
+import org.activiti.engine.history.HistoricActivityInstance;
+import org.activiti.engine.history.HistoricProcessInstance;
+import org.activiti.engine.repository.Deployment;
+import org.activiti.engine.repository.ProcessDefinition;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.apache.provisionr.activiti.karaf.commands.handlers.ActivitiPrintHandler;
+import org.apache.provisionr.activiti.karaf.commands.handlers.DefaultActivitiPrintHandler;
+import org.apache.provisionr.activiti.karaf.commands.util.Commands;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.felix.gogo.commands.Option;
+
+/**
+ * karaf command class that prints the details about the bpmn process inlcuding deployment, definition,
+ * instance and process varaible details.
+ *
+ * @author Srinivasan Chikkala
+ */
+@Command(scope = "activiti", name = "info", description = "Provides details about the Activiti process instance")
+public class InfoActivitiCommand extends ActivitiCommand {
+
+    private static final Logger LOG = Logger.getLogger(InfoActivitiCommand.class.getName());
+
+    @Argument(index = 0, name = "instanceID", description = "Instance ID for which the details should " +
+        "be displayed", required = true, multiValued = false)
+    private String instanceID;
+
+    @Option(name = "-v", aliases = "--verbose", description = "Full details of the process instance")
+    private boolean verbose;
+
+    @Option(name = "-q", aliases = "--quiet", description = "Show minimum required details of the process instance")
+    private boolean quiet;
+
+    private ActivitiPrintHandler printHandler;
+
+    public boolean isVerbose() {
+        return verbose;
+    }
+
+    public void setVerbose(boolean verbose) {
+        this.verbose = verbose;
+    }
+
+    public boolean isQuiet() {
+        return quiet;
+    }
+
+    public void setQuiet(boolean quiet) {
+        this.quiet = quiet;
+    }
+
+    public String getInstanceID() {
+        return instanceID;
+    }
+
+    public void setInstanceID(String instanceID) {
+        this.instanceID = instanceID;
+    }
+
+    public ActivitiPrintHandler getPrintHandler() {
+        return printHandler;
+    }
+
+    public void setPrintHandler(ActivitiPrintHandler printHandler) {
+        this.printHandler = printHandler;
+    }
+
+    @Override
+    protected Object doExecute() throws Exception {
+        Object obj = null;
+        try {
+            obj = executeCommand();
+        } catch (Exception ex) {
+            out().println(ex.getMessage());
+            LOG.log(Level.INFO, ex.getMessage(), ex);
+        }
+        return obj;
+    }
+
+    protected Object executeCommand() throws Exception {
+        ProcessEngine pe = this.getProcessEngine();
+        if (pe == null) {
+            out().println("Process Engine NOT Found!");
+            return null;
+        }
+        if (this.instanceID == null || this.instanceID.trim().length() == 0) {
+            out().println("Instance ID required to show the information about the instance");
+            return null;
+        }
+
+        this.printHandler = this.findBPMPrintHandler();
+
+        printDetails(this.instanceID.trim());
+        return null;
+    }
+
+    protected ActivitiPrintHandler findBPMPrintHandler() {
+        ActivitiPrintHandler handler;
+        List<ActivitiPrintHandler> hList = null;
+        try {
+            String filter = null; // add the filter here per process.
+            hList = this.getAllServices(ActivitiPrintHandler.class, filter);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        if (hList == null || hList.size() == 0) {
+            DefaultActivitiPrintHandler defHandler = new DefaultActivitiPrintHandler();
+            defHandler.setProcessEngine(this.getProcessEngine());
+            handler = defHandler;
+        } else {
+            handler = hList.get(0); // first one that matches.
+        }
+        return handler;
+    }
+
+    protected void printDeploymentInfo(Deployment depInfo) {
+        LinkedHashMap<String, String> nvMap = new LinkedHashMap<String, String>();
+        nvMap.put("Deployment ID", depInfo.getId());
+        nvMap.put("Deployment Name", depInfo.getName());
+        nvMap.put("Deployment Time", Commands.UTIL.formatDate(depInfo.getDeploymentTime()));
+        Commands.UTIL.printNameValues(new PrintWriter(out(), true), nvMap);
+    }
+
+    protected void printProcessDefinitionInfo(ProcessDefinition pd) {
+        LinkedHashMap<String, String> nvMap = new LinkedHashMap<String, String>();
+        nvMap.put("Definition ID", pd.getId());
+        nvMap.put("Definition Name", pd.getName());
+        nvMap.put("Version", Integer.toString(pd.getVersion()));
+        nvMap.put("Resource Name", pd.getResourceName());
+        Commands.UTIL.printNameValues(new PrintWriter(out(), true), nvMap);
+
+    }
+
+    protected void printProcessInstanceInfo(HistoricProcessInstance hpi) {
+        LinkedHashMap<String, String> nvMap = new LinkedHashMap<String, String>();
+        nvMap.put("Instance ID", hpi.getId());
+        nvMap.put("Start Activity", hpi.getStartActivityId());
+        nvMap.put("End Activity", hpi.getEndActivityId());
+        nvMap.put("Start Time", Commands.UTIL.formatDate(hpi.getStartTime()));
+        nvMap.put("End Time", Commands.UTIL.formatDate(hpi.getEndTime()));
+        if (!this.isQuiet()) {
+            nvMap.put("Duration", Commands.UTIL.formatDuration(hpi.getDurationInMillis()));
+        }
+
+        PrintWriter out = new PrintWriter(out(), true);
+        Commands.UTIL.printNameValues(out, nvMap);
+        // print instance data
+        this.getPrintHandler().printInstanceData(out, this.isVerbose(), this.isQuiet(), hpi);
+    }
+
+    protected void printActivityInstanceInfo(HistoricActivityInstance actInst) {
+
+        LinkedHashMap<String, String> nvMap = new LinkedHashMap<String, String>();
+        nvMap.put("Activity ID", actInst.getActivityId());
+        if (!this.isQuiet()) {
+            nvMap.put("Activity Type", actInst.getActivityType());
+        }
+        nvMap.put("Activity Name", actInst.getActivityName());
+        if (!this.isQuiet()) {
+            nvMap.put("Execution ID", actInst.getExecutionId());
+        }
+        nvMap.put("Start Time", Commands.UTIL.formatDate(actInst.getStartTime()));
+        nvMap.put("End Time", Commands.UTIL.formatDate(actInst.getEndTime()));
+        if (!this.isQuiet()) {
+            nvMap.put("Duration", Commands.UTIL.formatDuration(actInst.getDurationInMillis()));
+        }
+
+        PrintWriter out = new PrintWriter(out(), true);
+        Commands.UTIL.printNameValues(out, nvMap);
+        // print activity vars
+        this.getPrintHandler().printActivityData(out, this.isVerbose(), this.isQuiet(), actInst);
+        out().println("-------------");
+    }
+
+    protected void printDetails(String pid) {
+        ProcessEngine pe = this.getProcessEngine();
+        RepositoryService repo = pe.getRepositoryService();
+        RuntimeService rt = pe.getRuntimeService();
+        HistoryService hs = pe.getHistoryService();
+
+        ProcessInstance pi = rt.createProcessInstanceQuery().processInstanceId(pid).singleResult();
+        HistoricProcessInstance hpi = hs.createHistoricProcessInstanceQuery().processInstanceId(pid)
+            .singleResult();
+        if (pi == null && hpi == null) {
+            // both null means. no process with that id.
+            out().printf("No process details found with process id %s \n", pid);
+            return;
+        }
+
+        String pdId = null;
+        if (pi != null) {
+            pdId = pi.getProcessDefinitionId();
+        } else if (hpi != null) {
+            pdId = hpi.getProcessDefinitionId();
+        }
+
+        ProcessDefinition pd = repo.createProcessDefinitionQuery().processDefinitionId(pdId).singleResult();
+        Deployment depInfo = repo.createDeploymentQuery().deploymentId(pd.getDeploymentId()).singleResult();
+        // print
+        if (isVerbose()) {
+            out().println("======== Deployment Details");
+            printDeploymentInfo(depInfo);
+
+            out().println("======== Process Definition Details");
+            printProcessDefinitionInfo(pd);
+        }
+
+        out().println("======== Process Instance Details");
+        printProcessInstanceInfo(hpi);
+
+        List<HistoricActivityInstance> actInstList = hs.createHistoricActivityInstanceQuery()
+            .processInstanceId(hpi.getId()).orderByHistoricActivityInstanceStartTime().asc().list();
+        if (actInstList != null && actInstList.size() > 0) {
+            out().println("======== Activity Execution Details");
+            for (HistoricActivityInstance actInst : actInstList) {
+                printActivityInstanceInfo(actInst);
+            }
+        } else {
+            LOG.info("No Activity execution details");
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/KillActivitiCommand.java
----------------------------------------------------------------------
diff --git a/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/KillActivitiCommand.java b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/KillActivitiCommand.java
new file mode 100644
index 0000000..9ad47c1
--- /dev/null
+++ b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/KillActivitiCommand.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2012 Cisco Systems
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.provisionr.activiti.karaf.commands;
+
+import java.util.List;
+import org.activiti.engine.ProcessEngine;
+import org.activiti.engine.RuntimeService;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.felix.gogo.commands.Option;
+
+/**
+ * @author Srinivasan Chikkala
+ */
+@Command(scope = "activiti", name = "kill", description = "Kills any active Activiti process instances")
+public class KillActivitiCommand extends ActivitiCommand {
+
+    @Argument(index = 0, name = "instanceIDs", description = "Instance IDs to kill set of active process instances",
+        required = false, multiValued = true)
+    private String[] instanceIDs;
+
+    @Option(name = "-a", aliases = "--all", description = "Kill all active process instances")
+    private boolean killAll;
+
+    @Override
+    protected Object doExecute() throws Exception {
+        ProcessEngine processEngine = this.getProcessEngine();
+        if (processEngine == null) {
+            out().println("Process Engine NOT Found!");
+            return null;
+        }
+
+        RuntimeService runtimeService = processEngine.getRuntimeService();
+
+        if (this.instanceIDs != null && this.instanceIDs.length > 0) {
+            for (String instanceID : instanceIDs) {
+                runtimeService.deleteProcessInstance(instanceID, "Forcefully terminating the instance");
+                out().printf("Process instance %s terminated\n", instanceID);
+            }
+            return null;
+        }
+
+        if (!killAll) {
+            out().println("Process instance IDs required or use the command with -a or --all option");
+            return null;
+        } else {
+            out().println("Signalling all executions in all active process instances...");
+            List<ProcessInstance> piList = runtimeService.createProcessInstanceQuery().orderByProcessInstanceId().asc().list();
+            for (ProcessInstance pi : piList) {
+                String instanceID = pi.getProcessInstanceId();
+                runtimeService.deleteProcessInstance(instanceID, "Forcefully terminating the instance");
+                out().printf("Process instance %s terminated\n", instanceID);
+            }
+        }
+
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/ListActivitiCommand.java
----------------------------------------------------------------------
diff --git a/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/ListActivitiCommand.java b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/ListActivitiCommand.java
new file mode 100644
index 0000000..ee149ae
--- /dev/null
+++ b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/ListActivitiCommand.java
@@ -0,0 +1,220 @@
+/*
+ * Copyright 2012 Cisco Systems
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.provisionr.activiti.karaf.commands;
+
+import java.io.PrintWriter;
+import java.text.DateFormat;
+import java.util.Date;
+import java.util.List;
+import org.activiti.engine.HistoryService;
+import org.activiti.engine.ProcessEngine;
+import org.activiti.engine.RepositoryService;
+import org.activiti.engine.RuntimeService;
+import org.activiti.engine.history.HistoricProcessInstance;
+import org.activiti.engine.repository.Deployment;
+import org.activiti.engine.repository.ProcessDefinition;
+import org.activiti.engine.runtime.Execution;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.apache.provisionr.activiti.karaf.commands.util.TextTable;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.felix.gogo.commands.Option;
+
+/**
+ * @author Srinivasan Chikkala
+ */
+@Command(scope = "activiti", name = "list", description = "Displays information about Activiti active " +
+    "process instances, process definitions, history of process instances")
+public class ListActivitiCommand extends ActivitiCommand {
+
+    @Option(name = "-pi", aliases = "--active", description = "Display information about all active process instances")
+    private boolean active;
+
+    @Option(name = "-pd", aliases = "--definitions", description = "Display information about all process definitions")
+    private boolean definitions;
+
+    @Option(name = "-h", aliases = "--history", description = "Display information about history of all process instances")
+    private boolean history;
+
+    @Option(name = "-d", aliases = "--deployments", description = "Display information about all Activiti deployments")
+    private boolean deployments;
+
+
+    @Override
+    protected Object doExecute() throws Exception {
+        ProcessEngine pe = this.getProcessEngine();
+
+        if (pe == null) {
+            out().println("Process Engine NOT Found!");
+            return null;
+        }
+
+        if (!(this.active || this.definitions || this.history || this.deployments)) {
+            // none of them set, display everything 
+            // set all to true;
+            this.active = this.definitions = this.history = this.deployments = true;
+        }
+
+        if (this.deployments) {
+            RepositoryService repo = pe.getRepositoryService();
+            printDeployments(out(), repo);
+        }
+
+        if (this.definitions) {
+            RepositoryService repo = pe.getRepositoryService();
+            printProcessDefinitions(out(), repo);
+        }
+
+        if (this.history) {
+            HistoryService his = pe.getHistoryService();
+            boolean printActive = !this.active; // if we show active process, dont print then in history 
+            printHistoricProcessInstances(out(), his, printActive);
+        }
+
+        if (this.active) {
+            RuntimeService rt = pe.getRuntimeService();
+            printActiveProcessInstances(out(), rt);
+        }
+
+
+        return null;
+    }
+
+    private String formatDate(Date date) {
+        String dateTxt = "";
+        if (date != null) {
+            dateTxt = DateFormat.getDateTimeInstance().format(date);
+        }
+        return dateTxt;
+    }
+
+    private String formatBpmResource(String bpmResource) {
+        if (bpmResource.startsWith("bundleresource:")) {
+            return bpmResource.substring("bundleresource:".length());
+        } else {
+            return bpmResource;
+        }
+    }
+
+    private void printDeployments(PrintWriter out, RepositoryService repo) {
+
+        List<Deployment> depList = repo.createDeploymentQuery().orderByDeploymenTime().asc().list();
+
+        out.println();
+        out.println("Activiti Deployments");
+        out.println("--------------------");
+        if (depList.isEmpty()) {
+            out.println("No Activiti Deployments Found.");
+            return;
+        }
+
+        TextTable txtTable = new TextTable(3);
+
+        txtTable.addHeaders("ID", "Name", "Deployment Time");
+        for (Deployment dep : depList) {
+            txtTable.addRow(dep.getId(), dep.getName(), formatDate(dep.getDeploymentTime()));
+        }
+        txtTable.print(out);
+    }
+
+    private void printProcessDefinitions(PrintWriter out, RepositoryService repo) {
+        List<ProcessDefinition> pdList = repo.createProcessDefinitionQuery()
+            .orderByDeploymentId().asc().list();
+
+        out.println();
+        out.println("Activiti Process Definitions");
+        out.println("----------------------------");
+        if (pdList.isEmpty()) {
+            out.println("No Activiti Process Definitions Found.");
+            return;
+        }
+
+        TextTable txtTable = new TextTable(4);
+
+        txtTable.addHeaders("Definition ID", "Name", "Version", "Resource");
+        for (ProcessDefinition pd : pdList) {
+            Integer ver = pd.getVersion();
+            txtTable.addRow(pd.getId(), pd.getName(), ver.toString(), formatBpmResource(pd.getResourceName()));
+        }
+        txtTable.print(out);
+    }
+
+    private String getExecutions(RuntimeService rt, String pi) {
+        List<Execution> executions = rt.createExecutionQuery()
+            .processInstanceId(pi)
+            .orderByProcessInstanceId().asc().list();
+        StringBuilder bld = new StringBuilder();
+        boolean first = true;
+        for (Execution exec : executions) {
+            if (!first) {
+                bld.append(",");
+            } else {
+                first = false;
+            }
+            bld.append(exec.getId());
+        }
+        return bld.toString();
+    }
+
+    private void printActiveProcessInstances(PrintWriter out, RuntimeService rt) {
+
+        List<ProcessInstance> piList = rt.createProcessInstanceQuery().orderByProcessInstanceId().asc().list();
+
+        out.println();
+        out.println("Active Process Instances");
+        out.println("------------------------");
+        if (piList.isEmpty()) {
+            out.println("No Active Process Instances Found.");
+            return;
+        }
+
+        TextTable txtTable = new TextTable(3);
+
+        txtTable.addHeaders("Definition ID", "Instance ID", "Executions");
+        for (ProcessInstance pi : piList) {
+            txtTable.addRow(pi.getProcessDefinitionId(),
+                pi.getProcessInstanceId(), getExecutions(rt, pi.getProcessInstanceId()));
+        }
+        txtTable.print(out);
+    }
+
+    private void printHistoricProcessInstances(PrintWriter out, HistoryService his, boolean printActive) {
+
+        List<HistoricProcessInstance> hpiList = his.createHistoricProcessInstanceQuery()
+            .orderByProcessDefinitionId().asc().list();
+
+        out.println();
+        out.println("History of Activiti Process Instances");
+        out.println("-------------------------------------");
+        if (hpiList.isEmpty()) {
+            out.println("No History on Activiti Processes.");
+            return;
+        }
+
+        TextTable txtTable = new TextTable(4);
+
+        txtTable.addHeaders("Definition ID", "Instance ID", "Start Time", "End Time");
+        for (HistoricProcessInstance hpi : hpiList) {
+            Date endTime = hpi.getEndTime();
+            if (endTime == null && !printActive) {
+                continue;  // don't print active instance history if printActive is false - default.
+            }
+            txtTable.addRow(hpi.getProcessDefinitionId(), hpi.getId(),
+                formatDate(hpi.getStartTime()), formatDate(hpi.getEndTime()));
+        }
+        txtTable.print(out);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/ListGroupsCommand.java
----------------------------------------------------------------------
diff --git a/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/ListGroupsCommand.java b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/ListGroupsCommand.java
new file mode 100644
index 0000000..20c3c07
--- /dev/null
+++ b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/ListGroupsCommand.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2012 S.C. Axemblr Software Solutions S.R.L
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.provisionr.activiti.karaf.commands;
+
+import java.util.List;
+import org.activiti.engine.identity.Group;
+import org.apache.felix.gogo.commands.Command;
+
+@Command(scope = "activiti", name = "list-groups", description = "List groups")
+public class ListGroupsCommand extends ActivitiCommand {
+
+    @Override
+    protected Object doExecute() throws Exception {
+        List<Group> groups = getProcessEngine().getIdentityService()
+            .createGroupQuery().orderByGroupId().asc().list();
+
+        if (groups.isEmpty()) {
+            err().println("No groups found.");
+        }
+        for (Group group : groups) {
+            out().printf("%s\t%s\t%s\n", group.getId(), group.getName(), group.getType());
+        }
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/ListUsersCommand.java
----------------------------------------------------------------------
diff --git a/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/ListUsersCommand.java b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/ListUsersCommand.java
new file mode 100644
index 0000000..656d139
--- /dev/null
+++ b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/ListUsersCommand.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2012 S.C. Axemblr Software Solutions S.R.L
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.provisionr.activiti.karaf.commands;
+
+import java.util.List;
+import org.activiti.engine.identity.User;
+import org.apache.felix.gogo.commands.Command;
+
+@Command(scope = "activiti", name = "list-users", description = "List users")
+public class ListUsersCommand extends ActivitiCommand {
+
+    @Override
+    protected Object doExecute() throws Exception {
+        List<User> users = getProcessEngine().getIdentityService()
+            .createUserQuery().orderByUserId().asc().list();
+
+        if (users.isEmpty()) {
+            err().println("No users found.");
+        }
+        for (User user : users) {
+            out().printf("%s\t%s\t%s\n", user.getId(), user.getEmail(), user.getPassword());
+        }
+
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/SignalActivitiCommand.java
----------------------------------------------------------------------
diff --git a/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/SignalActivitiCommand.java b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/SignalActivitiCommand.java
new file mode 100644
index 0000000..4993c74
--- /dev/null
+++ b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/SignalActivitiCommand.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2012 Cisco Systems
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.provisionr.activiti.karaf.commands;
+
+import java.util.List;
+import org.activiti.engine.ProcessEngine;
+import org.activiti.engine.RuntimeService;
+import org.activiti.engine.runtime.Execution;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.felix.gogo.commands.Option;
+
+/**
+ * @author Srinivasan Chikkala
+ */
+@Command(scope = "activiti", name = "signal",
+    description = "Signals any active executions in Activiti process instances")
+public class SignalActivitiCommand extends ActivitiCommand {
+
+    @Argument(index = 0, name = "instanceIDs", description = "Instance IDs to signal set of active process " +
+        "instances", required = false, multiValued = true)
+    private String[] instanceIDs;
+
+    @Option(name = "-a", aliases = "--all", description = "Signal all active process instances")
+    private boolean signalAll;
+
+    @Option(name = "-activities", aliases = "--activities", required = false,
+        multiValued = true, description = "Signal all activities in a process instances")
+    private String[] activities;
+
+    @Override
+    protected Object doExecute() throws Exception {
+        ProcessEngine engine = this.getProcessEngine();
+        if (engine == null) {
+            out().println("Process Engine NOT Found!");
+            return null;
+        }
+        RuntimeService runtimeService = engine.getRuntimeService();
+
+        if (this.instanceIDs != null && this.instanceIDs.length > 0) {
+            for (String instanceID : this.instanceIDs) {
+                signal(runtimeService, instanceID, this.activities);
+            }
+            return null;
+        }
+
+        if (!signalAll) {
+            out().println("Process instance IDs required or use the command with -a or --all option");
+            return null;
+        } else {
+            out().println("Signalling all executions in all active process instances...");
+            List<ProcessInstance> piList = runtimeService.createProcessInstanceQuery().orderByProcessInstanceId().asc().list();
+            for (ProcessInstance pi : piList) {
+                signal(runtimeService, pi.getProcessInstanceId(), this.activities);
+            }
+        }
+
+        return null;
+    }
+
+    private void signal(RuntimeService rt, Execution exec) {
+        try {
+            if (!exec.isEnded()) {
+                rt.signal(exec.getId());
+            } else {
+                out().printf("Execution %s already ended \n" + exec.getId());
+            }
+        } catch (Exception ex) {
+            out().printf("Exception:%s in signaling the execution %s \n", ex.getMessage(), exec.getId());
+        }
+    }
+
+    private void signal(RuntimeService rt, String pi, String... activities) {
+        if (activities == null || activities.length == 0) {
+            // signal all executions in the instance 
+            out().println("Signaling all active executions in the process instance " + pi);
+            List<Execution> executions = rt.createExecutionQuery()
+                .processInstanceId(pi)
+                .orderByProcessInstanceId().asc().list();
+            for (Execution exec : executions) {
+                signal(rt, exec);
+            }
+        } else {
+            for (String activity : activities) {
+                out().printf("Signaling activity %s in process instance %s \n", activity, pi);
+                List<Execution> executions = rt.createExecutionQuery()
+                    .processInstanceId(pi)
+                    .activityId(activity)
+                    .orderByProcessInstanceId().asc().list();
+                for (Execution exec : executions) {
+                    signal(rt, exec);
+                }
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/StartActivitiCommand.java
----------------------------------------------------------------------
diff --git a/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/StartActivitiCommand.java b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/StartActivitiCommand.java
new file mode 100644
index 0000000..90d4114
--- /dev/null
+++ b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/StartActivitiCommand.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2012 Cisco Systems
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.provisionr.activiti.karaf.commands;
+
+import org.activiti.engine.ProcessEngine;
+import org.activiti.engine.RuntimeService;
+import org.activiti.engine.runtime.ProcessInstance;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+
+/**
+ * @author Srinivasan Chikkala
+ */
+@Command(scope = "activiti", name = "start",
+    description = "Starts the Activiti process instance from a deployed process definition")
+public class StartActivitiCommand extends ActivitiCommand {
+
+    @Argument(index = 0, name = "definitionID", required = true, multiValued = false,
+        description = "Activiti Process definition ID to start an instance of it.")
+    private String definitionID;
+
+    @Override
+    protected Object doExecute() throws Exception {
+        ProcessEngine pe = this.getProcessEngine();
+        if (pe == null) {
+            out().println("Process Engine NOT Found!");
+            return null;
+        }
+
+        RuntimeService rt = pe.getRuntimeService();
+        if (definitionID != null) {
+            ProcessInstance pi = rt.startProcessInstanceById(definitionID);
+            out().printf("Process instance %s Started\n", pi.getProcessInstanceId());
+        }
+
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-provisionr/blob/6ba40c4b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/UndeployActivitiCommand.java
----------------------------------------------------------------------
diff --git a/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/UndeployActivitiCommand.java b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/UndeployActivitiCommand.java
new file mode 100644
index 0000000..56faa3c
--- /dev/null
+++ b/activiti/commands/src/main/java/org/apache/provisionr/activiti/karaf/commands/UndeployActivitiCommand.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2012 Cisco Systems
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.provisionr.activiti.karaf.commands;
+
+import java.util.List;
+import org.activiti.engine.ProcessEngine;
+import org.activiti.engine.RepositoryService;
+import org.activiti.engine.repository.Deployment;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.felix.gogo.commands.Option;
+
+/**
+ * @author Srinivasan Chikkala
+ */
+@Command(scope = "activiti", name = "undeploy", description = "Undeploys the Activiti Deployments " +
+    "(Process definition, images, bar files etc")
+public class UndeployActivitiCommand extends ActivitiCommand {
+
+    @Argument(index = 0, name = "deploymentIDs", description = "Deployment IDs of the Activiti deployments " +
+        "for undeploying", required = false, multiValued = true)
+    private String[] deploymentIDs;
+
+    @Option(name = "-a", aliases = "--all", description = "Undeploys all Activiti deployments ")
+    private boolean undeployAll;
+
+    @Option(name = "-c", aliases = "--cascade", description = "Deletes the given deployment and cascade deletion to " +
+        "process instances, history process instances and jobs.")
+    private boolean cascade;
+
+
+    @Override
+    protected Object doExecute() throws Exception {
+        ProcessEngine engine = this.getProcessEngine();
+        if (engine == null) {
+            out().println("Process Engine NOT Found!");
+            return null;
+        }
+
+        RepositoryService repo = engine.getRepositoryService();
+
+        if (this.deploymentIDs != null && this.deploymentIDs.length > 0) {
+            for (String deploymentID : this.deploymentIDs) {
+                repo.deleteDeployment(deploymentID, this.cascade);
+                out().printf("Undeployed %s \n", deploymentID);
+            }
+            return null;
+        }
+
+        if (!undeployAll) {
+            out().println("Activiti Deployment IDs required or use the command with -a or --all " +
+                "option for all undeployments");
+            return null;
+        } else {
+            out().println("Undeploying all Activiti deployments...");
+            List<Deployment> depList = repo.createDeploymentQuery().orderByDeploymenTime().asc().list();
+            for (Deployment dep : depList) {
+                String deploymentID = dep.getId();
+                repo.deleteDeployment(deploymentID, this.cascade);
+                out().printf("Undeployed %s \n", deploymentID);
+            }
+        }
+
+        return null;
+    }
+
+}


Mime
View raw message