You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2014/12/17 07:24:22 UTC

[1/2] stratos git commit: Updating CLI distribution to have bin, lib, conf and logs folders

Repository: stratos
Updated Branches:
  refs/heads/4.1.0-test cd37ecda5 -> a3de00ebd


Updating CLI distribution to have bin, lib, conf and logs folders


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

Branch: refs/heads/4.1.0-test
Commit: e24ba2a8bedade9ae0bff4ff64be2c0ab0396bb0
Parents: cd37ecd
Author: Imesh Gunaratne <im...@apache.org>
Authored: Wed Dec 17 11:49:44 2014 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Wed Dec 17 11:49:44 2014 +0530

----------------------------------------------------------------------
 products/stratos-cli/distribution/pom.xml       | 34 +++++++++++++-
 .../distribution/src/main/assembly/bin.xml      | 49 +++++++++++++-------
 .../distribution/src/main/bin/stratos.bat       |  2 +-
 .../distribution/src/main/bin/stratos.sh        | 13 ++++--
 .../distribution/src/main/conf/log4j.properties | 37 +++++++++++++++
 5 files changed, 112 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/e24ba2a8/products/stratos-cli/distribution/pom.xml
----------------------------------------------------------------------
diff --git a/products/stratos-cli/distribution/pom.xml b/products/stratos-cli/distribution/pom.xml
index ae5ce40..137a48c 100644
--- a/products/stratos-cli/distribution/pom.xml
+++ b/products/stratos-cli/distribution/pom.xml
@@ -32,6 +32,27 @@
     <url>http://apache.org/</url>
     <description>Apache Stratos CLI Distribution</description>
 
+    <repositories>
+        <repository>
+            <id>wso2-nexus</id>
+            <name>WSO2 internal Repository</name>
+            <url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
+            <releases>
+                <enabled>true</enabled>
+                <updatePolicy>daily</updatePolicy>
+                <checksumPolicy>ignore</checksumPolicy>
+            </releases>
+        </repository>
+    </repositories>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.stratos</groupId>
+            <artifactId>org.apache.stratos.cli</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+
     <profiles>
         <profile>
             <id>default</id>
@@ -43,6 +64,18 @@
                 <plugins>
                     <plugin>
                         <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-jar-plugin</artifactId>
+                        <version>2.4</version>
+                        <configuration>
+                            <archive>
+                                <manifest>
+                                    <mainClass>org.apache.stratos.cli.Main</mainClass>
+                                </manifest>
+                            </archive>
+                        </configuration>
+                    </plugin>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
                         <artifactId>maven-assembly-plugin</artifactId>
                         <executions>
                             <execution>
@@ -64,5 +97,4 @@
             </build>
         </profile>
     </profiles>
-
 </project>

http://git-wip-us.apache.org/repos/asf/stratos/blob/e24ba2a8/products/stratos-cli/distribution/src/main/assembly/bin.xml
----------------------------------------------------------------------
diff --git a/products/stratos-cli/distribution/src/main/assembly/bin.xml b/products/stratos-cli/distribution/src/main/assembly/bin.xml
index 3998ff3..a97afa5 100644
--- a/products/stratos-cli/distribution/src/main/assembly/bin.xml
+++ b/products/stratos-cli/distribution/src/main/assembly/bin.xml
@@ -22,34 +22,33 @@
     <formats>
         <format>zip</format>
     </formats>
-    <includeBaseDirectory>false</includeBaseDirectory>
-
     <fileSets>
         <fileSet>
-            <directory>../../../components/org.apache.stratos.cli/target</directory>
-            <outputDirectory>${pom.artifactId}-${pom.version}</outputDirectory>
+            <directory>${project.basedir}/src/main/bin</directory>
+            <outputDirectory>/bin</outputDirectory>
             <includes>
-                <include>org.apache.stratos.cli-${pom.version}.jar</include>
+                <include>stratos.sh</include>
             </includes>
+            <fileMode>0755</fileMode>
         </fileSet>
         <fileSet>
-            <directory>src/main/bin</directory>
-            <outputDirectory>${pom.artifactId}-${pom.version}</outputDirectory>
+            <directory>${project.basedir}/src/main/bin</directory>
+            <outputDirectory>/bin</outputDirectory>
             <includes>
-                <include>stratos.sh</include>
+                <include>stratos.bat</include>
             </includes>
