2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
25 package org.onap.appc.executor.objects;
27 import org.onap.appc.util.MessageFormatter;
31 public enum LCMCommandStatus {
33 ACCEPTED(100, "ACCEPTED - request accepted"),
35 //ERROR(2xx) - request can't be handled due to some technical error
36 UNEXPECTED_ERROR(200, "UNEXPECTED ERROR - ${errorMsg}"),
38 //REJECT(3xx) - request has been rejected due to some business reason
39 // (e.g. no such service-instance-id, command is not supported, etc)
40 REJECTED(300, "REJECTED - ${errorMsg}"),
42 * TODO: Change responseMessage from "INVALID INPUT PARAMETER" to "INVALID INPUT PARAMETER(S)" tracked ATTAPPC-4863
44 * With consideration of updating integration test case effort, "INVALID INPUT PARAMETER" is used while the task
45 * ATTAPPC-4863 is tracking the need of this change when resource is available.
47 * However, when pushing this file to ONAP, responseMessage should be changed to "INVALID INPUT PARAMETER(S)",
48 * and this comments should be removed.
50 // TODO 77777777 to support "${paramName} with invalid value ${paramValue}"
51 INVALID_INPUT_PARAMETER(301, "INVALID INPUT PARAMETER - ${errorMsg}"),
52 MISSING_MANDATORY_PARAMETER(302, "MISSING MANDATORY PARAMETER - Parameter/s ${paramName} is/are missing" ),
53 REQUEST_PARSING_FAILED(303, "REQUEST PARSING FAILED - ${errorMsg}"),
54 VNF_NOT_FOUND(306, "VNF NOT FOUND - VNF with ID ${vnfId} was not found" ),
55 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
56 WORKFLOW_NOT_FOUND(308, "WORKFLOW NOT FOUND - No workflow found for VNF type ${vnfTypeVersion} and ${actionName} action"),
57 EXPIRED_REQUEST(311, "EXPIRED REQUEST"),
58 DUPLICATE_REQUEST(312, "DUPLICATE REQUEST"),
59 MISSING_VNF_DATA_IN_AAI(313, "MISSING VNF DATA IN A&AI - ${attributeName} not found for VNF ID = ${vnfId}"),
60 VSERVER_NOT_FOUND(314, "VSERVER NOT FOUND - vserver with ID ${id} was not found"),
61 MULTIPLE_REQUESTS_FOUND(315, "MULTIPLE REQUESTS FOUND - using search criteria: ${parameters}"),
62 POLICY_VALIDATION_FAILURE(316,"POLICY VALIDATION FAILURE - ${errorMsg}"),
63 EXLCUSIVE_REQUEST_IN_PROGRESS(317,"EXCLUSIVE REQUEST IN PROGRESS - ${errorMsg}"),
64 LOCKED_VNF_ID(318,"${errorMsg}"),
66 SUCCESS(400, "SUCCESS - request has been processed successfully"),
68 //ERROR(4xx) - failure for Async response
69 DG_FAILURE(401, "DG FAILURE - ${errorMsg}"),
70 EXPIRED_REQUEST_FAILURE(404, "EXPIRED REQUEST FAILURE - failed after accepted because TTL expired");
73 //ERROR(5xx) - failure for Intermediate response
74 // FAILURE(5xx) - request processing results with failure. The FAILURE response is always transmitted asynchronously, via DMaaP.
76 public static final String errorDgMessageParamName = "errorDgMessage";
78 private int responseCode;
79 private String responseMessage;
82 LCMCommandStatus(int responseCode, String responseMessage) {
83 this.responseCode = responseCode;
84 this.responseMessage = responseMessage;
87 public String getResponseMessage() {
88 return responseMessage;
91 public int getResponseCode() {
96 * @return messageTemplate
98 public String getFormattedMessage(Params params) {
99 Map<String, Object> paramsMap = params != null ? params.getParams() : null;
100 return MessageFormatter.format(getResponseMessage(), paramsMap);
103 public String getFormattedMessageWithCode(Params params) {
104 return getResponseCode() + "-" + getFormattedMessage(params);
108 public String toString() {
109 return "LCMCommandStatus{" +
110 "responseCode=" + responseCode +
111 ", responseMessage='" + responseMessage + '\'' +