summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzhangab <zhanganbing@chinamobile.com>2018-04-23 17:51:09 +0800
committerzhangab <zhanganbing@chinamobile.com>2018-04-23 17:51:16 +0800
commit45e1f95014548aa05120d2c304b0b920b46e79e3 (patch)
treed88e0cfdea54f98e7b226a799ff4f17d2bac08dd
parentd698af153772ca4351ad3b23fbb987fc749890af (diff)
delete useless java code
Change-Id: I9732a97e9e3fedda48eb32c476393d8617349275 Issue-ID: USECASEUI-103 Signed-off-by: zhangab <zhanganbing@chinamobile.com>
-rw-r--r--usecaseui-common/src/main/java/org/onap/portal/bean/MsbRegisterBean.java80
-rw-r--r--usecaseui-common/src/main/java/org/onap/portal/bean/ServiceNodeBean.java48
-rw-r--r--usecaseui-common/src/main/java/org/onap/portal/system/CommonUtil.java27
-rw-r--r--usecaseui-common/src/main/java/org/onap/portal/system/Constants.java20
-rw-r--r--usecaseui-common/src/main/java/org/onap/portal/system/RegisterService.java181
-rw-r--r--usecaseui-common/src/main/java/org/onap/portal/system/SystemListener.java39
-rw-r--r--usecaseui-common/src/main/webapp/WEB-INF/web.xml1
7 files changed, 0 insertions, 396 deletions
diff --git a/usecaseui-common/src/main/java/org/onap/portal/bean/MsbRegisterBean.java b/usecaseui-common/src/main/java/org/onap/portal/bean/MsbRegisterBean.java
deleted file mode 100644
index 56d09411..00000000
--- a/usecaseui-common/src/main/java/org/onap/portal/bean/MsbRegisterBean.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.portal.bean;
-
-import java.util.List;
-
-public class MsbRegisterBean {
- private String serviceName = "";
-
- private String lb_policy = "";
-
- private String url = "";
-
- private String protocol = "";
-
- private String visualRange = "";
-
- private List<ServiceNodeBean> nodes;
-
- public String getServiceName() {
- return serviceName;
- }
-
- public void setServiceName(String serviceName) {
- this.serviceName = serviceName;
- }
-
- public String getLb_policy() {
- return lb_policy;
- }
-
- public void setLb_policy(String lb_policy) {
- this.lb_policy = lb_policy;
- }
-
- public String getUrl() {
- return url;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- public String getProtocol() {
- return protocol;
- }
-
- public void setProtocol(String protocol) {
- this.protocol = protocol;
- }
-
- public String getVisualRange() {
- return visualRange;
- }
-
- public void setVisualRange(String visualRange) {
- this.visualRange = visualRange;
- }
-
- public List<ServiceNodeBean> getNodes() {
- return nodes;
- }
-
- public void setNodes(List<ServiceNodeBean> nodes) {
- this.nodes = nodes;
- }
-}
diff --git a/usecaseui-common/src/main/java/org/onap/portal/bean/ServiceNodeBean.java b/usecaseui-common/src/main/java/org/onap/portal/bean/ServiceNodeBean.java
deleted file mode 100644
index 47636e20..00000000
--- a/usecaseui-common/src/main/java/org/onap/portal/bean/ServiceNodeBean.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.portal.bean;
-
-public class ServiceNodeBean {
- private String ip = "";
-
- private String port = "";
-
- private int ttl = 0;
-
- public String getIp() {
- return ip;
- }
-
- public void setIp(String ip) {
- this.ip = ip;
- }
-
- public String getPort() {
- return port;
- }
-
- public void setPort(String port) {
- this.port = port;
- }
-
- public int getTtl() {
- return ttl;
- }
-
- public void setTtl(int ttl) {
- this.ttl = ttl;
- }
-}
diff --git a/usecaseui-common/src/main/java/org/onap/portal/system/CommonUtil.java b/usecaseui-common/src/main/java/org/onap/portal/system/CommonUtil.java
deleted file mode 100644
index 122f983d..00000000
--- a/usecaseui-common/src/main/java/org/onap/portal/system/CommonUtil.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.portal.system;
-
-public class CommonUtil {
-
- public static boolean isEmpty(String str) {
- if (null == str || "".equals(str.trim())) {
- return true;
- } else {
- return false;
- }
- }
-}
diff --git a/usecaseui-common/src/main/java/org/onap/portal/system/Constants.java b/usecaseui-common/src/main/java/org/onap/portal/system/Constants.java
deleted file mode 100644
index c239f3e6..00000000
--- a/usecaseui-common/src/main/java/org/onap/portal/system/Constants.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.portal.system;
-
-public class Constants {
- public final static String MARK_COLON = ":";
-}
diff --git a/usecaseui-common/src/main/java/org/onap/portal/system/RegisterService.java b/usecaseui-common/src/main/java/org/onap/portal/system/RegisterService.java
deleted file mode 100644
index d5896917..00000000
--- a/usecaseui-common/src/main/java/org/onap/portal/system/RegisterService.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.portal.system;
-
-import java.io.File;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.*;
-
-import net.sf.json.JSONObject;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.util.EntityUtils;
-import org.apache.commons.httpclient.HttpStatus;
-import org.dom4j.Document;
-import org.dom4j.Element;
-import org.dom4j.io.SAXReader;
-import org.onap.msb.sdk.discovery.common.RouteException;
-import org.onap.msb.sdk.discovery.entity.MicroServiceInfo;
-import org.onap.msb.sdk.discovery.entity.Node;
-import org.onap.msb.sdk.httpclient.msb.MSBServiceClient;
-import org.onap.portal.bean.MsbRegisterBean;
-import org.onap.portal.bean.ServiceNodeBean;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class RegisterService {
-
- private final static Logger logger = LoggerFactory.getLogger(RegisterService.class);
-
- public static HashMap<String, String> msbHostMap = new HashMap<String, String>();
- public static List<HashMap<String, String>> registerList = new ArrayList<HashMap<String, String>>();
-
- public static void registerMsb(String configPath) {
- File inputXml = new File(configPath);
- SAXReader saxReader = new SAXReader();
-
- try {
- Document document = saxReader.read(inputXml);
- Element rootNode = document.getRootElement();
- getMsbHostInfo(rootNode);
- getRegisterList(rootNode);
-
- String url = msbHostMap.get("hostIp") + Constants.MARK_COLON + msbHostMap.get("hostPort") + msbHostMap.get("msbApiRootDomain");
- for (int i = 0; i < registerList.size(); i++) {
- HashMap<String, String> registerInfo = registerList.get(i);
-
- ServiceNodeBean serviceNode = new ServiceNodeBean();
- serviceNode.setIp(registerInfo.get("ip"));
- serviceNode.setPort(registerInfo.get("port"));
- serviceNode.setTtl(Integer.valueOf(registerInfo.get("ttl")));
- List<ServiceNodeBean> nodeList = new ArrayList<ServiceNodeBean>();
- nodeList.add(serviceNode);
-
- MsbRegisterBean registerBean = new MsbRegisterBean();
- registerBean.setNodes(nodeList);
- registerBean.setServiceName(registerInfo.get("serviceName"));
- registerBean.setUrl(registerInfo.get("url"));
- registerBean.setProtocol(registerInfo.get("protocol"));
- registerBean.setVisualRange(registerInfo.get("visualRange"));
- registerBean.setLb_policy(registerInfo.get("lb_policy"));
-
- JSONObject registerObj = JSONObject.fromObject(registerBean);
- String registerResponse = registerPortalService(registerBean.getServiceName(), url, registerObj, "");
- }
- logger.info("open-o portal register task succeeded.");
- } catch (Exception e){
- logger.error("open-o portal register task failed.");
- logger.error(e.getMessage());
- }
- }
-
- private static void getMsbHostInfo(Element rootNode) {
- Element msbHostNode = rootNode.element("msbHost");
- Iterator iter = msbHostNode.elementIterator();
-
- while (iter.hasNext()) {
- Element element = (Element) iter.next();
- msbHostMap.put(element.getName(), element.getText());
- }
- }
-
- private static void getRegisterList(Element rootNode) {
- Element registerListNode = rootNode.element("registerList");
- Iterator iRegisterList = registerListNode.elementIterator();
-
- while (iRegisterList.hasNext()) {
- HashMap<String, String> registerMap = new HashMap<String, String>();
- Element registerInfo = (Element) iRegisterList.next();
- Iterator iRegisterInfo = registerInfo.elementIterator();
-
- while (iRegisterInfo.hasNext()) {
- Element element = (Element) iRegisterInfo.next();
- registerMap.put(element.getName(), element.getText());
- }
- registerList.add(registerMap);
- }
- }
-
- private static String registerPortalService(String serviceName, String url, JSONObject json, String token) {
- DefaultHttpClient client = new DefaultHttpClient();
- HttpPost post = new HttpPost(url);
- String response = null;
-
- try {
- if (null != json) {
- StringEntity s = new StringEntity(json.toString());
- s.setContentEncoding("UTF-8");
- s.setContentType("application/json");
- post.setEntity(s);
- }
- if (!CommonUtil.isEmpty(token)) {
- post.addHeader("X-Auth-Token", token);
- }
- HttpResponse res = client.execute(post);
- if (res.getStatusLine().getStatusCode() == HttpStatus.SC_OK
- || res.getStatusLine().getStatusCode() == HttpStatus.SC_CREATED) {
- String result = EntityUtils.toString(res.getEntity());
- if (!CommonUtil.isEmpty(result)) {
- response = result;
- } else {
- response = null;
- }
- }
- logger.info("register task [" + serviceName + "] completed successfully.");
- } catch (Exception e) {
- logger.error("register task [" + serviceName + "] failed because of errors.");
- logger.error(e.getMessage());
- }
-
- return response;
- }
-
- public static void registerUUI() {
- String msbAddress = System.getenv("MSB_ADDR");
- if (msbAddress == null || msbAddress.isEmpty()) {
- return;
- }
- if (msbAddress.contains(":")) {
- String[] ipAndPort = msbAddress.split(":");
- MSBServiceClient msbClient = new MSBServiceClient(ipAndPort[0], Integer.parseInt(ipAndPort[1]));
-
- MicroServiceInfo msinfo = new MicroServiceInfo();
- msinfo.setServiceName("usecase-ui");
- msinfo.setVersion("v1");
- msinfo.setUrl("/usecase-ui");
- msinfo.setProtocol("UI");
- msinfo.setVisualRange("1");
-
- try {
- Set<Node> nodes = new HashSet<>();
- Node node1 = new Node();
- node1.setIp(InetAddress.getLocalHost().getHostAddress());
- node1.setPort("8080");
- nodes.add(node1);
- msinfo.setNodes(nodes);
- msbClient.registerMicroServiceInfo(msinfo, false);
- } catch (UnknownHostException e) {
- e.printStackTrace();
- } catch (RouteException e) {
- e.printStackTrace();
- }
- }
- }
-}
diff --git a/usecaseui-common/src/main/java/org/onap/portal/system/SystemListener.java b/usecaseui-common/src/main/java/org/onap/portal/system/SystemListener.java
deleted file mode 100644
index 45dfb192..00000000
--- a/usecaseui-common/src/main/java/org/onap/portal/system/SystemListener.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright 2016-2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onap.portal.system;
-
-import java.io.File;
-
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SystemListener implements ServletContextListener {
-
- private final Logger logger = LoggerFactory.getLogger(this.getClass());
-
- public void contextDestroyed(ServletContextEvent sce) {
- }
-
- public void contextInitialized(ServletContextEvent servletContextEvent) {
- logger.info("usecase ui register task begin.");
-// String registerFilePath = SystemListener.class.getClassLoader().getResource("").getPath() + "portalConfig" + File.separator + "msb_register.xml";
- RegisterService.registerUUI();
- logger.info("usecase ui register task ended.");
- }
-}
diff --git a/usecaseui-common/src/main/webapp/WEB-INF/web.xml b/usecaseui-common/src/main/webapp/WEB-INF/web.xml
index 9fff24ad..a7a71867 100644
--- a/usecaseui-common/src/main/webapp/WEB-INF/web.xml
+++ b/usecaseui-common/src/main/webapp/WEB-INF/web.xml
@@ -7,6 +7,5 @@
<!-- This is a stub web.xml in the common area -->
<display-name>ecomp-sdk-app-common</display-name>
<listener>
- <listener-class>org.onap.portal.system.SystemListener</listener-class>
</listener>
</web-app>