1 package org.openecomp.sdc.vendorsoftwareproduct.errors;
4 import org.openecomp.sdc.common.errors.ErrorCategory;
5 import org.openecomp.sdc.common.errors.ErrorCode;
6 import org.openecomp.sdc.versioning.dao.types.Version;
8 public class DeploymentFlavorErrorBuilder {
9 private static final String CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG=
10 "Deployment Flavor cannot be added for VSPs onboarded with HEAT.";
11 private static final String FEATURE_GROUP_NOT_EXIST_FOR_VSP_MSG=
12 "Invalid request,Feature Group with Id %s does not exist for Vsp with Id %s and version " +
14 private static final String INVALID_COMPONENT_COMPUTE_ASSOCIATION_MSG
15 ="Invalid request,for valid association please provide ComponentId for Compute Flavor";
16 private static final String SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED_MSG=
17 "Invalid Request,Same Vfc cannot be associated more than once.";
18 private static final String DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED_MSG =
19 "Invalid request, Deployment Flavor with model %s already exists for Vsp with Id %s.";
20 private static final String DEPLOYMENT_FLAVOUR_NAME_FORMAT_MSG = "Field does not conform to predefined criteria"
21 + ": name : must match %s";
22 private static final String INVALID_COMPUTE_FLAVOR_ID_MSG =
23 "Invalid request, Compute Flavor with Id %s does not exist for VFC with Id %s.";
24 private static final String INVALID_COMPONENT_COMPUTE_ASSOCIATION_ERROR_MSG="VSP cannot be " +
25 "submitted with an invalid Deployment Flavor. All Deployment Flavor should have atleast a VFC included with it's required Compute needs. Please fix the Deployment Flavor and re-submit the VSP.";
27 private static final String FEATUREGROUP_REQUIRED_IN_DEPLOYMENT_FLAVOR_MSG = "VSP cannot be " +
28 "submitted with an invalid Deployment Flavor. All Deployment Flavor should have " +
29 "FeatureGroup. Please fix the Deployment Flavor and re-submit the VSP.";
31 public static ErrorCode getAddDeploymentNotSupportedHeatOnboardErrorBuilder(){
32 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
33 builder.withId(VendorSoftwareProductErrorCodes.CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
34 builder.withCategory(ErrorCategory.APPLICATION);
35 builder.withMessage(String.format(CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG));
36 return builder.build();
39 public static ErrorCode getFeatureGroupNotexistErrorBuilder( String featureGroupId, String
40 VspId, Version activeVersion){
41 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
42 builder.withId(VendorSoftwareProductErrorCodes.FEATURE_GROUP_NOT_EXIST_FOR_VSP);
43 builder.withCategory(ErrorCategory.APPLICATION);
44 builder.withMessage(String.format(FEATURE_GROUP_NOT_EXIST_FOR_VSP_MSG,featureGroupId,
45 VspId,activeVersion.toString()));
46 return builder.build();
49 public static ErrorCode getDuplicateVfcAssociationErrorBuilder(){
50 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
51 builder.withId(VendorSoftwareProductErrorCodes.SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED);
52 builder.withCategory(ErrorCategory.APPLICATION);
53 builder.withMessage(String.format(SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED_MSG));
54 return builder.build();
57 public static ErrorCode getInvalidAssociationErrorBuilder(){
58 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
59 builder.withId(VendorSoftwareProductErrorCodes.INVALID_COMPONENT_COMPUTE_ASSOCIATION);
60 builder.withCategory(ErrorCategory.APPLICATION);
61 builder.withMessage(String.format(INVALID_COMPONENT_COMPUTE_ASSOCIATION_MSG));
62 return builder.build();
65 public static ErrorCode getDuplicateDeploymentFlavorModelErrorBuilder(String name, String vspId){
66 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
67 builder.withId(VendorSoftwareProductErrorCodes.DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED);
68 builder.withCategory(ErrorCategory.APPLICATION);
69 builder.withMessage(String.format(DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED_MSG,name,vspId));
70 return builder.build();
72 public static ErrorCode getInvalidComputeIdErrorBuilder( String computeFlavorId, String
74 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
75 builder.withId(VendorSoftwareProductErrorCodes.INVALID_COMPUTE_FLAVOR_ID);
76 builder.withCategory(ErrorCategory.APPLICATION);
77 builder.withMessage(String.format(INVALID_COMPUTE_FLAVOR_ID_MSG,computeFlavorId,
79 return builder.build();
82 public static ErrorCode getInvalidComponentComputeAssociationErrorBuilder(){
83 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
84 builder.withId(VendorSoftwareProductErrorCodes.INVALID_COMPONENT_COMPUTE_ASSOCIATION);
85 builder.withCategory(ErrorCategory.APPLICATION);
86 builder.withMessage(String.format(INVALID_COMPONENT_COMPUTE_ASSOCIATION_ERROR_MSG));
87 return builder.build();
90 public static ErrorCode getFeatureGroupMandatoryErrorBuilder(){
91 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
92 builder.withId(VendorSoftwareProductErrorCodes.FEATUREGROUP_REQUIRED_IN_DEPLOYMENT_FLAVOR);
93 builder.withCategory(ErrorCategory.APPLICATION);
94 builder.withMessage(String.format(FEATUREGROUP_REQUIRED_IN_DEPLOYMENT_FLAVOR_MSG));
95 return builder.build();
98 public static ErrorCode getDeploymentFlavorNameFormatErrorBuilder(String pattern){
99 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
100 builder.withId(VendorSoftwareProductErrorCodes.DEPLOYMENT_FLAVOR_NAME_FORMAT_NOT_ALLOWED);
101 builder.withCategory(ErrorCategory.APPLICATION);
102 builder.withMessage(String.format(DEPLOYMENT_FLAVOUR_NAME_FORMAT_MSG, pattern));
103 return builder.build();