Displaying differences for changeset
display as  

src/csip/ServiceResourcesImpl.java

@@ -78,41 +78,27 @@
   }
 
   @Override
-  public void copyFileToWorkspace(String id) throws ServiceException, IOException {
+  public void copyIntoWorkspace(String id) throws ServiceException, IOException {
     Resource resource = Binaries.getResourceById(mds.getClass(), id);
-    String rfile = getResolved(id);
-    if (id == null)
+    if (resource == null)
       throw new IllegalArgumentException("Resource not found :" + id);
 
     if (resource.type() == ResourceType.FILE) {
       FileUtils.copyFileToDirectory(getFile(id), mds.getWorkspaceDir0());
     } else if (resource.type() == ResourceType.ARCHIVE) {
+      String rfile = getResolved(id);
       if (rfile.endsWith("/**")) {
-        rfile = rfile.substring(0, rfile.length() - 3);
-        File src = new File(new File(Config.getString(CSIP_DIR)), rfile);
-        
-        System.out.println("source " + src);
-        System.out.println("dest " + mds.getWorkspaceDir0());
-        cpContent(src, mds.getWorkspaceDir0());
+        rfile = rfile.trim().substring(0, rfile.length() - 3);
+        File src = new File(Config.getString(CSIP_DIR), rfile);
+        FileUtils.copyDirectory(src, mds.getWorkspaceDir0(), true);
       } else {
-        File src = new File(new File(Config.getString(CSIP_DIR)), rfile);
+        File src = new File(Config.getString(CSIP_DIR), rfile);
         FileUtils.copyToDirectory(src, mds.getWorkspaceDir0());
       }
     } else
       throw new IllegalArgumentException("Not a FILE or ARCHIVE Resource: " + id);
   }
 
-  static void cpContent(File src, File dest) throws IOException {
-    try (DirectoryStream<Path> stream = Files.newDirectoryStream(Paths.get(src.getPath()))) {
-      for (Path path : stream) {
-        FileUtils.copyToDirectory(new File(path.toString()), dest);
-      }
-    }
-  }
-
-//  public static void main(String[] args) throws IOException {
-//    cpContent(new File("/tmp/abc"), new File("/tmp/def"));
-//  }
   @Override
   public Connection getJDBC(String id) throws ServiceException {
     return Binaries.getResourceJDBC(mds.getClass(), id, mds.LOG);

src/csip/SessionWorkspaceImpl.java

@@ -116,19 +116,4 @@
     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/ServiceResources.java

@@ -1,5 +1,5 @@
 /*
- * $Id$
+ * $Id: 2.7+55 ServiceResources.java 54cb6e135a5e 2023-11-01 od $
  *
  * This file is part of the Cloud Services Integration Platform (CSIP),
  * a Model-as-a-Service framework, API and application suite.
@@ -32,7 +32,6 @@
    */
   Resource get(String id);
 
-
   /**
    * Get the resolved 'file' configuration for 'id'.
    *
@@ -41,7 +40,6 @@
    */
   String getResolved(String id);
 
-
   /**
    * Get a service resource file. Resources are defined as service annotations.
    *
@@ -52,7 +50,6 @@
    */
   File getFile(String id) throws ServiceException;
 
-
   /**
    * Get an executable from a resource definition. Resources are defined as
    * service annotations.
@@ -64,16 +61,14 @@
    */
   Executable getExe(String id) throws ServiceException;
 
-
   /**
-   * Copy a FILE Resource to the Workspace.
+   * Copy a FILE Resource (file or directory) to the Workspace.
    *
    * @param id The FILE resource ID.
    * @throws ServiceException if id does not exist
    * @throws IOException if copy fails
    */
-  void copyFileToWorkspace(String id) throws ServiceException, IOException;
-
+  void copyIntoWorkspace(String id) throws ServiceException, IOException;
 
   /**
    * Get a JDBC connection from a resource definition.

src/csip/api/server/SessionWorkspace.java

@@ -127,15 +127,5 @@
    */
   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;
 
 }