diff options
author | 2017-09-07 15:10:59 +0800 | |
---|---|---|
committer | 2017-09-07 15:10:59 +0800 | |
commit | 03cb28b3dfabbf7c49c645dde29a74fd5e60bbf8 (patch) | |
tree | 53e974160ce7c79108f3c6b45ee1a87aa7fcdda5 /esr-core | |
parent | 3acec6becfbb2ffb621a1f8c3eb0f14929b09226 (diff) |
Define AAI Vim register related API
Define AAI Vim register related API.Remove original MSB related class,this will realize by using java-sdk. Define external system bean related to AAI.
Change-Id: I1e99ea95e4e1e458787e3665979a1afeb4c11750
Issue-ID: AAI-263
Signed-off-by: lizi00164331 <li.zi30@zte.com.cn>
Diffstat (limited to 'esr-core')
14 files changed, 707 insertions, 201 deletions
diff --git a/esr-core/esr-mgr/pom.xml b/esr-core/esr-mgr/pom.xml index 37d529a..f54c8fd 100644 --- a/esr-core/esr-mgr/pom.xml +++ b/esr-core/esr-mgr/pom.xml @@ -141,6 +141,11 @@ <groupId>io.swagger</groupId> <artifactId>swagger-jersey2-jaxrs</artifactId> </dependency> + <dependency> + <groupId>io.dropwizard</groupId> + <artifactId>dropwizard-migrations</artifactId> + <version>0.8.0</version> + </dependency> <!-- jersey --> <dependency> <groupId>org.glassfish.jersey.core</groupId> @@ -154,6 +159,11 @@ <groupId>org.glassfish.jersey.containers</groupId> <artifactId>jersey-container-servlet-core</artifactId> </dependency> + <dependency> + <groupId>com.sun.jersey</groupId> + <artifactId>jersey-client</artifactId> + <version>1.18</version> + </dependency> <!-- consumer --> <dependency> <groupId>com.eclipsesource.jaxrs</groupId> diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/common/MsbUtil.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/common/MsbUtil.java new file mode 100644 index 0000000..0bd4f01 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/common/MsbUtil.java @@ -0,0 +1,29 @@ +/** + * Copyright 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.aai.esr.common; + + +public class MsbUtil { + +// public static String getVimBaseUrl() { +// return Config.getConfigration().getMsbServerAddr() + "/api/vim/v1"; +// } +// +// public static String getAaiServiceUrl() { +// return Config.getConfigration().getMsbServerAddr() + "/aai/v11/"; +// } + +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/AaiAdapterConfig.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/AaiAdapterConfig.java new file mode 100644 index 0000000..68bf1c9 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/AaiAdapterConfig.java @@ -0,0 +1,29 @@ +/** + * Copyright 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.aai.esr.externalservice.aai; + +public class AaiAdapterConfig { + + protected static String aaiAdapterAddr; + + public static void setAaiAdapterAddr(String address){ + aaiAdapterAddr = "https://" + address; + } + + public static String getAaiAdapterAddr(){ + return aaiAdapterAddr; + } +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/AaiCommon.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/AaiCommon.java new file mode 100644 index 0000000..c2088a1 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/AaiCommon.java @@ -0,0 +1,62 @@ +/** + * Copyright 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.aai.esr.externalservice.aai; + +import java.io.IOException; +import java.io.StringReader; +import com.sun.jersey.api.client.ClientResponse; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +public class AaiCommon { + + private static String AAI_AUTHENTICATION_USER = "AAI"; + private static String AAI_AUTHENTICATION_PAASWORD = "AAI"; + private static String RESOURCE_VERSION_PARAM = "resource-version"; + +// public String getAuthenticationCredentials() { +// String usernameAndPassword = AAI_AUTHENTICATION_USER + ":" +// + AAI_AUTHENTICATION_PAASWORD; +// return "Basic " + java.util.Base64.getEncoder().encodeToString("AAI:AAI".getBytes()); +// } + + public String getResourceVersion(ClientResponse response) + throws ParserConfigurationException, SAXException, IOException { + String respData = response.getEntity(String.class); + + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + InputSource is = new InputSource(new StringReader(respData)); + Document doc = builder.parse(is); + + NodeList nodeList = doc.getDocumentElement().getChildNodes(); + for (int i = 0; i < nodeList.getLength(); i++) { + Node currentNode = nodeList.item(i); + if (currentNode.getNodeName().equals(RESOURCE_VERSION_PARAM)) { + return currentNode.getTextContent(); + } + } + + return null; + } +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/AaiServiceConsumer.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/AaiServiceConsumer.java new file mode 100644 index 0000000..cbb65ad --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/AaiServiceConsumer.java @@ -0,0 +1,32 @@ +/** + * Copyright 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.aai.esr.externalservice.aai; + +import org.glassfish.jersey.client.ClientConfig; + +import com.eclipsesource.jaxrs.consumer.ConsumerFactory; + +public class AaiServiceConsumer { + private static IEsrVimRest aaiAdapterProxy; + + static { + ClientConfig config = new ClientConfig(); + aaiAdapterProxy = + ConsumerFactory.createConsumer(AaiAdapterConfig.getAaiAdapterAddr(), + config, IEsrVimRest.class); + } + +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/IEsrVimRest.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/IEsrVimRest.java new file mode 100644 index 0000000..0c45938 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/IEsrVimRest.java @@ -0,0 +1,81 @@ +/** + * Copyright 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.aai.esr.externalservice.aai; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import org.glassfish.jersey.client.ClientResponse; +import org.onap.aai.esr.externalservice.entity.CloudRegion; + +import retrofit2.http.Header; +import retrofit2.http.Headers; + + +@Path("/aai/v11/cloud-infrastructure/cloud-regions") +public interface IEsrVimRest { + +// @Headers({ +// "X-TransactionId: 9999", +// "Accept: application/json", +// "X-FromAppId: aai-esr" +// }) +// @Path("/cloud-region/{cloud_owner}/{cloud_region_id}") +// @PUT +// @Consumes(MediaType.APPLICATION_JSON) +// +// public ClientResponse registerVIMServce(@Header("Authorization") String authorization, @PathParam("cloud_owner") String cloud_owner, +// CloudRegion entity) throws Exception; +// +// @Headers({ +// "X-TransactionId: 9999", +// "Accept: application/json", +// "X-FromAppId: aai-esr" +// }) +// @Path("/cloud-region/{cloud_owner}/{cloud_region_id}?depth=all") +// @GET +// @Produces(MediaType.APPLICATION_JSON) +// public ClientResponse queryVIMDetail(@Header("Authorization") String authorization, @PathParam("cloud_owner") String cloud_owner, +// @PathParam("cloud_region_id") String cloud_region_id) throws Exception; +// +// @Headers({ +// "X-TransactionId: 9999", +// "Accept: application/json", +// "X-FromAppId: aai-esr" +// }) +// @Path("/") +// @GET +// @Produces(MediaType.APPLICATION_JSON) +// public ClientResponse queryVIMList(@Header("Authorization") String authorization) throws Exception; +// +// +// @Headers({ +// "X-TransactionId: 9999", +// "Accept: application/json", +// "X-FromAppId: aai-esr" +// }) +// @Path("/cloud-region/{cloud_owner}/{cloud_region_id}/esr-system-info/{esr_system_info_id}") +// @GET +// public ClientResponse delVIMAuthInfo(@Header("Authorization") String authorization, @PathParam("cloud_owner") String cloud_owner, +// @PathParam("cloud_region_id") String cloud_region_id, @PathParam("esr_system_info_id") String esr_system_info_id) throws Exception; + +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/entity/CloudRegion.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/entity/CloudRegion.java new file mode 100644 index 0000000..f4fcf20 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/entity/CloudRegion.java @@ -0,0 +1,112 @@ +/** + * Copyright 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.aai.esr.externalservice.entity; + +import java.util.ArrayList; + +public class CloudRegion { + + // required + private String cloudOwner; + //required + private String cloudRegionId; + //required + private String cloudType; + //required + private String cloudRegionVersion; + // not required + private String ownerDefinedType; + //not required + private String cloudZone; + //not required + private String complexName; + //not required + private String cloudExtraInfo; + + private ArrayList<EsrSystemInfo> esrSystemInfos; + + public String getCloudOwner() { + return cloudOwner; + } + + public void setCloudOwner(String cloudOwner) { + this.cloudOwner = cloudOwner; + } + + public String getCloudRegionId() { + return cloudRegionId; + } + + public void setCloudRegionId(String cloudRegionId) { + this.cloudRegionId = cloudRegionId; + } + + public String getCloudType() { + return cloudType; + } + + public void setCloudType(String cloudType) { + this.cloudType = cloudType; + } + + public String getCloudRegionVersion() { + return cloudRegionVersion; + } + + public void setCloudRegionVersion(String cloudRegionVersion) { + this.cloudRegionVersion = cloudRegionVersion; + } + + public String getOwnerDefinedType() { + return ownerDefinedType; + } + + public void setOwnerDefinedType(String ownerDefinedType) { + this.ownerDefinedType = ownerDefinedType; + } + + public String getCloudZone() { + return cloudZone; + } + + public void setCloudZone(String cloudZone) { + this.cloudZone = cloudZone; + } + + public String getComplexName() { + return complexName; + } + + public void setComplexName(String complexName) { + this.complexName = complexName; + } + + public String getCloudExtraInfo() { + return cloudExtraInfo; + } + + public void setCloudExtraInfo(String cloudExtraInfo) { + this.cloudExtraInfo = cloudExtraInfo; + } + + public ArrayList<EsrSystemInfo> getEsrSystemInfos() { + return esrSystemInfos; + } + + public void setEsrSystemInfos(ArrayList<EsrSystemInfo> esrSystemInfos) { + this.esrSystemInfos = esrSystemInfos; + } +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/entity/EsrEms.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/entity/EsrEms.java new file mode 100644 index 0000000..a11b5d4 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/entity/EsrEms.java @@ -0,0 +1,60 @@ +/** + * Copyright 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.aai.esr.externalservice.entity; + +import java.util.ArrayList; + +public class EsrEms { + private String emsId; + + private Boolean passive; + + private String remotePath; + + private ArrayList<EsrSystemInfo> esrSystemInfos; + + public String getEmsId() { + return emsId; + } + + public void setEmsId(String emsId) { + this.emsId = emsId; + } + + public Boolean getPassive() { + return passive; + } + + public void setPassive(Boolean passive) { + this.passive = passive; + } + + public String getRemotePath() { + return remotePath; + } + + public void setRemotePath(String remotePath) { + this.remotePath = remotePath; + } + + public ArrayList<EsrSystemInfo> getEsrSystemInfos() { + return esrSystemInfos; + } + + public void setEsrSystemInfos(ArrayList<EsrSystemInfo> esrSystemInfos) { + this.esrSystemInfos = esrSystemInfos; + } +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/entity/EsrSystemInfo.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/entity/EsrSystemInfo.java new file mode 100644 index 0000000..12bb2bc --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/entity/EsrSystemInfo.java @@ -0,0 +1,180 @@ +/** + * Copyright 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.aai.esr.externalservice.entity; + +public class EsrSystemInfo { + + private String esrSystemInfoId; + + private String systemName; + + private String type; + + private String vendor; + + private String version; + + private String serviceUrl; + + private String userName; + + private String password; + + private String systemType; + + private String protocal; + + private String sslCacert; + + private Boolean sslInsecure; + + private Boolean ipAddress; + + private Boolean port; + + private Boolean cloudDomain; + + private Boolean defaultTenant; + + public String getEsrSystemInfoId() { + return esrSystemInfoId; + } + + public void setEsrSystemInfoId(String esrSystemInfoId) { + this.esrSystemInfoId = esrSystemInfoId; + } + + public String getSystemName() { + return systemName; + } + + public void setSystemName(String systemName) { + this.systemName = systemName; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getVendor() { + return vendor; + } + + public void setVendor(String vendor) { + this.vendor = vendor; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getServiceUrl() { + return serviceUrl; + } + + public void setServiceUrl(String serviceUrl) { + this.serviceUrl = serviceUrl; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getSystemType() { + return systemType; + } + + public void setSystemType(String systemType) { + this.systemType = systemType; + } + + public String getProtocal() { + return protocal; + } + + public void setProtocal(String protocal) { + this.protocal = protocal; + } + + public String getSslCacert() { + return sslCacert; + } + + public void setSslCacert(String sslCacert) { + this.sslCacert = sslCacert; + } + + public Boolean getSslInsecure() { + return sslInsecure; + } + + public void setSslInsecure(Boolean sslInsecure) { + this.sslInsecure = sslInsecure; + } + + public Boolean getIpAddress() { + return ipAddress; + } + + public void setIpAddress(Boolean ipAddress) { + this.ipAddress = ipAddress; + } + + public Boolean getPort() { + return port; + } + + public void setPort(Boolean port) { + this.port = port; + } + + public Boolean getCloudDomain() { + return cloudDomain; + } + + public void setCloudDomain(Boolean cloudDomain) { + this.cloudDomain = cloudDomain; + } + + public Boolean getDefaultTenant() { + return defaultTenant; + } + + public void setDefaultTenant(Boolean defaultTenant) { + this.defaultTenant = defaultTenant; + } + +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/entity/EsrThirdpartySdnc.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/entity/EsrThirdpartySdnc.java new file mode 100644 index 0000000..068e288 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/entity/EsrThirdpartySdnc.java @@ -0,0 +1,50 @@ +/** + * Copyright 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.aai.esr.externalservice.entity; + +public class EsrThirdpartySdnc { + + private String thirdpartySdncId; + + private String location; + + private String productName; + + public String getThirdpartySdncId() { + return thirdpartySdncId; + } + + public void setThirdpartySdncId(String thirdpartySdncId) { + this.thirdpartySdncId = thirdpartySdncId; + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } + + public String getProductName() { + return productName; + } + + public void setProductName(String productName) { + this.productName = productName; + } + +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/entity/EsrVnfm.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/entity/EsrVnfm.java new file mode 100644 index 0000000..05d1789 --- /dev/null +++ b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/entity/EsrVnfm.java @@ -0,0 +1,62 @@ +/** + * Copyright 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.aai.esr.externalservice.entity; + +import java.util.ArrayList; + +public class EsrVnfm { + + private String vnfmId; + + private String vimId; + + private String certificateUrl; + + private ArrayList<EsrSystemInfo> esrSystemInfos; + + public String getVnfmId() { + return vnfmId; + } + + public void setVnfmId(String vnfmId) { + this.vnfmId = vnfmId; + } + + public String getVimId() { + return vimId; + } + + public void setVimId(String vimId) { + this.vimId = vimId; + } + + public String getCertificateUrl() { + return certificateUrl; + } + + public void setCertificateUrl(String certificateUrl) { + this.certificateUrl = certificateUrl; + } + + public ArrayList<EsrSystemInfo> getEsrSystemInfos() { + return esrSystemInfos; + } + + public void setEsrSystemInfos(ArrayList<EsrSystemInfo> esrSystemInfos) { + this.esrSystemInfos = esrSystemInfos; + } + +} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/entity/ServiceRegisterEntity.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/entity/ServiceRegisterEntity.java deleted file mode 100644 index 12ab147..0000000 --- a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/entity/ServiceRegisterEntity.java +++ /dev/null @@ -1,112 +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.aai.esr.externalservice.entity; - - -import java.util.ArrayList; - - -public class ServiceRegisterEntity { - private String serviceName; - private String version; - private String url; - private String protocol; - private String visualRange; - private ArrayList<ServiceNode> nodes = new ArrayList<ServiceNode>(); - - - /** - * set service entity. - * - * @param ip node ip. can be null - * @param port service port - * @param ttl service survival time - */ - public void setSingleNode(String ip, String port, int ttl) { - ServiceNode node = new ServiceNode(); - if (ip != null && ip.length() > 0) { - node.setIp(ip); - } else { - node.setIp(null); - } - node.setPort(port); - node.setTtl(ttl); - nodes.add(node); - } - - - public String getServiceName() { - return serviceName; - } - - - public void setServiceName(String serviceName) { - this.serviceName = serviceName; - } - - - public String getVersion() { - return version; - } - - - public void setVersion(String version) { - this.version = version; - } - - - 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 ArrayList<ServiceNode> getNodes() { - return nodes; - } - - - public void setNodes(ArrayList<ServiceNode> nodes) { - this.nodes = nodes; - } - -} - diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/msb/MicroserviceBusConsumer.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/msb/MicroserviceBusConsumer.java deleted file mode 100644 index c8c979c..0000000 --- a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/msb/MicroserviceBusConsumer.java +++ /dev/null @@ -1,50 +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.aai.esr.externalservice.msb; - -import com.eclipsesource.jaxrs.consumer.ConsumerFactory; - -import org.glassfish.jersey.client.ClientConfig; -import org.onap.aai.esr.common.Config; -import org.onap.aai.esr.externalservice.entity.ServiceRegisterEntity; -import org.onap.aai.esr.util.ExtsysUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - - -public class MicroserviceBusConsumer { - private static final Logger LOG = LoggerFactory.getLogger(MicroserviceBusConsumer.class); - - /** - * @param entity service entity - * @return register service to msb success return true, else return false. - */ - public static boolean registerService(ServiceRegisterEntity entity) { - ClientConfig config = new ClientConfig(); - LOG.info("microservice register body:" + ExtsysUtil.objectToString(entity)); - try { - MicroserviceBusRest resourceserviceproxy = ConsumerFactory.createConsumer( - Config.getConfigration().getMsbServerAddr(), config, MicroserviceBusRest.class); - resourceserviceproxy.registerServce("false", entity); - } catch (Exception error) { - LOG.error("microservice register failed!" + error.getMessage()); - return false; - } - return true; - } -} diff --git a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/msb/MicroserviceBusRest.java b/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/msb/MicroserviceBusRest.java deleted file mode 100644 index 381ad1a..0000000 --- a/esr-core/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/msb/MicroserviceBusRest.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.aai.esr.externalservice.msb; - -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - -import org.onap.aai.esr.externalservice.entity.ServiceRegisterEntity; - - - - -@Path("/onapapi/microservices/v1/services") -// @Path("/api/microservices/v1/services") -public interface MicroserviceBusRest { - @Path("") - @POST - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public ServiceRegisterEntity registerServce(@QueryParam("createOrUpdate") String createOrUpdate, - ServiceRegisterEntity entity)throws Exception; -} |