-            <fileMode>0755</fileMode>
         </fileSet>
         <fileSet>
-            <directory>src/main/bin</directory>
-            <outputDirectory>${pom.artifactId}-${pom.version}</outputDirectory>
+            <directory>${project.basedir}/src/main/conf</directory>
+            <outputDirectory>/conf</outputDirectory>
             <includes>
-                <include>stratos.bat</include>
+                <include>log4j.properties</include>
             </includes>
+            <fileMode>0600</fileMode>
         </fileSet>
         <fileSet>
             <directory>${project.basedir}</directory>
-            <outputDirectory>${pom.artifactId}-${pom.version}</outputDirectory>
+            <outputDirectory>/</outputDirectory>
             <includes>
                 <include>INSTALL.txt</include>
                 <include>README.txt</include>
@@ -58,16 +57,32 @@
     </fileSets>
     <files>
         <file>
-            <source>src/main/notice/NOTICE</source>
-            <outputDirectory>${pom.artifactId}-${pom.version}</outputDirectory>
+            <source>${project.basedir}/src/main/notice/NOTICE</source>
+            <outputDirectory>/</outputDirectory>
             <filtered>true</filtered>
             <fileMode>644</fileMode>
         </file>
         <file>
-            <source>src/main/license/LICENSE</source>
-            <outputDirectory>${pom.artifactId}-${pom.version}</outputDirectory>
+            <source>${project.basedir}/src/main/license/LICENSE</source>
+            <outputDirectory>/</outputDirectory>
             <filtered>true</filtered>
             <fileMode>644</fileMode>
         </file>
     </files>
+    <dependencySets>
+        <dependencySet>
+            <excludes>
+                <exclude>*:annotations*</exclude>
+                <exclude>*:icu4j*</exclude>
+                <exclude>*:jaxen*</exclude>
+                <exclude>*:jboss-transaction-api*</exclude>
+                <exclude>*:wrapper*</exclude>
+                <exclude>*:xom*</exclude>
+                <exclude>slf4j.wso2:slf4j</exclude>
+            </excludes>
+            <outputDirectory>/lib</outputDirectory>
+            <useProjectArtifact>true</useProjectArtifact>
+            <scope>runtime</scope>
+        </dependencySet>
+    </dependencySets>
 </assembly>

http://git-wip-us.apache.org/repos/asf/stratos/blob/e24ba2a8/products/stratos-cli/distribution/src/main/bin/stratos.bat
----------------------------------------------------------------------
diff --git a/products/stratos-cli/distribution/src/main/bin/stratos.bat b/products/stratos-cli/distribution/src/main/bin/stratos.bat
index d610d50..ed3c4f5 100644
--- a/products/stratos-cli/distribution/src/main/bin/stratos.bat
+++ b/products/stratos-cli/distribution/src/main/bin/stratos.bat
@@ -32,5 +32,5 @@ if "%STRATOS_CLI_HOME%"=="" set STRATOS_CLI_HOME=%CD%
 
 cd %STRATOS_CLI_HOME%
 
-java -jar "org.apache.stratos.cli-4.0.0-SNAPSHOT.jar" %*
+rem TODO: Update according to stratos.sh
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/e24ba2a8/products/stratos-cli/distribution/src/main/bin/stratos.sh
----------------------------------------------------------------------
diff --git a/products/stratos-cli/distribution/src/main/bin/stratos.sh b/products/stratos-cli/distribution/src/main/bin/stratos.sh
index b4b99b4..c1dda20 100755
--- a/products/stratos-cli/distribution/src/main/bin/stratos.sh
+++ b/products/stratos-cli/distribution/src/main/bin/stratos.sh
@@ -25,11 +25,16 @@
 #
 #   STRATOS_URL        The URL of the Stratos Controller
 
-if [ -z $STRATOS_CLI_HOME ] ; then
-STRATOS_CLI_HOME="$PWD"
+echo "Starting Stratos CLI..."
+if [ -z "$STRATOS_URL" ]; then
+    echo "STRATOS_URL environment variable is not set"
 fi
 
-#debug="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"
+script_path="$( cd -P "$( dirname "$SOURCE" )" && pwd )/`dirname $0`"
+lib_path=${script_path}/../lib/
+class_path=`echo ${lib_path}/*.jar | tr ' ' ':'`
 
