Repository: stratos
Updated Branches:
  refs/heads/master 4be1c863f -> dbc09b3dc


Added and updated cli commands for application and application signup commands


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/dbc09b3d
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/dbc09b3d
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/dbc09b3d

Branch: refs/heads/master
Commit: dbc09b3dc5824791729e8ac343b872ef51c1eca9
Parents: 4be1c86
Author: Shiro <[email protected]>
Authored: Fri Jan 16 10:47:37 2015 +0530
Committer: Imesh Gunaratne <[email protected]>
Committed: Fri Jan 16 11:26:16 2015 +0530

----------------------------------------------------------------------
 .../java/org/apache/stratos/cli/RestClient.java |   4 +-
 .../stratos/cli/RestCommandLineService.java     | 100 ++++++++++++--
 .../cli/commands/AddApplicationCommand.java     | 137 +++++++++++++++++++
 .../commands/AddApplicationSignupCommand.java   | 112 +++++++++++++++
 .../cli/commands/DeleteApplicationCommand.java  |  70 ++++++++++
 .../DeleteApplicationSignupCommand.java         |  71 ++++++++++
 .../commands/DescribeApplicationCommand.java    |   2 +-
 .../DescribeApplicationSignupCommand.java       |  67 +++++++++
 .../cli/commands/ListApplicationsCommand.java   |   2 +-
 .../commands/UndeployApplicationCommand.java    |   2 +-
 .../apache/stratos/cli/utils/CliConstants.java  |  51 ++++++-
 .../rest/endpoint/api/StratosApiV41.java        |   4 +-
 12 files changed, 597 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/dbc09b3d/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestClient.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestClient.java
 
b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestClient.java
index b2df173..b9fd977 100644
--- 
a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestClient.java
+++ 
b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestClient.java
@@ -201,7 +201,9 @@ public class RestClient implements GenericRestClient {
     public void deleteEntity(String serviceEndpoint, String identifier, String 
entityName) {
         try {
             int responseCode = executeDelete(serviceEndpoint, identifier);
-            if (responseCode == 200) {
+            if (responseCode == 404) {
+                System.out.println(String.format("%s not found", 
StringUtils.capitalize(entityName)));
+            } else if (responseCode == 200) {
                 System.out.println(String.format("Successfully deleted %s", 
entityName));
             }
         } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/dbc09b3d/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
 
b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
index c06767e..1de05ca 100644
--- 
a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
+++ 
b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
@@ -46,6 +46,7 @@ import 
org.apache.stratos.common.beans.kubernetes.KubernetesHostBean;
 import org.apache.stratos.common.beans.policy.autoscale.AutoscalePolicyBean;
 import org.apache.stratos.common.beans.policy.deployment.DeploymentPolicyBean;
 import org.apache.stratos.common.beans.topology.ClusterBean;
+import 
org.apache.stratos.common.beans.application.signup.ApplicationSignUpBean;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -69,6 +70,7 @@ public class RestCommandLineService {
 
     private static final String ENDPOINT_ADD_TENANT = API_CONTEXT + "/tenants";
     private static final String ENDPOINT_ADD_USER = API_CONTEXT + "/users";
+    private static final String ENDPOINT_ADD_APPLICATION = API_CONTEXT + 
"/applications";
 
     private static final String ENDPOINT_DEPLOY_CARTRIDGE = API_CONTEXT + 
"/cartridges";
     private static final String ENDPOINT_DEPLOY_AUTOSCALING_POLICY = 
API_CONTEXT + "/autoscalingPolicies";
@@ -84,6 +86,8 @@ public class RestCommandLineService {
     private static final String ENDPOINT_UNDEPLOY_SERVICE_GROUP = API_CONTEXT 
+ "/groups/{id}";
     private static final String ENDPOINT_UNDEPLOY_APPLICATION = API_CONTEXT + 
"/applications/{id}";
     private static final String ENDPOINT_UNDEPLOY_CARTRIDGE = API_CONTEXT + 
"/cartridges/{id}";
+    
+    private static final String ENDPOINT_REMOVE_APPLICATION = API_CONTEXT + 
"/applications/{appId}";
 
     private static final String ENDPOINT_LIST_AUTOSCALING_POLICIES = 
API_CONTEXT + "/autoscalingPolicies";
     private static final String ENDPOINT_LIST_DEPLOYMENT_POLICIES = 
API_CONTEXT + "/deploymentPolicies";
@@ -112,6 +116,7 @@ public class RestCommandLineService {
     private static final String ENDPOINT_SYNCHRONIZE_ARTIFACTS = API_CONTEXT + 
"/repo/synchronize/{subscriptionAlias}";
     private static final String ENDPOINT_ACTIVATE_TENANT = API_CONTEXT + 
"/tenants/activate/{tenantDomain}";
     private static final String ENDPOINT_DEACTIVATE_TENANT = API_CONTEXT + 
"/tenants/deactivate/{tenantDomain}";
+    private static final String ENDPOINT_APPLICATION_SIGNUP = API_CONTEXT + 
"/applications/{applicationId}/signup";
 
     private static final String ENDPOINT_UPDATE_DEPLOYMENT_POLICY = 
API_CONTEXT + "/deploymentPolicies";
     private static final String ENDPOINT_UPDATE_AUTOSCALING_POLICY = 
API_CONTEXT + "/autoscalePolicies";
@@ -673,18 +678,6 @@ public class RestCommandLineService {
         }
     }
 
-    /**
-     * Print error on console and log
-     * @param message
-     * @param e
-     */
-    private void printError(String message, Throwable e) {
-        // CLI console only get system output
-        System.out.println(message);
-        // Log error
-        log.error(message, e);
-    }
-
     public void listAutoscalingPolicies() throws CommandException {
         try {
             Type listType = new TypeToken<ArrayList<AutoscalePolicyBean>>() {
@@ -961,6 +954,11 @@ public class RestCommandLineService {
         }
     }
 
+    // This method helps to add applications
+    public void addApplication (String entityBody) {
+        restClient.deployEntity(ENDPOINT_ADD_APPLICATION, entityBody, 
"application");
+    }
+    
     // This method helps to deploy applications
     public void deployApplication (String applicationId, String entityBody) {
         
restClient.deployEntity(ENDPOINT_DEPLOY_APPLICATION.replace("{applicationId}", 
applicationId), entityBody,
@@ -968,11 +966,41 @@ public class RestCommandLineService {
     }
 
     // This method helps to undeploy applications
-    public void undeployApplication(String id) throws CommandException {
-        restClient.undeployEntity(ENDPOINT_UNDEPLOY_APPLICATION, 
"applicationId", id);
+    public void undeployApplication(String applicationId) throws 
CommandException {
+       DefaultHttpClient httpClient = new DefaultHttpClient();
+        try {
+            HttpResponse response = restClient.doPost(httpClient, 
restClient.getBaseURL()
+                    + ENDPOINT_UNDEPLOY_APPLICATION + "/" + applicationId, "");
+
+            String responseCode = "" + 
response.getStatusLine().getStatusCode();
+
+            GsonBuilder gsonBuilder = new GsonBuilder();
+            Gson gson = gsonBuilder.create();
+
+            if (responseCode.equals(CliConstants.RESPONSE_OK)) {
+                System.out.println("You have succesfully undelopyed 
application: " + applicationId);
+                return;
+            } else {
+                String resultString = CliUtils.getHttpResponseString(response);
+                ExceptionMapper exception = gson.fromJson(resultString, 
ExceptionMapper.class);
+                System.out.println(exception);
+            }
+
+        } catch (Exception e) {
+            String message = "Could not undeploy application";
+            printError(message, e);
+        } finally {
+            httpClient.getConnectionManager().shutdown();
+        }
+    }
+    
+    // This method helps to remove applications
+    public void deleteApplication (String applicationId) {
+        
restClient.deleteEntity(ENDPOINT_REMOVE_APPLICATION.replace("{applicationId}", 
applicationId), applicationId,
+                "application");
     }
 
-    // This method helps to describe applications
+    // This method helps to describe an application
     public void describeApplication (String applicationID) {
         try {
             Type listType = new TypeToken<ApplicationBean>() {
@@ -994,6 +1022,36 @@ public class RestCommandLineService {
         }
     }
 
+    // This method helps to add application signup
+    public void addApplicationSignup (String entityBody, String applicationId) 
{
+        
restClient.deployEntity(ENDPOINT_APPLICATION_SIGNUP.replace("{applicationId}", 
applicationId), entityBody, "application");
+    }
+    
+    // This method helps to describe application signup
+    public void describeApplicationSignup (String applicationId) {
+        try {
+               ApplicationSignUpBean bean = (ApplicationSignUpBean) 
restClient.listEntity(ENDPOINT_APPLICATION_SIGNUP.replace("{applicationId}", 
applicationId),
+                               ApplicationSignUpBean.class, 
"applicationSignup");
+
+            if (bean == null) {
+                System.out.println("Applicationsign up not found for 
application: " + applicationId);
+                return;
+            }
+
+            System.out.println("Application signup for application : " + 
applicationId);
+            System.out.println(getGson().toJson(bean));
+        } catch (Exception e) {
+            String message = "Could not describe application signup for 
application: " + applicationId;
+            printError(message, e);
+        }
+    }
+    
+    // This method helps to remove application signup
+    public void deleteApplicationSignup (String applicationId) {
+        
restClient.deleteEntity(ENDPOINT_APPLICATION_SIGNUP.replace("{applicationId}", 
applicationId), applicationId,
+                "application signup");
+    }
+    
     // This is for handle exception
     private void handleException(String key, Exception e, Object... args) 
throws CommandException {
         if (log.isDebugEnabled()) {
@@ -1009,4 +1067,16 @@ public class RestCommandLineService {
         System.out.println(message);
         throw new CommandException(message, e);
     }
+    
+    /**
+     * Print error on console and log
+     * @param message
+     * @param e
+     */
+    private void printError(String message, Throwable e) {
+        // CLI console only get system output
+        System.out.println(message);
+        // Log error
+        log.error(message, e);
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/dbc09b3d/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddApplicationCommand.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddApplicationCommand.java
 
b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddApplicationCommand.java
new file mode 100644
index 0000000..977f0ea
--- /dev/null
+++ 
b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddApplicationCommand.java
@@ -0,0 +1,137 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.stratos.cli.commands;
+
+import org.apache.commons.cli.*;
+import org.apache.stratos.cli.Command;
+import org.apache.stratos.cli.RestCommandLineService;
+import org.apache.stratos.cli.StratosCommandContext;
+import org.apache.stratos.cli.exception.CommandException;
+import org.apache.stratos.cli.utils.CliConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+
+public class AddApplicationCommand implements Command<StratosCommandContext> {
+
+    private static final Logger logger = 
LoggerFactory.getLogger(AddApplicationCommand.class);
+
+    private final Options options;
+
+    public AddApplicationCommand(){
+        options = constructOptions();
+    }
+
+    private Options constructOptions() {
+        final Options options = new Options();
+
+        Option resourcePath = new Option(CliConstants.RESOURCE_PATH, 
CliConstants.RESOURCE_PATH_LONG_OPTION, true,
+                "Application resource path");
+        resourcePath.setArgName("resource path");
+        options.addOption(resourcePath);
+
+        return options;
+    }
+
+    public String getName() {
+       return CliConstants.ADD_APPLICATION;
+    }
+
+    public String getDescription() {
+        return "Add application definition";
+    }
+
+    public String getArgumentSyntax() {
+        return null;
+    }
+
+    public int execute(StratosCommandContext context, String[] args) throws 
CommandException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("Executing {} command...", getName());
+        }
+
+        if (args != null && args.length > 0) {
+            String resourcePath = null;
+            String applicationDefinition = null;
+
+            final CommandLineParser parser = new GnuParser();
+            CommandLine commandLine;
+
+            try {
+                commandLine = parser.parse(options, args);
+
+                if (logger.isDebugEnabled()) {
+                    logger.debug("Application definition addition");
+                }
+
+                if (commandLine.hasOption(CliConstants.RESOURCE_PATH)) {
+                    if (logger.isTraceEnabled()) {
+                        logger.trace("Resource path option is passed");
+                    }
+                    resourcePath = 
commandLine.getOptionValue(CliConstants.RESOURCE_PATH);
+                    applicationDefinition = readResource(resourcePath);
+                }
+
+                if (resourcePath == null) {
+                    System.out.println("usage: " + getName() + " [-p <resource 
path>]");
+                    return CliConstants.COMMAND_FAILED;
+                }
+
+                
RestCommandLineService.getInstance().addApplication(applicationDefinition);
+                return CliConstants.COMMAND_SUCCESSFULL;
+
+            } catch (ParseException e) {
+                if (logger.isErrorEnabled()) {
+                    logger.error("Error parsing arguments", e);
+                }
+                System.out.println(e.getMessage());
+                return CliConstants.COMMAND_FAILED;
+            } catch (IOException e) {
+                System.out.println("Invalid resource path");
+                return CliConstants.COMMAND_FAILED;
+            }
+        } else {
+            context.getStratosApplication().printUsage(getName());
+            return CliConstants.COMMAND_FAILED;
+        }
+    }
+
+    private String readResource(String fileName) throws IOException {
+        BufferedReader br = new BufferedReader(new FileReader(fileName));
+        try {
+            StringBuilder sb = new StringBuilder();
+            String line = br.readLine();
+
+            while (line != null) {
+                sb.append(line);
+                sb.append("\n");
+                line = br.readLine();
+            }
+            return sb.toString();
+        } finally {
+            br.close();
+        }
+    }
+
+    public Options getOptions() {
+        return options;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/dbc09b3d/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddApplicationSignupCommand.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddApplicationSignupCommand.java
 
b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddApplicationSignupCommand.java
new file mode 100644
index 0000000..212fd6f
--- /dev/null
+++ 
b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddApplicationSignupCommand.java
@@ -0,0 +1,112 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.stratos.cli.commands;
+
+import org.apache.commons.cli.*;
+import org.apache.stratos.cli.Command;
+import org.apache.stratos.cli.RestCommandLineService;
+import org.apache.stratos.cli.StratosCommandContext;
+import org.apache.stratos.cli.exception.CommandException;
+import org.apache.stratos.cli.utils.CliConstants;
+import org.apache.stratos.cli.utils.CliUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.IOException;
+
+/**
+ * Deploy application command.
+ */
+public class AddApplicationSignupCommand implements 
Command<StratosCommandContext> {
+
+    private static final Logger logger = 
LoggerFactory.getLogger(AddApplicationSignupCommand.class);
+
+    private Options options;
+
+    public AddApplicationSignupCommand() {
+        options = new Options();
+        Option option = new Option(CliConstants.RESOURCE_PATH, 
CliConstants.RESOURCE_PATH_LONG_OPTION, true,
+                "Application sign up resource path");
+        option.setArgName("resource path");
+        options.addOption(option);
+    }
+
+    @Override
+    public String getName() {
+       return CliConstants.ADD_APPLICATION_SIGNUP;
+    }
+
+    @Override
+    public String getDescription() {
+        return "Add application sign up";
+    }
+
+    @Override
+    public String getArgumentSyntax() {
+        return "[application-id]";
+    }
+
+    @Override
+    public Options getOptions() {
+        return options;
+    }
+
+    @Override
+    public int execute(StratosCommandContext context, String[] args) throws 
CommandException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("Executing command: ", getName());
+        }
+
+        if ((args == null) || (args.length <= 0)) {
+            context.getStratosApplication().printUsage(getName());
+            return CliConstants.COMMAND_FAILED;
+        }
+        String applicationId = args[0];
+
+        try {
+            CommandLineParser parser = new GnuParser();
+            CommandLine commandLine = parser.parse(options, args);
+            if (commandLine.hasOption(CliConstants.RESOURCE_PATH)) {
+                String resourcePath = 
commandLine.getOptionValue(CliConstants.RESOURCE_PATH);
+                if (resourcePath == null) {
+                    System.out.println("usage: " + getName() + " [-" + 
CliConstants.RESOURCE_PATH + " " + CliConstants.RESOURCE_PATH_LONG_OPTION + 
"]");
+                    return CliConstants.COMMAND_FAILED;
+                }
+                String resourceFileContent = 
CliUtils.readResource(resourcePath);
+                
RestCommandLineService.getInstance().addApplicationSignup(resourceFileContent, 
applicationId);
+                return CliConstants.COMMAND_SUCCESSFULL;
+            } else {
+                System.out.println("usage: " + getName() + " [-" + 
CliConstants.RESOURCE_PATH + " " + CliConstants.RESOURCE_PATH_LONG_OPTION + 
"]");
+                return CliConstants.COMMAND_FAILED;
+            }
+        } catch (ParseException e) {
+            logger.error("Error parsing arguments", e);
+            System.out.println(e.getMessage());
+            return CliConstants.COMMAND_FAILED;
+        } catch (IOException e) {
+            System.out.println("Invalid resource path");
+            return CliConstants.COMMAND_FAILED;
+        } catch (Exception e) {
+            String message = "Unknown error occurred: " + e.getMessage();
+            System.out.println(message);
+            logger.error(message, e);
+            return CliConstants.COMMAND_FAILED;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/dbc09b3d/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeleteApplicationCommand.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeleteApplicationCommand.java
 
b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeleteApplicationCommand.java
new file mode 100644
index 0000000..1a907ae
--- /dev/null
+++ 
b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeleteApplicationCommand.java
@@ -0,0 +1,70 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.stratos.cli.commands;
+
+import org.apache.commons.cli.Options;
+import org.apache.stratos.cli.Command;
+import org.apache.stratos.cli.RestCommandLineService;
+import org.apache.stratos.cli.StratosCommandContext;
+import org.apache.stratos.cli.exception.CommandException;
+import org.apache.stratos.cli.utils.CliConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DeleteApplicationCommand implements 
Command<StratosCommandContext> {
+    private static final Logger logger = 
LoggerFactory.getLogger(DeleteApplicationCommand.class);
+
+    @Override
+    public String getName() {
+        return CliConstants.DELETE_APPLICATION;
+    }
+
+    @Override
+    public String getDescription() {
+        return "Delete Application";
+    }
+
+    @Override
+    public String getArgumentSyntax() {
+        return "[Application Id]";
+    }
+
+    @Override
+    public Options getOptions() {
+        return null;
+    }
+
+    @Override
+    public int execute(StratosCommandContext context, String[] args) throws 
CommandException {
+        if (logger.isDebugEnabled()) {
+                       logger.debug("Executing {} command...", getName());
+               }
+               if (args != null && args.length == 1) {
+                       String id = args[0];
+                       if (logger.isDebugEnabled()) {
+                               logger.debug("Getting delete application id 
{}", id);
+                       }
+                       
RestCommandLineService.getInstance().deleteApplication(id);
+                       return CliConstants.COMMAND_SUCCESSFULL;
+               } else {
+                       context.getStratosApplication().printUsage(getName());
+                       return CliConstants.COMMAND_FAILED;
+               }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/dbc09b3d/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeleteApplicationSignupCommand.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeleteApplicationSignupCommand.java
 
b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeleteApplicationSignupCommand.java
new file mode 100644
index 0000000..b3b45ac
--- /dev/null
+++ 
b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeleteApplicationSignupCommand.java
@@ -0,0 +1,71 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.stratos.cli.commands;
+
+import org.apache.commons.cli.Options;
+import org.apache.stratos.cli.Command;
+import org.apache.stratos.cli.RestCommandLineService;
+import org.apache.stratos.cli.StratosCommandContext;
+import org.apache.stratos.cli.exception.CommandException;
+import org.apache.stratos.cli.utils.CliConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DeleteApplicationSignupCommand implements 
Command<StratosCommandContext> {
+    private static final Logger logger = 
LoggerFactory.getLogger(DeleteApplicationSignupCommand.class);
+
+    @Override
+    public String getName() {
+        return CliConstants.DELETE_APPLICATION_SIGNUP;
+    }
+
+    @Override
+    public String getDescription() {
+        return "Delete Application Signup";
+    }
+
+    @Override
+    public String getArgumentSyntax() {
+        return "[Application Id]";
+    }
+
+    @Override
+    public Options getOptions() {
+        return null;
+    }
+
+    @Override
+    public int execute(StratosCommandContext context, String[] args) throws 
CommandException {
+        if (logger.isDebugEnabled()) {
+                       logger.debug("Executing {} command...", getName());
+               }
+               if (args != null && args.length == 1) {
+                       String id = args[0];
+                       if (logger.isDebugEnabled()) {
+                               logger.debug("Getting delete application id 
{}", id);
+                       }
+                       
RestCommandLineService.getInstance().deleteApplicationSignup(id);
+                       return CliConstants.COMMAND_SUCCESSFULL;
+               } else {
+                       context.getStratosApplication().printUsage(getName());
+                       return CliConstants.COMMAND_FAILED;
+               }
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/stratos/blob/dbc09b3d/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeApplicationCommand.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeApplicationCommand.java
 
b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeApplicationCommand.java
index dbac1e8..5fc2be8 100644
--- 
a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeApplicationCommand.java
+++ 
b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeApplicationCommand.java
@@ -36,7 +36,7 @@ public class DescribeApplicationCommand implements 
Command<StratosCommandContext
        }
 
        public String getName() {
-               return "describe-application";
+               return CliConstants.DESCRIBE_APPLICATION;
        }
 
        public String getDescription() {

http://git-wip-us.apache.org/repos/asf/stratos/blob/dbc09b3d/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeApplicationSignupCommand.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeApplicationSignupCommand.java
 
b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeApplicationSignupCommand.java
new file mode 100644
index 0000000..37857ad
--- /dev/null
+++ 
b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeApplicationSignupCommand.java
@@ -0,0 +1,67 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.stratos.cli.commands;
+
+import org.apache.commons.cli.Options;
+import org.apache.stratos.cli.Command;
+import org.apache.stratos.cli.RestCommandLineService;
+import org.apache.stratos.cli.StratosCommandContext;
+import org.apache.stratos.cli.exception.CommandException;
+import org.apache.stratos.cli.utils.CliConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DescribeApplicationSignupCommand implements 
Command<StratosCommandContext> {
+
+       private static final Logger logger = 
LoggerFactory.getLogger(DescribeApplicationSignupCommand.class);
+
+       public DescribeApplicationSignupCommand() {
+       }
+
+       public String getName() {
+               return CliConstants.DESCRIBE_APPLICATION_SIGNUP;
+       }
+
+       public String getDescription() {
+               return "Describe application sign up";
+       }
+
+       public String getArgumentSyntax() {
+               return "[application-id]";
+       }
+
+       public int execute(StratosCommandContext context, String[] args) throws 
CommandException {
+               if (logger.isDebugEnabled()) {
+                       logger.debug("Executing command: ", getName());
+               }
+               if ((args == null) || (args.length == 0)) {
+            context.getStratosApplication().printUsage(getName());
+            return CliConstants.COMMAND_FAILED;
+               } else {
+            String applicationId = args[0];
+            
RestCommandLineService.getInstance().describeApplicationSignup(applicationId);
+            return CliConstants.COMMAND_SUCCESSFULL;
+               }
+       }
+
+       public Options getOptions() {
+               return null;
+       }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/dbc09b3d/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListApplicationsCommand.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListApplicationsCommand.java
 
b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListApplicationsCommand.java
index a59d131..3933c83 100644
--- 
a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListApplicationsCommand.java
+++ 
b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListApplicationsCommand.java
@@ -35,7 +35,7 @@ public class ListApplicationsCommand implements 
Command<StratosCommandContext> {
     }
 
     public String getName() {
-        return "list-applications";
+        return CliConstants.LIST_APPLICATIONS;
     }
 
     public String getDescription() {

http://git-wip-us.apache.org/repos/asf/stratos/blob/dbc09b3d/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployApplicationCommand.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployApplicationCommand.java
 
b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployApplicationCommand.java
index 0fba797..162ade5 100644
--- 
a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployApplicationCommand.java
+++ 
b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployApplicationCommand.java
@@ -40,7 +40,7 @@ public class UndeployApplicationCommand implements 
Command<StratosCommandContext
 
     @Override
     public String getName() {
-        return "undeploy-application";
+        return CliConstants.UNDEPLOY_APPLICATION;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/stratos/blob/dbc09b3d/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/utils/CliConstants.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/utils/CliConstants.java
 
b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/utils/CliConstants.java
index b81b601..540ca22 100644
--- 
a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/utils/CliConstants.java
+++ 
b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/utils/CliConstants.java
@@ -79,6 +79,16 @@ public class CliConstants {
      * Add tenant
      */
     public static final String ADD_TENANT = "create-tenant";
+    
+    /**
+     * Add application
+     */
+    public static final String ADD_APPLICATION = "add-application";
+    
+    /**
+     * Add application signup
+     */
+    public static final String ADD_APPLICATION_SIGNUP = "add-application";
 
     /**
      * Add user
@@ -96,6 +106,11 @@ public class CliConstants {
     public static final String PARTITION_DEPLOYMENT = "deploy-partition";
 
     /**
+     * List applications
+     */
+    public static final String LIST_APPLICATIONS = "list-applications";
+    
+    /**
      * List partitions
      */
     public static final String LIST_PARTITION = "list-partitions";
@@ -154,7 +169,15 @@ public class CliConstants {
         * Synchronize repository
         */
        public static final String SYNC_ACTION = "sync";
-
+       
+       /**
+     * Describe the application signup
+     */
+    public static final String DESCRIBE_APPLICATION_SIGNUP = 
"describe-application-signup";
+    /**
+     * Describe the application
+     */
+    public static final String DESCRIBE_APPLICATION = "describe-application";
      /**
      * Describe the cartridge
      */
@@ -167,14 +190,20 @@ public class CliConstants {
      * Describe the auto scaling policy
      */
     public static final String DESCRIBE_AUTO_SCALING_POLICY = 
"describe-autoscaling-policy";
+    
+    /**
+     * Undeploy application
+     */
+    public static final String UNDEPLOY_APPLICATION = "undeploy-application";
     /**
-     * Undeploy deploy service
+     * Undeploy deployed service
      */
     public static final String UNDEPLOY_SERVICE = "undeploy-service";
     /**
      * Undeploy cartridge definition
      */
     public static final String UNDEPLOY_CARTRIDGE_DEFINITION = 
"undeploy-cartridge";
+    
     /**
      * Delete tenant
      */
@@ -186,12 +215,14 @@ public class CliConstants {
     /**
      * Deactivate tenant
      */
+    
     public static final String DEACTIVATE_TENANT = "deactivate-tenant";
     /**
      * Activate tenant
      */
     public static final String ACTIVATE_TENANT = "activate-tenant";
-     /**
+    
+    /**
      * Describe the deployment policy
      */
     public static final String DESCRIBE_DEPLOYMENT_POLICY = 
"describe-deployment-policy";
@@ -209,6 +240,16 @@ public class CliConstants {
         * List the available policies
         */
        public static final String POLICIES_ACTION = "policies";
+       
+       /**
+     * Delete application
+     */
+    public static final String DELETE_APPLICATION= "delete-application";
+    
+    /**
+     * Delete application signup
+     */
+    public static final String DELETE_APPLICATION_SIGNUP= 
"delete-application-signup";
 
        /**
         * Exit action
@@ -307,6 +348,10 @@ public class CliConstants {
     public static final String HOST_ID_OPTION = "h";
     public static final String HOST_ID_LONG_OPTION = "host-id";
     
+    // Application options
+    public static final String APPLICATION_ID_OPTION = "app";
+    public static final String APPLICATION_ID_LONG_OPTION = "application-id";
+        
     public static final String RESPONSE_INTERNAL_SERVER_ERROR = "500";
     public static final String RESPONSE_AUTHORIZATION_FAIL = "403";
     public static final String RESPONSE_NO_CONTENT = "204";

http://git-wip-us.apache.org/repos/asf/stratos/blob/dbc09b3d/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
 
b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
index 1ff28a2..bb17269 100644
--- 
a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
+++ 
b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
@@ -454,7 +454,6 @@ public class StratosApiV41 extends AbstractApi {
      * Gets the application sign up.
      *
      * @param applicationId the application id
-     * @param signUpId the sign up id
      * @return the application sign up
      * @throws RestAPIException the rest api exception
      */
@@ -463,8 +462,7 @@ public class StratosApiV41 extends AbstractApi {
     @Produces("application/json")
     @Consumes("application/json")
     @AuthorizationAction("/permission/protected/manage/monitor/tenants")
-    public Response getApplicationSignUp(@PathParam("applicationId") String 
applicationId,
-                                         @PathParam("signUpId") String 
signUpId) throws RestAPIException {
+    public Response getApplicationSignUp(@PathParam("applicationId") String 
applicationId) throws RestAPIException {
         ApplicationSignUpBean applicationSignUpBean = 
StratosApiV41Utils.getApplicationSignUp(applicationId);
         if (applicationSignUpBean == null) {
             return Response.status(Response.Status.NOT_FOUND).build();

Reply via email to