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 2013/07/05 12:32:52 UTC
[15/34] committing refactoered adc components and top level pom in
components
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ca25b1f7/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/StratosApplication.java
----------------------------------------------------------------------
diff --git a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/StratosApplication.java b/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/StratosApplication.java
deleted file mode 100644
index 4e6522b..0000000
--- a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/StratosApplication.java
+++ /dev/null
@@ -1,501 +0,0 @@
-/*
- * Copyright 2013, WSO2, Inc. http://wso2.org
- *
- * Licensed 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.wso2.carbon.adc.mgt.cli;
-
-import static org.wso2.carbon.adc.mgt.cli.utils.CliConstants.STRATOS_DIR;
-import static org.wso2.carbon.adc.mgt.cli.utils.CliConstants.STRATOS_HISTORY_DIR;
-
-import java.io.File;
-import java.io.PrintWriter;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.GnuParser;
-import org.apache.commons.cli.HelpFormatter;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.text.StrTokenizer;
-import org.apache.commons.validator.routines.UrlValidator;
-import org.apache.log4j.Level;
-import org.apache.log4j.LogManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.wso2.carbon.adc.mgt.cli.commands.AddDomainMappingCommand;
-import org.wso2.carbon.adc.mgt.cli.commands.CartridgesCommand;
-import org.wso2.carbon.adc.mgt.cli.commands.ExitCommand;
-import org.wso2.carbon.adc.mgt.cli.commands.HelpCommand;
-import org.wso2.carbon.adc.mgt.cli.commands.InfoCommand;
-import org.wso2.carbon.adc.mgt.cli.commands.ListCommand;
-import org.wso2.carbon.adc.mgt.cli.commands.PoliciesCommand;
-import org.wso2.carbon.adc.mgt.cli.commands.RemoveDomainMappingCommand;
-import org.wso2.carbon.adc.mgt.cli.commands.SubscribeCommand;
-import org.wso2.carbon.adc.mgt.cli.commands.SyncCommand;
-import org.wso2.carbon.adc.mgt.cli.commands.UnsubscribeCommand;
-import org.wso2.carbon.adc.mgt.cli.completer.CommandCompleter;
-import org.wso2.carbon.adc.mgt.cli.exception.CommandException;
-import org.wso2.carbon.adc.mgt.cli.utils.CliConstants;
-
-public class StratosApplication extends CommandLineApplication<StratosCommandContext> {
-
- private static final Logger logger = LoggerFactory.getLogger(StratosApplication.class);
-
- private final Map<String, Command<StratosCommandContext>> commands;
- private final StratosCommandContext context;
-
- private final Options options;
-
- public StratosApplication() {
- commands = new HashMap<String, Command<StratosCommandContext>>();
- context = new StratosCommandContext(this);
-
- options = constructOptions();
-
- createCommands();
- createAutocomplete();
- }
-
- /**
- * Construct Options.
- *
- * @return Options expected from command-line.
- */
- private Options constructOptions() {
- final Options options = new Options();
- Option usernameOption = new Option(CliConstants.USERNAME_OPTION, CliConstants.USERNAME_LONG_OPTION, true,
- "Username");
- usernameOption.setArgName("username");
- options.addOption(usernameOption);
-
- Option passwordOption = new Option(CliConstants.PASSWORD_OPTION, CliConstants.PASSWORD_LONG_OPTION, true,
- "Password");
- passwordOption.setArgName("password");
- passwordOption.setOptionalArg(true);
- options.addOption(passwordOption);
- options.addOption(CliConstants.HELP_OPTION, CliConstants.HELP_LONG_OPTION, false, "Display this help");
- options.addOption(CliConstants.TRACE_OPTION, false, "Enable trace logging");
- options.addOption(CliConstants.DEBUG_OPTION, false, "Enable debug logging");
- return options;
- }
-
- private void createCommands() {
- Command<StratosCommandContext> command = new HelpCommand();
- commands.put(command.getName(), command);
-
- command = new ExitCommand();
- commands.put(command.getName(), command);
-
- command = new SubscribeCommand();
- commands.put(command.getName(), command);
-
- command = new UnsubscribeCommand();
- commands.put(command.getName(), command);
-
- command = new CartridgesCommand();
- commands.put(command.getName(), command);
-
- command = new ListCommand();
- commands.put(command.getName(), command);
-
- command = new InfoCommand();
- commands.put(command.getName(), command);
-
- command = new AddDomainMappingCommand();
- commands.put(command.getName(), command);
-
- command = new RemoveDomainMappingCommand();
- commands.put(command.getName(), command);
-
- command = new SyncCommand();
- commands.put(command.getName(), command);
-
- command = new PoliciesCommand();
- commands.put(command.getName(), command);
-
- if (logger.isDebugEnabled()) {
- logger.debug("Created {} commands for the application. {}", commands.size(), commands.keySet());
- }
- }
-
- private void createAutocomplete() {
- reader.addCompleter(new CommandCompleter(commands));
- }
-
- @Override
- protected String getPrompt() {
- return CliConstants.STRATOS_SHELL_PROMPT;
- }
-
- @Override
- protected File getHistoryFile() {
- File stratosFile = new File(System.getProperty("user.home"), STRATOS_DIR);
- File historyFile = new File(stratosFile, STRATOS_HISTORY_DIR);
- return historyFile;
- }
-
- @Override
- public int run(String[] args) {
- boolean loaded = loadRequiredProperties();
- if (!loaded) {
- return CliConstants.ERROR_CODE;
- }
-
- // To get the command action from arguments
- String[] remainingArgs = null;
-
- // Command action
- String action = null;
-
- String usernameInput = null;
- String passwordInput = null;
-
- if (args != null && args.length > 0) {
- // Arguments are passed.
- if (logger.isDebugEnabled()) {
- logger.debug("Arguments:");
- for (String arg : args) {
- logger.debug(arg);
- }
- }
-
- final CommandLineParser parser = new GnuParser();
- CommandLine commandLine;
- try {
- // Must add all options. Otherwise actions cannot be performed directly by command line.
- Options allCommandOptions = new Options();
- for (Command<StratosCommandContext> command : commands.values()) {
- Options commandOptions = command.getOptions();
- if (commandOptions != null) {
- Collection<?> allOptions = commandOptions.getOptions();
- for (Object o : allOptions) {
- allCommandOptions.addOption((Option) o);
- }
- }
- }
- // Add options in this application
- Collection<?> allOptions = options.getOptions();
- for (Object o : allOptions) {
- allCommandOptions.addOption((Option) o);
- }
-
- commandLine = parser.parse(allCommandOptions, args);
- remainingArgs = commandLine.getArgs();
- if (remainingArgs != null && remainingArgs.length > 0) {
- // Get command action
- action = remainingArgs[0];
- }
-
- // Set logger levels from this point onwards
- setLoggerLevel(commandLine.hasOption(CliConstants.TRACE_OPTION),
- commandLine.hasOption(CliConstants.DEBUG_OPTION));
-
- if (commandLine.hasOption(CliConstants.USERNAME_OPTION)) {
- if (logger.isTraceEnabled()) {
- logger.trace("Username option is passed");
- }
- usernameInput = commandLine.getOptionValue(CliConstants.USERNAME_OPTION);
- }
- if (commandLine.hasOption(CliConstants.PASSWORD_OPTION)) {
- if (logger.isTraceEnabled()) {
- logger.trace("Password option is passed");
- }
- passwordInput = commandLine.getOptionValue(CliConstants.PASSWORD_OPTION);
- }
- if (commandLine.hasOption(CliConstants.HELP_ACTION)) {
- printHelp();
- return CliConstants.SUCCESSFUL_CODE;
- }
- } catch (ParseException e) {
- if (logger.isErrorEnabled()) {
- logger.error("Error parsing arguments when trying to login", e);
- }
- System.out.println(e.getMessage());
- return CliConstants.BAD_ARGS_CODE;
- }
-
- }
-
- if (StringUtils.isNotBlank(action)) {
- // User is executing an action
- if (logger.isDebugEnabled()) {
- logger.debug("Action: {}", action);
- }
- Command<StratosCommandContext> command = commands.get(action);
- if (command == null) {
- printHelp();
- return CliConstants.BAD_ARGS_CODE;
- }
-
- boolean loginRequired = !CliConstants.HELP_ACTION.equals(action);
-
- if (loginRequired && logger.isDebugEnabled()) {
- logger.debug("Trying to login...");
- }
-
- if (loginRequired && !login(usernameInput, passwordInput, false)) {
- if (logger.isDebugEnabled()) {
- logger.debug("Exiting from CLI. Login required but login might have failed: {}", action);
- }
- // Exit
- return CliConstants.ERROR_CODE;
- }
-
- try {
- String[] actionArgs = Arrays.copyOfRange(remainingArgs, 1, remainingArgs.length);
- if (logger.isDebugEnabled()) {
- logger.debug("Executing Action: {} {}", action, Arrays.asList(actionArgs));
- }
- int returnCode = command.execute(context, actionArgs);
- if (logger.isDebugEnabled()) {
- logger.debug("Exiting with error code {} after executing action {}", returnCode, action);
- }
- System.exit(returnCode);
- } catch (CommandException e) {
- if (logger.isErrorEnabled()) {
- logger.error("Error executing command: " + action, e);
- }
- return CliConstants.ERROR_CODE;
- }
- } else {
- if (login(usernameInput, passwordInput, true)) {
- System.out.println("Successfully Authenticated.");
- } else {
- // Exit
- return CliConstants.ERROR_CODE;
- }
-
- promptLoop();
- }
- return CliConstants.SUCCESSFUL_CODE;
- }
-
- private boolean login(String usernameInput, String passwordInput, boolean validateLogin) {
- // TODO Previous CLI version uses a keystore. Here we are not using it.
- // Check whether user has passed username and password
- if (StringUtils.isBlank(usernameInput) && StringUtils.isBlank(passwordInput)) {
- // User has not passed any arguments.
- // Try authenticating from the values found
- usernameInput = context.getString(CliConstants.STRATOS_USERNAME_ENV_PROPERTY);
- passwordInput = context.getString(CliConstants.STRATOS_PASSWORD_ENV_PROPERTY);
-
- if (logger.isDebugEnabled()) {
- if (StringUtils.isNotBlank(usernameInput) && StringUtils.isNotBlank(passwordInput)) {
- logger.debug("Found authentication details for {} from context", usernameInput);
- }
- }
-
- }
- // Get user input if not passed as args
- if (StringUtils.isBlank(usernameInput)) {
- usernameInput = getInput("Username");
- } else {
- System.out.format("Username: %s%n", usernameInput);
- }
- if (StringUtils.isBlank(passwordInput)) {
- passwordInput = getInput("Password", '*');
- }
-
- boolean success = false;
- String stratosURL = null;
- stratosURL = context.getString(CliConstants.STRATOS_URL_ENV_PROPERTY);
-
- try {
- success = CommandLineService.getInstance().login(stratosURL, usernameInput, passwordInput, validateLogin);
- } catch (Exception e) {
- if (logger.isErrorEnabled()) {
- logger.error("Error when trying to login", e);
- }
- }
- if (success) {
- if (logger.isDebugEnabled()) {
- logger.debug("Successfully Authenticated.");
- }
- } else {
- if (logger.isDebugEnabled()) {
- logger.debug("Authentication failed.");
- }
- }
- return success;
- }
-
- @Override
- protected int executeCommand(String line) {
- String[] tokens = new StrTokenizer(line).getTokenArray();
- String action = tokens[0];
- String[] actionArgs = Arrays.copyOfRange(tokens, 1, tokens.length);
- if (logger.isDebugEnabled()) {
- logger.debug("Executing command action: {}, Tokens: {}", action, tokens.length);
- }
- Command<StratosCommandContext> command = commands.get(action);
- if (command == null) {
- System.out.println(action + ": command not found.");
- return CliConstants.BAD_ARGS_CODE;
- }
- try {
- return command.execute(context, actionArgs);
- } catch (CommandException e) {
- if (logger.isErrorEnabled()) {
- logger.error("Error executing command: " + action, e);
- }
- return CliConstants.ERROR_CODE;
- }
- }
-
- /**
- * @return {@code true} if required properties are loaded
- */
- private boolean loadRequiredProperties() {
- if (logger.isDebugEnabled()) {
- logger.debug("Loading properties...");
- }
- // Load properties
- String stratosURL = null;
- String username = null;
- String password = null;
-
- stratosURL = System.getenv(CliConstants.STRATOS_URL_ENV_PROPERTY);
- username = System.getenv(CliConstants.STRATOS_USERNAME_ENV_PROPERTY);
- password = System.getenv(CliConstants.STRATOS_PASSWORD_ENV_PROPERTY);
-
- if (StringUtils.isBlank(stratosURL)) {
- if (logger.isDebugEnabled()) {
- logger.debug("Required configuration not found.");
- }
- // Stratos Controller details are not set.
- 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" });
- 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("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) {
- // We are using Log4j. So, get the logger and set log levels.
- org.apache.log4j.Logger logger = LogManager.getLogger(StratosApplication.class.getPackage().getName());
- if (logger != null && trace) {
- logger.setLevel(Level.TRACE);
- LogManager.getRootLogger().setLevel(Level.TRACE);
- } else if (logger != null && debug) {
- logger.setLevel(Level.DEBUG);
- LogManager.getRootLogger().setLevel(Level.DEBUG);
- }
- }
-
- public void printHelp(final String action) {
- Command<StratosCommandContext> command = commands.get(action);
- if (command == null) {
- System.out.println(action + ": command not found. Help not available.");
- return;
- }
- System.out.println(command.getDescription());
- Options options = command.getOptions();
- if (options != null) {
- if (StringUtils.isNotBlank(command.getArgumentSyntax())) {
- printHelp(command.getName() + " " + command.getArgumentSyntax(), options);
- } else {
- printHelp(command.getName(), options);
- }
- } else {
- // No options. Just print the usage.
- printUsage(command);
- }
- }
-
- public void printHelp() {
- printHelp(CliConstants.STRATOS_APPLICATION_NAME, options);
- System.out.println("\n\nAvailable Commands: ");
- for (String action : commands.keySet()) {
- Command<StratosCommandContext> command = commands.get(action);
- if (command != null) {
- System.out.format("%-25s %s%n", command.getName(), command.getDescription());
- }
- }
-
- System.out.println("\nFor help on a specific command type:\nhelp [command]");
- }
-
- /**
- * Print "help" with usage
- */
- private void printHelp(final String commandLineSyntax, final Options options) {
- final HelpFormatter helpFormatter = new HelpFormatter();
- helpFormatter.printHelp(commandLineSyntax, options, true);
- }
-
- public void printUsage(final String action) {
- Command<StratosCommandContext> command = commands.get(action);
- if (command == null) {
- return;
- }
- printUsage(command);
- }
-
- private void printUsage(Command<StratosCommandContext> command) {
- Options options = command.getOptions();
- if (options != null) {
- if (StringUtils.isNotBlank(command.getArgumentSyntax())) {
- printUsage(command.getName() + " " + command.getArgumentSyntax(), options);
- } else {
- printUsage(command.getName(), options);
- }
- } else {
- System.out.print("usage: ");
- if (StringUtils.isNotBlank(command.getArgumentSyntax())) {
- System.out.println(command.getName() + " " + command.getArgumentSyntax());
- } else {
- System.out.println(command.getName());
- }
- }
- }
-
- /**
- * Print "usage"
- */
- private void printUsage(final String commandLineSyntax, final Options options) {
- final PrintWriter writer = new PrintWriter(System.out);
- final HelpFormatter usageFormatter = new HelpFormatter();
- usageFormatter.printUsage(writer, 80, commandLineSyntax, options);
- writer.flush();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ca25b1f7/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/StratosCommandContext.java
----------------------------------------------------------------------
diff --git a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/StratosCommandContext.java b/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/StratosCommandContext.java
deleted file mode 100644
index 4ffb8e4..0000000
--- a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/StratosCommandContext.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright 2013, WSO2, Inc. http://wso2.org
- *
- * Licensed 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.wso2.carbon.adc.mgt.cli;
-
-public class StratosCommandContext extends CommandContext {
-
- public StratosCommandContext(StratosApplication application) {
- super(application);
- }
-
- public StratosApplication getStratosApplication() {
- return (StratosApplication) getApplication();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ca25b1f7/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/AddDomainMappingCommand.java
----------------------------------------------------------------------
diff --git a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/AddDomainMappingCommand.java b/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/AddDomainMappingCommand.java
deleted file mode 100644
index b6029e3..0000000
--- a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/AddDomainMappingCommand.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2013, WSO2, Inc. http://wso2.org
- *
- * Licensed 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.wso2.carbon.adc.mgt.cli.commands;
-
-import org.apache.commons.cli.Options;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.wso2.carbon.adc.mgt.cli.Command;
-import org.wso2.carbon.adc.mgt.cli.CommandLineService;
-import org.wso2.carbon.adc.mgt.cli.StratosCommandContext;
-import org.wso2.carbon.adc.mgt.cli.exception.CommandException;
-import org.wso2.carbon.adc.mgt.cli.utils.CliConstants;
-
-public class AddDomainMappingCommand implements Command<StratosCommandContext> {
-
- private static final Logger logger = LoggerFactory.getLogger(AddDomainMappingCommand.class);
-
- public AddDomainMappingCommand() {
- }
-
- @Override
- public String getName() {
- return CliConstants.ADD_DOMAIN_MAPPING_ACTION;
- }
-
- @Override
- public String getDescription() {
- return "Map domain for the subscribed cartridge";
- }
-
- @Override
- public String getArgumentSyntax() {
- return "[Cartridge alias] [Domain]";
- }
-
- @Override
- public int execute(StratosCommandContext context, String[] args) throws CommandException {
- if (logger.isDebugEnabled()) {
- logger.debug("Executing {} command...", getName());
- }
- if (args != null && args.length == 2) {
- String alias = args[0];
- String domain = args[1];
- if (logger.isDebugEnabled()) {
- logger.debug("Adding domain mapping {} for alias {}", domain, alias);
- }
-
- String domainToDisplay = null;
-
- domainToDisplay = CommandLineService.getInstance().addDomainMapping(domain, alias);
-
- if (StringUtils.isBlank(domainToDisplay)) {
- System.out.println("Error adding domain mapping.");
- return CliConstants.BAD_ARGS_CODE;
- } else {
- System.out.format("Your own domain is added. Please CNAME it to systems domain %s.%n", domainToDisplay);
- return CliConstants.SUCCESSFUL_CODE;
- }
- } else {
- context.getStratosApplication().printUsage(getName());
- return CliConstants.BAD_ARGS_CODE;
- }
- }
-
- @Override
- public Options getOptions() {
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ca25b1f7/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/CartridgesCommand.java
----------------------------------------------------------------------
diff --git a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/CartridgesCommand.java b/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/CartridgesCommand.java
deleted file mode 100644
index 07cc8ce..0000000
--- a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/CartridgesCommand.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2013, WSO2, Inc. http://wso2.org
- *
- * Licensed 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.wso2.carbon.adc.mgt.cli.commands;
-
-import org.apache.commons.cli.Options;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.wso2.carbon.adc.mgt.cli.Command;
-import org.wso2.carbon.adc.mgt.cli.CommandLineService;
-import org.wso2.carbon.adc.mgt.cli.StratosCommandContext;
-import org.wso2.carbon.adc.mgt.cli.exception.CommandException;
-import org.wso2.carbon.adc.mgt.cli.utils.CliConstants;
-
-public class CartridgesCommand implements Command<StratosCommandContext> {
-
- private static final Logger logger = LoggerFactory.getLogger(CartridgesCommand.class);
-
- public CartridgesCommand() {
- }
-
- @Override
- public String getName() {
- return CliConstants.CARTRIDGES_ACTION;
- }
-
- @Override
- public String getDescription() {
- return "List available cartridges";
- }
-
- @Override
- public String getArgumentSyntax() {
- 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 == 0) {
- CommandLineService.getInstance().listAvailableCartridges();
- return CliConstants.SUCCESSFUL_CODE;
- } else {
- context.getStratosApplication().printUsage(getName());
- return CliConstants.BAD_ARGS_CODE;
- }
- }
-
- @Override
- public Options getOptions() {
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ca25b1f7/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/ExitCommand.java
----------------------------------------------------------------------
diff --git a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/ExitCommand.java b/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/ExitCommand.java
deleted file mode 100644
index 8123eee..0000000
--- a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/ExitCommand.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2013, WSO2, Inc. http://wso2.org
- *
- * Licensed 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.wso2.carbon.adc.mgt.cli.commands;
-
-import org.apache.commons.cli.Options;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.wso2.carbon.adc.mgt.cli.Command;
-import org.wso2.carbon.adc.mgt.cli.StratosCommandContext;
-import org.wso2.carbon.adc.mgt.cli.exception.CommandException;
-import org.wso2.carbon.adc.mgt.cli.utils.CliConstants;
-
-public class ExitCommand implements Command<StratosCommandContext> {
-
- private static final Logger logger = LoggerFactory.getLogger(ExitCommand.class);
-
- public ExitCommand() {
- }
-
- @Override
- public String getName() {
- return CliConstants.EXIT_ACTION;
- }
-
- @Override
- public String getDescription() {
- return "Exit from Stratos Client Tool";
- }
-
- @Override
- public String getArgumentSyntax() {
- return null;
- }
-
- @Override
- public int execute(StratosCommandContext context, String[] args) throws CommandException {
- // Nothing to execute here. This is a special command.
- if (logger.isDebugEnabled()) {
- logger.debug("Executing {} command...", getName());
- }
- if (args == null || args.length == 0) {
- return CliConstants.SUCCESSFUL_CODE;
- } else {
- context.getStratosApplication().printUsage(getName());
- return CliConstants.BAD_ARGS_CODE;
- }
- }
-
- @Override
- public Options getOptions() {
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ca25b1f7/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/HelpCommand.java
----------------------------------------------------------------------
diff --git a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/HelpCommand.java b/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/HelpCommand.java
deleted file mode 100644
index 1afcf70..0000000
--- a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/HelpCommand.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2013, WSO2, Inc. http://wso2.org
- *
- * Licensed 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.wso2.carbon.adc.mgt.cli.commands;
-
-import org.apache.commons.cli.Options;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.wso2.carbon.adc.mgt.cli.Command;
-import org.wso2.carbon.adc.mgt.cli.StratosCommandContext;
-import org.wso2.carbon.adc.mgt.cli.exception.CommandException;
-import org.wso2.carbon.adc.mgt.cli.utils.CliConstants;
-
-public class HelpCommand implements Command<StratosCommandContext> {
-
- private static final Logger logger = LoggerFactory.getLogger(HelpCommand.class);
-
- public HelpCommand() {
- }
-
- @Override
- public String getName() {
- return CliConstants.HELP_ACTION;
- }
-
- @Override
- public String getDescription() {
- return "Help for commands";
- }
-
- @Override
- public String getArgumentSyntax() {
- return "[command]";
- }
-
- @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().printHelp();
- return CliConstants.SUCCESSFUL_CODE;
- } else if (args != null && args.length == 1) {
- context.getStratosApplication().printHelp(args[0]);
- return CliConstants.SUCCESSFUL_CODE;
- } else {
- context.getStratosApplication().printUsage(getName());
- return CliConstants.BAD_ARGS_CODE;
- }
- }
-
- @Override
- public Options getOptions() {
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ca25b1f7/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/InfoCommand.java
----------------------------------------------------------------------
diff --git a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/InfoCommand.java b/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/InfoCommand.java
deleted file mode 100644
index a596f16..0000000
--- a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/InfoCommand.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2013, WSO2, Inc. http://wso2.org
- *
- * Licensed 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.wso2.carbon.adc.mgt.cli.commands;
-
-import org.apache.commons.cli.Options;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.wso2.carbon.adc.mgt.cli.Command;
-import org.wso2.carbon.adc.mgt.cli.CommandLineService;
-import org.wso2.carbon.adc.mgt.cli.StratosCommandContext;
-import org.wso2.carbon.adc.mgt.cli.exception.CommandException;
-import org.wso2.carbon.adc.mgt.cli.utils.CliConstants;
-
-public class InfoCommand implements Command<StratosCommandContext> {
-
- private static final Logger logger = LoggerFactory.getLogger(InfoCommand.class);
-
- public InfoCommand() {
- }
-
- @Override
- public String getName() {
- return CliConstants.INFO_ACTION;
- }
-
- @Override
- public String getDescription() {
- return "Get information about a subscribed cartridge";
- }
-
- @Override
- public String getArgumentSyntax() {
- return "[Cartridge alias]";
- }
-
- @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 alias = args[0];
- if (logger.isDebugEnabled()) {
- logger.debug("Getting info {}", alias);
- }
- CommandLineService.getInstance().info(alias);
- return CliConstants.SUCCESSFUL_CODE;
- } else {
- context.getStratosApplication().printUsage(getName());
- return CliConstants.BAD_ARGS_CODE;
- }
- }
-
- @Override
- public Options getOptions() {
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ca25b1f7/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/ListCommand.java
----------------------------------------------------------------------
diff --git a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/ListCommand.java b/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/ListCommand.java
deleted file mode 100644
index 4227107..0000000
--- a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/ListCommand.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright 2013, WSO2, Inc. http://wso2.org
- *
- * Licensed 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.wso2.carbon.adc.mgt.cli.commands;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.GnuParser;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.wso2.carbon.adc.mgt.cli.Command;
-import org.wso2.carbon.adc.mgt.cli.CommandLineService;
-import org.wso2.carbon.adc.mgt.cli.StratosCommandContext;
-import org.wso2.carbon.adc.mgt.cli.exception.CommandException;
-import org.wso2.carbon.adc.mgt.cli.utils.CliConstants;
-
-public class ListCommand implements Command<StratosCommandContext> {
-
- private static final Logger logger = LoggerFactory.getLogger(ListCommand.class);
-
- private final Options options;
-
- public ListCommand() {
- options = constructOptions();
- }
-
- /**
- * Construct Options.
- *
- * @return Options expected from command-line.
- */
- private Options constructOptions() {
- final Options options = new Options();
- Option fullOption = new Option(CliConstants.FULL_OPTION, CliConstants.FULL_LONG_OPTION, false,
- "Display extra details");
- options.addOption(fullOption);
- return options;
- }
-
- @Override
- public String getName() {
- return CliConstants.LIST_ACTION;
- }
-
- @Override
- public String getDescription() {
- return "List subscribed cartridges with details";
- }
-
- @Override
- public String getArgumentSyntax() {
- 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 == 0) {
- CommandLineService.getInstance().listSubscribedCartridges(false);
- return CliConstants.SUCCESSFUL_CODE;
- } else if (args != null && args.length > 0) {
- String[] remainingArgs = null;
- boolean full = false;
- final CommandLineParser parser = new GnuParser();
- CommandLine commandLine;
- try {
- commandLine = parser.parse(options, args);
- remainingArgs = commandLine.getArgs();
- if (!(remainingArgs == null || remainingArgs.length == 0)) {
- context.getStratosApplication().printUsage(getName());
- return CliConstants.BAD_ARGS_CODE;
- }
-
- if (commandLine.hasOption(CliConstants.FULL_OPTION)) {
- if (logger.isTraceEnabled()) {
- logger.trace("Full option is passed");
- }
- full = true;
- }
- if (logger.isDebugEnabled()) {
- logger.debug("Listing subscribed cartridges, Full Option: {}", full);
- }
- CommandLineService.getInstance().listSubscribedCartridges(full);
- return CliConstants.SUCCESSFUL_CODE;
- } catch (ParseException e) {
- if (logger.isErrorEnabled()) {
- logger.error("Error parsing arguments", e);
- }
- System.out.println(e.getMessage());
- return CliConstants.BAD_ARGS_CODE;
- }
- } else {
- context.getStratosApplication().printUsage(getName());
- return CliConstants.BAD_ARGS_CODE;
- }
- }
-
- @Override
- public Options getOptions() {
- return options;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ca25b1f7/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/PoliciesCommand.java
----------------------------------------------------------------------
diff --git a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/PoliciesCommand.java b/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/PoliciesCommand.java
deleted file mode 100644
index 0c67066..0000000
--- a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/PoliciesCommand.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2013, WSO2, Inc. http://wso2.org
- *
- * Licensed 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.wso2.carbon.adc.mgt.cli.commands;
-
-import org.apache.commons.cli.Options;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.wso2.carbon.adc.mgt.cli.Command;
-import org.wso2.carbon.adc.mgt.cli.CommandLineService;
-import org.wso2.carbon.adc.mgt.cli.StratosCommandContext;
-import org.wso2.carbon.adc.mgt.cli.exception.CommandException;
-import org.wso2.carbon.adc.mgt.cli.utils.CliConstants;
-
-public class PoliciesCommand implements Command<StratosCommandContext> {
-
- private static final Logger logger = LoggerFactory.getLogger(PoliciesCommand.class);
-
- public PoliciesCommand() {
- }
-
- @Override
- public String getName() {
- return CliConstants.POLICIES_ACTION;
- }
-
- @Override
- public String getDescription() {
- return "List available policies";
- }
-
- @Override
- public String getArgumentSyntax() {
- 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 == 0) {
- CommandLineService.getInstance().listAvailablePolicies();
- return CliConstants.SUCCESSFUL_CODE;
- } else {
- context.getStratosApplication().printUsage(getName());
- return CliConstants.BAD_ARGS_CODE;
- }
- }
-
- @Override
- public Options getOptions() {
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ca25b1f7/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/RemoveDomainMappingCommand.java
----------------------------------------------------------------------
diff --git a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/RemoveDomainMappingCommand.java b/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/RemoveDomainMappingCommand.java
deleted file mode 100644
index c394421..0000000
--- a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/RemoveDomainMappingCommand.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2013, WSO2, Inc. http://wso2.org
- *
- * Licensed 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.wso2.carbon.adc.mgt.cli.commands;
-
-import org.apache.commons.cli.Options;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.wso2.carbon.adc.mgt.cli.Command;
-import org.wso2.carbon.adc.mgt.cli.CommandLineService;
-import org.wso2.carbon.adc.mgt.cli.StratosCommandContext;
-import org.wso2.carbon.adc.mgt.cli.exception.CommandException;
-import org.wso2.carbon.adc.mgt.cli.utils.CliConstants;
-
-public class RemoveDomainMappingCommand implements Command<StratosCommandContext> {
-
- private static final Logger logger = LoggerFactory.getLogger(RemoveDomainMappingCommand.class);
-
- public RemoveDomainMappingCommand() {
- }
-
- @Override
- public String getName() {
- return CliConstants.REMOVE_DOMAIN_MAPPING_ACTION;
- }
-
- @Override
- public String getDescription() {
- return "Remove domain mapping for the subscribed cartridge";
- }
-
- @Override
- public String getArgumentSyntax() {
- return "[Cartridge alias]";
- }
-
- @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 alias = args[0];
- if (logger.isDebugEnabled()) {
- logger.debug("Removing domain mapping for {}", alias);
- }
- CommandLineService.getInstance().removeDomainMapping(alias);
- return CliConstants.SUCCESSFUL_CODE;
- } else {
- context.getStratosApplication().printUsage(getName());
- return CliConstants.BAD_ARGS_CODE;
- }
- }
-
- @Override
- public Options getOptions() {
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ca25b1f7/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/SubscribeCommand.java
----------------------------------------------------------------------
diff --git a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/SubscribeCommand.java b/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/SubscribeCommand.java
deleted file mode 100644
index be49e2a..0000000
--- a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/SubscribeCommand.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Copyright 2013, WSO2, Inc. http://wso2.org
- *
- * Licensed 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.wso2.carbon.adc.mgt.cli.commands;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.GnuParser;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.wso2.carbon.adc.mgt.cli.Command;
-import org.wso2.carbon.adc.mgt.cli.CommandLineService;
-import org.wso2.carbon.adc.mgt.cli.StratosCommandContext;
-import org.wso2.carbon.adc.mgt.cli.exception.CommandException;
-import org.wso2.carbon.adc.mgt.cli.utils.CliConstants;
-
-public class SubscribeCommand implements Command<StratosCommandContext> {
-
- private static final Logger logger = LoggerFactory.getLogger(ListCommand.class);
-
- private final Options options;;
-
- public SubscribeCommand() {
- options = constructOptions();
- }
-
- /**
- * Construct Options.
- *
- * @return Options expected from command-line.
- */
- private Options constructOptions() {
- final Options options = new Options();
- Option policyOption = new Option(CliConstants.POLICY_OPTION, CliConstants.POLICY_LONG_OPTION, true,
- "Auto-scaling policy.\nPlease use \"" + CliConstants.POLICIES_ACTION
- + "\" command to view the available policies.");
- policyOption.setArgName("policy name");
- options.addOption(policyOption);
-
- Option connectOption = new Option(CliConstants.CONNECT_OPTION, CliConstants.CONNECT_LONG_OPTION, true,
- "Data cartridge type");
- connectOption.setArgName("data cartridge type");
- options.addOption(connectOption);
-
- Option aliasOption = new Option(CliConstants.DATA_ALIAS_OPTION, CliConstants.DATA_ALIAS_LONG_OPTION, true,
- "Data cartridge alias");
- aliasOption.setArgName("alias");
- options.addOption(aliasOption);
-
- Option urlOption = new Option(CliConstants.REPO_URL_OPTION, CliConstants.REPO_URL_LONG_OPTION, true,
- "GIT repository URL");
- urlOption.setArgName("url");
- options.addOption(urlOption);
-
- options.addOption(CliConstants.PRIVATE_REPO_OPTION, CliConstants.PRIVATE_REPO_LONG_OPTION, false,
- "Private repository");
-
- Option usernameOption = new Option(CliConstants.USERNAME_OPTION, CliConstants.USERNAME_LONG_OPTION, true,
- "GIT repository username");
- usernameOption.setArgName("username");
- options.addOption(usernameOption);
-
- Option passwordOption = new Option(CliConstants.PASSWORD_OPTION, CliConstants.PASSWORD_LONG_OPTION, true,
- "GIT repository password");
- passwordOption.setArgName("password");
- passwordOption.setOptionalArg(true);
- options.addOption(passwordOption);
- return options;
- }
-
- @Override
- public String getName() {
- return CliConstants.SUBSCRIBE_ACTION;
- }
-
- @Override
- public String getDescription() {
- return "Subscribe to a cartridge";
- }
-
- @Override
- public String getArgumentSyntax() {
- return "[Cartridge type] [Cartridge alias]";
- }
-
- @Override
- public int execute(StratosCommandContext context, String[] args) throws CommandException {
- if (logger.isDebugEnabled()) {
- logger.debug("Executing {} command...", getName());
- }
- if (args != null && args.length > 0) {
- String[] remainingArgs = null;
- String type = null;
- String alias = null;
- String policy = null;
- String repoURL = null, dataCartridgeType = null, dataCartridgeAlias = null, username = "", password = "";
- boolean privateRepo = false;
- final CommandLineParser parser = new GnuParser();
- CommandLine commandLine;
- try {
- commandLine = parser.parse(options, args);
- remainingArgs = commandLine.getArgs();
- if (remainingArgs != null && remainingArgs.length == 2) {
- // Get type
- type = remainingArgs[0];
- alias = remainingArgs[1];
- } else {
- context.getStratosApplication().printUsage(getName());
- return CliConstants.BAD_ARGS_CODE;
- }
-
- if (logger.isDebugEnabled()) {
- logger.debug("Subscribing to {} cartridge with alias {}", type, alias);
- }
-
- if (commandLine.hasOption(CliConstants.POLICY_OPTION)) {
- if (logger.isTraceEnabled()) {
- logger.trace("Policy option is passed");
- }
- policy = commandLine.getOptionValue(CliConstants.POLICY_OPTION);
- }
- if (commandLine.hasOption(CliConstants.REPO_URL_OPTION)) {
- if (logger.isTraceEnabled()) {
- logger.trace("RepoURL option is passed");
- }
- repoURL = commandLine.getOptionValue(CliConstants.REPO_URL_OPTION);
- }
- if (commandLine.hasOption(CliConstants.PRIVATE_REPO_OPTION)) {
- if (logger.isTraceEnabled()) {
- logger.trace("privateRepo option is passed");
- }
- privateRepo = true;
- }
- if (commandLine.hasOption(CliConstants.USERNAME_OPTION)) {
- if (logger.isTraceEnabled()) {
- logger.trace("Username option is passed");
- }
- username = commandLine.getOptionValue(CliConstants.USERNAME_OPTION);
- }
- if (commandLine.hasOption(CliConstants.PASSWORD_OPTION)) {
- if (logger.isTraceEnabled()) {
- logger.trace("Password option is passed");
- }
- password = commandLine.getOptionValue(CliConstants.PASSWORD_OPTION);
- }
- if (commandLine.hasOption(CliConstants.CONNECT_OPTION)) {
- if (logger.isTraceEnabled()) {
- logger.trace("Connect option is passed");
- }
- dataCartridgeType = commandLine.getOptionValue(CliConstants.CONNECT_OPTION);
- }
- if (commandLine.hasOption(CliConstants.DATA_ALIAS_OPTION)) {
- if (logger.isTraceEnabled()) {
- logger.trace("Data alias option is passed");
- }
- dataCartridgeAlias = commandLine.getOptionValue(CliConstants.DATA_ALIAS_OPTION);
- }
-
- if (StringUtils.isNotBlank(username) && StringUtils.isBlank(password)) {
- password = context.getApplication().getInput("GIT Repository Password", '*');
- }
-
- if (StringUtils.isNotBlank(dataCartridgeType) && !StringUtils.isNotBlank(dataCartridgeAlias)) {
- System.out.println("Data cartridge alias is required.");
- context.getStratosApplication().printUsage(getName());
- return CliConstants.BAD_ARGS_CODE;
- }
- CommandLineService.getInstance().subscribe(type, alias, policy, repoURL, privateRepo, username,
- password, dataCartridgeType, dataCartridgeAlias);
- return CliConstants.SUCCESSFUL_CODE;
- } catch (ParseException e) {
- if (logger.isErrorEnabled()) {
- logger.error("Error parsing arguments", e);
- }
- System.out.println(e.getMessage());
- return CliConstants.BAD_ARGS_CODE;
- }
- } else {
- context.getStratosApplication().printUsage(getName());
- return CliConstants.BAD_ARGS_CODE;
- }
- }
-
- @Override
- public Options getOptions() {
- return options;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ca25b1f7/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/SyncCommand.java
----------------------------------------------------------------------
diff --git a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/SyncCommand.java b/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/SyncCommand.java
deleted file mode 100644
index f8e8518..0000000
--- a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/SyncCommand.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2013, WSO2, Inc. http://wso2.org
- *
- * Licensed 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.wso2.carbon.adc.mgt.cli.commands;
-
-import org.apache.commons.cli.Options;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.wso2.carbon.adc.mgt.cli.Command;
-import org.wso2.carbon.adc.mgt.cli.CommandLineService;
-import org.wso2.carbon.adc.mgt.cli.StratosCommandContext;
-import org.wso2.carbon.adc.mgt.cli.exception.CommandException;
-import org.wso2.carbon.adc.mgt.cli.utils.CliConstants;
-
-public class SyncCommand implements Command<StratosCommandContext> {
-
- private static final Logger logger = LoggerFactory.getLogger(SyncCommand.class);
-
- public SyncCommand() {
- }
-
- @Override
- public String getName() {
- return CliConstants.SYNC_ACTION;
- }
-
- @Override
- public String getDescription() {
- return "Synchronize GIT repository for the subscribed cartridge";
- }
-
- @Override
- public String getArgumentSyntax() {
- return "[Cartridge alias]";
- }
-
- @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 alias = args[0];
- if (logger.isDebugEnabled()) {
- logger.debug("Synchronizing repository for alias {}", alias);
- }
-
- CommandLineService.getInstance().sync(alias);
- return CliConstants.SUCCESSFUL_CODE;
- } else {
- context.getStratosApplication().printUsage(getName());
- return CliConstants.BAD_ARGS_CODE;
- }
- }
-
- @Override
- public Options getOptions() {
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ca25b1f7/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/UnsubscribeCommand.java
----------------------------------------------------------------------
diff --git a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/UnsubscribeCommand.java b/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/UnsubscribeCommand.java
deleted file mode 100644
index 80e53f2..0000000
--- a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/commands/UnsubscribeCommand.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright 2013, WSO2, Inc. http://wso2.org
- *
- * Licensed 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.wso2.carbon.adc.mgt.cli.commands;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.GnuParser;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.wso2.carbon.adc.mgt.cli.Command;
-import org.wso2.carbon.adc.mgt.cli.CommandLineService;
-import org.wso2.carbon.adc.mgt.cli.StratosCommandContext;
-import org.wso2.carbon.adc.mgt.cli.exception.CommandException;
-import org.wso2.carbon.adc.mgt.cli.utils.CliConstants;
-
-public class UnsubscribeCommand implements Command<StratosCommandContext> {
-
- private static final Logger logger = LoggerFactory.getLogger(UnsubscribeCommand.class);
-
- private final Options options;;
-
- public UnsubscribeCommand() {
- options = constructOptions();
- }
-
- /**
- * Construct Options.
- *
- * @return Options expected from command-line.
- */
- private Options constructOptions() {
- final Options options = new Options();
- Option forceOption = new Option(CliConstants.FORCE_OPTION, CliConstants.FORCE_LONG_OPTION, false,
- "Never prompt for confirmation");
- options.addOption(forceOption);
- return options;
- }
-
- @Override
- public String getName() {
- return CliConstants.UNSUBSCRIBE_ACTION;
- }
-
- @Override
- public String getDescription() {
- return "Unsubscribe from a subscribed cartridge";
- }
-
- @Override
- public String getArgumentSyntax() {
- return "[Cartridge alias]";
- }
-
- @Override
- public int execute(StratosCommandContext context, String[] args) throws CommandException {
- if (logger.isDebugEnabled()) {
- logger.debug("Executing {} command...", getName());
- }
- if (args != null && args.length > 0) {
- String[] remainingArgs = null;
- String alias = null;
- boolean force = false;
- final CommandLineParser parser = new GnuParser();
- CommandLine commandLine;
- try {
- commandLine = parser.parse(options, args);
- remainingArgs = commandLine.getArgs();
- if (remainingArgs != null && remainingArgs.length == 1) {
- // Get alias
- alias = remainingArgs[0];
- } else {
- if (logger.isDebugEnabled()) {
- logger.debug("Unsubscribe: not enough arguments");
- }
- context.getStratosApplication().printUsage(getName());
- return CliConstants.BAD_ARGS_CODE;
- }
-
- if (commandLine.hasOption(CliConstants.FORCE_OPTION)) {
- if (logger.isTraceEnabled()) {
- logger.trace("Force option is passed");
- }
- force = true;
- }
- if (logger.isDebugEnabled()) {
- logger.debug("Unsubscribing {}, Force Option: {}", alias, force);
- }
- if (force || context.getApplication().getConfirmation("Are you sure you want to unsubscribe?")) {
- System.out.format("Unsubscribing the cartridge %s%n", alias);
- CommandLineService.getInstance().unsubscribe(alias);
- }
- return CliConstants.SUCCESSFUL_CODE;
- } catch (ParseException e) {
- if (logger.isErrorEnabled()) {
- logger.error("Error parsing arguments", e);
- }
- System.out.println(e.getMessage());
- return CliConstants.BAD_ARGS_CODE;
- }
- } else {
- context.getStratosApplication().printUsage(getName());
- return CliConstants.BAD_ARGS_CODE;
- }
- }
-
- @Override
- public Options getOptions() {
- return options;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ca25b1f7/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/completer/CommandCompleter.java
----------------------------------------------------------------------
diff --git a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/completer/CommandCompleter.java b/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/completer/CommandCompleter.java
deleted file mode 100644
index 7344dd3..0000000
--- a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/completer/CommandCompleter.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2013, WSO2, Inc. http://wso2.org
- *
- * Licensed 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.wso2.carbon.adc.mgt.cli.completer;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import jline.console.completer.ArgumentCompleter;
-import jline.console.completer.Completer;
-import jline.console.completer.StringsCompleter;
-
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.text.StrTokenizer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.wso2.carbon.adc.mgt.cli.Command;
-import org.wso2.carbon.adc.mgt.cli.StratosApplication;
-import org.wso2.carbon.adc.mgt.cli.StratosCommandContext;
-import org.wso2.carbon.adc.mgt.cli.utils.CliConstants;
-
-public class CommandCompleter implements Completer {
-
- private static final Logger logger = LoggerFactory.getLogger(StratosApplication.class);
-
- /**
- * Keep arguments for each command
- */
- private final Map<String, Collection<String>> argumentMap;
-
- private final Completer helpCommandCompleter;
-
- private final Completer defaultCommandCompleter;
-
- public CommandCompleter(Map<String, Command<StratosCommandContext>> commands) {
- if (logger.isDebugEnabled()) {
- logger.debug("Creating auto complete for {} commands", commands.size());
- }
- argumentMap = new HashMap<String, Collection<String>>();
- defaultCommandCompleter = new StringsCompleter(commands.keySet());
- helpCommandCompleter = new ArgumentCompleter(new StringsCompleter(CliConstants.HELP_ACTION),
- defaultCommandCompleter);
- for (String action : commands.keySet()) {
- Command<StratosCommandContext> command = commands.get(action);
- Options commandOptions = command.getOptions();
- if (commandOptions != null) {
- if (logger.isDebugEnabled()) {
- logger.debug("Creating argument completer for command: {}", action);
- }
- List<String> arguments = new ArrayList<String>();
- Collection<?> allOptions = commandOptions.getOptions();
- for (Object o : allOptions) {
- Option option = (Option) o;
- String longOpt = option.getLongOpt();
- String opt = option.getOpt();
- if (StringUtils.isNotBlank(longOpt)) {
- arguments.add("--" + longOpt);
- } else if (StringUtils.isNotBlank(opt)) {
- arguments.add("-" + opt);
- }
- }
-
- argumentMap.put(action, arguments);
- }
- }
- }
-
- @Override
- public int complete(String buffer, int cursor, List<CharSequence> candidates) {
- if (logger.isTraceEnabled()) {
- logger.trace("Buffer: {}, cursor: {}", buffer, cursor);
- logger.trace("Candidates {}", candidates);
- }
- if (StringUtils.isNotBlank(buffer)) {
- // User is typing a command
- StrTokenizer strTokenizer = new StrTokenizer(buffer);
- String action = strTokenizer.next();
- Collection<String> arguments = argumentMap.get(action);
- if (arguments != null) {
- if (logger.isTraceEnabled()) {
- logger.trace("Arguments found for {}, Tokens: {}", action, strTokenizer.getTokenList());
- logger.trace("Arguments for {}: {}", action, arguments);
- }
- List<String> args = new ArrayList<String>(arguments);
- List<Completer> completers = new ArrayList<Completer>();
- for (String token : strTokenizer.getTokenList()) {
- boolean argContains = arguments.contains(token);
- if (token.startsWith("-") && !argContains) {
- continue;
- }
- if (argContains) {
- if (logger.isTraceEnabled()) {
- logger.trace("Removing argument {}", token);
- }
- args.remove(token);
- }
- completers.add(new StringsCompleter(token));
- }
- completers.add(new StringsCompleter(args));
- Completer completer = new ArgumentCompleter(completers);
- return completer.complete(buffer, cursor, candidates);
- } else if (CliConstants.HELP_ACTION.equals(action)) {
- // For help action, we need to display available commands as arguments
- return helpCommandCompleter.complete(buffer, cursor, candidates);
- }
- }
- if (logger.isTraceEnabled()) {
- logger.trace("Using Default Completer...");
- }
- return defaultCommandCompleter.complete(buffer, cursor, candidates);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ca25b1f7/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/exception/CommandException.java
----------------------------------------------------------------------
diff --git a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/exception/CommandException.java b/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/exception/CommandException.java
deleted file mode 100644
index 691bbd1..0000000
--- a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/exception/CommandException.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2013, WSO2, Inc. http://wso2.org
- *
- * Licensed 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.wso2.carbon.adc.mgt.cli.exception;
-
-public class CommandException extends Exception {
-
- private static final long serialVersionUID = 1L;
-
- public CommandException() {
- }
-
- public CommandException(String message) {
- super(message);
- }
-
- public CommandException(Throwable cause) {
- super(cause);
- }
-
- public CommandException(String message, Throwable cause) {
- super(message, cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ca25b1f7/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/utils/CliConstants.java
----------------------------------------------------------------------
diff --git a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/utils/CliConstants.java b/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/utils/CliConstants.java
deleted file mode 100644
index b2818f6..0000000
--- a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/utils/CliConstants.java
+++ /dev/null
@@ -1,111 +0,0 @@
-package org.wso2.carbon.adc.mgt.cli.utils;
-
-/**
- * Constants for CLI Tool
- */
-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 SUCCESSFUL_CODE = 0;
- public static final int BAD_ARGS_CODE = 1;
- public static final int ERROR_CODE = 2;
-
-
- /**
- * The Directory for storing configuration
- */
- public static final String STRATOS_DIR = ".stratos";
- public static final String STRATOS_HISTORY_DIR = ".history";
-
- public static final String HELP_ACTION = "help";
-
- /**
- * Subscribe to a cartridge.
- */
- public static final String SUBSCRIBE_ACTION = "subscribe";
-
- public static final String UNSUBSCRIBE_ACTION = "unsubscribe";
-
- /**
- * List the subscribed cartridges
- */
- public static final String LIST_ACTION = "list";
-
- /**
- * List the available cartridges
- */
- public static final String CARTRIDGES_ACTION = "cartridges";
-
- /**
- * Give information of a cartridge.
- */
- public static final String INFO_ACTION = "info";
-
- /**
- * Synchronize repository
- */
- public static final String SYNC_ACTION = "sync";
-
- /**
- * Domain mapping
- */
- public static final String ADD_DOMAIN_MAPPING_ACTION = "add-domain-mapping";
- /**
- * Remove Domain mapping
- */
- public static final String REMOVE_DOMAIN_MAPPING_ACTION = "remove-domain-mapping";
-
- /**
- * List the available policies
- */
- public static final String POLICIES_ACTION = "policies";
-
- /**
- * Exit action
- */
- public static final String EXIT_ACTION = "exit";
-
- public static final String REPO_URL_OPTION = "r";
- public static final String REPO_URL_LONG_OPTION = "repoURL";
-
- public static final String PRIVATE_REPO_OPTION = "i";
- public static final String PRIVATE_REPO_LONG_OPTION = "privateRepo";
-
- public static final String USERNAME_OPTION = "u";
- public static final String USERNAME_LONG_OPTION = "username";
-
- public static final String PASSWORD_OPTION = "p";
- public static final String PASSWORD_LONG_OPTION = "password";
-
- public static final String HELP_OPTION = "h";
- public static final String HELP_LONG_OPTION = "help";
-
- public static final String POLICY_OPTION = "o";
- public static final String POLICY_LONG_OPTION = "policy";
-
- public static final String CONNECT_OPTION = "c";
- public static final String CONNECT_LONG_OPTION = "connect";
-
- public static final String DATA_ALIAS_OPTION = "d";
- public static final String DATA_ALIAS_LONG_OPTION = "data-alias";
-
- public static final String FULL_OPTION = "f";
- public static final String FULL_LONG_OPTION = "full";
-
- public static final String FORCE_OPTION = "f";
- public static final String FORCE_LONG_OPTION = "force";
-
- public static final String TRACE_OPTION = "trace";
-
- public static final String DEBUG_OPTION = "debug";
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ca25b1f7/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/utils/CliMessages.java
----------------------------------------------------------------------
diff --git a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/utils/CliMessages.java b/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/utils/CliMessages.java
deleted file mode 100644
index e69de29..0000000
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ca25b1f7/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/utils/CommandLineUtils.java
----------------------------------------------------------------------
diff --git a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/utils/CommandLineUtils.java b/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/utils/CommandLineUtils.java
deleted file mode 100644
index 9ef34fe..0000000
--- a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/utils/CommandLineUtils.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright 2013, WSO2, Inc. http://wso2.org
- *
- * Licensed 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.wso2.carbon.adc.mgt.cli.utils;
-
-import java.text.MessageFormat;
-import java.util.ResourceBundle;
-
-public class CommandLineUtils {
-
- private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("Resources");
-
- public static <T> void printTable(T[] data, RowMapper<T> mapper, String... headers) {
- if (data == null) {
- return;
- }
- // The maximum number of columns
- // All data String[] length must be equal to this
- int columns = headers.length;
- int rows = data.length + 1;
-
- String[][] table = new String[rows][columns];
- table[0] = headers;
-
- for (int i = 0; i < data.length; i++) {
- T t = data[i];
- table[i + 1] = mapper.getData(t);
- }
-
- // Find the maximum length of a string in each column
- int[] lengths = new int[columns];
- for (int i = 0; i < table.length; i++) {
- for (int j = 0; j < table[i].length; j++) {
- lengths[j] = Math.max(table[i][j].length(), lengths[j]);
- }
- }
-
- // The border rows
- String borders[] = new String[lengths.length];
- // Generate a format string for each column
- String[] formats = new String[lengths.length];
- for (int i = 0; i < lengths.length; i++) {
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.append("+");
- for (int j = 0; j < lengths[i] + 2; j++) {
- stringBuilder.append("-");
- }
- boolean finalColumn = (i + 1 == lengths.length);
- if (finalColumn) {
- stringBuilder.append("+\n");
- }
- borders[i] = stringBuilder.toString();
- formats[i] = "| %1$-" + lengths[i] + "s " + (finalColumn ? "|\n" : "");
- }
-
- // Print the table
- for (int i = 0; i < table.length; i++) {
- for (int j = 0; j < table[i].length; j++) {
- System.out.print(borders[j]);
- }
- for (int j = 0; j < table[i].length; j++) {
- System.out.format(formats[j], table[i][j]);
- }
- if (i + 1 == table.length) {
- for (int j = 0; j < table[i].length; j++) {
- System.out.print(borders[j]);
- }
- }
- }
- }
-
- public static String getMessage(String key, Object... args) {
- String message = BUNDLE.getString(key);
- if (args != null && args.length > 0) {
- message = MessageFormat.format(message, args);
- }
- return message;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ca25b1f7/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/utils/RowMapper.java
----------------------------------------------------------------------
diff --git a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/utils/RowMapper.java b/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/utils/RowMapper.java
deleted file mode 100644
index a181a3c..0000000
--- a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/java/org/wso2/carbon/adc/mgt/cli/utils/RowMapper.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2013, WSO2, Inc. http://wso2.org
- *
- * Licensed 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.wso2.carbon.adc.mgt.cli.utils;
-
-public interface RowMapper<T> {
- String[] getData(T t);
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ca25b1f7/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/resources/Resources.properties
----------------------------------------------------------------------
diff --git a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/resources/Resources.properties b/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/resources/Resources.properties
deleted file mode 100644
index fcec66f..0000000
--- a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/resources/Resources.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-cannot.list.available.cartridges=An error occurred when getting available cartridges.
-cannot.list.subscribed.cartridges=An error occurred when getting subscribed cartridges.
-cannot.get.cartridge.info=An error occurred when getting cartridge information.
-cannot.syncrepo=Synchronization failed
-cannot.subscribe=Subscribe failed
-cannot.unsubscribe=Unsubscribe failed
-cannot.mapdomain=Map Domain failed
-cannot.removedomain=Mapped Domain removal failed
-
-notsubscribed.error=You have not subscribed to {0}
-domainmapping.exists.error=The domain mapping {0} already exists for {1}
-
-cartridge.notregistered=Cartridge {0} is not registered
-cartridge.invalid.alias=The provided cartridge alias is not valid. The alias can contain only lowercase characters and numbers.
-cartridge.already.subscribed=You have already subscribed for cartridge type {0}
-cartridge.alias.duplicate=Duplicate cartridge alias {0}
-
-policy.error=Could not load policy.
-repository.required=An external repository required
-repository.credentials.required=Username and Password are required for the repository: {0}
-repository.transport.error=Error connecting to the repository: {0}
-repository.invalid.error=Invalid repository: {0}
-remote.error=Error connecting to back-end service.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ca25b1f7/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/resources/log4j.properties b/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/resources/log4j.properties
deleted file mode 100755
index 958eb9c..0000000
--- a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/resources/log4j.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-log4j.appender.console=org.apache.log4j.ConsoleAppender
-log4j.appender.console.Target=System.out
-log4j.appender.console.layout=org.apache.log4j.PatternLayout
-log4j.appender.console.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p %c{1} [%t] %n%m%n
-
-log4j.appender.file=org.apache.log4j.RollingFileAppender
-log4j.appender.file.File=${user.home}/.stratos/.stratos-cli.log
-log4j.appender.file.MaxFileSize=10MB
-log4j.appender.file.MaxBackupIndex=100
-log4j.appender.file.layout=org.apache.log4j.PatternLayout
-log4j.appender.file.layout.conversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p %c{1} [%t] %n%m%n
-
-#Loggers
-log4j.rootLogger=info, file
-log4j.logger.org.wso2.carbon.adc.mgt.cli=info
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ca25b1f7/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/resources/wso2carbon.jks
----------------------------------------------------------------------
diff --git a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/resources/wso2carbon.jks b/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/resources/wso2carbon.jks
deleted file mode 100644
index 7942c53..0000000
Binary files a/components/org.wso2.carbon.adc.mgt.cli/2.1.3/src/main/resources/wso2carbon.jks and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ca25b1f7/components/pom.xml
----------------------------------------------------------------------
diff --git a/components/pom.xml b/components/pom.xml
index f468500..9b7cade 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -1,16 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
- <!--
- ~ Copyright (c) 2009-2010, WSO2 Inc. (http://www.wso2.org) All Rights
- Reserved. ~ ~ Licensed 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.
- -->
+<!--
+ 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.
+-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
@@ -43,9 +49,18 @@
</organization>
<modules>
- <!--module>load-balancer</module-->
- <!--module>stratos</module-->
- </modules>
+ <!-- ADC -->
+ <module>org.apache.stratos.adc.topology.mgt/2.1.3</module>
+ <module>org.apache.stratos.adc.mgt/2.1.3</module>
+ <module>org.apache.stratos.adc.mgt.repository.synchronizer/2.1.1</module>
+ <module>org.apache.stratos.adc.mgt.cli/2.1.3</module>
+ <!-- ELB -->
+ <module>lb-endpoint/org.apache.stratos.lb.endpoint/4.1.3</module>
+ <module>org.apache.stratos.lb.common/4.1.3</module>
+ <module>autoscaler/org.apache.stratos.mediator.autoscale/4.1.3</module>
+ <module>autoscaler-service/org.apache.stratos.autoscaler.service/4.1.0</module>
+ </modules>
+
<build>
<plugins>
<plugin>