-java -jar ${debug} $STRATOS_CLI_HOME/org.apache.stratos.cli-4.1.0-SNAPSHOT.jar $*
+properties="-Dlog4j.configuration=file://${script_path}/../conf/log4j.properties"
+#debug="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"
 
+java -cp "${class_path}" ${properties} ${debug} org.apache.stratos.cli.Main

http://git-wip-us.apache.org/repos/asf/stratos/blob/e24ba2a8/products/stratos-cli/distribution/src/main/conf/log4j.properties
----------------------------------------------------------------------
diff --git a/products/stratos-cli/distribution/src/main/conf/log4j.properties b/products/stratos-cli/distribution/src/main/conf/log4j.properties
new file mode 100644
index 0000000..ec18740
--- /dev/null
+++ b/products/stratos-cli/distribution/src/main/conf/log4j.properties
@@ -0,0 +1,37 @@
+#
+# 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.
+#
+
+# Set root logger level and appenders
+log4j.rootLogger=INFO, FILE_APPENDER
+
+# CONSOLE_APPENDER is set to be a ConsoleAppender.
+#log4j.appender.CONSOLE_APPENDER=org.apache.log4j.ConsoleAppender
+
+# The standard error log where all the warnings, errors and fatal errors will be logged
+log4j.appender.FILE_APPENDER=org.apache.log4j.FileAppender
+log4j.appender.FILE_APPENDER.File=logs/stratos-cli.log
+log4j.appender.FILE_APPENDER.layout=org.apache.log4j.PatternLayout
+log4j.appender.FILE_APPENDER.layout.ConversionPattern=%d{ISO8601} [%X{ip}-%X{host}] [%t] %5p %c{1} %m%n
+log4j.appender.FILE_APPENDER.threshold=DEBUG
+
+# CONSOLE_APPENDER uses PatternLayout.
+log4j.appender.CONSOLE_APPENDER.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE_APPENDER.layout.ConversionPattern=[%d{ISO8601}] %5p - [%c{1}] %m%n
+
+log4j.logger.org.apache.stratos.cli=INFO


[2/2] stratos git commit: Adding null condition to application name and generic method to print errors

Posted by im...@apache.org.
Adding null condition to application name and generic method to print errors


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

Branch: refs/heads/4.1.0-test
Commit: a3de00ebd9d51c8315f26621ec42f28e38529656
Parents: e24ba2a
Author: Imesh Gunaratne <im...@apache.org>
Authored: Wed Dec 17 11:53:49 2014 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Wed Dec 17 11:53:49 2014 +0530

----------------------------------------------------------------------
 components/org.apache.stratos.cli/pom.xml       |  28 -----
 .../java/org/apache/stratos/cli/CliTool.java    |  32 ++----
 .../main/java/org/apache/stratos/cli/Main.java  |  35 +++++++
 .../stratos/cli/RestCommandLineService.java     | 105 ++++++++++---------
 .../apache/stratos/cli/utils/CliConstants.java  |   4 -
 5 files changed, 101 insertions(+), 103 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/a3de00eb/components/org.apache.stratos.cli/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/pom.xml b/components/org.apache.stratos.cli/pom.xml
index 60467eb..a53c2e3 100644
--- a/components/org.apache.stratos.cli/pom.xml
+++ b/components/org.apache.stratos.cli/pom.xml
@@ -38,10 +38,6 @@
 	</properties>
 
 	<dependencies>
-		<!-- <dependency>
-			<groupId>org.wso2.carbon</groupId>
-			<artifactId>org.wso2.carbon.ui</artifactId>
-		</dependency> -->
 		<!-- Adding HttpClient dependencies. Those were resolved with above one -->
 		<dependency>
 			<groupId>commons-httpclient</groupId>
@@ -118,30 +114,6 @@
 	</dependencies>
 	<build>
 		<plugins>
-			<plugin>
-				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-assembly-plugin</artifactId>
-				<configuration>
-					<archive>
-						<manifest>
-							<mainClass>org.apache.stratos.cli.CliTool</mainClass>
-						</manifest>
-					</archive>
-					<descriptors>
-						<descriptor>src/main/assembly/src.xml</descriptor>
-					</descriptors>
-					<appendAssemblyId>false</appendAssemblyId>
-				</configuration>
-				<executions>
-					<execution>
-						<id>make-assembly</id> <!-- this is used for inheritance merges -->
-						<phase>package</phase> <!-- bind to the packaging phase -->
-						<goals>
-							<goal>single</goal>
-						</goals>
-					</execution>
-				</executions>
-			</plugin>
 			<plugin>  
 				<groupId>org.apache.maven.plugins</groupId> 
 				<artifactId>maven-dependency-plugin</artifactId> 

