From ef09bfdbe63f5e5bd94a8118812d0f4ef28183ba Mon Sep 17 00:00:00 2001
From: ulrich <undisclosed>
Date: Fri, 06 Apr 2018 16:15:51 +0000
Subject: [PATCH] Ermittlung des Datenverzeichnisses auf eine Relation zu catalina.base umgestellt und nach wbx-lib verschoben. Kontext fuer data wird nun selbsttaetig angelegt. Versionsnummer aus Referenz zu Moment.js entfernt.

---
 src/java/de/uhilger/filecms/api/FileMgr.java |   73 +++---------------------------------
 1 files changed, 7 insertions(+), 66 deletions(-)

diff --git a/src/java/de/uhilger/filecms/api/FileMgr.java b/src/java/de/uhilger/filecms/api/FileMgr.java
index cbcfca6..f96d2f0 100644
--- a/src/java/de/uhilger/filecms/api/FileMgr.java
+++ b/src/java/de/uhilger/filecms/api/FileMgr.java
@@ -23,6 +23,8 @@
 import de.uhilger.filecms.pub.FileNameComparator;
 import de.uhilger.wbx.Bild;
 import de.uhilger.wbx.WbxUtils;
+import static de.uhilger.wbx.WbxUtils.EMPTY_STRING;
+import static de.uhilger.wbx.WbxUtils.WBX_FILE_BASE;
 import de.uhilger.wbx.data.Inhalt;
 import java.io.File;
 import java.io.FileInputStream;
@@ -36,6 +38,8 @@
 import java.security.Principal;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.Enumeration;
 import java.util.Iterator;
 import java.util.List;
@@ -147,77 +151,14 @@
     return files;
   }
 
-  public List<Inhalt> collectFiles(String relativePath, int maxTiefe, int maxAnzahl) {
+  public List<Inhalt> collect(String relativePath, int maxTiefe, int maxAnzahl, int len) {
+    
     WbxUtils wu = new WbxUtils();
     HttpServletRequest req = getRequest();
     String requestUrl = req.getRequestURL().toString();
     String contextPath = req.getContextPath();
-    return wu.collectFiles(requestUrl, contextPath, relativePath, maxTiefe, maxAnzahl);
+    return wu.collectFiles(requestUrl, contextPath, relativePath, maxTiefe, maxAnzahl, len);
   }
-
-  /**
-   * Wie list nur mit drill down
-   * 
-   * TODO '/data' muss noch variabel gestaltet werden
-   * 
-   * @param relativePath
-   * @param maxTiefe
-   * @param maxAnzahl
-   * @return 
-   */
-  /*
-    Beispiel
-    http://localhost:8097/file-cms/svc?c=de.uhilger.filecms.api.FileMgr&m=collectFiles&p=/data/admin/journal/&p=2&p=200&f=JSONNICE
-  */
-  public List<Inhalt> collectFilesAlt(String relativePath, int maxTiefe, int maxAnzahl) {
-    Bild bild = new Bild();
-    WbxUtils wu = new WbxUtils();
-    String basis = wu.getJNDIParameter(WbxUtils.WBX_FILE_BASE, WbxUtils.EMPTY_STRING);
-    String pubDirName = wu.getJNDIParameter(WbxUtils.WBX_PUB_DIR_NAME, WbxUtils.WBX_DEFAULT_PUB_DIR_NAME);
-    String relPath = relativePath.replace("/data", pubDirName);
-    String absPath = basis + relPath;
-    
-    ArrayList beitraege = new ArrayList();
-    ArrayList<Inhalt> files = new ArrayList<>();
-    wu.collectFiles(new File(absPath), 0, beitraege, maxTiefe, maxAnzahl);
-
-    Iterator i = beitraege.iterator();
-    while(i.hasNext()) {
-      File beitrag = (File) i.next();
-      Inhalt cont = new Inhalt();
-      cont.setMimetype(bild.getMimeType(beitrag));
-      cont.setIsDirectory(beitrag.isDirectory());
-      cont.setIsHidden(beitrag.isHidden());
-      cont.setLastModified(beitrag.lastModified());
-      cont.setLength(beitrag.length());
-      
-      /*
-        den 'https://..'-Teil bis vor dem 
-        ContextPath ermitteln
-      */
-      StringBuffer requestUrl = getRequest().getRequestURL();
-      String contextPath = getRequest().getContextPath();
-      int pos = requestUrl.indexOf(contextPath);
-      
-      /*
-        den Teil des Pfades ermitteln, der zwischen dem 
-        ContextPath zum oeffentlichen Ordner und dem Dateiname 
-        steht
-      */
-      String absolutePath = beitrag.getAbsolutePath();
-      absolutePath = absolutePath.replace(beitrag.getName(), "");
-      absolutePath = absolutePath.replace(pubDirName, "");
-      String part = relativePath.replace("/data", "");
-      int pos2 = absolutePath.indexOf(part);
-      String mittelteil = absolutePath.substring(pos2);
-      mittelteil = mittelteil.replace(part, "");
-      cont.setBase(requestUrl.substring(0, pos));
-      
-      cont.setUrl(/*requestUrl.substring(0, pos) + "/data" + */ mittelteil + beitrag.getName());
-      files.add(cont);
-    }
-    return files;
-  } 
   
   public FileRef newFolder(String relPath, String folderName) {
     if (!relPath.startsWith(".")) {

--
Gitblit v1.9.3