ca20d97e4a3f379432a07ce6b21aec362611aed8
[sdc.git] /
1 /*
2  * Copyright © 2016-2017 European Support Limited
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 package org.openecomp.sdc.vendorsoftwareproduct.errors;
18
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;
22
23 public class VendorSoftwareProductInvalidErrorBuilder {
24   private static final String VSP_INVALID_MSG =
25       "Vendor software product with Id %s and version %s is invalid - does not contain "
26           + "service model.";
27   private static final String VSP_INVALID_MISSING_DEPLOYMENT_FLAVOR_MSG = "VSP has to have a " +
28       "minimum of one Deployment Flavor defined for being able to be instantiated.Please add a Deployment Flavor and re-submit the VSP.";
29
30   private VendorSoftwareProductInvalidErrorBuilder() {
31
32   }
33
34   /**
35    * Instantiates a new Vendor software product invalid error builder.
36    *
37    * @param vendorSoftwareProductId the vendor software product id
38    * @param version                 the version
39    */
40   public static ErrorCode vendorSoftwareProductMissingServiceModelErrorBuilder(String
41                                                                                    vendorSoftwareProductId,
42                                                                                Version version) {
43     ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
44     builder.withId(VendorSoftwareProductErrorCodes.VSP_INVALID);
45     builder.withCategory(ErrorCategory.APPLICATION);
46     builder
47         .withMessage(String.format(VSP_INVALID_MSG, vendorSoftwareProductId, version.getId()));
48     return builder.build();
49   }
50
51   /**
52    * Instantiates a new Vendor software product invalid error builder.
53    */
54   public static ErrorCode vspMissingDeploymentFlavorErrorBuilder() {
55     ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
56     builder.withId(VendorSoftwareProductErrorCodes.VSP_INVALID);
57     builder.withCategory(ErrorCategory.APPLICATION);
58     builder
59         .withMessage(VSP_INVALID_MISSING_DEPLOYMENT_FLAVOR_MSG);
60     return builder.build();
61   }
62
63 }