Refactoring data-provider:provider generateDTOs 26/102526/9
authorSingal, Kapil (ks220y) <ks220y@att.com>
Thu, 27 Feb 2020 20:24:18 +0000 (15:24 -0500)
committerSingal, Kapil (ks220y) <ks220y@att.com>
Thu, 27 Feb 2020 21:47:52 +0000 (16:47 -0500)
Fixing EsInit.script file creation

Change-Id: I615114e617bdabbb876a66610caa2665b17f0a71
Issue-ID: SDNC-1085
Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com>
sdnr/wt/data-provider/provider/pom.xml
sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/MavenDatabasePluginInitFile.java

index 3f72ce1..d834dc2 100644 (file)
@@ -61,7 +61,7 @@
             <artifactId>mockito-core</artifactId>
             <scope>test</scope>
         </dependency>
-         <dependency>
+        <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>sdnr-wt-data-provider-setup</artifactId>
             <version>${project.version}</version>
                             <goal>exec</goal>
                         </goals>
                         <configuration>
-                           <executable>java</executable>
+                            <executable>java</executable>
                             <arguments>
                                 <argument>-jar</argument>
-                                <argument>${basedir}/../../data-provider/setup/target/sdnr-dmt.jar</argument>
+                                <argument>${basedir}/../setup/target/sdnr-dmt.jar</argument>
                                 <argument>-c</argument>
                                 <argument>pluginfile</argument>
                                 <argument>-of</argument>
index a63f8d4..e923b27 100644 (file)
@@ -5,6 +5,8 @@
  * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
  * All rights reserved.
  * ================================================================================
+ * Update Copyright (C) 2020 AT&T Intellectual Property. 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
@@ -23,7 +25,6 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data;
 
 import java.io.File;
 import java.io.IOException;
-import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.util.ArrayList;
 import java.util.List;
@@ -44,15 +45,20 @@ public class MavenDatabasePluginInitFile {
     "{\"type\":\"custom\",\"tokenizer\":\"whitespace\"}}}}";
 
        public static void create(Release release, String filename) throws IOException {
-               
+
                ReleaseInformation ri = ReleaseInformation.getInstance(release);
                Set<ComponentName> comps=ri.getComponents();
-               List<String> lines = new ArrayList<String>();
+               List<String> lines = new ArrayList<>();
                for(ComponentName c:comps) {
                        lines.add(String.format("PUT:%s/:{"+settings+","+mappings+"}",ri.getIndex(c),shards,replicas,ri.getDatabaseMapping(c)));
                        lines.add(String.format("PUT:%s/_alias/%s/:{}", ri.getIndex(c),ri.getAlias(c)));
                }
-               Files.write(new File(filename).toPath(),lines,StandardCharsets.UTF_8);
-               
+
+               File filePath = new File(filename);
+               if (filePath.getParentFile() != null && !filePath.getParentFile().exists()){
+                       //Crate Directory if missing
+                       filePath.getParentFile().mkdirs();
+               }
+               Files.write(filePath.toPath(), lines);
        }
 }