Displaying differences for changeset
display as  

nbproject/project.properties

@@ -46,8 +46,8 @@
 javac.processormodulepath=
 javac.processorpath=\
     ${javac.classpath}
-javac.source=17
-javac.target=17
+javac.source=1.8
+javac.target=1.8
 javac.test.classpath=\
     ${javac.classpath}:\
     ${build.classes.dir}:\

src/csip/Config.java

@@ -159,7 +159,7 @@
       /*
        * The CSIP version for platform and context (placeholder)
        */
-      put(CSIP_PLATFORM_VERSION, "$version: 2.8.21 default 914 88296ebb726e 2024-06-13 od, built at 2024-08-05 12:39 by od$");
+      put(CSIP_PLATFORM_VERSION, "$version: 2.8.22 default 915 f93db2a58c82 2024-08-05 od, built at 2024-08-08 15:59 by od$");
       put(CSIP_CONTEXT_VERSION, "$version: 0.0.0 000000000000");
 
       put("csip.response.version", "true");

src/csip/SessionWorkspaceImpl.java

@@ -11,6 +11,8 @@
  */
 package csip;
 
+import static csip.Config.CSIP_DIR;
+import static csip.Config.CSIP_WORK_DIR;
 import csip.api.server.ServiceException;
 import csip.api.server.SessionWorkspace;
 import java.io.File;
@@ -35,37 +37,31 @@
     super(mds);
   }
 
-
   @Override
   public Stream<String> lines(String filename) throws IOException {
     return Files.lines(getFile(filename).toPath());
   }
 
-
   @Override
   public Stream<String> lines(File file) throws IOException {
     return Files.lines(file.toPath());
   }
 
-
   @Override
   public String toString() {
     return getDir().toString();
   }
 
-
   @Override
   public File getDir() {
     return mds.getWorkspaceDir0();
   }
 
-
   @Override
   public File getFile(String filename) {
     return new File(getDir(), filename);
   }
 
-
   @Override
   public File[] getFiles(String... pattern) throws IOException {
     List<File> files = new ArrayList<>();
@@ -76,7 +72,6 @@
     return files.toArray(new File[0]);
   }
 
-
   @Override
   public File getExistingFile(String filename) throws FileNotFoundException {
     File f = getFile(filename);
@@ -85,19 +80,16 @@
     return f;
   }
 
-
   @Override
   public Path getPath() {
     return getDir().toPath();
   }
 
-
   @Override
   public String readString(String filename) throws IOException {
     return FileUtils.readFileToString(getFile(filename), "UTF-8");
   }
 
-
   @Override
   public File writeString(String filename, String data) throws IOException {
     File f = getFile(filename);
@@ -105,19 +97,16 @@
     return f;
   }
 
-
   @Override
   public byte[] readBytes(String filename) throws IOException {
     return FileUtils.readFileToByteArray(getFile(filename));
   }
 
-
   @Override
   public void writeBytes(String filename, byte[] data) throws IOException {
     FileUtils.writeByteArrayToFile(getFile(filename), data);
   }
 
-
   @Override
   public SessionWorkspaceImpl exist(String... filenames) throws ServiceException {
     for (String n : filenames) {
@@ -127,4 +116,19 @@
     return this;
   }
 
+  @Override
+  public void copyFrom(String csipSubDir) throws IOException, IllegalAccessException {
+    File srcDir = new File(Config.getString(CSIP_DIR), csipSubDir);
+    if (srcDir.toString().startsWith(Config.getString(CSIP_WORK_DIR))
+        || srcDir.toString().startsWith(Config.getString(Config.CSIP_RESULTS_DIR)))
+      throw new IllegalAccessException(srcDir.toString());
+
+    FileUtils.copyDirectory(srcDir, getDir(), true);
+  }
+
+//  public static void main(String[] args) throws IOException {
+//    FileUtils.copyDirectory(new File("/od/projects/csip-all/csip-core/lib"),
+//        new File("/tmp/ws"), true);
+//
+//  }
 }

src/csip/api/server/SessionWorkspace.java

@@ -33,7 +33,6 @@
    */
   Stream<String> lines(String filename) throws IOException;
 
-
   /**
    * Get the lines as stream.
    *
@@ -43,7 +42,6 @@
    */
   Stream<String> lines(File file) throws IOException;
 
-
   /**
    * Get a the workspace folder for this model run.
    *
@@ -51,7 +49,6 @@
    */
   File getDir();
 
-
   /**
    * Get a file with the workspace folder.
    *
@@ -60,7 +57,6 @@
    */
   File getFile(String filename);
 
-
   /**
    * Get files in workspace based on pattern.
    *
@@ -70,7 +66,6 @@
    */
   File[] getFiles(String... pattern) throws IOException;
 
-
   /**
    * Get a file with the workspace folder. The file must exist.
    *
@@ -80,23 +75,22 @@
    */
   File getExistingFile(String filename) throws FileNotFoundException;
 
-
   /**
    * Get the Path object of the workspace.
+   *
    * @return the Path
    */
   Path getPath();
 
-
   /**
    * Get the content of a file within the workspace as String.
+   *
    * @param filename the file name
    * @return the String content
    * @throws IOException if reading fails
    */
   String readString(String filename) throws IOException;
 
-
   /**
    * Write a string to a file within the workspace.
    *
@@ -106,16 +100,15 @@
    */
   File writeString(String filename, String data) throws IOException;
 
-
   /**
    * Get the content of a file within the workspace as byte array.
+   *
    * @param filename the filename
    * @return the content as byte array
    * @throws IOException
    */
   byte[] readBytes(String filename) throws IOException;
 
-
   /**
    * Write bytes to a file within the workspace.
    *
@@ -125,7 +118,6 @@
    */
   void writeBytes(String filename, byte[] data) throws IOException;
 
-
   /**
    * Check is a file exists in the workspace.
    *
@@ -135,4 +127,15 @@
    */
   SessionWorkspace exist(String... filenames) throws ServiceException;
 
+  /**
+   * Copies all files from the directory 'csipSubDir' into the current
+   * workspace.
+   *
+   * @param csipSubDir the directory to copy the files from. This is a directory
+   * within "${csip.dir}"
+   * @throws IOException if this was not successful.
+   * @throws IllegalAccessException if not allowed
+   */
+  void copyFrom(String csipSubDir) throws IOException, IllegalAccessException;
+
 }