1 48 49 package org.jpublish.repository; 50 51 import java.io.IOException ; 52 53 import org.apache.commons.logging.Log; 54 import org.apache.commons.logging.LogFactory; 55 import org.apache.commons.vfs.FileSystemManager; 56 import org.jpublish.RequestContext; 57 58 74 75 public class RepositoryWrapper { 76 77 private Log log = LogFactory.getLog(RepositoryWrapper.class); 78 private Repository repository; 79 private RequestContext context; 80 81 87 88 public RepositoryWrapper(Repository repository, RequestContext context) { 89 this.repository = repository; 90 this.context = context; 91 } 92 93 98 99 public Repository getRepository() { 100 return repository; 101 } 102 103 110 111 public FileSystemManager getFileSystemManager() throws IOException { 112 return repository.getFileSystemManager(); 113 } 114 115 120 121 public String getName() { 122 return repository.getName(); 123 } 124 125 131 132 public String get(String path) { 133 if (log.isDebugEnabled()) { 134 log.debug("get(" + path + ")"); 135 } 136 return get(path, true); 137 } 138 139 147 148 public String get(String path, boolean merged) { 149 try { 150 Content content = repository.getContent(path); 151 if (merged) { 152 return content.render(context); 153 } else { 154 return content.getContentString(); 155 } 156 } catch (Exception e) { 157 if (log.isDebugEnabled()) { 158 e.printStackTrace(); 159 } 160 return "Error loading content: " + e.getMessage(); 161 } 162 } 163 164 172 173 public long getLastModified(String path) throws IOException { 174 return repository.getLastModified(path); 175 } 176 177 } 178 | Popular Tags |