diff options
author | 2017-09-08 13:58:24 +0800 | |
---|---|---|
committer | 2017-09-08 13:58:24 +0800 | |
commit | c3966c0f911b119e9493c4faa7b8eba2ecbc7457 (patch) | |
tree | 815dc8a2764e9073f1178a1d0fc782ab1741c9da /esr-mgr | |
parent | fa6dd60a45a093205ae55065f6de044c91493e60 (diff) |
Fix the esr-server setup issue.
remove the dependency on jersey client in version 1.18. Change the service portal to 9518.
Change-Id: I65657840b8ecfc7a592dc03d439fedf84491114e
Issue-ID: AAI-273
Signed-off-by: lizi00164331 <li.zi30@zte.com.cn>
Diffstat (limited to 'esr-mgr')
6 files changed, 107 insertions, 134 deletions
diff --git a/esr-mgr/pom.xml b/esr-mgr/pom.xml index c524f03..5ccf3e5 100644 --- a/esr-mgr/pom.xml +++ b/esr-mgr/pom.xml @@ -142,11 +142,7 @@ <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> @@ -160,11 +156,6 @@ <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-mgr/src/main/java/org/onap/aai/esr/ExtsysApp.java b/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysApp.java index 6552d95..43b29ad 100644 --- a/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysApp.java +++ b/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysApp.java @@ -15,26 +15,23 @@ */ package org.onap.aai.esr; -import com.fasterxml.jackson.annotation.JsonInclude; -import io.dropwizard.Application; -import io.dropwizard.assets.AssetsBundle; -import io.dropwizard.server.SimpleServerFactory; -import io.dropwizard.setup.Bootstrap; -import io.dropwizard.setup.Environment; -import io.swagger.jaxrs.config.BeanConfig; -import io.swagger.jaxrs.listing.ApiListingResource; -import org.glassfish.jersey.media.multipart.MultiPartFeature; -import org.onap.aai.esr.common.Config; import org.onap.aai.esr.externalservice.msb.MsbHelper; +import org.onap.aai.esr.resource.EmsManager; +import org.onap.aai.esr.resource.ThirdpatySdncManager; +import org.onap.aai.esr.resource.VimManager; +import org.onap.aai.esr.resource.VnfmManager; import org.onap.msb.sdk.httpclient.msb.MSBServiceClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import io.dropwizard.Application; +import io.dropwizard.setup.Environment; + public class ExtsysApp extends Application<ExtsysAppConfiguration> { private static final Logger LOGGER = LoggerFactory.getLogger(ExtsysApp.class); - + public static void main(String[] args) throws Exception { new ExtsysApp().run(args); } @@ -44,58 +41,25 @@ public class ExtsysApp extends Application<ExtsysAppConfiguration> { return "ONAP-ESR"; } - - @Override - public void initialize(Bootstrap<ExtsysAppConfiguration> bootstrap) { - bootstrap.addBundle(new AssetsBundle("/api-doc", "/api-doc", "index.html", "api-doc")); - } - @Override public void run(ExtsysAppConfiguration configuration, Environment environment) { - LOGGER.info("Start to initialize esr."); - environment.jersey().packages("org.onap.aai.esr.resource"); - environment.jersey().register(MultiPartFeature.class); - String MSB_IP=configuration.getMsbIp(); - int MSB_Port=configuration.getMsbPort(); - - initSwaggerConfig(environment, configuration); - Config.setConfigration(configuration); - MSBServiceClient msbClient = new MSBServiceClient(MSB_IP, MSB_Port); - - MsbHelper helper = new MsbHelper(msbClient); - try { - helper.registerMsb(); - } catch (Exception e) { - LOGGER.error("Register ESR to msb failed", e); - } + LOGGER.info("Start to initialize esr."); + environment.jersey().register(new EmsManager()); + environment.jersey().register(new ThirdpatySdncManager()); + environment.jersey().register(new VimManager()); + environment.jersey().register(new VnfmManager()); +// String MSB_IP="127.0.0.1"; + String MSB_IP=configuration.getMsbIp(); + Integer MSB_Port= Integer.valueOf(configuration.getMsbPort()); + MSBServiceClient msbClient = new MSBServiceClient(MSB_IP, MSB_Port); + MsbHelper helper = new MsbHelper(msbClient); + try { + helper.registerMsb(); + } catch (Exception e) { + LOGGER.error("Register esr-server to msb by java-sdk failed", e); + } LOGGER.info("Initialize extsys finished."); } - /** - * initialize swagger configuration. - * - * @param environment environment information - * @param configuration configuration - */ - private void initSwaggerConfig(Environment environment, ExtsysAppConfiguration configuration) { - environment.jersey().register(new ApiListingResource()); - environment.getObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL); - - BeanConfig config = new BeanConfig(); - config.setTitle("Open-o ExtSys Service rest API"); - config.setVersion("1.0.0"); - config.setResourcePackage("org.onap.aai.esr.resource"); - // set rest api basepath in swagger - SimpleServerFactory simpleServerFactory = - (SimpleServerFactory) configuration.getServerFactory(); - String basePath = simpleServerFactory.getApplicationContextPath(); - String rootPath = simpleServerFactory.getJerseyRootPath(); - rootPath = rootPath.substring(0, rootPath.indexOf("/*")); - basePath = basePath.equals("/") ? rootPath - : (new StringBuilder()).append(basePath).append(rootPath).toString(); - config.setBasePath(basePath); - config.setScan(true); - } - } diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysAppConfiguration.java b/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysAppConfiguration.java index 862c6a5..9823ddc 100644 --- a/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysAppConfiguration.java +++ b/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysAppConfiguration.java @@ -18,14 +18,13 @@ package org.onap.aai.esr; import com.fasterxml.jackson.annotation.JsonProperty; import io.dropwizard.Configuration; -import io.dropwizard.db.DataSourceFactory; import org.hibernate.validator.constraints.NotEmpty; - -import javax.validation.Valid; -import javax.validation.constraints.NotNull; +import org.jvnet.hk2.annotations.Service; +import javax.validation.Valid; +@Service public class ExtsysAppConfiguration extends Configuration { @NotEmpty private String template; @@ -37,7 +36,7 @@ public class ExtsysAppConfiguration extends Configuration { private String msbIp; @NotEmpty - private int msbPort; + private String msbPort; @NotEmpty private String msbServerAddr; @@ -76,16 +75,6 @@ public class ExtsysAppConfiguration extends Configuration { } @JsonProperty - public int getMsbPort() { - return msbPort; - } - - @JsonProperty - public int setMsbPort() { - return msbPort; - } - - @JsonProperty public String getMsbServerAddr() { return msbServerAddr; } @@ -103,4 +92,13 @@ public class ExtsysAppConfiguration extends Configuration { public void setServiceIp(String serviceIp) { this.serviceIp = serviceIp; } + @JsonProperty + public void setMsbPort(String msbPort) { + this.msbPort = msbPort; + } + + @JsonProperty + public String getMsbPort() { + return msbPort; + } } diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/AaiCommon.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/AaiCommon.java index c2088a1..d77722a 100644 --- a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/AaiCommon.java +++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/AaiCommon.java @@ -17,11 +17,11 @@ 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.glassfish.jersey.client.ClientResponse; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -34,15 +34,15 @@ public class AaiCommon { 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 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); + String respData = response.readEntity(String.class); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/IEsrVimRest.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/IEsrVimRest.java index 0c45938..b01c6ef 100644 --- a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/IEsrVimRest.java +++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/IEsrVimRest.java @@ -34,48 +34,48 @@ 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; + @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-mgr/src/test/java/org/onap/aai/esr/db/resource/VimResourceTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/db/resource/VimResourceTest.java new file mode 100644 index 0000000..6265c21 --- /dev/null +++ b/esr-mgr/src/test/java/org/onap/aai/esr/db/resource/VimResourceTest.java @@ -0,0 +1,20 @@ +/** + * 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.db.resource; + +public class VimResourceTest { + +} |