http://git-wip-us.apache.org/repos/asf/stratos/blob/a3de00eb/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/CliTool.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/CliTool.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/CliTool.java
index ac21579..2175abf 100644
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/CliTool.java
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/CliTool.java
@@ -30,17 +30,7 @@ import org.slf4j.LoggerFactory;
  */
 public class CliTool {
 
-	private static final Logger logger = LoggerFactory.getLogger(CliTool.class);
-
-	/**
-	 * Main executable method used to call from CLI.
-	 * 
-	 */
-	public static void main(final String[] args) {
-		CliTool cliTool = new CliTool();
-		cliTool.createConfigDirectory();
-		cliTool.handleConsoleInputs(args);
-	}
+	private static final Logger log = LoggerFactory.getLogger(CliTool.class);
 
 	/**
 	 * Here is the place all the command line inputs get processed
@@ -48,27 +38,27 @@ public class CliTool {
 	 * @param arguments
 	 *            passed to CLI tool.
 	 */
-	private void handleConsoleInputs(String[] arguments) {
-		if (logger.isInfoEnabled()) {
-			logger.info("Stratos CLI Started...");
+	void handleConsoleInputs(String[] arguments) {
+		if (log.isInfoEnabled()) {
+			log.info("Stratos CLI started...");
 		}
 		StratosApplication application = new StratosApplication(arguments);
 		application.start(arguments);
 	}
 
-	private void createConfigDirectory() {
+	void createConfigDirectory() {
 		File stratosFile = new File(System.getProperty("user.home"), STRATOS_DIR);
 		if (stratosFile.exists()) {
-			if (logger.isInfoEnabled()) {
-				logger.info("Using directory: {}", stratosFile.getPath());
+			if (log.isInfoEnabled()) {
+				log.info("Using directory: {}", stratosFile.getPath());
 			}
 		} else {
 			if (stratosFile.mkdir()) {
-				if (logger.isInfoEnabled()) {
-					logger.info("Created directory: {}", stratosFile.getPath());
+				if (log.isInfoEnabled()) {
+					log.info("Created directory: {}", stratosFile.getPath());
 				}
-			} else if (logger.isWarnEnabled()) {
-				logger.warn("Failed to created directory: {}", stratosFile.getPath());
+			} else if (log.isWarnEnabled()) {
+				log.warn("Failed to created directory: {}", stratosFile.getPath());
 			}
 		}
 	}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a3de00eb/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/Main.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/Main.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/Main.java
new file mode 100644
index 0000000..d14ee07
--- /dev/null
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/Main.java
@@ -0,0 +1,35 @@
+/*
+ * 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;
+
+/**
+ * CLI main class.
+ */
+public class Main {
+    /**
+     * Main executable method used to call from CLI.
+     *
+     */
+    public static void main(final String[] args) {
+        CliTool cliTool = new CliTool();
+        cliTool.createConfigDirectory();
+        cliTool.handleConsoleInputs(args);
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/a3de00eb/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 bb015bc..0f1cc09 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
@@ -26,6 +26,7 @@ import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.ConfigurationContextFactory;
 import org.apache.axis2.description.TransportOutDescription;
 import org.apache.axis2.transport.http.HttpTransportProperties;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.http.HttpResponse;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.stratos.cli.exception.CommandException;
@@ -174,7 +175,8 @@ public class RestCommandLineService {
                 log.debug("Initialized REST Client for user {}", username);
             }
         } catch (AxisFault e) {
-            System.out.println("Error connecting to the stratos server");
+            String message = "Error connecting to the stratos server";
+            printError(message, e);
             throw new CommandException(e);
         }
 
@@ -198,18 +200,15 @@ public class RestCommandLineService {
             }
         } catch (ConnectException e) {
             String message = "Could not connect to stratos manager";
-            System.out.println(message);
-            log.error(message, e);
+            printError(message, e);
             return false;
         } catch (java.lang.NoSuchMethodError e) {
             String message = "Authentication failed!";
-            System.out.println(message);
-            log.error(message, e);
+            printError(message, e);
             return false;
         } catch (Exception e) {
             String message = "An unknown error occurred: " + e.getMessage();
-            System.out.println(message);
-            log.error(message, e);
+            printError(message, e);
             return false;
         } finally {
             httpClient.getConnectionManager().shutdown();
@@ -282,8 +281,7 @@ public class RestCommandLineService {
                     "Multi-Tenant");
         } catch (Exception e) {
             String message = "Error in listing cartridges";
-            System.out.println(message);
-            log.error(message, e);
+            printError(message, e);
         }
     }
 
@@ -349,8 +347,7 @@ public class RestCommandLineService {
             System.out.println("-------------------------------------");
         } catch (Exception e) {
             String message = "Error in describing cartridge: " + cartridgeType;
-            System.out.println(message);
-            log.error(message, e);
+            printError(message, e);
         }
     }
 
@@ -438,7 +435,8 @@ public class RestCommandLineService {
             }
 
         } catch (Exception e) {
-            handleException("Exception in creating User", e);
+            String message = "Could not add user";
+            printError(message, e);
         } finally {
             httpClient.getConnectionManager().shutdown();
         }
@@ -466,7 +464,8 @@ public class RestCommandLineService {
             }
 
         } catch (Exception e) {
-            handleException("Exception in deleting " + tenantDomain + " tenant", e);
+            String message = "Could not delete tenant";
+            printError(message, e);
         } finally {
             httpClient.getConnectionManager().shutdown();
         }
@@ -494,7 +493,8 @@ public class RestCommandLineService {
             }
 
         } catch (Exception e) {
-            handleException("Exception in deleting " + userName + " user", e);
+            String message = "Could not delete user";
+            printError(message, e);
         } finally {
             httpClient.getConnectionManager().shutdown();
         }
@@ -522,7 +522,8 @@ public class RestCommandLineService {
             }
 
         } catch (Exception e) {
-            handleException("Exception in deactivating " + tenantDomain + " tenant", e);
+            String message = "Could not de-activate tenant";
+            printError(message, e);
         } finally {
             httpClient.getConnectionManager().shutdown();
         }
