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/23 14:04:19 UTC
[3/4] Renaming Stratos CLI Component. org.apache.stratos.adc.mgt.cli
to org.apache.stratos.cli
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4f790fe5/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/ExitCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/ExitCommand.java b/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/ExitCommand.java
deleted file mode 100644
index e0ff8c3..0000000
--- a/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/ExitCommand.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.adc.mgt.cli.commands;
-
-import org.apache.commons.cli.Options;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.stratos.adc.mgt.cli.Command;
-import org.apache.stratos.adc.mgt.cli.StratosCommandContext;
-import org.apache.stratos.adc.mgt.cli.exception.CommandException;
-import org.apache.stratos.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/4f790fe5/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/HelpCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/HelpCommand.java b/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/HelpCommand.java
deleted file mode 100644
index ca74687..0000000
--- a/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/HelpCommand.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.adc.mgt.cli.commands;
-
-import org.apache.commons.cli.Options;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.stratos.adc.mgt.cli.Command;
-import org.apache.stratos.adc.mgt.cli.StratosCommandContext;
-import org.apache.stratos.adc.mgt.cli.exception.CommandException;
-import org.apache.stratos.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/4f790fe5/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/InfoCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/InfoCommand.java b/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/InfoCommand.java
deleted file mode 100644
index a4ac08e..0000000
--- a/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/InfoCommand.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.adc.mgt.cli.commands;
-
-import org.apache.stratos.adc.mgt.cli.Command;
-import org.apache.stratos.adc.mgt.cli.exception.CommandException;
-import org.apache.commons.cli.Options;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.stratos.adc.mgt.cli.CommandLineService;
-import org.apache.stratos.adc.mgt.cli.StratosCommandContext;
-import org.apache.stratos.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/4f790fe5/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/ListCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/ListCommand.java b/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/ListCommand.java
deleted file mode 100644
index 1b96182..0000000
--- a/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/ListCommand.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.adc.mgt.cli.commands;
-
-import org.apache.stratos.adc.mgt.cli.Command;
-import org.apache.stratos.adc.mgt.cli.exception.CommandException;
-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.apache.stratos.adc.mgt.cli.CommandLineService;
-import org.apache.stratos.adc.mgt.cli.StratosCommandContext;
-import org.apache.stratos.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/4f790fe5/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/PoliciesCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/PoliciesCommand.java b/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/PoliciesCommand.java
deleted file mode 100644
index 4811efd..0000000
--- a/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/PoliciesCommand.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.adc.mgt.cli.commands;
-
-import org.apache.commons.cli.Options;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.stratos.adc.mgt.cli.Command;
-import org.apache.stratos.adc.mgt.cli.CommandLineService;
-import org.apache.stratos.adc.mgt.cli.StratosCommandContext;
-import org.apache.stratos.adc.mgt.cli.exception.CommandException;
-import org.apache.stratos.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/4f790fe5/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/RemoveDomainMappingCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/RemoveDomainMappingCommand.java b/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/RemoveDomainMappingCommand.java
deleted file mode 100644
index a3b4cc0..0000000
--- a/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/RemoveDomainMappingCommand.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.adc.mgt.cli.commands;
-
-import org.apache.stratos.adc.mgt.cli.Command;
-import org.apache.stratos.adc.mgt.cli.CommandLineService;
-import org.apache.stratos.adc.mgt.cli.StratosCommandContext;
-import org.apache.stratos.adc.mgt.cli.exception.CommandException;
-import org.apache.stratos.adc.mgt.cli.utils.CliConstants;
-import org.apache.commons.cli.Options;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-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/4f790fe5/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/SubscribeCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/SubscribeCommand.java b/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/SubscribeCommand.java
deleted file mode 100644
index 90908e9..0000000
--- a/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/SubscribeCommand.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.adc.mgt.cli.commands;
-
-import org.apache.stratos.adc.mgt.cli.Command;
-import org.apache.stratos.adc.mgt.cli.CommandLineService;
-import org.apache.stratos.adc.mgt.cli.StratosCommandContext;
-import org.apache.stratos.adc.mgt.cli.exception.CommandException;
-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.apache.stratos.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/4f790fe5/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/SyncCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/SyncCommand.java b/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/SyncCommand.java
deleted file mode 100644
index 6e21a4d..0000000
--- a/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/SyncCommand.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.adc.mgt.cli.commands;
-
-import org.apache.stratos.adc.mgt.cli.exception.CommandException;
-import org.apache.commons.cli.Options;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.stratos.adc.mgt.cli.Command;
-import org.apache.stratos.adc.mgt.cli.CommandLineService;
-import org.apache.stratos.adc.mgt.cli.StratosCommandContext;
-import org.apache.stratos.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/4f790fe5/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/UnsubscribeCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/UnsubscribeCommand.java b/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/UnsubscribeCommand.java
deleted file mode 100644
index 9b178e4..0000000
--- a/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/commands/UnsubscribeCommand.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.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.apache.stratos.adc.mgt.cli.Command;
-import org.apache.stratos.adc.mgt.cli.CommandLineService;
-import org.apache.stratos.adc.mgt.cli.StratosCommandContext;
-import org.apache.stratos.adc.mgt.cli.exception.CommandException;
-import org.apache.stratos.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/4f790fe5/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/completer/CommandCompleter.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/completer/CommandCompleter.java b/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/completer/CommandCompleter.java
deleted file mode 100644
index 3405762..0000000
--- a/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/completer/CommandCompleter.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.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.apache.stratos.adc.mgt.cli.Command;
-import org.apache.stratos.adc.mgt.cli.StratosApplication;
-import org.apache.stratos.adc.mgt.cli.StratosCommandContext;
-import org.apache.stratos.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/4f790fe5/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/exception/CommandException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/exception/CommandException.java b/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/exception/CommandException.java
deleted file mode 100644
index a462500..0000000
--- a/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/exception/CommandException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.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/4f790fe5/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/utils/CliConstants.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/utils/CliConstants.java b/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/utils/CliConstants.java
deleted file mode 100644
index 986bb72..0000000
--- a/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/utils/CliConstants.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.stratos.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/4f790fe5/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/utils/CommandLineUtils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/utils/CommandLineUtils.java b/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/utils/CommandLineUtils.java
deleted file mode 100644
index c6167f2..0000000
--- a/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/utils/CommandLineUtils.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.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/4f790fe5/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/utils/RowMapper.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/utils/RowMapper.java b/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/utils/RowMapper.java
deleted file mode 100644
index 0a61ad7..0000000
--- a/components/org.apache.stratos.adc.mgt.cli/src/main/java/org/apache/stratos/adc/mgt/cli/utils/RowMapper.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
-
- * http://www.apache.org/licenses/LICENSE-2.0
-
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.stratos.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/4f790fe5/components/org.apache.stratos.adc.mgt.cli/src/main/resources/Resources.properties
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.adc.mgt.cli/src/main/resources/Resources.properties b/components/org.apache.stratos.adc.mgt.cli/src/main/resources/Resources.properties
deleted file mode 100644
index fcec66f..0000000
--- a/components/org.apache.stratos.adc.mgt.cli/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/4f790fe5/components/org.apache.stratos.adc.mgt.cli/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.adc.mgt.cli/src/main/resources/log4j.properties b/components/org.apache.stratos.adc.mgt.cli/src/main/resources/log4j.properties
deleted file mode 100755
index 958eb9c..0000000
--- a/components/org.apache.stratos.adc.mgt.cli/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/4f790fe5/components/org.apache.stratos.adc.mgt.cli/src/main/resources/wso2carbon.jks
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.adc.mgt.cli/src/main/resources/wso2carbon.jks b/components/org.apache.stratos.adc.mgt.cli/src/main/resources/wso2carbon.jks
deleted file mode 100644
index 7942c53..0000000
Binary files a/components/org.apache.stratos.adc.mgt.cli/src/main/resources/wso2carbon.jks and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4f790fe5/components/org.apache.stratos.cli/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/pom.xml b/components/org.apache.stratos.cli/pom.xml
new file mode 100644
index 0000000..effe542
--- /dev/null
+++ b/components/org.apache.stratos.cli/pom.xml
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ # 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">
+
+ <parent>
+ <groupId>org.apache.stratos</groupId>
+ <artifactId>stratos-components-parent</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>org.apache.stratos.adc.mgt.cli</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache Stratos - ADC Management CLI</name>
+ <description>ADC management CLI bundle</description>
+ <url>http://apache.org</url>
+
+ <properties>
+ <slf4j.version>1.7.5</slf4j.version>
+ </properties>
+
+ <dependencies>
+ <!-- <dependency>
+ <groupId>org.wso2.carbon</groupId>
+ <artifactId>org.wso2.carbon.ui</artifactId>
+ </dependency> -->
+ <!-- Adding HttpClient dependencies. Those were resolved with above one -->
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>${commons-httpclient.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.wso2.securevault</groupId>
+ <artifactId>org.wso2.securevault</artifactId>
+ <version>1.0.0-wso2v2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents.wso2</groupId>
+ <artifactId>httpcore</artifactId>
+ <version>4.1.0-wso2v1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.stratos</groupId>
+ <artifactId>org.apache.stratos.adc.mgt.stub</artifactId>
+ <version>${apache.stratos.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-cli</groupId>
+ <artifactId>commons-cli</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>jline</groupId>
+ <artifactId>jline</artifactId>
+ <version>2.11</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-validator</groupId>
+ <artifactId>commons-validator</artifactId>
+ <version>1.4.0</version>
+ </dependency>
+ <!-- Logging -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>${slf4j.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.1</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>org.apache.stratos.adc.mgt.cli.CliTool</mainClass>
+ </manifest>
+ </archive>
+ <descriptors>
+ <descriptor>src/main/assembly/src.xml</descriptor>
+ </descriptors>
+ </configuration>
+ <executions>
+ <execution>
+ <id>make-assembly</id> <!-- this is used for inheritance merges -->
+ <phase>package</phase> <!-- bind to the packaging phase -->
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4f790fe5/components/org.apache.stratos.cli/src/main/assembly/src.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/assembly/src.xml b/components/org.apache.stratos.cli/src/main/assembly/src.xml
new file mode 100644
index 0000000..ec41ef1
--- /dev/null
+++ b/components/org.apache.stratos.cli/src/main/assembly/src.xml
@@ -0,0 +1,36 @@
+<!--
+ 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.
+ -->
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <id>Tool</id>
+ <formats>
+ <format>jar</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+ <dependencySets>
+ <dependencySet>
+ <outputDirectory>/</outputDirectory>
+ <useProjectArtifact>true</useProjectArtifact>
+ <unpack>true</unpack>
+ <scope>runtime</scope>
+ </dependencySet>
+ </dependencySets>
+</assembly>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4f790fe5/components/org.apache.stratos.cli/src/main/java/Main.iml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/Main.iml b/components/org.apache.stratos.cli/src/main/java/Main.iml
new file mode 100644
index 0000000..9a9b340
--- /dev/null
+++ b/components/org.apache.stratos.cli/src/main/java/Main.iml
@@ -0,0 +1,204 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ </component>
+ <component name="org.twodividedbyzero.idea.findbugs">
+ <option name="_basePreferences">
+ <map>
+ <entry key="property.analysisEffortLevel" value="default" />
+ <entry key="property.analyzeAfterCompile" value="false" />
+ <entry key="property.annotationGutterIconEnabled" value="true" />
+ <entry key="property.annotationSuppressWarningsClass" value="edu.umd.cs.findbugs.annotations.SuppressWarnings" />
+ <entry key="property.annotationTextRangeMarkupEnabled" value="true" />
+ <entry key="property.exportAsHtml" value="true" />
+ <entry key="property.exportAsXml" value="true" />
+ <entry key="property.exportBaseDir" value="" />
+ <entry key="property.exportCreateArchiveDir" value="false" />
+ <entry key="property.exportOpenBrowser" value="true" />
+ <entry key="property.minPriorityToReport" value="Medium" />
+ <entry key="property.runAnalysisInBackground" value="false" />
+ <entry key="property.showHiddenDetectors" value="false" />
+ <entry key="property.toolWindowToFront" value="true" />
+ </map>
+ </option>
+ <option name="_detectors">
+ <map>
+ <entry key="AppendingToAnObjectOutputStream" value="true" />
+ <entry key="AtomicityProblem" value="true" />
+ <entry key="BadAppletConstructor" value="false" />
+ <entry key="BadResultSetAccess" value="true" />
+ <entry key="BadSyntaxForRegularExpression" value="true" />
+ <entry key="BadUseOfReturnValue" value="true" />
+ <entry key="BadlyOverriddenAdapter" value="true" />
+ <entry key="BooleanReturnNull" value="true" />
+ <entry key="BuildInterproceduralCallGraph" value="false" />
+ <entry key="BuildObligationPolicyDatabase" value="true" />
+ <entry key="CallToUnsupportedMethod" value="false" />
+ <entry key="CalledMethods" value="true" />
+ <entry key="CheckCalls" value="false" />
+ <entry key="CheckExpectedWarnings" value="false" />
+ <entry key="CheckImmutableAnnotation" value="true" />
+ <entry key="CheckTypeQualifiers" value="true" />
+ <entry key="CloneIdiom" value="true" />
+ <entry key="ComparatorIdiom" value="true" />
+ <entry key="ConfusedInheritance" value="true" />
+ <entry key="ConfusionBetweenInheritedAndOuterMethod" value="true" />
+ <entry key="CrossSiteScripting" value="true" />
+ <entry key="DefaultEncodingDetector" value="true" />
+ <entry key="DoInsideDoPrivileged" value="true" />
+ <entry key="DontCatchIllegalMonitorStateException" value="true" />
+ <entry key="DontIgnoreResultOfPutIfAbsent" value="true" />
+ <entry key="DontUseEnum" value="true" />
+ <entry key="DroppedException" value="true" />
+ <entry key="DumbMethodInvocations" value="true" />
+ <entry key="DumbMethods" value="true" />
+ <entry key="DuplicateBranches" value="true" />
+ <entry key="EmptyZipFileEntry" value="true" />
+ <entry key="EqualsOperandShouldHaveClassCompatibleWithThis" value="true" />
+ <entry key="ExplicitSerialization" value="true" />
+ <entry key="FieldItemSummary" value="true" />
+ <entry key="FinalizerNullsFields" value="true" />
+ <entry key="FindBadCast2" value="true" />
+ <entry key="FindBadForLoop" value="true" />
+ <entry key="FindBugsSummaryStats" value="true" />
+ <entry key="FindCircularDependencies" value="false" />
+ <entry key="FindDeadLocalStores" value="true" />
+ <entry key="FindDoubleCheck" value="true" />
+ <entry key="FindEmptySynchronizedBlock" value="true" />
+ <entry key="FindFieldSelfAssignment" value="true" />
+ <entry key="FindFinalizeInvocations" value="true" />
+ <entry key="FindFloatEquality" value="true" />
+ <entry key="FindFloatMath" value="false" />
+ <entry key="FindHEmismatch" value="true" />
+ <entry key="FindInconsistentSync2" value="true" />
+ <entry key="FindJSR166LockMonitorenter" value="true" />
+ <entry key="FindLocalSelfAssignment2" value="true" />
+ <entry key="FindMaskedFields" value="true" />
+ <entry key="FindMismatchedWaitOrNotify" value="true" />
+ <entry key="FindNakedNotify" value="true" />
+ <entry key="FindNonSerializableStoreIntoSession" value="false" />
+ <entry key="FindNonSerializableValuePassedToWriteObject" value="false" />
+ <entry key="FindNonShortCircuit" value="true" />
+ <entry key="FindNullDeref" value="true" />
+ <entry key="FindNullDerefsInvolvingNonShortCircuitEvaluation" value="true" />
+ <entry key="FindOpenStream" value="true" />
+ <entry key="FindPuzzlers" value="true" />
+ <entry key="FindRefComparison" value="true" />
+ <entry key="FindReturnRef" value="true" />
+ <entry key="FindRunInvocations" value="true" />
+ <entry key="FindSelfComparison" value="true" />
+ <entry key="FindSelfComparison2" value="true" />
+ <entry key="FindSleepWithLockHeld" value="true" />
+ <entry key="FindSpinLoop" value="true" />
+ <entry key="FindSqlInjection" value="true" />
+ <entry key="FindTwoLockWait" value="true" />
+ <entry key="FindUncalledPrivateMethods" value="true" />
+ <entry key="FindUnconditionalWait" value="true" />
+ <entry key="FindUninitializedGet" value="true" />
+ <entry key="FindUnrelatedTypesInGenericContainer" value="true" />
+ <entry key="FindUnreleasedLock" value="true" />
+ <entry key="FindUnsatisfiedObligation" value="true" />
+ <entry key="FindUnsyncGet" value="true" />
+ <entry key="FindUseOfNonSerializableValue" value="true" />
+ <entry key="FindUselessControlFlow" value="true" />
+ <entry key="FormatStringChecker" value="true" />
+ <entry key="FunctionsThatMightBeMistakenForProcedures" value="true" />
+ <entry key="HugeSharedStringConstants" value="true" />
+ <entry key="IDivResultCastToDouble" value="true" />
+ <entry key="IncompatMask" value="true" />
+ <entry key="InconsistentAnnotations" value="true" />
+ <entry key="InefficientMemberAccess" value="false" />
+ <entry key="InefficientToArray" value="true" />
+ <entry key="InfiniteLoop" value="true" />
+ <entry key="InfiniteRecursiveLoop" value="true" />
+ <entry key="InheritanceUnsafeGetResource" value="true" />
+ <entry key="InitializationChain" value="true" />
+ <entry key="InitializeNonnullFieldsInConstructor" value="true" />
+ <entry key="InstantiateStaticClass" value="true" />
+ <entry key="IntCast2LongAsInstant" value="true" />
+ <entry key="InvalidJUnitTest" value="true" />
+ <entry key="IteratorIdioms" value="true" />
+ <entry key="LazyInit" value="true" />
+ <entry key="LoadOfKnownNullValue" value="true" />
+ <entry key="LostLoggerDueToWeakReference" value="true" />
+ <entry key="MethodReturnCheck" value="true" />
+ <entry key="Methods" value="true" />
+ <entry key="MultithreadedInstanceAccess" value="true" />
+ <entry key="MutableLock" value="true" />
+ <entry key="MutableStaticFields" value="true" />
+ <entry key="Naming" value="true" />
+ <entry key="Noise" value="false" />
+ <entry key="NoiseNullDeref" value="false" />
+ <entry key="NoteAnnotationRetention" value="true" />
+ <entry key="NoteCheckReturnValueAnnotations" value="true" />
+ <entry key="NoteDirectlyRelevantTypeQualifiers" value="true" />
+ <entry key="NoteJCIPAnnotation" value="true" />
+ <entry key="NoteNonNullAnnotations" value="true" />
+ <entry key="NoteNonnullReturnValues" value="true" />
+ <entry key="NoteSuppressedWarnings" value="true" />
+ <entry key="NoteUnconditionalParamDerefs" value="true" />
+ <entry key="NumberConstructor" value="true" />
+ <entry key="OverridingEqualsNotSymmetrical" value="true" />
+ <entry key="PreferZeroLengthArrays" value="true" />
+ <entry key="PublicSemaphores" value="false" />
+ <entry key="QuestionableBooleanAssignment" value="true" />
+ <entry key="ReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass" value="true" />
+ <entry key="ReadReturnShouldBeChecked" value="true" />
+ <entry key="RedundantInterfaces" value="true" />
+ <entry key="ReflectiveClasses" value="true" />
+ <entry key="RepeatedConditionals" value="true" />
+ <entry key="ResolveAllReferences" value="false" />
+ <entry key="RuntimeExceptionCapture" value="true" />
+ <entry key="SerializableIdiom" value="true" />
+ <entry key="StartInConstructor" value="true" />
+ <entry key="StaticCalendarDetector" value="true" />
+ <entry key="StringConcatenation" value="true" />
+ <entry key="SuperfluousInstanceOf" value="true" />
+ <entry key="SuspiciousThreadInterrupted" value="true" />
+ <entry key="SwitchFallthrough" value="true" />
+ <entry key="SynchronizationOnSharedBuiltinConstant" value="true" />
+ <entry key="SynchronizeAndNullCheckField" value="true" />
+ <entry key="SynchronizeOnClassLiteralNotGetClass" value="true" />
+ <entry key="SynchronizingOnContentsOfFieldToProtectField" value="true" />
+ <entry key="TestASM" value="false" />
+ <entry key="TestDataflowAnalysis" value="false" />
+ <entry key="TestingGround" value="false" />
+ <entry key="TestingGround2" value="false" />
+ <entry key="TrainFieldStoreTypes" value="true" />
+ <entry key="TrainLongInstantfParams" value="true" />
+ <entry key="TrainNonNullAnnotations" value="true" />
+ <entry key="TrainUnconditionalDerefParams" value="true" />
+ <entry key="URLProblems" value="true" />
+ <entry key="UncallableMethodOfAnonymousClass" value="true" />
+ <entry key="UnnecessaryMath" value="true" />
+ <entry key="UnreadFields" value="true" />
+ <entry key="UselessSubclassMethod" value="false" />
+ <entry key="VarArgsProblems" value="true" />
+ <entry key="VolatileUsage" value="true" />
+ <entry key="WaitInLoop" value="true" />
+ <entry key="WrongMapIterator" value="true" />
+ <entry key="XMLFactoryBypass" value="true" />
+ </map>
+ </option>
+ <option name="_reportCategories">
+ <map>
+ <entry key="BAD_PRACTICE" value="true" />
+ <entry key="CORRECTNESS" value="true" />
+ <entry key="EXPERIMENTAL" value="true" />
+ <entry key="I18N" value="true" />
+ <entry key="MALICIOUS_CODE" value="true" />
+ <entry key="MT_CORRECTNESS" value="true" />
+ <entry key="PERFORMANCE" value="true" />
+ <entry key="SECURITY" value="true" />
+ <entry key="STYLE" value="true" />
+ </map>
+ </option>
+ </component>
+</module>
+
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4f790fe5/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/CliTool.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/CliTool.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/CliTool.java
new file mode 100644
index 0000000..4a824a4
--- /dev/null
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/CliTool.java
@@ -0,0 +1,76 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.adc.mgt.cli;
+
+import static org.apache.stratos.adc.mgt.cli.utils.CliConstants.STRATOS_DIR;
+
+import java.io.File;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class is used for input the commands through CLITool, command prompt.
+ */
+public class CliTool {
+
+ private static final Logger logger = LoggerFactory.getLogger(CliTool.class);
+
+ /**
+ * Main executable method used to call from CLI.
+ *
+ */
+ public static void main(final String[] args) {
+ CliTool cliTool = new CliTool();
+ cliTool.createConfigDirectory();
+ cliTool.handleConsoleInputs(args);
+ }
+
+ /**
+ * Here is the place all the command line inputs get processed
+ *
+ * @param arguments
+ * passed to CLI tool.
+ */
+ private void handleConsoleInputs(String[] arguments) {
+ if (logger.isInfoEnabled()) {
+ logger.info("Stratos CLI Started...");
+ }
+ StratosApplication application = new StratosApplication();
+ application.start(arguments);
+ }
+
+ private void createConfigDirectory() {
+ File stratosFile = new File(System.getProperty("user.home"), STRATOS_DIR);
+ if (stratosFile.exists()) {
+ if (logger.isInfoEnabled()) {
+ logger.info("Using directory: {}", stratosFile.getPath());
+ }
+ } else {
+ if (stratosFile.mkdir()) {
+ if (logger.isInfoEnabled()) {
+ logger.info("Created directory: {}", stratosFile.getPath());
+ }
+ } else if (logger.isWarnEnabled()) {
+ logger.warn("Failed to created directory: {}", stratosFile.getPath());
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4f790fe5/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/Command.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/Command.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/Command.java
new file mode 100644
index 0000000..caebaa4
--- /dev/null
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/Command.java
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.adc.mgt.cli;
+
+import org.apache.stratos.adc.mgt.cli.exception.CommandException;
+import org.apache.commons.cli.Options;
+
+public interface Command<T extends CommandContext> {
+
+ /**
+ * @return The name of the command
+ */
+ String getName();
+
+ /**
+ * Information about the command
+ *
+ * @return The description of the command
+ */
+ String getDescription();
+
+ /**
+ * This should return the syntax required for the command.
+ *
+ * Used to display help.
+ *
+ * @return The syntax for this command
+ */
+ String getArgumentSyntax();
+
+ /**
+ * The options accepted by the command
+ *
+ * @return The Options for the commands
+ */
+ Options getOptions();
+
+ /**
+ * Executing the commands. Returns a code
+ *
+ * @param context
+ * The context assoicated with the Command Line Application
+ * @param args
+ * The arguments for the command
+ * @return The status code
+ * @throws org.apache.stratos.adc.mgt.cli.exception.CommandException
+ * if any errors occur when executing the command
+ */
+ int execute(T context, String[] args) throws CommandException;
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/4f790fe5/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/CommandContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/CommandContext.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/CommandContext.java
new file mode 100644
index 0000000..745b2f4
--- /dev/null
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/CommandContext.java
@@ -0,0 +1,88 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.stratos.adc.mgt.cli;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Observable;
+
+public class CommandContext extends Observable {
+
+ /**
+ * Properties for the context.
+ */
+ private Map<String, Object> properties;
+
+ /**
+ * The application
+ */
+ private final CommandLineApplication<? extends CommandContext> application;
+
+ public CommandContext(CommandLineApplication<? extends CommandContext> application) {
+ properties = new HashMap<String, Object>();
+ this.application = application;
+ }
+
+ public final CommandLineApplication<? extends CommandContext> getApplication() {
+ return application;
+ }
+
+ /**
+ * Set property in the context
+ *
+ * @param key
+ * The key
+ * @param o
+ * The value for the key
+ * @return The previous value or null
+ */
+ public Object put(String key, Object o) {
+ Object previous = properties.put(key, o);
+ setChanged();
+ notifyObservers();
+ return previous;
+ }
+
+ /**
+ * Get property value from the context
+ *
+ * @param key
+ * The key
+ * @return The value
+ */
+ public Object getObject(String key) {
+ return properties.get(key);
+ }
+
+ /**
+ * Get the string value, or null
+ *
+ * @param key
+ * The key
+ * @return The string value, or null.
+ */
+ public String getString(String key) {
+ Object o = getObject(key);
+ if (o instanceof String) {
+ return (String) o;
+ }
+ return null;
+ }
+
+}