re base code
[sdc.git] / openecomp-be / backend / openecomp-sdc-vendor-software-product-manager / src / main / java / org / openecomp / sdc / vendorsoftwareproduct / errors / ComponentDependencyModelErrorBuilder.java
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
20 import org.openecomp.sdc.common.errors.ErrorCategory;
21 import org.openecomp.sdc.common.errors.ErrorCode;
22
23 import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.*;
24
25 public class ComponentDependencyModelErrorBuilder {
26
27   private static final String CYCLIC_DEPENDENCY_COMPONENT_MSG = "Cyclic dependency exists between"
28       + " components.";
29
30   private static final String INVALID_REALTION_TYPE_MSG = "Invalid relation type for components.";
31
32   private static final String NO_SOURCE_COMPONENT_MSG = "Source component is mandatory.";
33
34   private static final String SOURCE_TARGET_COMPONENT_EQUAL_MSG = "Source and target components "
35       + "are same.";
36
37   private ComponentDependencyModelErrorBuilder(){
38
39   }
40
41   public static ErrorCode getcyclicDependencyComponentErrorBuilder() {
42     ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
43     builder.withId(CYCLIC_DEPENDENCY_IN_COMPONENTS);
44     builder.withCategory(ErrorCategory.APPLICATION);
45     builder.withMessage(String.format(CYCLIC_DEPENDENCY_COMPONENT_MSG));
46     return builder.build();
47   }
48
49   public static ErrorCode getInvalidRelationTypeErrorBuilder() {
50     ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
51     builder.withId(INVALID_COMPONENT_RELATION_TYPE);
52     builder.withCategory(ErrorCategory.APPLICATION);
53     builder.withMessage(String.format(INVALID_REALTION_TYPE_MSG));
54     return builder.build();
55   }
56
57   public static ErrorCode getNoSourceComponentErrorBuilder() {
58     ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
59     builder.withId(NO_SOURCE_COMPONENT);
60     builder.withCategory(ErrorCategory.APPLICATION);
61     builder.withMessage(String.format(NO_SOURCE_COMPONENT_MSG));
62     return builder.build();
63   }
64
65   public static ErrorCode getSourceTargetComponentEqualErrorBuilder() {
66     ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
67     builder.withId(SAME_SOURCE_TARGET_COMPONENT);
68     builder.withCategory(ErrorCategory.APPLICATION);
69     builder.withMessage(String.format(SOURCE_TARGET_COMPONENT_EQUAL_MSG));
70     return builder.build();
71   }
72 }