2 * Copyright 2017-2022 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 jakarta.ws.rs.client.Entity;
\r
19 import jakarta.ws.rs.core.MediaType;
\r
20 import org.onap.holmes.common.utils.CommonUtils;
\r
21 import org.onap.holmes.common.utils.JerseyClient;
\r
22 import org.onap.holmes.rulemgt.bean.request.CorrelationCheckRule4Engine;
\r
23 import org.onap.holmes.rulemgt.bean.request.CorrelationDeployRule4Engine;
\r
24 import org.springframework.stereotype.Service;
\r
26 import static org.onap.holmes.rulemgt.constant.RuleMgtConstant.ENGINE_PATH;
\r
29 public class EngineService {
\r
31 private static final String PORT = "9102";
\r
32 private static final String SEP = "//";
\r
33 private static final String COLON = ":";
\r
35 protected boolean delete(String packageName, String ip) {
\r
36 return JerseyClient.newInstance()
\r
38 .delete(getUrl(ip)) != null;
\r
41 protected boolean check(CorrelationCheckRule4Engine correlationCheckRule4Engine, String ip) {
\r
42 return JerseyClient.newInstance()
\r
43 .header("Accept", MediaType.APPLICATION_JSON)
\r
44 .post(getUrl(ip), Entity.json(correlationCheckRule4Engine)) != null;
\r
47 protected String deploy(CorrelationDeployRule4Engine correlationDeployRule4Engine, String ip) {
\r
48 return JerseyClient.newInstance()
\r
49 .header("Accept", MediaType.APPLICATION_JSON)
\r
50 .put(getUrl(ip), Entity.json(correlationDeployRule4Engine));
\r
53 private String getRequestPref() {
\r
54 return CommonUtils.isHttpsEnabled() ? JerseyClient.PROTOCOL_HTTPS : JerseyClient.PROTOCOL_HTTP;
\r
57 private String getUrl(String ip) {
\r
58 return new StringBuilder(getRequestPref())
\r
64 .append(ENGINE_PATH)
\r