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