[SDC-29] Amdocs OnBoard 1707 initial commit.
[sdc.git] / openecomp-be / backend / openecomp-sdc-vendor-software-product-manager / src / main / java / org / openecomp / sdc / vendorsoftwareproduct / errors / CompositionEditNotAllowedErrorBuilder.java
1 package org.openecomp.sdc.vendorsoftwareproduct.errors;
2
3 import org.openecomp.sdc.common.errors.ErrorCategory;
4 import org.openecomp.sdc.common.errors.ErrorCode;
5 import org.openecomp.sdc.versioning.dao.types.Version;
6
7
8 public class CompositionEditNotAllowedErrorBuilder {
9   private static final String VSP_COMPOSITION_EDIT_NOT_ALLOWED_MSG =
10       "Composition entities may not be created / deleted for Vendor Software Product %s, version %s"
11           + "whose entities were uploaded";
12   private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
13
14   /**
15    * Instantiates a new error builder.
16    *
17    * @param vendorSoftwareProductId the vendor software product id
18    * @param version                 the version
19    */
20   public CompositionEditNotAllowedErrorBuilder(String vendorSoftwareProductId, Version version) {
21     builder.withId(VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED);
22     builder.withCategory(ErrorCategory.APPLICATION);
23     builder.withMessage(
24         String.format(VSP_COMPOSITION_EDIT_NOT_ALLOWED_MSG, vendorSoftwareProductId,
25             version == null ? null : version.toString()));
26
27   }
28
29   /**
30    * Build error code.
31    *
32    * @return the error code
33    */
34   public ErrorCode build() {
35     return builder.build();
36   }
37 }