From 57699dfe08e82a7a045027d4fd4a201c8ad79428 Mon Sep 17 00:00:00 2001 From: YuanHu Date: Tue, 20 Sep 2016 19:55:39 +0800 Subject: Delete the redundant Configuration Items. Such as opentoscaServerAddr, yamlParseAddr, ariaParserAddr, wso2HostIp, wso2HostPort, ldapServerIp, ldapServerPort, ldapLogindn, ldapPassword, ldapVersion. Change-Id: Ia1b6693a66cf500f94cb58b51543c35d57520c23 Signed-off-by: YuanHu --- .../org/openo/commontosca/catalog/CatalogApp.java | 2 - .../catalog/CatalogAppConfiguration.java | 130 --------------------- .../openo/commontosca/catalog/common/MsbUtil.java | 3 +- .../catalog/common/YmalParseBaseAddrConfig.java | 30 ----- .../container/ContainerServiceConsumer.java | 4 +- .../catalog/model/parser/AbstractModelParser.java | 4 +- .../model/parser/yaml/aria/AriaModelParser.java | 6 +- .../aria/service/AriaParserServiceConsumer.java | 2 +- .../parser/yaml/aria/service/IAriaParserRest.java | 3 +- .../model/plan/wso2/Wso2ServiceConsumer.java | 58 ++++++--- 10 files changed, 53 insertions(+), 189 deletions(-) delete mode 100644 catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/YmalParseBaseAddrConfig.java (limited to 'catalog-core/catalog-mgr/src') diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/CatalogApp.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/CatalogApp.java index 4764c7b4..8a00fbe6 100644 --- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/CatalogApp.java +++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/CatalogApp.java @@ -35,7 +35,6 @@ import org.openo.commontosca.catalog.common.HttpServerAddrConfig; import org.openo.commontosca.catalog.common.HttpServerPathConfig; import org.openo.commontosca.catalog.common.MsbAddrConfig; import org.openo.commontosca.catalog.common.ServiceRegistrer; -import org.openo.commontosca.catalog.common.YmalParseBaseAddrConfig; import org.openo.commontosca.catalog.db.dao.DaoManager; import org.openo.commontosca.catalog.db.entity.NodeTemplateData; import org.openo.commontosca.catalog.db.entity.PackageData; @@ -97,7 +96,6 @@ public class CatalogApp extends Application { MsbAddrConfig.setMsbAddress(configuration.getMsbServerAddr()); HttpServerAddrConfig.setHttpServerAddress(configuration.getHttpServerAddr()); HttpServerPathConfig.setHttpServerPath(configuration.getHttpServerPath()); - YmalParseBaseAddrConfig.setYmalParseBaseAddr(configuration.getYamlParseAddr()); initDao(); final ConsoleHealthCheck healthCheck = new ConsoleHealthCheck(configuration.getTemplate()); environment.healthChecks().register("template", healthCheck); diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/CatalogAppConfiguration.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/CatalogAppConfiguration.java index 79737559..fa17a972 100644 --- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/CatalogAppConfiguration.java +++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/CatalogAppConfiguration.java @@ -39,43 +39,15 @@ public class CatalogAppConfiguration extends Configuration { @NotEmpty private String httpServerAddr; - - @NotEmpty - private String opentoscaServerAddr; - - @NotEmpty - private String yamlParseAddr; @NotEmpty private String parserType; - - @NotEmpty - private String ariaParserAddr; - - @NotEmpty - private String wso2HostIp; - - @NotEmpty - private String wso2HostPort; @NotEmpty private String cataloguePath; @NotEmpty private String httpServerPath; - @NotEmpty - private String ldapServerIp; - - @NotEmpty - private String ldapServerPort; - - @NotEmpty - private String ldapLogindn; - @NotEmpty - private String ldapPassword; - - @NotEmpty - private String ldapVersion; @Valid @NotNull private DataSourceFactory database = new DataSourceFactory(); @@ -129,26 +101,6 @@ public class CatalogAppConfiguration extends Configuration { public void setHttpServerAddr(String httpServerAddr) { this.httpServerAddr = httpServerAddr; } - - @JsonProperty - public String getOpentoscaServerAddr() { - return opentoscaServerAddr; - } - - @JsonProperty - public void setOpentoscaServerAddr(String opentoscaServerAddr) { - this.opentoscaServerAddr = opentoscaServerAddr; - } - - @JsonProperty - public String getYamlParseAddr() { - return yamlParseAddr; - } - - @JsonProperty - public void setYamlParseAddr(String yamlParseAddr) { - this.yamlParseAddr = yamlParseAddr; - } public String getParserType() { return parserType; @@ -158,38 +110,6 @@ public class CatalogAppConfiguration extends Configuration { this.parserType = parserType; } - public String getAriaParserAddr() { - return ariaParserAddr; - } - - public void setAriaParserAddr(String ariaParserAddr) { - this.ariaParserAddr = ariaParserAddr; - } - - @JsonProperty - public String getWso2HostIp() { - return wso2HostIp; - } - - @JsonProperty - public void setWso2HostIp(String wso2HostIp) { - this.wso2HostIp = wso2HostIp; - } - - @JsonProperty - public String getWso2HostPort() { - return wso2HostPort; - } - - @JsonProperty - public void setWso2HostPort(String wso2HostPort) { - this.wso2HostPort = wso2HostPort; - } - - public String getWso2BaseUrl() { - return "http://" + this.wso2HostIp + ":" + this.wso2HostPort; - } - @JsonProperty public String getCataloguePath() { return cataloguePath; @@ -200,56 +120,6 @@ public class CatalogAppConfiguration extends Configuration { this.cataloguePath = cataloguePath; } - @JsonProperty - public String getLdapServerIp() { - return ldapServerIp; - } - - @JsonProperty - public void setLdapServerIp(String ldapServerIp) { - this.ldapServerIp = ldapServerIp; - } - - @JsonProperty - public String getLdapServerPort() { - return ldapServerPort; - } - - @JsonProperty - public void setLdapServerPort(String ldapServerPort) { - this.ldapServerPort = ldapServerPort; - } - - @JsonProperty - public String getLdapLogindn() { - return ldapLogindn; - } - - @JsonProperty - public void setLdapLogindn(String ldapLogindn) { - this.ldapLogindn = ldapLogindn; - } - - @JsonProperty - public String getLdapPassword() { - return ldapPassword; - } - - @JsonProperty - public void setLdapPassword(String ldapPassword) { - this.ldapPassword = ldapPassword; - } - - @JsonProperty - public String getLdapVersion() { - return ldapVersion; - } - - @JsonProperty - public void setLdapVersion(String ldapVersion) { - this.ldapVersion = ldapVersion; - } - @JsonProperty public String getHttpServerPath() { return httpServerPath; diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/MsbUtil.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/MsbUtil.java index 121646b0..25f4501b 100644 --- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/MsbUtil.java +++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/MsbUtil.java @@ -51,7 +51,6 @@ public class MsbUtil { } public static String getYamlParseBaseUrl() { - return YmalParseBaseAddrConfig.getYmalParseBaseAddr() + "/api/yamlparser/v1"; -// return Config.getConfigration().getYamlParseAddr() + "/api/yamlparser/v1"; + return Config.getConfigration().getMsbServerAddr() + "/openoapi/yamlparser/v1"; } } diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/YmalParseBaseAddrConfig.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/YmalParseBaseAddrConfig.java deleted file mode 100644 index 57d45b1c..00000000 --- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/YmalParseBaseAddrConfig.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright 2016 [ZTE] and others. - * - * 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.openo.commontosca.catalog.common; - -public class YmalParseBaseAddrConfig { - - protected static String yamlParseAddr; - - public static String getYmalParseBaseAddr() { - return yamlParseAddr; - } - - public static void setYmalParseBaseAddr(String yamlParseAddr) { - YmalParseBaseAddrConfig.yamlParseAddr = yamlParseAddr; - } -} diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/ContainerServiceConsumer.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/ContainerServiceConsumer.java index 4d26c06a..64530fd0 100644 --- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/ContainerServiceConsumer.java +++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/ContainerServiceConsumer.java @@ -212,7 +212,7 @@ public class ContainerServiceConsumer { */ private static String getBaseUrl() { StringBuffer buffer = new StringBuffer(); - buffer.append(Config.getConfigration().getOpentoscaServerAddr() + "/containerapi/extension"); + buffer.append(Config.getConfigration().getMsbServerAddr() + "/containerapi/extension"); return buffer.toString(); } @@ -223,7 +223,7 @@ public class ContainerServiceConsumer { */ private static String getPackageUrl() { StringBuffer buffer = new StringBuffer(); - buffer.append(Config.getConfigration().getOpentoscaServerAddr()); + buffer.append(Config.getConfigration().getMsbServerAddr()); return buffer.toString(); } } diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/AbstractModelParser.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/AbstractModelParser.java index 4cb59b08..4d2134fe 100644 --- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/AbstractModelParser.java +++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/AbstractModelParser.java @@ -50,8 +50,8 @@ public abstract class AbstractModelParser { String destPath = Class.class.getClass().getResource("/").getPath() + org.openo.commontosca.catalog.filemanage.http.ToolUtil.getHttpServerPath() + toTempFileLocalPath(fileLocation); - if (!org.openo.commontosca.catalog.filemanage.http.ToolUtil.copyFile(fileLocation, destPath, - true)) { + if (!org.openo.commontosca.catalog.filemanage.http.ToolUtil.copyFile( + fileLocation, destPath, true)) { throw new CatalogResourceException("Copy Temporary To HttpServer Failed."); } return destPath; diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/AriaModelParser.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/AriaModelParser.java index 4e9e66eb..2ec83cbf 100644 --- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/AriaModelParser.java +++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/AriaModelParser.java @@ -58,7 +58,7 @@ public class AriaModelParser extends AbstractModelParser { // service template CsarFileUriResponse stDownloadUri = buildServiceTemplateDownloadUri(packageId, fileLocation); - ServiceTemplate st = parseServiceTemplate(packageId, result, stDownloadUri.getDownloadUri()); + ServiceTemplate st = parseServiceTemplate(result, packageId, stDownloadUri.getDownloadUri()); // node templates List ntList = parseNodeTemplates(packageId, st.getServiceTemplateId(), result); st.setType(getTemplateType(getSubstitutionType(result), ntList).toString()); @@ -197,12 +197,12 @@ public class AriaModelParser extends AbstractModelParser { /** - * @param packageId * @param result + * @param packageId * @param downloadUri * @return */ - private ServiceTemplate parseServiceTemplate(String packageId, AriaParserResult result, + private ServiceTemplate parseServiceTemplate(AriaParserResult result, String packageId, String downloadUri) { ServiceTemplate st = new ServiceTemplate(); diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/service/AriaParserServiceConsumer.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/service/AriaParserServiceConsumer.java index 53b18225..03122eeb 100644 --- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/service/AriaParserServiceConsumer.java +++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/service/AriaParserServiceConsumer.java @@ -42,7 +42,7 @@ public class AriaParserServiceConsumer { try { IAriaParserRest parseProxy = ConsumerFactory.createConsumer( - Config.getConfigration().getAriaParserAddr(), + Config.getConfigration().getMsbServerAddr(), new ClientConfig(), IAriaParserRest.class); String jsonStr = parseProxy.parse(request); diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/service/IAriaParserRest.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/service/IAriaParserRest.java index 4b53f341..63fc81c7 100644 --- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/service/IAriaParserRest.java +++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/service/IAriaParserRest.java @@ -25,10 +25,11 @@ import javax.ws.rs.core.MediaType; import org.openo.commontosca.catalog.model.parser.yaml.aria.entity.AriaParserRequest; -@Path("/indirect/plan") +@Path("/openoapi/tosca/v1") public interface IAriaParserRest { @POST + @Path("/indirect/plan") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) String parse(AriaParserRequest request) throws Exception; diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/plan/wso2/Wso2ServiceConsumer.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/plan/wso2/Wso2ServiceConsumer.java index 6cdda700..089c368d 100644 --- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/plan/wso2/Wso2ServiceConsumer.java +++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/plan/wso2/Wso2ServiceConsumer.java @@ -16,9 +16,22 @@ package org.openo.commontosca.catalog.model.plan.wso2; -import com.google.gson.Gson; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; +import java.util.zip.ZipInputStream; -import com.eclipsesource.jaxrs.consumer.ConsumerFactory; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; import org.apache.http.HttpEntity; import org.apache.http.entity.ContentType; @@ -33,16 +46,8 @@ import org.openo.commontosca.catalog.model.plan.wso2.entity.StartProcessResponse import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.util.Map; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; -import java.util.zip.ZipInputStream; +import com.eclipsesource.jaxrs.consumer.ConsumerFactory; +import com.google.gson.Gson; @@ -59,11 +64,15 @@ public class Wso2ServiceConsumer { */ public static DeployPackageResponse deployPackage(String zipFileLocation, String planFilePath) throws CatalogResourceException { + IpPort ipPort = getIpPort(Config.getConfigration().getMsbServerAddr()); + if (ipPort == null) { + throw new CatalogResourceException("getMsbServerAddr failed."); + } InputStream ins = null; try { ins = getInputStream(zipFileLocation, planFilePath); - RestResponse res = RestfulClient.post(Config.getConfigration().getWso2HostIp(), - Integer.parseInt(Config.getConfigration().getWso2HostPort()), WSO2_APP_URL, + RestResponse res = RestfulClient.post( + ipPort.getIp(), ipPort.getPort(), WSO2_APP_URL, buildRequest(ins, planFilePath)); if (res.getStatusCode() == null || res.getResult() == null) { @@ -94,6 +103,23 @@ public class Wso2ServiceConsumer { } } + @Data + @NoArgsConstructor + @AllArgsConstructor + public static class IpPort { + private String ip; + private int port; + } + + private static IpPort getIpPort(String addr) { + Pattern p = Pattern.compile("//(.*?):(.*)"); + Matcher m = p.matcher(addr); + while(m.find()){ + return new IpPort(m.group(1), Integer.valueOf(m.group(2))); + } + return null; + } + private static HttpEntity buildRequest(InputStream inputStream, String filePath) throws FileNotFoundException { MultipartEntityBuilder builder = MultipartEntityBuilder.create(); @@ -149,7 +175,7 @@ public class Wso2ServiceConsumer { try { ClientConfig config = new ClientConfig(); Iwso2RestService wso2Proxy = ConsumerFactory.createConsumer( - Config.getConfigration().getWso2BaseUrl(), config, Iwso2RestService.class); + Config.getConfigration().getMsbServerAddr(), config, Iwso2RestService.class); DeletePackageResponse response = wso2Proxy.deletePackage(packageName); if (response.isSuccess()) { return response; @@ -174,7 +200,7 @@ public class Wso2ServiceConsumer { try { ClientConfig config = new ClientConfig(); Iwso2RestService wso2Proxy = ConsumerFactory.createConsumer( - Config.getConfigration().getWso2BaseUrl(), config, Iwso2RestService.class); + Config.getConfigration().getMsbServerAddr(), config, Iwso2RestService.class); StartProcessResponse response = wso2Proxy.startProcess(new StartProcessRequest(processId, params)); if (response.isSuccess()) { -- cgit 1.2.3-korg