@@ -550,7 +551,8 @@ public class RestCommandLineService {
             }
 
         } catch (Exception e) {
-            handleException("Error in activating tenant: " + tenantDomain, e);
+            String message = "Could not activate tenant";
+            printError(message, e);
         } finally {
             httpClient.getConnectionManager().shutdown();
         }
@@ -587,9 +589,8 @@ public class RestCommandLineService {
             System.out.println("Tenants:");
             CliUtils.printTable(tenantArray, rowMapper, "Domain", "Tenant ID", "Email", "State");
         } catch (Exception e) {
-            String message = "Error in listing users";
-            System.out.println(message);
-            log.error(message, e);
+            String message = "Could not list tenants";
+            printError(message, e);
         }
     }
 
@@ -621,9 +622,8 @@ public class RestCommandLineService {
             System.out.println("Users:");
             CliUtils.printTable(usersArray, rowMapper, "Username", "Role");
         } catch (Exception e) {
-            String message = "Error in listing users";
-            System.out.println(message);
-            log.error(message, e);
+            String message = "Could not list users";
+            printError(message, e);
         }
     }
 
@@ -664,7 +664,8 @@ public class RestCommandLineService {
                 public String[] getData(ApplicationDefinition applicationDefinition) {
                     String[] data = new String[4];
                     data[0] = applicationDefinition.getApplicationId();
-                    data[1] = applicationDefinition.getName();
+                    data[1] = StringUtils.isEmpty(applicationDefinition.getName()) ? "" :
+                            applicationDefinition.getName();
                     data[2] = applicationDefinition.getAlias();
                     data[3] = applicationDefinition.getStatus();
                     return data;
@@ -677,12 +678,23 @@ public class RestCommandLineService {
             System.out.println("Applications found:");
             CliUtils.printTable(array, rowMapper, "Application ID", "Name", "Alias", "Status");
         } catch (Exception e) {
-            String message = "Error in listing applications";
-            System.out.println(message);
-            log.error(message, e);
+            String message = "Could not list applications";
+            printError(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);
+    }
+
     public void listAutoscalingPolicies() throws CommandException {
         try {
             Type listType = new TypeToken<ArrayList<AutoscalePolicy>>() {
@@ -711,9 +723,8 @@ public class RestCommandLineService {
             System.out.println("Autoscaling policies found:");
             CliUtils.printTable(array, rowMapper, "ID", "Accessibility");
         } catch (Exception e) {
-            String message = "Error in listing autoscaling policies";
-            System.out.println(message);
-            log.error(message, e);
+            String message = "Could not list autoscaling policies";
+            printError(message, e);
         }
     }
 
@@ -731,8 +742,7 @@ public class RestCommandLineService {
 	        System.out.println(getGson().toJson(policy));
 	    } catch (Exception e) {
 	        String message = "Error in describing deployment policy: " + id;
-	        System.out.println(message);
-	        log.error(message, e);
+	        printError(message, e);
 	    }
     }
 
@@ -749,9 +759,8 @@ public class RestCommandLineService {
             System.out.println("Autoscaling policy: " + id);
             System.out.println(getGson().toJson(policy));
         } catch (Exception e) {
-            String message = "Error in describing autoscaling policy: " + id;
-            System.out.println(message);
-            log.error(message, e);
+            String message = "Could not describe autoscaling policy: " + id;
+            printError(message, e);
         }
     }
 
@@ -784,9 +793,8 @@ public class RestCommandLineService {
                 return;
             }
         } catch (Exception e) {
-            String message = "Error in listing kubernetes groups";
-            System.out.println(message);
-            log.error(message, e);
+            String message = "Could not list kubernetes groups";
+            printError(message, e);
         }
     }
 
