2 * Copyright © 2016-2017 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.openecomp.sdc.vendorsoftwareproduct.errors;
19 import org.openecomp.sdc.common.errors.ErrorCategory;
20 import org.openecomp.sdc.common.errors.ErrorCode;
21 import org.openecomp.sdc.versioning.dao.types.Version;
23 public class DeploymentFlavorErrorBuilder {
24 private static final String CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG =
25 "Deployment Flavor cannot be added for VSPs onboarded with HEAT.";
26 private static final String FEATURE_GROUP_NOT_EXIST_FOR_VSP_MSG =
27 "Invalid request, Feature Group provided does not exist for this Vsp.";
28 private static final String INVALID_COMPONENT_COMPUTE_ASSOCIATION_MSG
29 = "Invalid request,for valid association please provide ComponentId for Compute Flavor";
30 private static final String SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED_MSG =
31 "Invalid Request,Same Vfc cannot be associated more than once.";
32 private static final String DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED_MSG =
33 "Invalid request, Deployment Flavor with model %s already exists for Vsp with Id %s.";
34 private static final String DEPLOYMENT_FLAVOUR_NAME_FORMAT_MSG = "Field does not conform to predefined criteria"
35 + ": name : must match %s";
36 private static final String INVALID_COMPUTE_FLAVOR_ID_MSG =
37 "Invalid request, Compute Flavor provided does not exist for this VFC.";
38 private static final String INVALID_COMPONENT_COMPUTE_ASSOCIATION_ERROR_MSG="VSP cannot be " +
39 "submitted with an invalid Deployment Flavor. All Deployment Flavor should have atleast a VFC included with it's required Compute needs. " +
40 "Please fix the Deployment Flavor %s and re-submit the VSP.";
42 private static final String FEATUREGROUP_REQUIRED_IN_DEPLOYMENT_FLAVOR_MSG = "VSP cannot be " +
43 "submitted with an invalid Deployment Flavor. All Deployment Flavor should have " +
44 "FeatureGroup. Please fix the Deployment Flavor %s and re-submit the VSP.";
46 private DeploymentFlavorErrorBuilder(){
50 public static ErrorCode getAddDeploymentNotSupportedHeatOnboardErrorBuilder(){
51 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
52 builder.withId(VendorSoftwareProductErrorCodes.CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
53 builder.withCategory(ErrorCategory.APPLICATION);
54 builder.withMessage(CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG);
55 return builder.build();
58 public static ErrorCode getFeatureGroupNotexistErrorBuilder( String featureGroupId, String
59 vspId, Version activeVersion){
60 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
61 builder.withId(VendorSoftwareProductErrorCodes.FEATURE_GROUP_NOT_EXIST_FOR_VSP);
62 builder.withCategory(ErrorCategory.APPLICATION);
63 builder.withMessage(FEATURE_GROUP_NOT_EXIST_FOR_VSP_MSG);
64 return builder.build();
67 public static ErrorCode getDuplicateVfcAssociationErrorBuilder(){
68 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
69 builder.withId(VendorSoftwareProductErrorCodes
70 .SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED);
71 builder.withCategory(ErrorCategory.APPLICATION);
72 builder.withMessage(SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED_MSG);
73 return builder.build();
76 public static ErrorCode getInvalidAssociationErrorBuilder() {
77 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
78 builder.withId(VendorSoftwareProductErrorCodes.INVALID_COMPONENT_COMPUTE_ASSOCIATION);
79 builder.withCategory(ErrorCategory.APPLICATION);
80 builder.withMessage(INVALID_COMPONENT_COMPUTE_ASSOCIATION_MSG);
81 return builder.build();
84 public static ErrorCode getDuplicateDeploymentFlavorModelErrorBuilder(String name,
86 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
87 builder.withId(VendorSoftwareProductErrorCodes.DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED);
88 builder.withCategory(ErrorCategory.APPLICATION);
89 builder.withMessage(String.format(DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED_MSG,name,vspId));
90 return builder.build();
92 public static ErrorCode getInvalidComputeIdErrorBuilder(String computeFlavorId, String
94 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
95 builder.withId(VendorSoftwareProductErrorCodes.INVALID_COMPUTE_FLAVOR_ID);
96 builder.withCategory(ErrorCategory.APPLICATION);
97 builder.withMessage(String.format(INVALID_COMPUTE_FLAVOR_ID_MSG,computeFlavorId,
99 return builder.build();
102 public static ErrorCode getInvalidComponentComputeAssociationErrorBuilder(String model) {
103 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
104 builder.withId(VendorSoftwareProductErrorCodes.INVALID_COMPONENT_COMPUTE_ASSOCIATION);
105 builder.withCategory(ErrorCategory.APPLICATION);
106 builder.withMessage(String.format(INVALID_COMPONENT_COMPUTE_ASSOCIATION_ERROR_MSG, model));
107 return builder.build();
110 public static ErrorCode getFeatureGroupMandatoryErrorBuilder(String model) {
111 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
112 builder.withId(VendorSoftwareProductErrorCodes.FEATUREGROUP_REQUIRED_IN_DEPLOYMENT_FLAVOR);
113 builder.withCategory(ErrorCategory.APPLICATION);
114 builder.withMessage(String.format(FEATUREGROUP_REQUIRED_IN_DEPLOYMENT_FLAVOR_MSG, model));
115 return builder.build();
118 public static ErrorCode getDeploymentFlavorNameFormatErrorBuilder(String pattern){
119 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
120 builder.withId(VendorSoftwareProductErrorCodes.DEPLOYMENT_FLAVOR_NAME_FORMAT_NOT_ALLOWED);
121 builder.withCategory(ErrorCategory.APPLICATION);
122 builder.withMessage(String.format(DEPLOYMENT_FLAVOUR_NAME_FORMAT_MSG, pattern));
123 return builder.build();