You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ch...@apache.org on 2014/05/11 07:54:31 UTC
git commit: fixing https://issues.apache.org/jira/browse/STRATOS-649
Repository: incubator-stratos
Updated Branches:
refs/heads/master 4e602ca80 -> 6892d2103
fixing https://issues.apache.org/jira/browse/STRATOS-649
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/6892d210
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/6892d210
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/6892d210
Branch: refs/heads/master
Commit: 6892d210393c1bc3fbf9163ed1e8f22ca08e3482
Parents: 4e602ca
Author: Chris Snow <ch...@gmail.com>
Authored: Sun May 11 05:29:31 2014 +0000
Committer: Chris Snow <ch...@gmail.com>
Committed: Sun May 11 05:29:31 2014 +0000
----------------------------------------------------------------------
.../apache/stratos/cli/StratosApplication.java | 61 ++++++++++----------
1 file changed, 29 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/6892d210/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 8a888ee..e4bc0c0 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
@@ -468,17 +468,6 @@ public class StratosApplication extends CommandLineApplication<StratosCommandCon
username = System.getenv(CliConstants.STRATOS_USERNAME_ENV_PROPERTY);
password = System.getenv(CliConstants.STRATOS_PASSWORD_ENV_PROPERTY);
- int slashCount = StringUtils.countMatches(stratosURL, "/");
- int colonCount = StringUtils.countMatches(stratosURL, ":");
-
- if ( ! (colonCount == 2 && (slashCount == 3 || slashCount == 2))) {
- if (logger.isDebugEnabled()) {
- logger.debug("Invalid STRATOS_URL");
- }
-
- System.out.println("Invalid STRATOS_URL. Please enter correct STRATOS_URL");
- return false;
- }
if (StringUtils.isBlank(stratosURL)) {
if (logger.isDebugEnabled()) {
logger.debug("Required configuration not found.");
@@ -487,30 +476,38 @@ public class StratosApplication extends CommandLineApplication<StratosCommandCon
System.out.format("Could not find required \"%s\" variable in your environment.%n",
CliConstants.STRATOS_URL_ENV_PROPERTY);
return false;
- } else {
- if (logger.isDebugEnabled()) {
- logger.debug("Required configuration found. Validating {}", stratosURL);
- }
- UrlValidator urlValidator = new UrlValidator(new String[] { "https" },UrlValidator.ALLOW_LOCAL_URLS);
- if (!urlValidator.isValid(stratosURL)) {
- if (logger.isDebugEnabled()) {
- logger.debug("Stratos Controller URL {} is not valid", stratosURL);
- }
- System.out.format(
- "The \"%s\" variable in your environment is not a valid URL. You have provided \"%s\".%n"
- + "Please provide the Stratos Controller URL as follows%nhttps://<host>:<port>%n",
- CliConstants.STRATOS_URL_ENV_PROPERTY, stratosURL);
- return false;
- }
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Required configuration found. Validating {}", stratosURL);
+ }
+
+ int slashCount = StringUtils.countMatches(stratosURL, "/");
+ int colonCount = StringUtils.countMatches(stratosURL, ":");
+
+ UrlValidator urlValidator = new UrlValidator(new String[] { "https" },UrlValidator.ALLOW_LOCAL_URLS);
+
+ // port must be provided, so colonCount must be 2
+ // context path must not be provided, so slashCount must not be >3
+
+ if (!urlValidator.isValid(stratosURL) || colonCount != 2 || slashCount >3) {
if (logger.isDebugEnabled()) {
- logger.debug("Stratos Controller URL {} is valid.", stratosURL);
- logger.debug("Adding the values to context.");
+ logger.debug("Stratos Controller URL {} is not valid", stratosURL);
}
- context.put(CliConstants.STRATOS_URL_ENV_PROPERTY, stratosURL);
- context.put(CliConstants.STRATOS_USERNAME_ENV_PROPERTY, username);
- context.put(CliConstants.STRATOS_PASSWORD_ENV_PROPERTY, password);
- return true;
+ System.out.format(
+ "The \"%s\" variable in your environment is not a valid URL. You have provided \"%s\".%n"
+ + "Please provide the Stratos Controller URL as follows%nhttps://<host>:<port>%n",
+ CliConstants.STRATOS_URL_ENV_PROPERTY, stratosURL);
+ return false;
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("Stratos Controller URL {} is valid.", stratosURL);
+ logger.debug("Adding the values to context.");
}
+ context.put(CliConstants.STRATOS_URL_ENV_PROPERTY, stratosURL);
+ context.put(CliConstants.STRATOS_USERNAME_ENV_PROPERTY, username);
+ context.put(CliConstants.STRATOS_PASSWORD_ENV_PROPERTY, password);
+ return true;
}
private void setLoggerLevel(boolean trace, boolean debug) {