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 org.openecomp.sdc.common.errors.ErrorCategory;
19 import org.openecomp.sdc.common.errors.ErrorCode;
20 import org.openecomp.sdc.versioning.dao.types.Version;
22 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 " + "service model.";
26 private static final String VSP_INVALID_MISSING_DEPLOYMENT_FLAVOR_MSG =
27 "VSP has to have a " + "minimum of one Deployment Flavor defined for being able to be instantiated.Please add a "
28 + "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";
32 private VendorSoftwareProductInvalidErrorBuilder() {
36 * Instantiates a new Vendor software product invalid error builder.
38 * @param vendorSoftwareProductId the vendor software product id
39 * @param version the version
41 public static ErrorCode vendorSoftwareProductMissingServiceModelErrorBuilder(String vendorSoftwareProductId, Version version) {
42 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
43 builder.withId(VendorSoftwareProductErrorCodes.VSP_INVALID);
44 builder.withCategory(ErrorCategory.APPLICATION);
45 builder.withMessage(String.format(VSP_INVALID_MSG, vendorSoftwareProductId, version.getId()));
46 return builder.build();
50 * Instantiates a new Vendor software product invalid error builder.
52 public static ErrorCode vspMissingDeploymentFlavorErrorBuilder() {
53 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
54 builder.withId(VendorSoftwareProductErrorCodes.VSP_INVALID);
55 builder.withCategory(ErrorCategory.APPLICATION);
56 builder.withMessage(VSP_INVALID_MISSING_DEPLOYMENT_FLAVOR_MSG);
57 return builder.build();
60 public static ErrorCode candidateDataNotProcessedOrAbortedErrorBuilder(String fileName) {
61 ErrorCode.ErrorCodeBuilder builder = getErrorCodeBuilder(VendorSoftwareProductErrorCodes.VSP_INVALID, ErrorCategory.APPLICATION);
62 builder.withMessage(String.format(CANDIDATE_DATA_NOT_PROCESSED_OR_ABORTED, fileName));
63 return builder.build();
66 public static ErrorCode invalidProcessedCandidate(String fileName) {
67 ErrorCode.ErrorCodeBuilder builder = getErrorCodeBuilder(VendorSoftwareProductErrorCodes.VSP_INVALID, ErrorCategory.APPLICATION);
68 builder.withMessage(String.format(INVALID_PROCESSED_CANDIDATE, fileName));
69 return builder.build();
72 public static ErrorCode.ErrorCodeBuilder getErrorCodeBuilder(String errorCode, ErrorCategory errorCategory) {
73 ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
74 builder.withId(errorCode);
75 builder.withCategory(errorCategory);