1 package org.jahia.services.webdav; 2 3 import org.apache.slide.event.MacroListener; 4 import org.apache.slide.event.MacroEvent; 5 import org.apache.slide.event.VetoException; 6 import org.apache.slide.content.*; 7 import org.apache.slide.structure.Structure; 8 import org.apache.slide.structure.StructureImpl; 9 import org.apache.slide.security.Security; 10 import org.apache.slide.security.ACLSecurityImpl; 11 import org.apache.slide.lock.Lock; 12 import org.apache.slide.lock.LockImpl; 13 import org.apache.log4j.Logger; 14 15 29 public class JahiaMacroListener implements MacroListener { 30 private static Logger logger = Logger.getLogger (JahiaMacroListener.class); 31 32 public JahiaMacroListener() { 33 } 34 35 public void copy(MacroEvent event) throws VetoException { 36 try { 37 } catch (Exception e) { 55 56 } 57 } 58 59 public void move(MacroEvent event) throws VetoException { 60 JahiaWebdavBaseService.getInstance().move( event.getSourceURI(), event.getTargetURI(), event.getNamespace().getName()); 61 } 62 63 public void delete(MacroEvent event) throws VetoException { 64 } 65 66 73 private static String getFilename(String uri) { 74 if (uri.indexOf('/') == -1) { 75 return uri; 76 } 77 if (uri.equals("/")) { 78 return ""; 79 } 80 if (uri.endsWith("/")) { 81 return uri.substring(1+uri.lastIndexOf('/', uri.length() - 2), 82 uri.length() - 1); 83 } else { 84 return uri.substring(1+uri.lastIndexOf('/')); 85 } 86 } 87 88 private Content getContentHelper(MacroEvent event) { 89 Security security = new ACLSecurityImpl(event.getNamespace(), 90 event.getNamespace().getConfig()); 91 Lock lock = new LockImpl(event.getNamespace(), 92 event.getNamespace().getConfig(), 93 security); 94 Structure structure = new StructureImpl(event.getNamespace(), 95 event.getNamespace().getConfig(), 96 security, 97 lock); 98 Content helper = new ContentImpl( 99 event.getNamespace(), 100 event.getNamespace().getConfig(), 101 security, 102 structure, 103 lock); 104 return helper; 105 } 106 107 } 108 | Popular Tags |