[jbosstools-commits] JBoss Tools SVN: r30567 - in workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped: util and 1 other directory.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Thu Apr 14 08:03:31 EDT 2011


Author: adietish
Date: 2011-04-14 08:03:30 -0400 (Thu, 14 Apr 2011)
New Revision: 30567

Added:
   workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/
   workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/CommandFormatException.java
   workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/CommandLineException.java
   workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/DefaultOperationRequestAddress.java
   workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/DefaultOperationRequestBuilder.java
   workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationFormatException.java
   workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestAddress.java
   workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestBuilder.java
   workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestParser.java
   workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/Util.java
   workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/ValidatingOperationCallbackHandler.java
Modified:
   workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/MinimalisticStandaloneDeployer.java
Log:


Modified: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/MinimalisticStandaloneDeployer.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/MinimalisticStandaloneDeployer.java	2011-04-14 00:21:55 UTC (rev 30566)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/MinimalisticStandaloneDeployer.java	2011-04-14 12:03:30 UTC (rev 30567)
@@ -25,56 +25,81 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
+import java.util.List;
 import java.util.concurrent.CancellationException;
 
 import org.jboss.as.controller.client.ModelControllerClient;
 import org.jboss.as.controller.client.OperationBuilder;
 import org.jboss.as.protocol.StreamUtils;
 import org.jboss.dmr.ModelNode;
+import org.jboss.ide.eclipse.as7.deployment.detyped.util.Util;
 
 /**
  * @author André Dietisheim
  */
 public class MinimalisticStandaloneDeployer {
 
-	public static void undeploy(File file, String host, int port) throws CancellationException, IOException {
+	public static void undeploy(String name, String host, int port) throws CancellationException, IOException {
 		ModelControllerClient client = ModelControllerClient.Factory.create(host, port);
+		try {
+			// undeploy
+			ModelNode request = new ModelNode();
+			request.get("operation").set("undeploy");
+			request.get("address").add("deployment", name);
+			ModelNode result = client.execute(request);
 
-		String name = file.getName();
+			// remove
+			request = new ModelNode();
+			request.get("operation").set("remove");
+			request.get("address").add("deployment", name);
+			result = client.execute(request);
+		} finally {
+			StreamUtils.safeClose(client);
+		}
+	}
 
-		// undeploy
-		ModelNode request = new ModelNode();
-		request.get("operation").set("undeploy");
-        request.get("address").add("deployment", name);
-		ModelNode result = client.execute(request);
-
-		// remove
-		request = new ModelNode();
-		request.get("operation").set("remove");
-        request.get("address").add("deployment", name);
-		result = client.execute(request);
-		
-		StreamUtils.safeClose(client);
-	}
-	
 	public static void deploy(File file, String host, int port) throws CancellationException, IOException {
 		ModelControllerClient client = ModelControllerClient.Factory.create(host, port);
+		try {
+			String name = file.getName();
 
-		String name = file.getName();
+			ModelNode request = new ModelNode();
+			request.get("operation").set("add");
+			request.get("address").add("deployment", name);
+			request.get("enabled").set(true);
 
+			OperationBuilder operation = OperationBuilder.Factory.create(request);
+			operation.addInputStream(new BufferedInputStream(new FileInputStream(file)));
+			request.get("input-stream-index").set(0);
+			ModelNode result = client.execute(operation.build());
 
-        ModelNode request = new ModelNode();
-        request.get("operation").set("add");
-        request.get("address").add("deployment", name);
-        request.get("enabled").set(true);
+			throwOnFailure(result);
+		} finally {
+			StreamUtils.safeClose(client);
+		}
+	}
 
-		OperationBuilder op = OperationBuilder.Factory.create(request);
-        op.addInputStream(new BufferedInputStream(new FileInputStream(file)));
-        request.get("input-stream-index").set(0);
-        
-        ModelNode result = client.execute(op.build());
+	private static void throwOnFailure(ModelNode result) {
+		if (!Util.isSuccess(result)) {
+			throw new RuntimeException(Util.getFailureDescription(result));
+		}
+	}
 
-		StreamUtils.safeClose(client);
+	public static boolean isDeployed(String name, String host, int port) throws CancellationException, IOException {
+		ModelControllerClient client = ModelControllerClient.Factory.create(host, port);
+		try {
+			ModelNode request = new ModelNode();
+			request.get("operation").set("read-children-names");
+			request.get("child-type").set("deployment");
+			
+			ModelNode result = client.execute(request);
+			return false;
+		} finally {
+			StreamUtils.safeClose(client);
+		}
 	}
 
+	public static List<String> getDeployments() {
+		return null;
+	}
 }

Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/CommandFormatException.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/CommandFormatException.java	                        (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/CommandFormatException.java	2011-04-14 12:03:30 UTC (rev 30567)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as7.deployment.detyped.util;
+
+/**
+ * @author Alexey Loubyansky
+ *
+ */
+public class CommandFormatException extends CommandLineException {
+
+    private static final long serialVersionUID = -5802389813870206943L;
+
+    /**
+     * @param message
+     * @param cause
+     */
+    public CommandFormatException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    /**
+     * @param message
+     */
+    public CommandFormatException(String message) {
+        super(message);
+    }
+
+    /**
+     * @param cause
+     */
+    public CommandFormatException(Throwable cause) {
+        super(cause);
+    }
+}


Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/CommandFormatException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/CommandLineException.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/CommandLineException.java	                        (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/CommandLineException.java	2011-04-14 12:03:30 UTC (rev 30567)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as7.deployment.detyped.util;
+
+/**
+ * @author Alexey Loubyansky
+ *
+ */
+public class CommandLineException extends Exception {
+
+    private static final long serialVersionUID = 423938082439473323L;
+
+    public CommandLineException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public CommandLineException(String message) {
+        super(message);
+    }
+
+    public CommandLineException(Throwable cause) {
+        super(cause);
+    }
+}


Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/CommandLineException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/DefaultOperationRequestAddress.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/DefaultOperationRequestAddress.java	                        (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/DefaultOperationRequestAddress.java	2011-04-14 12:03:30 UTC (rev 30567)
@@ -0,0 +1,258 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as7.deployment.detyped.util;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * This implementation is not thread-safe.
+ *
+ * @author Alexey Loubyansky
+ */
+public class DefaultOperationRequestAddress implements OperationRequestAddress {
+
+    private final List<NodeImpl> nodes = new ArrayList<NodeImpl>();
+
+    public DefaultOperationRequestAddress() {
+    }
+
+    /**
+     * Creates a prefix and initializes it to the value of the argument.
+     * @param initial  the initial value
+     */
+    public DefaultOperationRequestAddress(OperationRequestAddress initial) {
+        if(!initial.isEmpty()) {
+            for(Node node : initial) {
+                toNode(node.getType(), node.getName());
+            }
+        }
+    }
+
+    @Override
+    public void toNodeType(String nodeType) {
+
+        nodes.add(new NodeImpl(nodeType, null));
+    }
+
+    @Override
+    public void toNode(String nodeName) {
+
+        if(nodes.isEmpty())
+            throw new IllegalStateException("The prefix should end with the node type before going to a specific node name.");
+
+        nodes.get(nodes.size() - 1).name = nodeName;
+    }
+
+    @Override
+    public void toNode(String nodeType, String nodeName) {
+
+        if(endsOnType()) {
+            throw new IllegalStateException("The prefix ends on a type. A node name must be specified before this method can be invoked.");
+        }
+        nodes.add(new NodeImpl(nodeType, nodeName));
+    }
+
+    @Override
+    public String toNodeType() {
+
+        if(nodes.isEmpty()) {
+            return null;
+        }
+        String name = nodes.get(nodes.size() - 1).name;
+        nodes.get(nodes.size() - 1).name = null;
+        return name;
+    }
+
+    @Override
+    public Node toParentNode() {
+
+        if(nodes.isEmpty()) {
+            return null;
+        }
+        return nodes.remove(nodes.size() - 1);
+    }
+
+    @Override
+    public void reset() {
+        nodes.clear();
+    }
+
+    @Override
+    public boolean endsOnType() {
+        if(nodes.isEmpty()) {
+            return false;
+        }
+
+        NodeImpl node = nodes.get(nodes.size() - 1);
+        return node.name == null;
+    }
+
+    @Override
+    public boolean isEmpty() {
+        return nodes.isEmpty();
+    }
+
+    @Override
+    public Iterator<Node> iterator() {
+
+        final Node[] array = nodes.toArray(new Node[nodes.size()]);
+        return new Iterator<Node>() {
+
+            int i = 0;
+
+            @Override
+            public boolean hasNext() {
+                return i < array.length;
+            }
+
+            @Override
+            public Node next() {
+                return array[i++];
+            }
+
+            @Override
+            public void remove() {
+                throw new UnsupportedOperationException();
+            }
+
+        };
+    }
+
+    @Override
+    public String getNodeType() {
+
+        if(nodes.isEmpty()) {
+            return null;
+        }
+        return nodes.get(nodes.size() - 1).type;
+    }
+
+    @Override
+    public String getNodeName() {
+
+        if(nodes.isEmpty()) {
+            return null;
+        }
+        return nodes.get(nodes.size() - 1).name;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((nodes == null) ? 0 : nodes.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (!(obj instanceof OperationRequestAddress))
+            return false;
+
+        OperationRequestAddress other = (OperationRequestAddress) obj;
+
+        if(isEmpty() != other.isEmpty())
+            return false;
+
+        Iterator<Node> thisIterator = iterator();
+        Iterator<Node> otherIterator = other.iterator();
+        boolean result = true;
+        while(result) {
+            if(!thisIterator.next().equals(otherIterator.next())) {
+                result = false;
+            } else {
+                if (!thisIterator.hasNext()) {
+                    if (otherIterator.hasNext()) {
+                        result = false;
+                    }
+                    break;
+                }
+                if (!otherIterator.hasNext()) {
+                    if (thisIterator.hasNext()) {
+                        result = false;
+                    }
+                    break;
+                }
+            }
+        }
+        return result;
+    }
+
+    private static final class NodeImpl implements Node {
+
+        String type;
+        String name;
+
+        NodeImpl(String type, String name) {
+            this.type = type;
+            this.name = name;
+        }
+
+        @Override
+        public String getType() {
+            return type;
+        }
+        @Override
+        public String getName() {
+            return name;
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + ((name == null) ? 0 : name.hashCode());
+            result = prime * result + ((type == null) ? 0 : type.hashCode());
+            return result;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj)
+                return true;
+            if (obj == null)
+                return false;
+
+            if(!(obj instanceof Node))
+                return false;
+
+            Node other = (Node) obj;
+            if (name == null) {
+                if (other.getName() != null)
+                    return false;
+            } else if (!name.equals(other.getName()))
+                return false;
+            if (type == null) {
+                if (other.getType() != null)
+                    return false;
+            } else if (!type.equals(other.getType()))
+                return false;
+            return true;
+        }
+    }
+}


Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/DefaultOperationRequestAddress.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/DefaultOperationRequestBuilder.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/DefaultOperationRequestBuilder.java	                        (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/DefaultOperationRequestBuilder.java	2011-04-14 12:03:30 UTC (rev 30567)
@@ -0,0 +1,235 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as7.deployment.detyped.util;
+
+import java.util.Iterator;
+
+import org.jboss.dmr.ModelNode;
+import org.jboss.ide.eclipse.as7.deployment.detyped.util.OperationRequestAddress.Node;
+
+/**
+ *
+ * @author Alexey Loubyansky
+ */
+public class DefaultOperationRequestBuilder extends ValidatingOperationCallbackHandler implements OperationRequestBuilder {
+
+    private ModelNode request = new ModelNode();
+    private OperationRequestAddress prefix;
+
+    public DefaultOperationRequestBuilder() {
+        this.prefix = new DefaultOperationRequestAddress();
+    }
+
+    public DefaultOperationRequestBuilder(OperationRequestAddress prefix) {
+        if(prefix == null) {
+            throw new IllegalArgumentException("Prefix can't be null");
+        }
+        this.prefix = new DefaultOperationRequestAddress(prefix);
+    }
+
+    /* (non-Javadoc)
+     * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#rootNode()
+     */
+    @Override
+    public void rootNode() {
+        prefix.reset();
+    }
+
+    /* (non-Javadoc)
+     * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#parentNode()
+     */
+    @Override
+    public void parentNode() {
+        prefix.toParentNode();
+    }
+
+    /* (non-Javadoc)
+     * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#nodeType()
+     */
+    @Override
+    public void nodeType() {
+        prefix.toNodeType();
+    }
+
+    /* (non-Javadoc)
+     * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#nodeTypeNameSeparator(int)
+     */
+    @Override
+    public void nodeTypeNameSeparator(int index) {
+    }
+
+    /* (non-Javadoc)
+     * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#nodeSeparator(int)
+     */
+    @Override
+    public void nodeSeparator(int index) {
+    }
+
+    /* (non-Javadoc)
+     * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#addressOperationSeparator(int)
+     */
+    @Override
+    public void addressOperationSeparator(int index) {
+    }
+
+    /* (non-Javadoc)
+     * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#operationName(java.lang.String)
+     */
+    @Override
+    public void validatedOperationName(String operationName) {
+        this.setOperationName(operationName);
+    }
+
+    /* (non-Javadoc)
+     * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#propertyListStart(int)
+     */
+    @Override
+    public void propertyListStart(int index) {
+    }
+
+    /* (non-Javadoc)
+     * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#propertyNameValueSeparator(int)
+     */
+    @Override
+    public void propertyNameValueSeparator(int index) {
+    }
+
+    /* (non-Javadoc)
+     * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#propertySeparator(int)
+     */
+    @Override
+    public void propertySeparator(int index) {
+    }
+
+    /* (non-Javadoc)
+     * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#propertyListEnd(int)
+     */
+    @Override
+    public void propertyListEnd(int index) {
+    }
+
+    @Override
+    protected void validatedNodeType(String nodeType)
+            throws OperationFormatException {
+        this.addNodeType(nodeType);
+    }
+
+    @Override
+    protected void validatedNodeName(String nodeName)
+            throws OperationFormatException {
+        this.addNodeName(nodeName);
+    }
+
+    @Override
+    protected void validatedPropertyName(String propertyName)
+            throws OperationFormatException {
+        throw new OperationFormatException("Property '" + propertyName + "' is missing the value.");
+    }
+
+    @Override
+    protected void validatedProperty(String name, String value,
+            int nameValueSeparatorIndex) throws OperationFormatException {
+        this.addProperty(name, value);
+    }
+
+    @Override
+    public void nodeTypeOrName(String typeOrName)
+            throws OperationFormatException {
+
+        if(prefix.endsOnType()) {
+            this.addNodeName(typeOrName);
+        } else {
+            this.addNodeType(typeOrName);
+        }
+    }
+
+    /**
+     * Makes sure that the operation name and the address have been set and returns a ModelNode
+     * representing the operation request.
+     */
+    public ModelNode buildRequest() throws OperationFormatException {
+
+        ModelNode address = request.get("address");
+        if(prefix.isEmpty()) {
+            address.setEmptyList();
+        } else {
+            Iterator<Node> iterator = prefix.iterator();
+            while (iterator.hasNext()) {
+                OperationRequestAddress.Node node = iterator.next();
+                if (node.getName() != null) {
+                    address.add(node.getType(), node.getName());
+                } else if (iterator.hasNext()) {
+                    throw new OperationFormatException(
+                            "The node name is not specified for type '"
+                                    + node.getType() + "'");
+                }
+            }
+        }
+
+        if(!request.hasDefined("operation")) {
+            throw new OperationFormatException("The operation name is missing or the format of the operation request is wrong.");
+        }
+
+        return request;
+    }
+
+    @Override
+    public void setOperationName(String name) {
+        request.get("operation").set(name);
+    }
+
+    @Override
+    public void addNode(String type, String name) {
+        prefix.toNode(type, name);
+    }
+
+    @Override
+    public void addNodeType(String type) {
+        prefix.toNodeType(type);
+    }
+
+    @Override
+    public void addNodeName(String name) {
+        prefix.toNode(name);
+    }
+
+    @Override
+    public void addProperty(String name, String value) {
+
+        if(name == null || name.trim().isEmpty())
+            throw new IllegalArgumentException("The argument name is not specified: '" + name + "'");
+        if(value == null || value.trim().isEmpty())
+            throw new IllegalArgumentException("The argument value is not specified: '" + value + "'");
+        ModelNode toSet = null;
+        try {
+            toSet = ModelNode.fromString(value);
+        } catch (Exception e) {
+            // just use the string
+            toSet = new ModelNode().set(value);
+        }
+        request.get(name).set(toSet);
+    }
+
+    public ModelNode getModelNode() {
+        return request;
+    }
+}


Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/DefaultOperationRequestBuilder.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationFormatException.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationFormatException.java	                        (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationFormatException.java	2011-04-14 12:03:30 UTC (rev 30567)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as7.deployment.detyped.util;
+
+
+/**
+ *
+ * @author Alexey Loubyansky
+ */
+public class OperationFormatException extends CommandFormatException {
+
+    /**
+     *
+     */
+    private static final long serialVersionUID = -3481664048439674648L;
+
+    /**
+     * @param message
+     * @param cause
+     */
+    public OperationFormatException(String message, Throwable cause) {
+        super(message, cause);
+        // TODO Auto-generated constructor stub
+    }
+
+    /**
+     * @param message
+     */
+    public OperationFormatException(String message) {
+        super(message);
+        // TODO Auto-generated constructor stub
+    }
+
+    /**
+     * @param cause
+     */
+    public OperationFormatException(Throwable cause) {
+        super(cause);
+        // TODO Auto-generated constructor stub
+    }
+
+}


Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationFormatException.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestAddress.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestAddress.java	                        (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestAddress.java	2011-04-14 12:03:30 UTC (rev 30567)
@@ -0,0 +1,110 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as7.deployment.detyped.util;
+
+
+
+/**
+ * An instance of this interface represents a prefix for the operation request address part.
+ *
+ * @author Alexey Loubyansky
+ */
+public interface OperationRequestAddress extends Iterable<OperationRequestAddress.Node> {
+
+    /**
+     * Appends the node type to the prefix.
+     * Note, the current prefix must end on the node name before this method
+     * is invoked.
+     *
+     * @param nodeType  the node type to append to the prefix.
+     */
+    void toNodeType(String nodeType);
+
+    /**
+     * Appends the node name to the prefix.
+     * Note, the current prefix must end on the node type before this method
+     * is invoked.
+     *
+     * @param nodeName the node name to append to the prefix.
+     */
+    void toNode(String nodeName);
+
+    /**
+     * Appends the node to the prefix.
+     * Note, the current prefix must end on the node (i.e. node name) before
+     * this method is invoked.
+     *
+     * @param nodeType  the node type of the node to append to the prefix
+     * @param nodeName  the node name of the node to append to the prefix
+     */
+    void toNode(String nodeType, String nodeName);
+
+    /**
+     * Sets the current prefix to the node type of the current node,
+     * i.e. the node name is removed from the end of the prefix.
+     * @return the node name the prefix ended on
+     */
+    String toNodeType();
+
+    /**
+     * Removes the last node in the prefix, i.e. moves the value a node up.
+     * @return the node the prefix ended on
+     */
+    Node toParentNode();
+
+    /**
+     * Resets the prefix, i.e. this will make the prefix empty.
+     */
+    void reset();
+
+    /**
+     * Checks whether the prefix ends on a node type or a node name.
+     * @return  true if the prefix ends on a node type, otherwise false.
+     */
+    boolean endsOnType();
+
+    /**
+     * Checks whether the prefix is empty.
+     * @return  true if the prefix is empty, otherwise false.
+     */
+    boolean isEmpty();
+
+    /**
+     * Returns the node type of the last node.
+     * @return the node type of the last node or null if the prefix is empty.
+     */
+    String getNodeType();
+
+    /**
+     * Returns the node name of the last node.
+     * @return  the node name of the last node or null if the prefix ends
+     * on a type or is empty.
+     */
+    String getNodeName();
+
+    interface Node {
+
+        String getType();
+
+        String getName();
+    }
+}


Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestAddress.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestBuilder.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestBuilder.java	                        (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestBuilder.java	2011-04-14 12:03:30 UTC (rev 30567)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as7.deployment.detyped.util;
+
+import org.jboss.dmr.ModelNode;
+
+/**
+ * TODO this is not used for now...
+ *
+ * @author Alexey Loubyansky
+ */
+public interface OperationRequestBuilder {
+
+    /**
+     * Sets the name operation to be invoked.
+     *
+     * @param name the name of the operation to invoke.
+     */
+    void setOperationName(String name);
+
+    /**
+     * The address is specified as a path to the target node. Each element of the path is a node
+     * and is identified by its type and name.
+     *
+     * @param type the type of the node
+     * @param name the name of the node
+     */
+    void addNode(String type, String name);
+
+    /**
+     * This method is supposed to be invoked from applying the prefix with ends on a node type.
+     * @param type  the type of the node.
+     */
+    void addNodeType(String type);
+
+    /**
+     * This method assumes there is a non-empty prefix which ends on a node type.
+     * Otherwise, this method will result in an exception.
+     * @param name the name of the node for the type specified by the prefix.
+     */
+    void addNodeName(String name);
+
+    /**
+     * Adds an argument.
+     *
+     * @param name the name of the argument
+     * @param value the value of the argument
+     */
+    void addProperty(String name, String value);
+
+    /**
+     * Builds the operation request based on the collected operation name, address and arguments.
+     *
+     * @return an instance of ModelNode representing the operation request
+     * @throws OperationFormatException
+     */
+    ModelNode buildRequest() throws OperationFormatException;
+}


Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestBuilder.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestParser.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestParser.java	                        (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestParser.java	2011-04-14 12:03:30 UTC (rev 30567)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as7.deployment.detyped.util;
+
+
+/**
+ *
+ * @author Alexey Loubyansky
+ */
+public interface OperationRequestParser {
+
+    interface CallbackHandler {
+
+        void start(String operationString);
+
+        void rootNode();
+
+        void parentNode();
+
+        void nodeType();
+
+        void nodeType(String nodeType) throws OperationFormatException;
+
+        void nodeTypeNameSeparator(int index);
+
+        void nodeName(String nodeName) throws OperationFormatException;
+
+        void nodeSeparator(int index);
+
+        void addressOperationSeparator(int index);
+
+        void operationName(String operationName) throws OperationFormatException;
+
+        void propertyListStart(int index);
+
+        void propertyName(String propertyName) throws OperationFormatException;
+
+        void propertyNameValueSeparator(int index);
+
+        void property(String name, String value, int nameValueSeparatorIndex) throws OperationFormatException;
+
+        void propertySeparator(int index);
+
+        void propertyListEnd(int index);
+
+        // TODO this is not good
+        void nodeTypeOrName(String typeOrName) throws OperationFormatException;
+    }
+
+    void parse(String operationRequest, CallbackHandler handler) throws OperationFormatException;
+}


Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/OperationRequestParser.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/Util.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/Util.java	                        (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/Util.java	2011-04-14 12:03:30 UTC (rev 30567)
@@ -0,0 +1,164 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as7.deployment.detyped.util;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.as.controller.client.ModelControllerClient;
+import org.jboss.dmr.ModelNode;
+import org.jboss.dmr.Property;
+
+/**
+ *
+ * @author Alexey Loubyansky
+ */
+public class Util {
+
+    public static boolean isSuccess(ModelNode operationResult) {
+        if(operationResult != null) {
+            ModelNode outcome = operationResult.get("outcome");
+            return outcome != null && outcome.asString().equals("success");
+        }
+        return false;
+    }
+
+    public static String getFailureDescription(ModelNode operationResult) {
+        if(operationResult == null) {
+            return null;
+        }
+
+        ModelNode descr = operationResult.get("failure-description");
+        if(descr == null) {
+            return null;
+        }
+
+        return descr.asString();
+    }
+
+    public static List<String> getList(ModelNode operationResult) {
+        if(!operationResult.hasDefined("result"))
+            return Collections.emptyList();
+
+        List<ModelNode> nodeList = operationResult.get("result").asList();
+        if(nodeList.isEmpty())
+            return Collections.emptyList();
+
+        List<String> list = new ArrayList<String>(nodeList.size());
+        for(ModelNode node : nodeList) {
+            list.add(node.asString());
+        }
+        return list;
+    }
+
+    public static byte[] getHash(ModelNode operationResult) {
+        if(!operationResult.hasDefined("result"))
+            return null;
+        return operationResult.get("result").asBytes();
+    }
+
+    public static List<String> getRequestPropertyNames(ModelNode operationResult) {
+        if(!operationResult.hasDefined("result"))
+            return Collections.emptyList();
+
+        ModelNode result = operationResult.get("result");
+        if(!result.hasDefined("request-properties"))
+            return Collections.emptyList();
+
+        List<Property> nodeList = result.get("request-properties").asPropertyList();
+        if(nodeList.isEmpty())
+            return Collections.emptyList();
+
+        List<String> list = new ArrayList<String>(nodeList.size());
+        for(Property node : nodeList) {
+            list.add(node.getName());
+        }
+        return list;
+    }
+
+    public static boolean isDeployed(String name, ModelControllerClient client) {
+        return getDeployments(client).contains(name);
+    }
+
+    public static List<String> getDeployments(ModelControllerClient client) {
+
+        DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
+        final ModelNode request;
+        try {
+            builder.operationName("read-children-names");
+            builder.addProperty("child-type", "deployment");
+            request = builder.buildRequest();
+        } catch (OperationFormatException e) {
+            throw new IllegalStateException("Failed to build operation", e);
+        }
+
+        try {
+            ModelNode outcome = client.execute(request);
+            if (isSuccess(outcome)) {
+                return getList(outcome);
+            }
+        } catch (Exception e) {
+        }
+
+        return Collections.emptyList();
+    }
+
+    public static List<String> getJmsResources(ModelControllerClient client, String type) {
+
+        DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
+        final ModelNode request;
+        try {
+            builder.addNode("subsystem", "jms");
+            builder.operationName("read-children-names");
+            builder.addProperty("child-type", type);
+            request = builder.buildRequest();
+        } catch (OperationFormatException e) {
+            throw new IllegalStateException("Failed to build operation", e);
+        }
+
+        try {
+            ModelNode outcome = client.execute(request);
+            if (isSuccess(outcome)) {
+                return getList(outcome);
+            }
+        } catch (Exception e) {
+        }
+
+        return Collections.emptyList();
+    }
+
+    public static boolean isTopic(ModelControllerClient client, String name) {
+        List<String> topics = getJmsResources(client, "topic");
+        return topics.contains(name);
+    }
+
+    public static boolean isQueue(ModelControllerClient client, String name) {
+        List<String> queues = getJmsResources(client, "queue");
+        return queues.contains(name);
+    }
+
+    public static boolean isConnectionFactory(ModelControllerClient client, String name) {
+        List<String> cf = getJmsResources(client, "connection-factory");
+        return cf.contains(name);
+    }
+}


Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/Util.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/ValidatingOperationCallbackHandler.java
===================================================================
--- workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/ValidatingOperationCallbackHandler.java	                        (rev 0)
+++ workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/ValidatingOperationCallbackHandler.java	2011-04-14 12:03:30 UTC (rev 30567)
@@ -0,0 +1,137 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as7.deployment.detyped.util;
+
+import java.util.regex.Pattern;
+
+import org.jboss.ide.eclipse.as7.deployment.detyped.util.OperationRequestParser.CallbackHandler;
+
+/**
+ *
+ * @author Alexey Loubyansky
+ */
+public abstract class ValidatingOperationCallbackHandler implements CallbackHandler {
+
+    private static final Pattern ALPHANUMERICS_PATTERN = Pattern.compile("[_a-zA-Z](?:[-_a-zA-Z0-9]*[_a-zA-Z0-9])?");
+    private static final Pattern NODE_NAME_PATTERN = Pattern.compile("\\*|[^*\\p{Space}\\p{Cntrl}]+");
+
+
+    protected String operationStr;
+
+    @Override
+    public void start(String operationString) {
+        this.operationStr = operationString;
+    }
+
+    /* (non-Javadoc)
+     * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#nodeType(java.lang.String)
+     */
+    @Override
+    public void nodeType(String nodeType) throws OperationFormatException {
+
+        assertValidType(nodeType);
+        validatedNodeType(nodeType);
+    }
+
+    protected abstract void validatedNodeType(String nodeType) throws OperationFormatException;
+
+    /* (non-Javadoc)
+     * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#nodeName(java.lang.String)
+     */
+    @Override
+    public void nodeName(String nodeName) throws OperationFormatException {
+
+        assertValidNodeName(nodeName);
+        validatedNodeName(nodeName);
+    }
+
+    protected abstract void validatedNodeName(String nodeName) throws OperationFormatException;
+
+    /* (non-Javadoc)
+     * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#operationName(java.lang.String)
+     */
+    @Override
+    public void operationName(String operationName)
+            throws OperationFormatException {
+
+        if (operationName == null || !ALPHANUMERICS_PATTERN.matcher(operationName).matches()) {
+            throw new OperationFormatException("'" + operationName + "' is not a valid operation name.");
+        }
+
+        validatedOperationName(operationName);
+    }
+
+    protected abstract void validatedOperationName(String operationName) throws OperationFormatException;
+
+    /* (non-Javadoc)
+     * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#propertyName(java.lang.String)
+     */
+    @Override
+    public void propertyName(String propertyName)
+            throws OperationFormatException {
+
+        assertValidParameterName(propertyName);
+        validatedPropertyName(propertyName);
+    }
+
+    protected abstract void validatedPropertyName(String propertyName) throws OperationFormatException;
+
+    /* (non-Javadoc)
+     * @see org.jboss.as.cli.operation.OperationParser.CallbackHandler#property(java.lang.String, java.lang.String, int)
+     */
+    @Override
+    public void property(String name, String value, int nameValueSeparatorIndex)
+            throws OperationFormatException {
+
+        assertValidParameterName(name);
+
+        if (value.isEmpty()) {
+            throw new OperationFormatException("Parameter '" + value + "' is missing value.");
+        }
+
+        validatedProperty(name, value, nameValueSeparatorIndex);
+    }
+
+    protected abstract void validatedProperty(String name, String value, int nameValueSeparatorIndex) throws OperationFormatException;
+
+    protected void assertValidType(String nodeType)
+            throws OperationFormatException {
+        if (nodeType == null || !ALPHANUMERICS_PATTERN.matcher(nodeType).matches()) {
+            throw new OperationFormatException("'" + nodeType + "' is not a valid node type name.");
+        }
+    }
+
+    protected void assertValidNodeName(String nodeName)
+            throws OperationFormatException {
+        if (nodeName == null || !NODE_NAME_PATTERN.matcher(nodeName).matches()) {
+            throw new OperationFormatException("'" + nodeName + "' is not a valid node name.");
+        }
+    }
+
+    protected void assertValidParameterName(String name)
+            throws OperationFormatException {
+        if (name == null || !ALPHANUMERICS_PATTERN.matcher(name).matches()) {
+            throw new OperationFormatException("'" + name + "' is not a valid parameter name.");
+        }
+    }
+
+}


Property changes on: workspace/adietish/org.jboss.ide.eclipse.as7.deployment.detyped/src/org/jboss/ide/eclipse/as7/deployment/detyped/util/ValidatingOperationCallbackHandler.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain



More information about the jbosstools-commits mailing list