Delete the redundant Configuration Items. Such as opentoscaServerAddr, yamlParseAddr...
authorYuanHu <yuan.hu1@zte.com.cn>
Tue, 20 Sep 2016 11:55:39 +0000 (19:55 +0800)
committerYuanHu <yuan.hu1@zte.com.cn>
Tue, 20 Sep 2016 11:55:39 +0000 (19:55 +0800)
Change-Id: Ia1b6693a66cf500f94cb58b51543c35d57520c23
Signed-off-by: YuanHu <yuan.hu1@zte.com.cn>
catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/CatalogApp.java
catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/CatalogAppConfiguration.java
catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/MsbUtil.java
catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/YmalParseBaseAddrConfig.java [deleted file]
catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/externalservice/container/ContainerServiceConsumer.java
catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/AbstractModelParser.java
catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/AriaModelParser.java
catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/service/AriaParserServiceConsumer.java
catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/parser/yaml/aria/service/IAriaParserRest.java
catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/model/plan/wso2/Wso2ServiceConsumer.java
catalog-core/distribution/catalog-standalone/src/main/assembly/conf/catalog.yml

index 4764c7b..8a00fbe 100644 (file)
@@ -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<CatalogAppConfiguration> {
     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);
index 7973755..fa17a97 100644 (file)
@@ -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;
index 121646b..25f4501 100644 (file)
@@ -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 (file)
index 57d45b1..0000000
+++ /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;
-  }
-}
index 4d26c06..64530fd 100644 (file)
@@ -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();
   }
 }
index 4cb59b0..4d2134f 100644 (file)
@@ -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;
index 4e9e66e..2ec83cb 100644 (file)
@@ -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<NodeTemplate> 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();
 
index 53b1822..03122ee 100644 (file)
@@ -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);
index 4b53f34..63fc81c 100644 (file)
@@ -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;
index 6cdda70..089c368 100644 (file)
 
 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()) {
index 863fff9..97ec352 100644 (file)
@@ -22,18 +22,8 @@ msbServerAddr: http://127.0.0.1:80
 
 httpServerAddr: http://127.0.0.1:8080
 
-opentoscaServerAddr: http://127.0.0.1:1337
-
-yamlParseAddr: http://127.0.0.1:8210
-
 parserType: zte
 
-ariaParserAddr: http://127.0.0.1:8204/openoapi/tosca/v1
-
-wso2HostIp: 127.0.0.1
-
-wso2HostPort: 9090
-
 #catalogue path to store csar temperarily
 cataloguePath: ./catalog
 httpServerPath: ../tomcat/webapps/ROOT/
@@ -51,12 +41,6 @@ database:
 
   # the JDBC URL
   url: jdbc:mysql://127.0.0.1:3306/catalog
-#LDAP
-ldapServerIp: 127.0.0.1
-ldapServerPort: 20096
-ldapLogindn: uid=admin,ou=system
-ldapPassword: nsoc
-ldapVersion: 3
 
 # use the simple server factory if you only want to run on a single port
 #server: