1 5 6 package org.exoplatform.services.jcr.impl.storage.filesystem.nodedata; 7 8 9 import javax.jcr.ItemExistsException; 10 import javax.jcr.RepositoryException; 11 import javax.jcr.Node; 12 import org.exoplatform.services.jcr.core.ItemLocation; 13 import org.exoplatform.services.jcr.core.NodeChange; 14 import org.exoplatform.services.jcr.core.NodeData; 15 import org.exoplatform.services.jcr.impl.core.NodeImpl; 16 import org.exoplatform.services.jcr.storage.Container; 17 import java.io.File ; 18 import java.util.ArrayList ; 19 import java.util.List ; 20 21 27 28 public final class FolderNodeContainer extends BaseNodeContainer { 29 30 31 FolderNodeContainer(String jcrPath, File storage) { 32 super(jcrPath, "nt:folder", storage); 33 } 34 35 36 public NodeData getNodeByPath(String relPath) { 37 38 if (relPath.length() != 0) 39 return null; 40 else 41 return getRootNode(); 42 43 } 44 45 public List getChildren(String relPath) { 46 50 ArrayList list = new ArrayList (); 51 52 File [] cFiles = storage.listFiles(); 53 for (int i = 0; i < cFiles.length; i++){ 54 try { 55 NodeContainer nodeContainer; 56 String path = new ItemLocation(containerPath, cFiles[i].getName()).getPath(); 57 66 list.add(path); 67 } catch (Exception e) { 68 e.printStackTrace(); 69 } 70 } 71 return list; 72 } 73 74 public void add(Node node) throws ItemExistsException, RepositoryException { 75 } 78 79 80 public final void update(Node node) { 81 } 83 84 public final void delete(String absPath) { 85 86 log.debug("FolderNode Container delete node:" + absPath); 88 deleteRecursively(storage); 89 } 90 91 final void deleteRecursively(File file) { 92 93 File [] children = file.listFiles(); 94 if(children != null) { 95 for(int i=0; i<children.length; i++) { 96 log.debug("File :" + children[i]+" found for delete."); 97 deleteRecursively(children[i]); 98 } 99 } 100 System.out.println("File exists: " + file.exists()); 101 System.out.println("File is file: " + file.isFile()); 102 System.out.println("File deleted: " + file.delete()); 103 107 109 } 110 111 } 112 | Popular Tags |