X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=appc-provider%2Fappc-provider-bundle%2Fsrc%2Fmain%2Fjava%2Forg%2Fopenecomp%2Fappc%2Fprovider%2FAppcProviderLcm.java;h=b13a74201411c3d800388d7d0072565cf12c9cdc;hb=78f459993575bcab672898610ec281674ccaebc3;hp=370ed52871599a69c819849ca456276d717e593e;hpb=cf896d8cff45754a3bdb00f2f277eef3a5ae0cd2;p=appc.git diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderLcm.java b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderLcm.java index 370ed5287..b13a74201 100644 --- a/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderLcm.java +++ b/appc-provider/appc-provider-bundle/src/main/java/org/openecomp/appc/provider/AppcProviderLcm.java @@ -503,25 +503,6 @@ public class AppcProviderLcm implements AutoCloseable, AppcProviderLcmService { return buildStatus(statusCode, statusMessage); } - private RequestHandlerOutput executeRequest(RequestHandlerInput request){ - RequestHandler handler = getRequestHandler(); - RequestHandlerOutput requestHandlerOutput; - if (handler != null) { - try { - requestHandlerOutput = handler.handleRequest(request); - } catch (Exception e) { - logger.info("UNEXPECTED FAILURE while executing " + request.getRequestContext().getAction().name()); - requestHandlerOutput = createErrorRequestHandlerObj(request, - LCMCommandStatus.UNEXPECTED_ERROR, Msg.EXCEPTION_CALLING_DG, e); - } - } else { - String errorMsg = "LCM request cannot be processed at the moment because APPC isn't running"; - requestHandlerOutput = createErrorRequestHandlerObj(request, - LCMCommandStatus.REJECTED, Msg.REQUEST_HANDLER_UNAVAILABLE, new APPCException(errorMsg)); - } - return requestHandlerOutput; - } - private RequestHandlerOutput createErrorRequestHandlerObj(RequestHandlerInput request, LCMCommandStatus cmdStatus, Msg msg, @@ -1006,33 +987,39 @@ public class AppcProviderLcm implements AutoCloseable, AppcProviderLcmService { public Future> checkLock(CheckLockInput input) { logger.debug("Input received : " + input.toString()); CheckLockOutputBuilder outputBuilder = new CheckLockOutputBuilder(); - String action = Action.CheckLock.toString() ; + String action = Action.CheckLock.toString(); String rpcName = Action.CheckLock.name().toLowerCase(); - RequestHandlerOutput requestHandlerOutput=null; - Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action); - if(null == status) { + RequestHandlerOutput requestHandlerOutput = null; + Status status = ValidationService.getInstance().validateInput(input.getCommonHeader(), + input.getAction(), action); + if (null == status) { try { - RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).action(action).rpcName(rpcName).build(); - requestHandlerOutput=executeRequest(request); + RequestHandlerInput request = new RequestInputBuilder().requestContext().commonHeader(input + .getCommonHeader()).actionIdentifiers(input.getActionIdentifiers()).action(action) + .rpcName(rpcName).build(); + requestHandlerOutput = executeRequest(request); status = buildStatusWithDispatcherOutput(requestHandlerOutput); - logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", input.getActionIdentifiers(), status.getCode(), status.getMessage())); + logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s", + input.getActionIdentifiers(), status.getCode(), status.getMessage())); } catch (ParseException e) { status = buildParsingErrorStatus(e); LoggingUtils.logErrorMessage( - LoggingConstants.TargetNames.APPC_PROVIDER, - String.format(COMMON_ERROR_MESSAGE_TEMPLATE, action, e.getMessage()), - this.getClass().getName()); + LoggingConstants.TargetNames.APPC_PROVIDER, + String.format(COMMON_ERROR_MESSAGE_TEMPLATE, action, e.getMessage()), + this.getClass().getName()); } } outputBuilder.setCommonHeader(input.getCommonHeader()); outputBuilder.setStatus(status); - if(requestHandlerOutput.getResponseContext().getStatus().getCode() == 400) { - outputBuilder.setLocked(CheckLockOutput.Locked.valueOf(requestHandlerOutput.getResponseContext().getAdditionalContext().get("locked").toUpperCase())); + if (requestHandlerOutput != null && requestHandlerOutput.getResponseContext().getStatus().getCode() == 400) { + outputBuilder.setLocked(CheckLockOutput.Locked.valueOf(requestHandlerOutput.getResponseContext() + .getAdditionalContext().get("locked").toUpperCase())); } - RpcResult result = RpcResultBuilder. status(true).withResult(outputBuilder.build()).build(); + RpcResult result = RpcResultBuilder.status(true) + .withResult(outputBuilder.build()).build(); return Futures.immediateFuture(result); } @@ -1191,5 +1178,22 @@ public class AppcProviderLcm implements AutoCloseable, AppcProviderLcmService { .toLowerCase(); } - + RequestHandlerOutput executeRequest(RequestHandlerInput request){ + RequestHandler handler = getRequestHandler(); + RequestHandlerOutput requestHandlerOutput; + if (handler != null) { + try { + requestHandlerOutput = handler.handleRequest(request); + } catch (Exception e) { + logger.info("UNEXPECTED FAILURE while executing " + request.getRequestContext().getAction().name()); + requestHandlerOutput = createErrorRequestHandlerObj(request, + LCMCommandStatus.UNEXPECTED_ERROR, Msg.EXCEPTION_CALLING_DG, e); + } + } else { + String errorMsg = "LCM request cannot be processed at the moment because APPC isn't running"; + requestHandlerOutput = createErrorRequestHandlerObj(request, + LCMCommandStatus.REJECTED, Msg.REQUEST_HANDLER_UNAVAILABLE, new APPCException(errorMsg)); + } + return requestHandlerOutput; + } }