add SDC client and reception handle
[multicloud/framework.git] / artifactbroker / reception / src / main / java / org / onap / policy / distribution / reception / parameters / PluginHandlerParameters.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2018 Ericsson. All rights reserved.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.distribution.reception.parameters;
22
23 import java.util.Map;
24 import java.util.Map.Entry;
25
26 import org.onap.policy.common.parameters.GroupValidationResult;
27 import org.onap.policy.common.parameters.ParameterGroup;
28 import org.onap.policy.common.parameters.ValidationStatus;
29 import org.onap.policy.distribution.forwarding.parameters.ArtifactForwarderParameters;
30
31 /**
32  * Class to hold all the plugin handler parameters.
33  *
34  * @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
35  */
36 public class PluginHandlerParameters implements ParameterGroup {
37
38     private static final String PLUGIN_HANDLER = "_PluginHandler";
39
40     private String name;
41     private Map<String, ArtifactForwarderParameters> artifactForwarders;
42
43     /**
44      * Constructor for instantiating PluginHandlerParameters.
45      *
46      * @param artifactForwarders the map of policy forwarders
47      */
48     public PluginHandlerParameters(
49             final Map<String, ArtifactForwarderParameters> artifactForwarders) {
50         this.artifactForwarders = artifactForwarders;
51     }
52
53     /**
54      * Return the artifactForwarders of this PluginHandlerParameters instance.
55      *
56      * @return the artifactForwarders
57      */
58     public Map<String, ArtifactForwarderParameters> getArtifactForwarders() {
59         return artifactForwarders;
60     }
61
62     @Override
63     public String getName() {
64         return name + PLUGIN_HANDLER;
65     }
66
67     /**
68      * Validate the plugin handler parameters.
69      *
70      */
71     @Override
72     public GroupValidationResult validate() {
73         final GroupValidationResult validationResult = new GroupValidationResult(this);
74         if (artifactForwarders == null || artifactForwarders.size() == 0) {
75             validationResult.setResult("artifactForwarders", ValidationStatus.INVALID,
76                     "must have at least one policy forwarder");
77         } else {
78             for (final Entry<String, ArtifactForwarderParameters> nestedGroupEntry : artifactForwarders.entrySet()) {
79                 validationResult.setResult("artifactForwarders", nestedGroupEntry.getKey(),
80                         nestedGroupEntry.getValue().validate());
81             }
82         }
83         return validationResult;
84     }
85
86     /**
87      * Set the name of this group.
88      *
89      * @param name the name to set.
90      */
91     public void setName(final String name) {
92         this.name = name;
93     }
94 }