aboutsummaryrefslogtreecommitdiffstats
path: root/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java')
-rw-r--r--appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/ChefAdapterImpl.java54
1 files changed, 25 insertions, 29 deletions
diff --git a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/ChefAdapterImpl.java b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/ChefAdapterImpl.java
index f689668bb..f5b6b6751 100644
--- a/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/ChefAdapterImpl.java
+++ b/appc-adapters/appc-chef-adapter/appc-chef-adapter-bundle/src/main/java/org/onap/appc/adapter/chef/impl/ChefAdapterImpl.java
@@ -114,21 +114,18 @@ public class ChefAdapterImpl implements ChefAdapter {
@Override
public void vnfcEnvironment(Map<String, String> params, SvcLogicContext ctx) throws SvcLogicException {
int code;
- try {
- logger.info("environment of VNF-C");
- chefInfo(params, ctx);
- RequestContext rc = new RequestContext(ctx);
- logger.info("Context" + ctx);
- rc.isAlive();
- String env = params.get("Environment");
- logger.info("Environmnet" + env);
- if (env.equals(StringUtils.EMPTY)) {
- chefServerResult(rc, 200, "Skip Environment block ");
- } else {
- JSONObject envJ = new JSONObject(env);
- String envName = envJ.getString("name");
- String message;
- if (privateKeyChecker.doesExist(clientPrivatekey)) {
+ logger.info("environment of VNF-C");
+ chefInfo(params, ctx);
+ String env = params.get("Environment");
+ logger.info("Environmnet" + env);
+ if (env.equals(StringUtils.EMPTY)) {
+ chefServerResult(new RequestContext(ctx), 200, "Skip Environment block ");
+ } else {
+ String message;
+ if (privateKeyChecker.doesExist(clientPrivatekey)) {
+ try {
+ JSONObject envJ = new JSONObject(env);
+ String envName = envJ.getString("name");
// update the details of an environment on the Chef server.
ChefApiClient chefApiClient = chefApiClientFactory.create(chefserver, organizations, username, clientPrivatekey);
ChefResponse chefResponse = chefApiClient.put("/environments/" + envName, env);
@@ -141,22 +138,21 @@ public class ChefAdapterImpl implements ChefAdapter {
message = chefResponse.getBody();
logger.info("requestbody {}", chefResponse.getBody());
}
-
- } else {
- code = 500;
- message = CANNOT_FIND_PRIVATE_KEY_STR + clientPrivatekey;
- doFailure(ctx, code, message);
+ chefServerResult(new RequestContext(ctx), code, message);
+ } catch (JSONException e) {
+ code = 401;
+ logger.error(POSTING_REQUEST_JSON_ERROR_STR, e);
+ doFailure(ctx, code, POSTING_REQUEST_JSON_ERROR_STR + e.getMessage());
+ } catch (Exception e) {
+ code = 401;
+ logger.error(POSTING_REQUEST_ERROR_STR, e);
+ doFailure(ctx, code, POSTING_REQUEST_ERROR_STR + e.getMessage());
}
- chefServerResult(rc, code, message);
+ } else {
+ code = 500;
+ message = CANNOT_FIND_PRIVATE_KEY_STR + clientPrivatekey;
+ doFailure(ctx, code, message);
}
- } catch (JSONException e) {
- code = 401;
- logger.error(POSTING_REQUEST_JSON_ERROR_STR, e);
- doFailure(ctx, code, POSTING_REQUEST_JSON_ERROR_STR + e.getMessage());
- } catch (Exception e) {
- code = 401;
- logger.error(POSTING_REQUEST_ERROR_STR, e);
- doFailure(ctx, code, POSTING_REQUEST_ERROR_STR + e.getMessage());
}
}