2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.openecomp.policy.pap.xacml.rest.elk.client;
23 import java.util.ArrayList;
25 import org.openecomp.policy.rest.adapter.PolicyRestAdapter;
27 import io.searchbox.client.JestResult;
29 public interface ElkConnector {
31 public static final String ELK_URL = "http://localhost:9200";
32 public static final String ELK_INDEX_POLICY = "policy";
34 public enum PolicyIndexType {
42 public enum PolicyType {
53 public enum PolicyBodyType {
61 public JestResult policy(String policyId)
62 throws IllegalStateException, IllegalArgumentException;
64 public boolean delete(PolicyRestAdapter policyData)
65 throws IllegalStateException;
67 public ArrayList<PolicyLocator> policyLocators(PolicyIndexType type, String text,int connector)
68 throws IllegalStateException, IllegalArgumentException;
70 public ArrayList<PolicyLocator> policyLocators(PolicyIndexType type, String text,
71 ArrayList<Pair<ArrayList<String>,ArrayList<String>>> filter_s,int connector)
72 throws IllegalStateException, IllegalArgumentException;
74 public JestResult search(PolicyIndexType type, String text)
75 throws IllegalStateException, IllegalArgumentException;
77 public JestResult search(PolicyIndexType type, String text,
78 ArrayList<Pair<ArrayList<String>,ArrayList<String>>> filter_s)
79 throws IllegalStateException, IllegalArgumentException;
81 public boolean update(PolicyRestAdapter policyData) throws IllegalStateException;
83 public ElkConnector singleton = new ElkConnectorImpl();
85 public static PolicyIndexType toPolicyIndexType(PolicyType type)
86 throws IllegalArgumentException {
88 throw new IllegalArgumentException("Unsupported NULL type conversion");
92 return PolicyIndexType.config;
94 return PolicyIndexType.action;
96 return PolicyIndexType.decision;
98 return PolicyIndexType.closedloop;
100 return PolicyIndexType.closedloop;
102 return PolicyIndexType.config;
104 return PolicyIndexType.config;
106 return PolicyIndexType.all;
108 throw new IllegalArgumentException("Unsupported type conversion to index: " + type.name());
112 public static PolicyIndexType toPolicyIndexType(String policyName)
113 throws IllegalArgumentException {
114 if (policyName == null)
115 throw new IllegalArgumentException("Unsupported NULL policy name conversion");
117 if (policyName.startsWith("Config_Fault")) {
118 return PolicyIndexType.closedloop;
119 } else if (policyName.startsWith("Config_PM")) {
120 return PolicyIndexType.closedloop;
121 } else if (policyName.startsWith("Config_FW")) {
122 return PolicyIndexType.config;
123 } else if (policyName.startsWith("Config_MS")) {
124 return PolicyIndexType.config;
125 }else if (policyName.startsWith("Action")) {
126 return PolicyIndexType.action;
127 } else if (policyName.startsWith("Decision")) {
128 return PolicyIndexType.decision;
129 } else if (policyName.startsWith("Config")) {
130 return PolicyIndexType.config;
132 throw new IllegalArgumentException
133 ("Unsupported policy name conversion to index: " +
138 public static PolicyType toPolicyType(String policyName)
139 throws IllegalArgumentException {
140 if (policyName == null)
141 throw new IllegalArgumentException("Unsupported NULL policy name conversion to Policy Type");
143 if (policyName.startsWith("Config_Fault")) {
144 return PolicyType.Config_Fault;
145 } else if (policyName.startsWith("Config_PM")) {
146 return PolicyType.Config_PM;
147 } else if (policyName.startsWith("Config_FW")) {
148 return PolicyType.Config_FW;
149 } else if (policyName.startsWith("Config_MS")) {
150 return PolicyType.Config_MS;
151 }else if (policyName.startsWith("Action")) {
152 return PolicyType.Action;
153 } else if (policyName.startsWith("Decision")) {
154 return PolicyType.Decision;
155 } else if (policyName.startsWith("Config")) {
156 return PolicyType.Config;
158 throw new IllegalArgumentException
159 ("Unsupported policy name conversion to index: " +