f0a9f8f31c079a732a3081ac365a02430669f0c4
[sdc.git] /
1 package org.openecomp.sdc.vendorsoftwareproduct.errors;
2
3
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;
7
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 " +
13                     "%s.";
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. " +
26             "Please fix the Deployment Flavor %s and re-submit the VSP.";
27
28     private static final String FEATUREGROUP_REQUIRED_IN_DEPLOYMENT_FLAVOR_MSG = "VSP cannot be " +
29             "submitted with an invalid Deployment Flavor. All Deployment Flavor should have " +
30             "FeatureGroup. Please fix the Deployment Flavor %s and re-submit the VSP.";
31
32     public static ErrorCode getAddDeploymentNotSupportedHeatOnboardErrorBuilder(){
33         ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
34         builder.withId(VendorSoftwareProductErrorCodes.CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
35         builder.withCategory(ErrorCategory.APPLICATION);
36         builder.withMessage(String.format(CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG));
37         return builder.build();
38     }
39
40     public static ErrorCode getFeatureGroupNotexistErrorBuilder( String featureGroupId, String
41             VspId, Version activeVersion){
42         ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
43         builder.withId(VendorSoftwareProductErrorCodes.FEATURE_GROUP_NOT_EXIST_FOR_VSP);
44         builder.withCategory(ErrorCategory.APPLICATION);
45         builder.withMessage(String.format(FEATURE_GROUP_NOT_EXIST_FOR_VSP_MSG,featureGroupId,
46                 VspId,activeVersion.toString()));
47         return builder.build();
48     }
49
50     public static ErrorCode getDuplicateVfcAssociationErrorBuilder(){
51         ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
52         builder.withId(VendorSoftwareProductErrorCodes.SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED);
53         builder.withCategory(ErrorCategory.APPLICATION);
54         builder.withMessage(String.format(SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED_MSG));
55         return builder.build();
56     }
57
58     public static ErrorCode getInvalidAssociationErrorBuilder(){
59         ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
60         builder.withId(VendorSoftwareProductErrorCodes.INVALID_COMPONENT_COMPUTE_ASSOCIATION);
61         builder.withCategory(ErrorCategory.APPLICATION);
62         builder.withMessage(String.format(INVALID_COMPONENT_COMPUTE_ASSOCIATION_MSG));
63         return builder.build();
64     }
65
66     public static ErrorCode getDuplicateDeploymentFlavorModelErrorBuilder(String name, String vspId){
67         ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
68         builder.withId(VendorSoftwareProductErrorCodes.DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED);
69         builder.withCategory(ErrorCategory.APPLICATION);
70         builder.withMessage(String.format(DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED_MSG,name,vspId));
71         return builder.build();
72     }
73     public static ErrorCode getInvalidComputeIdErrorBuilder( String computeFlavorId, String
74             vfcId){
75         ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
76         builder.withId(VendorSoftwareProductErrorCodes.INVALID_COMPUTE_FLAVOR_ID);
77         builder.withCategory(ErrorCategory.APPLICATION);
78         builder.withMessage(String.format(INVALID_COMPUTE_FLAVOR_ID_MSG,computeFlavorId,
79                 vfcId));
80         return builder.build();
81     }
82
83     public static ErrorCode getInvalidComponentComputeAssociationErrorBuilder(String model){
84         ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
85         builder.withId(VendorSoftwareProductErrorCodes.INVALID_COMPONENT_COMPUTE_ASSOCIATION);
86         builder.withCategory(ErrorCategory.APPLICATION);
87         builder.withMessage(String.format(INVALID_COMPONENT_COMPUTE_ASSOCIATION_ERROR_MSG, model));
88         return builder.build();
89     }
90
91     public static ErrorCode getFeatureGroupMandatoryErrorBuilder(String model){
92         ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
93         builder.withId(VendorSoftwareProductErrorCodes.FEATUREGROUP_REQUIRED_IN_DEPLOYMENT_FLAVOR);
94         builder.withCategory(ErrorCategory.APPLICATION);
95         builder.withMessage(String.format(FEATUREGROUP_REQUIRED_IN_DEPLOYMENT_FLAVOR_MSG, model));
96         return builder.build();
97     }
98
99     public static ErrorCode getDeploymentFlavorNameFormatErrorBuilder(String pattern){
100         ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
101         builder.withId(VendorSoftwareProductErrorCodes.DEPLOYMENT_FLAVOR_NAME_FORMAT_NOT_ALLOWED);
102         builder.withCategory(ErrorCategory.APPLICATION);
103         builder.withMessage(String.format(DEPLOYMENT_FLAVOUR_NAME_FORMAT_MSG, pattern));
104         return builder.build();
105     }
106 }