| | |
| | | package de.uhilger.filecms.pub; |
| | | |
| | | import de.uhilger.filecms.api.Api; |
| | | import de.uhilger.filecms.data.Bild; |
| | | import de.uhilger.wbx.Bild; |
| | | import de.uhilger.filecms.data.FileRef; |
| | | import java.io.File; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.logging.Logger; |
| | | |
| | |
| | | * @return Liste der Dateien und Ordner am Ort relPath |
| | | */ |
| | | public List<FileRef> list(String relPath) { |
| | | Bild bild = new Bild(); |
| | | return listInt(relPath, null, null); |
| | | } |
| | | |
| | | /** |
| | | * Inhalte der WebBox listen. Hier wird nur ausgegeben was mit |
| | | * einer relativen Pfadangabe ausgehend von www, der oeffentlichen |
| | | * Ablage einer WeBox, erreichbar ist. |
| | | * |
| | | * Andere Inhalte werden nicht ausgegeben. |
| | | * |
| | | * @param relPath der relative Pfad, der von www aus gelistet werden soll, ohne www |
| | | * @return Liste der Dateien und Ordner am Ort relPath |
| | | */ |
| | | public List<FileRef> listOrdered(String relPath, String orderBy, String order) { |
| | | return listInt(relPath, orderBy, order); |
| | | } |
| | | |
| | | private List<FileRef> listInt(String relPath, String orderBy, String order) { |
| | | List<FileRef> files = new ArrayList(); |
| | | StringBuffer path = new StringBuffer(PUB_DIR_PATH); // www/ |
| | | path.append(relPath); |
| | | File dir = new File(getBase().getAbsolutePath(), path.toString()); |
| | | if(dir.exists()) { |
| | | File[] fileArray = dir.listFiles(); |
| | | for(int i = 0; i < fileArray.length; i++) { |
| | | logger.fine(fileArray[i].toURI().toString()); |
| | | String fname = fileArray[i].toURI().toString().replace("file:/", ""); |
| | | if(fileArray[i].isDirectory()) { |
| | | fname = fname.substring(0, fname.length() - 1); |
| | | if(!relPath.startsWith(".")) { |
| | | Bild bild = new Bild(); |
| | | StringBuffer path = new StringBuffer(PUB_DIR_PATH); // www/ |
| | | path.append(relPath); |
| | | File dir = new File(getBase().getAbsolutePath(), path.toString()); |
| | | if(dir.exists()) { |
| | | File[] fileArray = dir.listFiles(new ImgFileFilter()); |
| | | if(orderBy != null && orderBy.equalsIgnoreCase("date")) { |
| | | Arrays.sort(fileArray, new FileDateComparator(order)); |
| | | } |
| | | logger.fine(fname); |
| | | FileRef ref = new FileRef(fname, fileArray[i].isDirectory()); |
| | | ref.setMimetype(bild.getMimeType(fileArray[i])); |
| | | files.add(ref); |
| | | for(int i = 0; i < fileArray.length; i++) { |
| | | logger.fine(fileArray[i].toURI().toString()); |
| | | String fname = fileArray[i].toURI().toString().replace("file:/", ""); |
| | | if(fileArray[i].isDirectory()) { |
| | | fname = fname.substring(0, fname.length() - 1); |
| | | } |
| | | logger.fine(fname); |
| | | FileRef ref = new FileRef(fname, fileArray[i].isDirectory()); |
| | | ref.setMimetype(bild.getMimeType(fileArray[i])); |
| | | files.add(ref); |
| | | } |
| | | } |
| | | } |
| | | return files; |
| | | } |
| | | } |
| | | |
| | | } |