1 24 package org.riotfamily.components.property; 25 26 import java.io.IOException ; 27 28 import org.apache.commons.logging.Log; 29 import org.apache.commons.logging.LogFactory; 30 import org.riotfamily.common.web.file.FileStore; 31 import org.riotfamily.common.web.file.FileUtils; 32 33 38 public class FileStoreProperyProcessor extends AbstractSinglePropertyProcessor { 39 40 private static Log log = LogFactory.getLog(FileStoreProperyProcessor.class); 41 42 private FileStore fileStore; 43 44 public FileStoreProperyProcessor() { 45 } 46 47 public FileStoreProperyProcessor(String property, FileStore fileStore) { 48 this.fileStore = fileStore; 49 setProperty(property); 50 } 51 52 public void setFileStore(FileStore fileStore) { 53 this.fileStore = fileStore; 54 } 55 56 protected String copy(String s) { 57 if (s != null) { 58 try { 59 return FileUtils.copy(fileStore, s); 60 } 61 catch (IOException e) { 62 log.error("Error copying file", e); 63 } 64 } 65 return null; 66 } 67 68 protected void delete(String s) { 69 if (s != null) { 70 fileStore.delete(s); 71 } 72 } 73 74 protected Object resolveString(String s) { 75 return s; 76 } 77 78 protected String convertToString(Object object) { 79 return (String ) object; 80 } 81 82 } 83 | Popular Tags |