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.
16 package org.openecomp.sdc.vendorsoftwareproduct.errors;
18 import lombok.AccessLevel;
19 import lombok.NoArgsConstructor;
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 @NoArgsConstructor(access = AccessLevel.PRIVATE)
25 public class VendorSoftwareProductInvalidErrorBuilder {
27 private static final String VSP_INVALID_MSG = "Vendor software product with Id %s and version %s is invalid - does not contain service model.";
28 private static final String VSP_INVALID_MISSING_DEPLOYMENT_FLAVOR_MSG = "VSP has to have a minimum of one Deployment Flavor defined for being able to be instantiated.Please add a Deployment Flavor and re-submit the VSP.";
29 private static final String CANDIDATE_DATA_NOT_PROCESSED_OR_ABORTED = "Uploaded network package file %s was not processed/aborted.";
30 private static final String INVALID_PROCESSED_CANDIDATE = "Uploaded network package file %s is invalid and need to be aborted";
33 * Instantiates a new Vendor software product invalid error builder.
35 * @param vendorSoftwareProductId the vendor software product id
36 * @param version the version
38 public static ErrorCode vendorSoftwareProductMissingServiceModelErrorBuilder(String vendorSoftwareProductId, Version version) {
39 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
40 builder.withId(VendorSoftwareProductErrorCodes.VSP_INVALID);
41 builder.withCategory(ErrorCategory.APPLICATION);
42 builder.withMessage(String.format(VSP_INVALID_MSG, vendorSoftwareProductId, version.getId()));
43 return builder.build();
47 * Instantiates a new Vendor software product invalid error builder.
49 public static ErrorCode vspMissingDeploymentFlavorErrorBuilder() {
50 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
51 builder.withId(VendorSoftwareProductErrorCodes.VSP_INVALID);
52 builder.withCategory(ErrorCategory.APPLICATION);
53 builder.withMessage(VSP_INVALID_MISSING_DEPLOYMENT_FLAVOR_MSG);
54 return builder.build();
57 public static ErrorCode candidateDataNotProcessedOrAbortedErrorBuilder(String fileName) {
58 ErrorCode.ErrorCodeBuilder builder = getErrorCodeBuilder(VendorSoftwareProductErrorCodes.VSP_INVALID, ErrorCategory.APPLICATION);
59 builder.withMessage(String.format(CANDIDATE_DATA_NOT_PROCESSED_OR_ABORTED, fileName));
60 return builder.build();
63 public static ErrorCode invalidProcessedCandidate(String fileName) {
64 ErrorCode.ErrorCodeBuilder builder = getErrorCodeBuilder(VendorSoftwareProductErrorCodes.VSP_INVALID, ErrorCategory.APPLICATION);
65 builder.withMessage(String.format(INVALID_PROCESSED_CANDIDATE, fileName));
66 return builder.build();
69 public static ErrorCode.ErrorCodeBuilder getErrorCodeBuilder(String errorCode, ErrorCategory errorCategory) {
70 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
71 builder.withId(errorCode);
72 builder.withCategory(errorCategory);