2 * Copyright 2017-2021 ZTE Corporation.
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
16 package org.onap.holmes.rulemgt.bolt.enginebolt;
\r
18 import org.jvnet.hk2.annotations.Service;
\r
19 import org.onap.holmes.common.utils.CommonUtils;
\r
20 import org.onap.holmes.common.utils.JerseyClient;
\r
21 import org.onap.holmes.rulemgt.bean.request.CorrelationCheckRule4Engine;
\r
22 import org.onap.holmes.rulemgt.bean.request.CorrelationDeployRule4Engine;
\r
24 import javax.ws.rs.client.Entity;
\r
25 import javax.ws.rs.core.MediaType;
\r
27 import static org.onap.holmes.rulemgt.constant.RuleMgtConstant.ENGINE_PATH;
\r
30 public class EngineService {
\r
32 private static final String PORT = "9102";
\r
33 private static final String SEP = "//";
\r
34 private static final String COLON = ":";
\r
36 protected boolean delete(String packageName, String ip) {
\r
37 return new JerseyClient()
\r
39 .delete(getUrl(ip)) != null;
\r
42 protected boolean check(CorrelationCheckRule4Engine correlationCheckRule4Engine, String ip) {
\r
43 return new JerseyClient()
\r
44 .header("Accept", MediaType.APPLICATION_JSON)
\r
45 .post(getUrl(ip), Entity.json(correlationCheckRule4Engine)) != null;
\r
48 protected String deploy(CorrelationDeployRule4Engine correlationDeployRule4Engine, String ip) {
\r
49 return new JerseyClient()
\r
50 .header("Accept", MediaType.APPLICATION_JSON)
\r
51 .put(getUrl(ip), Entity.json(correlationDeployRule4Engine));
\r
55 private String getRequestPref() {
\r
56 return CommonUtils.isHttpsEnabled() ? JerseyClient.PROTOCOL_HTTPS : JerseyClient.PROTOCOL_HTTP;
\r
59 private String getUrl(String ip) {
\r
60 return new StringBuilder(getRequestPref())
\r
65 .append(ENGINE_PATH)
\r