2 * Copyright © 2016-2018 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 VendorSoftwareProductInvalidErrorBuilder {
24 private static final String VSP_INVALID_MSG =
25 "Vendor software product with Id %s and version %s is invalid - does not contain "
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 "
29 + "Deployment Flavor and re-submit the VSP.";
30 private static final String CANDIDATE_DATA_NOT_PROCESSED_OR_ABORTED = "Uploaded network package"
31 + " file %s was not processed/aborted.";
32 private static final String INVALID_PROCESSED_CANDIDATE = "Uploaded network package file %s"
33 + " is invalid and need to be aborted";
35 private VendorSoftwareProductInvalidErrorBuilder() {
40 * Instantiates a new Vendor software product invalid error builder.
42 * @param vendorSoftwareProductId the vendor software product id
43 * @param version the version
45 public static ErrorCode vendorSoftwareProductMissingServiceModelErrorBuilder(String
46 vendorSoftwareProductId,
48 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
49 builder.withId(VendorSoftwareProductErrorCodes.VSP_INVALID);
50 builder.withCategory(ErrorCategory.APPLICATION);
52 .withMessage(String.format(VSP_INVALID_MSG, vendorSoftwareProductId, version.getId()));
53 return builder.build();
57 * Instantiates a new Vendor software product invalid error builder.
59 public static ErrorCode vspMissingDeploymentFlavorErrorBuilder() {
60 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
61 builder.withId(VendorSoftwareProductErrorCodes.VSP_INVALID);
62 builder.withCategory(ErrorCategory.APPLICATION);
64 .withMessage(VSP_INVALID_MISSING_DEPLOYMENT_FLAVOR_MSG);
65 return builder.build();
68 public static ErrorCode candidateDataNotProcessedOrAbortedErrorBuilder(String fileName) {
69 ErrorCode.ErrorCodeBuilder builder = getErrorCodeBuilder(VendorSoftwareProductErrorCodes
70 .VSP_INVALID, ErrorCategory.APPLICATION);
71 builder.withMessage(String.format(CANDIDATE_DATA_NOT_PROCESSED_OR_ABORTED, fileName));
72 return builder.build();
75 public static ErrorCode invalidProcessedCandidate(String fileName) {
76 ErrorCode.ErrorCodeBuilder builder = getErrorCodeBuilder(VendorSoftwareProductErrorCodes
77 .VSP_INVALID, ErrorCategory.APPLICATION);
78 builder.withMessage(String.format(INVALID_PROCESSED_CANDIDATE, fileName));
79 return builder.build();
82 public static ErrorCode.ErrorCodeBuilder getErrorCodeBuilder(String errorCode, ErrorCategory
84 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
85 builder.withId(errorCode);
86 builder.withCategory(errorCategory);