2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ============LICENSE_END=========================================================
24 package org.onap.appc.executor.objects;
26 import org.onap.appc.util.MessageFormatter;
30 public enum LCMCommandStatus {
32 ACCEPTED(100, "ACCEPTED - request accepted"),
34 //ERROR(2xx) - request can't be handled due to some technical error
35 UNEXPECTED_ERROR(200, "UNEXPECTED ERROR - ${errorMsg}"),
37 //REJECT(3xx) - request has been rejected due to some business reason
38 // (e.g. no such service-instance-id, command is not supported, etc)
39 REJECTED(300, "REJECTED - ${errorMsg}"),
41 * TODO: Change responseMessage from "INVALID INPUT PARAMETER" to "INVALID INPUT PARAMETER(S)" tracked ATTAPPC-4863
43 * With consideration of updating integration test case effort, "INVALID INPUT PARAMETER" is used while the task
44 * ATTAPPC-4863 is tracking the need of this change when resource is available.
46 * However, when pushing this file to ONAP, responseMessage should be changed to "INVALID INPUT PARAMETER(S)",
47 * and this comments should be removed.
49 // TODO 77777777 to support "${paramName} with invalid value ${paramValue}"
50 INVALID_INPUT_PARAMETER(301, "INVALID INPUT PARAMETER - ${errorMsg}"),
51 MISSING_MANDATORY_PARAMETER(302, "MISSING MANDATORY PARAMETER - Parameter/s ${paramName} is/are missing" ),
52 REQUEST_PARSING_FAILED(303, "REQUEST PARSING FAILED - ${errorMsg}"),
53 VNF_NOT_FOUND(306, "VNF NOT FOUND - VNF with ID ${vnfId} was not found" ),
54 DG_WORKFLOW_NOT_FOUND(307, "DG WORKFLOW NOT FOUND - No DG workflow found for the combination of ${dgModule} module ${dgName} name and ${dgVersion} version"),//TODO need to support it
55 WORKFLOW_NOT_FOUND(308, "WORKFLOW NOT FOUND - No workflow found for VNF type ${vnfTypeVersion} and ${actionName} action"),
56 EXPIRED_REQUEST(311, "EXPIRED REQUEST"),
57 DUPLICATE_REQUEST(312, "DUPLICATE REQUEST"),
58 MISSING_VNF_DATA_IN_AAI(313, "MISSING VNF DATA IN A&AI - ${attributeName} not found for VNF ID = ${vnfId}"),
59 VSERVER_NOT_FOUND(314, "VSERVER NOT FOUND - vserver with ID ${id} was not found"),
60 MULTIPLE_REQUESTS_FOUND(315, "MULTIPLE REQUESTS FOUND - using search criteria: ${parameters}"),
61 POLICY_VALIDATION_FAILURE(316,"POLICY VALIDATION FAILURE - ${errorMsg}"),
62 EXLCUSIVE_REQUEST_IN_PROGRESS(317,"EXCLUSIVE REQUEST IN PROGRESS - ${errorMsg}"),
63 LOCKED_VNF_ID(318,"${errorMsg}"),
65 SUCCESS(400, "SUCCESS - request has been processed successfully"),
67 //ERROR(4xx) - failure for Async response
68 DG_FAILURE(401, "DG FAILURE - ${errorMsg}"),
69 EXPIRED_REQUEST_FAILURE(404, "EXPIRED REQUEST FAILURE - failed after accepted because TTL expired");
72 //ERROR(5xx) - failure for Intermediate response
73 // FAILURE(5xx) - request processing results with failure. The FAILURE response is always transmitted asynchronously, via DMaaP.
75 public static final String errorDgMessageParamName = "errorDgMessage";
77 private int responseCode;
78 private String responseMessage;
81 LCMCommandStatus(int responseCode, String responseMessage) {
82 this.responseCode = responseCode;
83 this.responseMessage = responseMessage;
86 public String getResponseMessage() {
87 return responseMessage;
90 public int getResponseCode() {
95 * @return messageTemplate
97 public String getFormattedMessage(Params params) {
98 Map<String, Object> paramsMap = params != null ? params.getParams() : null;
99 return MessageFormatter.format(getResponseMessage(), paramsMap);
102 public String getFormattedMessageWithCode(Params params) {
103 return getResponseCode() + "-" + getFormattedMessage(params);
107 public String toString() {
108 return "LCMCommandStatus{" +
109 "responseCode=" + responseCode +
110 ", responseMessage='" + responseMessage + '\'' +