You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ga...@apache.org on 2015/01/25 19:28:14 UTC
[1/2] stratos git commit: Update the error messgae of the update
cartridge
Repository: stratos
Updated Branches:
refs/heads/master aa6e3e105 -> 9082125bb
Update the error messgae of the update cartridge
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/e9a23e09
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/e9a23e09
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/e9a23e09
Branch: refs/heads/master
Commit: e9a23e09e356936a9fd4a3d66ef375eb8e04c5d8
Parents: aa6e3e1
Author: Gayan Gunarathne <ga...@wso2.com>
Authored: Sun Jan 25 23:32:14 2015 +0530
Committer: Gayan Gunarathne <ga...@wso2.com>
Committed: Sun Jan 25 23:32:14 2015 +0530
----------------------------------------------------------------------
.../org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/e9a23e09/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
index ccbd306..a9df2cd 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
@@ -140,7 +140,7 @@ public class StratosApiV41Utils {
cartridgeDefinition.getType()));
}
} catch (Exception e) {
- String msg = "Could not add cartridge";
+ String msg = "No cartridge definition exists with this definition.Please use the POST method to add the cartridge";
log.error(msg, e);
throw new RestAPIException(msg);
}
[2/2] stratos git commit: Extracting the method of
createCartridgeConfig
Posted by ga...@apache.org.
Extracting the method of createCartridgeConfig
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/9082125b
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/9082125b
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/9082125b
Branch: refs/heads/master
Commit: 9082125bb57f77af140595f66b0d475e3fd8925d
Parents: e9a23e0
Author: Gayan Gunarathne <ga...@wso2.com>
Authored: Sun Jan 25 23:41:36 2015 +0530
Committer: Gayan Gunarathne <ga...@wso2.com>
Committed: Sun Jan 25 23:41:36 2015 +0530
----------------------------------------------------------------------
.../rest/endpoint/api/StratosApiV41Utils.java | 43 +++++++++++---------
1 file changed, 24 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/9082125b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
index a9df2cd..3529781 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
@@ -96,13 +96,8 @@ public class StratosApiV41Utils {
log.debug(String.format("Adding cartridge: [cartridge-type] %s ", cartridgeDefinition.getType()));
}
- CartridgeConfig cartridgeConfig = ObjectConverter.convertCartridgeBeanToStubCartridgeConfig(cartridgeDefinition);
- if (cartridgeConfig == null) {
- throw new RestAPIException("Could not read cartridge definition, cartridge deployment failed");
- }
- if (StringUtils.isEmpty(cartridgeConfig.getCategory())) {
- throw new RestAPIException(String.format("Category is not specified in cartridge: [cartridge-type] %s",cartridgeConfig.getType()));
- }
+ CartridgeConfig cartridgeConfig =
+ createCartridgeConfig(cartridgeDefinition);
CloudControllerServiceClient cloudControllerServiceClient = CloudControllerServiceClient.getInstance();
cloudControllerServiceClient.addCartridge(cartridgeConfig);
@@ -123,30 +118,40 @@ public class StratosApiV41Utils {
log.debug(String.format("Adding cartridge: [cartridge-type] %s ", cartridgeDefinition.getType()));
}
- CartridgeConfig cartridgeConfig =
- ObjectConverter.convertCartridgeBeanToStubCartridgeConfig(cartridgeDefinition);
- if (cartridgeConfig == null) {
- throw new RestAPIException("Could not read cartridge definition, cartridge deployment failed");
- }
- if (StringUtils.isEmpty(cartridgeConfig.getCategory())) {
- throw new RestAPIException(String.format("Category is not specified in cartridge: [cartridge-type] %s",
- cartridgeConfig.getType()));
- }
+ CartridgeConfig cartridgeConfig = createCartridgeConfig(cartridgeDefinition);
CloudControllerServiceClient cloudControllerServiceClient = CloudControllerServiceClient.getInstance();
cloudControllerServiceClient.updateCartridge(cartridgeConfig);
if (log.isDebugEnabled()) {
- log.debug(String.format("Successfully added cartridge: [cartridge-type] %s ",
+ log.debug(String.format("Successfully update cartridge: [cartridge-type] %s ",
cartridgeDefinition.getType()));
}
- } catch (Exception e) {
+ } catch (CloudControllerServiceCartridgeDefinitionNotExistsExceptionException e) {
String msg = "No cartridge definition exists with this definition.Please use the POST method to add the cartridge";
log.error(msg, e);
throw new RestAPIException(msg);
+ } catch (Exception e) {
+ String msg = "Could not add cartridge";
+ log.error(msg, e);
+ throw new RestAPIException(msg);
+ }
+ }
+
+ private static CartridgeConfig createCartridgeConfig(CartridgeBean cartridgeDefinition)
+ throws RestAPIException {
+ CartridgeConfig cartridgeConfig =
+ ObjectConverter.convertCartridgeBeanToStubCartridgeConfig(cartridgeDefinition);
+ if (cartridgeConfig == null) {
+ throw new RestAPIException("Could not read cartridge definition, cartridge deployment failed");
+ }
+ if (StringUtils.isEmpty(cartridgeConfig.getCategory())) {
+ throw new RestAPIException(String.format("Category is not specified in cartridge: [cartridge-type] %s",
+ cartridgeConfig.getType()));
}
+ return cartridgeConfig;
}
- public static void removeCartridge(String cartridgeType) throws RestAPIException {
+ public static void removeCartridge(String cartridgeType) throws RestAPIException {
try {
if(log.isDebugEnabled()) {