You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by is...@apache.org on 2014/03/27 13:29:09 UTC

[03/10] git commit: Using proper variable names for username & password

Using proper variable names for username & password


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

Branch: refs/heads/master
Commit: 770acad67c18547f5ba80622a93e5d62edd57cce
Parents: ace7b25
Author: M. Isuru Tharanga Chrishantha Perera <is...@apache.org>
Authored: Tue Mar 25 14:32:16 2014 +0530
Committer: M. Isuru Tharanga Chrishantha Perera <is...@apache.org>
Committed: Tue Mar 25 14:32:16 2014 +0530

----------------------------------------------------------------------
 .../stratos/cli/CommandLineApplication.java     |  8 +++----
 .../apache/stratos/cli/GenericRestClient.java   | 14 ++++++-------
 .../java/org/apache/stratos/cli/RestClient.java | 22 ++++++++++----------
 .../apache/stratos/cli/StratosApplication.java  |  6 +++---
 4 files changed, 25 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/770acad6/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/CommandLineApplication.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/CommandLineApplication.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/CommandLineApplication.java
index d1b644e..6b80c57 100644
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/CommandLineApplication.java
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/CommandLineApplication.java
@@ -35,11 +35,11 @@ public abstract class CommandLineApplication<T extends CommandContext> {
 
 	protected ConsoleReader reader;
 	protected FileHistory history;
-    protected String userName;
+    protected String username;
 
 	public CommandLineApplication(String[] args) {
         if (args != null && args.length > 1) {
-            userName = args[1];
+            username = args[1];
         }
         reader = createConsoleReader();
     }
@@ -54,7 +54,7 @@ public abstract class CommandLineApplication<T extends CommandContext> {
 		try {
 			consoleReader = new ConsoleReader();
 			consoleReader.setPrompt(getPrompt());
-			history = new FileHistory(getHistoryFile(userName));
+			history = new FileHistory(getHistoryFile(username));
 			consoleReader.setHistory(history);
 		} catch (IOException e) {
 			throw new IllegalStateException("Cannot create jline console reader", e);
@@ -87,7 +87,7 @@ public abstract class CommandLineApplication<T extends CommandContext> {
 	 * 
 	 * @return File for storing history
 	 */
-	protected abstract File getHistoryFile(String userName);
+	protected abstract File getHistoryFile(String username);
 
 	public final void start(String[] args) {
 		Thread shutdownHookThread = new Thread("CLI Shutdown Hook") {

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/770acad6/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/GenericRestClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/GenericRestClient.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/GenericRestClient.java
index 0d9b5a6..1a11f9a 100644
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/GenericRestClient.java
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/GenericRestClient.java
@@ -30,33 +30,33 @@ public interface GenericRestClient {
      *              This should be REST endpoint
      * @param jsonParamString
      *              The json string which should be executed from the post request
-     * @param userName
+     * @param username
      *              User name for basic auth
-     * @param passWord
+     * @param password
      *              Password for basic auth
      * @return The HttpResponse
      * @throws org.apache.http.client.ClientProtocolException and IOException
      *             if any errors occur when executing the request
      */
     public HttpResponse doPost(DefaultHttpClient httpClient, String resourcePath, String jsonParamString,
-                               String userName, String passWord) throws Exception;
+                               String username, String password) throws Exception;
 
     /**
      * Handle http get request. Return String
      *
      * @param resourcePath
      *              This should be REST endpoint
-     * @param userName
+     * @param username
      *              User name for basic auth
-     * @param passWord
+     * @param password
      *              Password for basic auth
      * @return The HttpResponse
      * @throws org.apache.http.client.ClientProtocolException and IOException
      *             if any errors occur when executing the request
      */
-    public HttpResponse doGet(DefaultHttpClient httpClient, String resourcePath, String userName, String passWord) throws Exception;
+    public HttpResponse doGet(DefaultHttpClient httpClient, String resourcePath, String username, String password) throws Exception;
 
-    public HttpResponse doDelete(DefaultHttpClient httpClient, String resourcePath, String userName, String passWord);
+    public HttpResponse doDelete(DefaultHttpClient httpClient, String resourcePath, String username, String password);
 
     public void doPut();
 }

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/770acad6/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 b83813d..30432fb 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
@@ -54,16 +54,16 @@ public class RestClient implements GenericRestClient{
      *              This should be REST endpoint
      * @param jsonParamString
      *              The json string which should be executed from the post request
-     * @param userName
+     * @param username
      *              User name for basic auth
-     * @param passWord
+     * @param password
      *              Password for basic auth
      * @return The HttpResponse
      * @throws org.apache.http.client.ClientProtocolException and IOException
      *             if any errors occur when executing the request
      */
-    public HttpResponse doPost(DefaultHttpClient httpClient, String resourcePath, String jsonParamString, String userName,
-                               String passWord) throws Exception{
+    public HttpResponse doPost(DefaultHttpClient httpClient, String resourcePath, String jsonParamString, String username,
+                               String password) throws Exception{
         try {
             HttpPost postRequest = new HttpPost(resourcePath);
 
@@ -71,7 +71,7 @@ public class RestClient implements GenericRestClient{
             input.setContentType("application/json");
             postRequest.setEntity(input);
 
-            String userPass = userName + ":" + passWord;
+            String userPass = username + ":" + password;
             String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userPass.getBytes("UTF-8"));
             postRequest.addHeader("Authorization", basicAuth);
 
@@ -102,20 +102,20 @@ public class RestClient implements GenericRestClient{
      *              This should be httpClient which used to connect to rest endpoint
      * @param resourcePath
      *              This should be REST endpoint
-     * @param userName
+     * @param username
      *              User name for basic auth
-     * @param passWord
+     * @param password
      *              Password for basic auth
      * @return The HttpResponse
      * @throws org.apache.http.client.ClientProtocolException and IOException
      *             if any errors occur when executing the request
      */
-    public HttpResponse doGet(DefaultHttpClient httpClient, String resourcePath, String userName, String passWord) throws Exception{
+    public HttpResponse doGet(DefaultHttpClient httpClient, String resourcePath, String username, String password) throws Exception{
         try {
             HttpGet getRequest = new HttpGet(resourcePath);
             getRequest.addHeader("Content-Type", "application/json");
 
-            String userPass = userName + ":" + passWord;
+            String userPass = username + ":" + password;
             String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userPass.getBytes("UTF-8"));
             getRequest.addHeader("Authorization", basicAuth);
 
@@ -138,12 +138,12 @@ public class RestClient implements GenericRestClient{
         }
     }
 
-    public HttpResponse doDelete(DefaultHttpClient httpClient, String resourcePath, String userName, String passWord) {
+    public HttpResponse doDelete(DefaultHttpClient httpClient, String resourcePath, String username, String password) {
         try {
             HttpDelete httpDelete = new HttpDelete(resourcePath);
             httpDelete.addHeader("Content-Type", "application/json");
 
-            String userPass = userName + ":" + passWord;
+            String userPass = username + ":" + password;
             String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userPass.getBytes("UTF-8"));
             httpDelete.addHeader("Authorization", basicAuth);
 

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/770acad6/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java
index 2a0a0a5..9d435d7 100644
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java
@@ -227,9 +227,9 @@ public class StratosApplication extends CommandLineApplication<StratosCommandCon
 	}
 
 	@Override
-	protected File getHistoryFile(String userName) {
+	protected File getHistoryFile(String username) {
 		File stratosFile = new File(System.getProperty("user.home"), STRATOS_DIR);
-		File historyFile = new File(stratosFile, STRATOS_HISTORY_DIR + "_" + userName);
+		File historyFile = new File(stratosFile, STRATOS_HISTORY_DIR + "_" + username);
 		return historyFile;
 	}
 
@@ -401,7 +401,7 @@ public class StratosApplication extends CommandLineApplication<StratosCommandCon
 
         // This is to create the history file.
         // This section execute only when user didn't enter the username as command line arguments
-        if (userName == null) {
+        if (username == null) {
             reader = null;
             reader = createConsoleReaderWhithoutArgs(usernameInput);
         }