[AAI-170 R1710] Upversion sdc-distribution-client
[aai/model-loader.git] / src / main / java / org / openecomp / modelloader / config / ModelLoaderConfig.java
index 26f13ad..adc8f0b 100644 (file)
@@ -1,36 +1,36 @@
-/*-
+/**
  * ============LICENSE_START=======================================================
- * MODEL LOADER SERVICE
+ * Model Loader
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017 AT&T Intellectual Property.
+ * Copyright © 2017 Amdocs
+ * All rights reserved.
  * ================================================================================
  * 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
- * 
+ * 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.
  * ============LICENSE_END=========================================================
+ *
+ * ECOMP and OpenECOMP are trademarks
+ * and service marks of AT&T Intellectual Property.
  */
-
 package org.openecomp.modelloader.config;
 
 import org.eclipse.jetty.util.security.Password;
 import org.openecomp.sdc.api.consumer.IConfiguration;
 
-import java.io.File;
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
 
 public class ModelLoaderConfig implements IConfiguration {
-
+       
   // Configuration file structure
   public static final String PREFIX_MODEL_LOADER_CONFIG = "ml";
   public static final String PREFIX_DISTRIBUTION_CLIENT = 
@@ -62,6 +62,8 @@ public class ModelLoaderConfig implements IConfiguration {
   protected static final String PROP_ML_DISTRIBUTION_USER = PREFIX_DISTRIBUTION_CLIENT + "USER";
   protected static final String PROP_ML_DISTRIBUTION_ARTIFACT_TYPES = PREFIX_DISTRIBUTION_CLIENT
       + "ARTIFACT_TYPES";
+  protected static final String PROP_ML_DISTRIBUTION_HTTPS_WITH_DMAAP =
+          PREFIX_DISTRIBUTION_CLIENT + "USE_HTTPS_WITH_DMAAP";
 
   protected static final String PROP_AAI_BASE_URL = PREFIX_AAI + "BASE_URL";
   protected static final String PROP_AAI_KEYSTORE_FILE = PREFIX_AAI + "KEYSTORE_FILE";
@@ -86,17 +88,9 @@ public class ModelLoaderConfig implements IConfiguration {
    * @param modelLoaderProperties properties needed to be configured for the model loader
    * @param certLocation location of the certificate
    */
-  public ModelLoaderConfig(Properties modelLoaderProperties) {
+  public ModelLoaderConfig(Properties modelLoaderProperties, String certLocation) {
     this.modelLoaderProperties = modelLoaderProperties;
-    
-    String aaiKeystoreFile = modelLoaderProperties.getProperty(PROP_AAI_KEYSTORE_FILE);
-    if(aaiKeystoreFile != null){
-           URL keystoreURL = this.getClass().getClassLoader().getResource(aaiKeystoreFile);
-           if(keystoreURL != null){
-               File fKeystoreLocation = new File(keystoreURL.getPath());
-               this.certLocation = fKeystoreLocation.getParent();
-           }
-    }
+    this.certLocation = certLocation;
 
     // Get list of artifacts
     artifactTypes = new ArrayList<String>();
@@ -173,6 +167,17 @@ public class ModelLoaderConfig implements IConfiguration {
     return modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_USER);
   }
 
+  @Override
+  public boolean isFilterInEmptyResources() {
+      return false;
+  }
+
+  @Override
+  public Boolean isUseHttpsWithDmaap() {
+      String useHTTPS = modelLoaderProperties.getProperty(PROP_ML_DISTRIBUTION_HTTPS_WITH_DMAAP);
+      return useHTTPS == null ? false : Boolean.valueOf(useHTTPS);
+  }
+  
   public String getAaiKeyStorePath() {
     return certLocation + "/" + modelLoaderProperties.getProperty(PROP_AAI_KEYSTORE_FILE);
   }
@@ -185,12 +190,12 @@ public class ModelLoaderConfig implements IConfiguration {
     return modelLoaderProperties.getProperty(PROP_AAI_BASE_URL);
   }
 
-  public String getAaiModelUrl() {
-    return modelLoaderProperties.getProperty(PROP_AAI_MODEL_RESOURCE_URL);
+  public String getAaiModelUrl(String version) {
+    return modelLoaderProperties.getProperty(PROP_AAI_MODEL_RESOURCE_URL).replace("v*", version);
   }
 
-  public String getAaiNamedQueryUrl() {
-    return modelLoaderProperties.getProperty(PROP_AAI_NAMED_QUERY_RESOURCE_URL);
+  public String getAaiNamedQueryUrl(String version) {
+    return modelLoaderProperties.getProperty(PROP_AAI_NAMED_QUERY_RESOURCE_URL).replace("v*", version);
   }
 
   public String getAaiVnfImageUrl() {
@@ -232,4 +237,5 @@ public class ModelLoaderConfig implements IConfiguration {
 
     return false;
   }
+  
 }