@@ -815,7 +823,8 @@ public class RestCommandLineService {
             }
 
         } catch (Exception e) {
-            handleException("Error in deploying host to Kubernetes cluster: " + clusterId, e);
+            String message = "Could not add host to Kubernetes cluster: " + clusterId;
+            printError(message, e);
         } finally {
             httpClient.getConnectionManager().shutdown();
         }
@@ -847,9 +856,8 @@ public class RestCommandLineService {
                 return;
             }
         } catch (Exception e) {
-            String message = "Error in listing kubernetes hosts";
-            System.out.println(message);
-            log.error(message, e);
+            String message = "Could not list kubernetes hosts";
+            printError(message, e);
         }
     }
 
@@ -885,9 +893,8 @@ public class RestCommandLineService {
                 System.out.println(exception);
             }
         } catch (Exception e) {
-            String message = "Error in synchronizing artifacts for cartridge subscription alias: " + cartridgeAlias;
-            System.out.println(message);
-            log.error(message, e);
+            String message = "Could not synchronize artifacts for cartridge subscription alias: " + cartridgeAlias;
+            printError(message, e);
         } finally {
             httpClient.getConnectionManager().shutdown();
         }
@@ -917,9 +924,8 @@ public class RestCommandLineService {
             System.out.println("Service Group : " + groupDefinitionName);
             System.out.println(getGson().toJson(bean));
         } catch (Exception e) {
-            String message = "Error in describing service group: " + groupDefinitionName;
-            System.out.println(message);
-            log.error(message, e);
+            String message = "Could not describe service group: " + groupDefinitionName;
+            printError(message, e);
         }
     }
 
@@ -950,9 +956,8 @@ public class RestCommandLineService {
             System.out.println("Application: " + applicationID);
             System.out.println(getGson().toJson(application));
         } catch (Exception e) {
-            String message = "Error in describing application: " + applicationID;
-            System.out.println(message);
-            log.error(message, e);
+            String message = "Could not describe application: " + applicationID;
+            printError(message, e);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/a3de00eb/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 1c616e9..19482c3 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
@@ -25,13 +25,9 @@ package org.apache.stratos.cli.utils;
 public class CliConstants {
 
 	public static final String STRATOS_APPLICATION_NAME = "stratos";
-
 	public static final String STRATOS_URL_ENV_PROPERTY = "STRATOS_URL";
-
 	public static final String STRATOS_USERNAME_ENV_PROPERTY = "STRATOS_USERNAME";
-
 	public static final String STRATOS_PASSWORD_ENV_PROPERTY = "STRATOS_PASSWORD";
-
 	public static final String STRATOS_SHELL_PROMPT = "stratos> ";
 	
 	public static final int COMMAND_SUCCESSFULL = 0;