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;
20 import org.openecomp.sdc.common.errors.ErrorCategory;
21 import org.openecomp.sdc.common.errors.ErrorCode;
22 import org.openecomp.sdc.versioning.dao.types.Version;
24 public class DeploymentFlavorErrorBuilder {
25 private static final String CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG =
26 "Deployment Flavor cannot be added for VSPs onboarded with HEAT.";
27 private static final String FEATURE_GROUP_NOT_EXIST_FOR_VSP_MSG =
28 "Invalid request,Feature Group with Id %s does not exist for Vsp with Id %s and version "
30 private static final String INVALID_COMPONENT_COMPUTE_ASSOCIATION_MSG
31 = "Invalid request,for valid association please provide ComponentId for Compute Flavor";
32 private static final String SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED_MSG =
33 "Invalid Request,Same Vfc cannot be associated more than once.";
34 private static final String DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED_MSG =
35 "Invalid request, Deployment Flavor with model %s already exists for Vsp with Id %s.";
36 private static final String DEPLOYMENT_FLAVOUR_NAME_FORMAT_MSG = "Field does not conform to predefined criteria"
37 + ": name : must match %s";
38 private static final String INVALID_COMPUTE_FLAVOR_ID_MSG =
39 "Invalid request, Compute Flavor with Id %s does not exist for VFC with Id %s.";
40 private static final String INVALID_COMPONENT_COMPUTE_ASSOCIATION_ERROR_MSG="VSP cannot be " +
41 "submitted with an invalid Deployment Flavor. All Deployment Flavor should have atleast a VFC included with it's required Compute needs. " +
42 "Please fix the Deployment Flavor %s and re-submit the VSP.";
44 private static final String FEATUREGROUP_REQUIRED_IN_DEPLOYMENT_FLAVOR_MSG = "VSP cannot be " +
45 "submitted with an invalid Deployment Flavor. All Deployment Flavor should have " +
46 "FeatureGroup. Please fix the Deployment Flavor %s and re-submit the VSP.";
48 private DeploymentFlavorErrorBuilder(){
52 public static ErrorCode getAddDeploymentNotSupportedHeatOnboardErrorBuilder(){
53 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
54 builder.withId(VendorSoftwareProductErrorCodes.CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
55 builder.withCategory(ErrorCategory.APPLICATION);
56 builder.withMessage(CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG);
57 return builder.build();
60 public static ErrorCode getFeatureGroupNotexistErrorBuilder( String featureGroupId, String
61 vspId, Version activeVersion){
62 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
63 builder.withId(VendorSoftwareProductErrorCodes.FEATURE_GROUP_NOT_EXIST_FOR_VSP);
64 builder.withCategory(ErrorCategory.APPLICATION);
65 builder.withMessage(String.format(FEATURE_GROUP_NOT_EXIST_FOR_VSP_MSG,featureGroupId,
66 vspId,activeVersion.toString()));
67 return builder.build();
70 public static ErrorCode getDuplicateVfcAssociationErrorBuilder(){
71 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
72 builder.withId(VendorSoftwareProductErrorCodes
73 .SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED);
74 builder.withCategory(ErrorCategory.APPLICATION);
75 builder.withMessage(SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED_MSG);
76 return builder.build();
79 public static ErrorCode getInvalidAssociationErrorBuilder() {
80 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
81 builder.withId(VendorSoftwareProductErrorCodes.INVALID_COMPONENT_COMPUTE_ASSOCIATION);
82 builder.withCategory(ErrorCategory.APPLICATION);
83 builder.withMessage(INVALID_COMPONENT_COMPUTE_ASSOCIATION_MSG);
84 return builder.build();
87 public static ErrorCode getDuplicateDeploymentFlavorModelErrorBuilder(String name,
89 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
90 builder.withId(VendorSoftwareProductErrorCodes.DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED);
91 builder.withCategory(ErrorCategory.APPLICATION);
92 builder.withMessage(String.format(DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED_MSG,name,vspId));
93 return builder.build();
95 public static ErrorCode getInvalidComputeIdErrorBuilder(String computeFlavorId, String
97 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
98 builder.withId(VendorSoftwareProductErrorCodes.INVALID_COMPUTE_FLAVOR_ID);
99 builder.withCategory(ErrorCategory.APPLICATION);
100 builder.withMessage(String.format(INVALID_COMPUTE_FLAVOR_ID_MSG,computeFlavorId,
102 return builder.build();
105 public static ErrorCode getInvalidComponentComputeAssociationErrorBuilder(String model) {
106 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
107 builder.withId(VendorSoftwareProductErrorCodes.INVALID_COMPONENT_COMPUTE_ASSOCIATION);
108 builder.withCategory(ErrorCategory.APPLICATION);
109 builder.withMessage(String.format(INVALID_COMPONENT_COMPUTE_ASSOCIATION_ERROR_MSG, model));
110 return builder.build();
113 public static ErrorCode getFeatureGroupMandatoryErrorBuilder(String model) {
114 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
115 builder.withId(VendorSoftwareProductErrorCodes.FEATUREGROUP_REQUIRED_IN_DEPLOYMENT_FLAVOR);
116 builder.withCategory(ErrorCategory.APPLICATION);
117 builder.withMessage(String.format(FEATUREGROUP_REQUIRED_IN_DEPLOYMENT_FLAVOR_MSG, model));
118 return builder.build();
121 public static ErrorCode getDeploymentFlavorNameFormatErrorBuilder(String pattern){
122 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
123 builder.withId(VendorSoftwareProductErrorCodes.DEPLOYMENT_FLAVOR_NAME_FORMAT_NOT_ALLOWED);
124 builder.withCategory(ErrorCategory.APPLICATION);
125 builder.withMessage(String.format(DEPLOYMENT_FLAVOUR_NAME_FORMAT_MSG, pattern));
126 return builder.build();