private Reader getReader(String encoding) throws IOException { Reader reader = null; String resourcePath = toResourcePath(templatePath); Resource resource = getResourceResolver().getResource(resourcePath); if (resource.exists()) { reader = encoding != null ? new java.io.InputStreamReader(resource.getInputStream(), encoding) : new java.io.InputStreamReader(resource.getInputStream()); } return reader; } }
private Reader getReader(String encoding) throws IOException { Reader reader = null; String resourcePath = toResourcePath(templatePath); Resource resource = getResourceResolver().getResource(resourcePath); if (resource.exists()) { reader = encoding != null ? new java.io.InputStreamReader(resource.getInputStream(), encoding) : new java.io.InputStreamReader(resource.getInputStream()); } return reader; } }
public InputStream getDocument(String documentPath) throws IOException { if (isForbidden(documentPath)) { throw new IOException("Document path: " + documentPath + " is within a protected directory, cannot retrieve input stream"); } String resourcePath = toResourcePath(documentPath); Resource resource = this.resolver.getResource(resourcePath); return resource.getInputStream(); }
public InputStream getDocument(String documentPath) throws IOException { if (isForbidden(documentPath)) { throw new IOException("Document path: " + documentPath + " is within a protected directory, cannot retrieve input stream"); } String resourcePath = toResourcePath(documentPath); Resource resource = this.resolver.getResource(resourcePath); return resource.getInputStream(); }
/** * Gets resources that match a given location pattern. A resource in the returned array can live * in the class path as either a class file or as an entry within one of the JAR files in the * class path. * * This function is provided here as it is generally useful for implementation classes. * * @param documentPathPattern String * @return Resource[] * @throws IOException */ protected Resource[] getDocumentResources(String documentPathPattern) throws IOException { String resourcePath = toResourcePath(documentPathPattern); Resource[] resources = resolver.getResources(resourcePath); ArrayList<Resource> list = new ArrayList<Resource>(resources.length); for (Resource resource : resources) { // only keep documents, not directories if (!resource.getURL().toExternalForm().endsWith("/")) { list.add(resource); } } return list.toArray(new Resource[list.size()]); } }
/** * Gets resources that match a given location pattern. A resource in the returned array can live * in the class path as either a class file or as an entry within one of the JAR files in the * class path. * * This function is provided here as it is generally useful for implementation classes. * * @param documentPathPattern String * @return Resource[] * @throws IOException */ protected Resource[] getDocumentResources(String documentPathPattern) throws IOException { String resourcePath = toResourcePath(documentPathPattern); Resource[] resources = resolver.getResources(resourcePath); ArrayList<Resource> list = new ArrayList<Resource>(resources.length); for (Resource resource : resources) { // only keep documents, not directories if (!resource.getURL().toExternalForm().endsWith("/")) { list.add(resource); } } return list.toArray(new Resource[list.size()]); } }
public boolean hasDocument(String documentPath) { boolean has = false; if (!isForbidden(documentPath)) { String resourcePath = toResourcePath(documentPath); Resource resource = this.resolver.getResource(resourcePath); has = resource.exists(); } return has; }
public boolean hasDocument(String documentPath) { boolean has = false; if (!isForbidden(documentPath)) { String resourcePath = toResourcePath(documentPath); Resource resource = this.resolver.getResource(resourcePath); has = resource.exists(); } return has; }
/** * @see org.springframework.extensions.webscripts.ScriptContent#getReader() */ public Reader getReader() { Reader reader = null; try { String resourcePath = toResourcePath(scriptPath); Resource resource = getResourceResolver().getResource(resourcePath); if (resource.exists()) { reader = new java.io.InputStreamReader(resource.getInputStream(), "UTF-8"); } } catch (IOException e) { throw new PlatformRuntimeException( "Unable to load script: " + scriptPath, e); } return reader; }
/** * @see org.springframework.extensions.webscripts.ScriptContent#getReader() */ public Reader getReader() { Reader reader = null; try { String resourcePath = toResourcePath(scriptPath); Resource resource = getResourceResolver().getResource(resourcePath); if (resource.exists()) { reader = new java.io.InputStreamReader(resource.getInputStream(), "UTF-8"); } } catch (IOException e) { throw new PlatformRuntimeException( "Unable to load script: " + scriptPath, e); } return reader; }
/** * @see org.springframework.extensions.webscripts.ScriptContent#getInputStream() */ public InputStream getInputStream() { InputStream is = null; try { String resourcePath = toResourcePath(scriptPath); Resource resource = getResourceResolver().getResource(resourcePath); if (resource.exists()) { is = resource.getInputStream(); } } catch (IOException e) { throw new PlatformRuntimeException( "Unable to load script: " + scriptPath, e); } return is; }
public long lastModified(String documentPath) throws IOException { long lastModified = -1; if (!isForbidden(documentPath)) { String resourcePath = toResourcePath(documentPath); Resource resource = this.resolver.getResource(resourcePath); lastModified = resource.lastModified(); } return lastModified; }
public long lastModified(String documentPath) throws IOException { long lastModified = -1; if (!isForbidden(documentPath)) { String resourcePath = toResourcePath(documentPath); Resource resource = this.resolver.getResource(resourcePath); lastModified = resource.lastModified(); } return lastModified; }
/** * @see org.springframework.extensions.webscripts.ScriptContent#getInputStream() */ public InputStream getInputStream() { InputStream is = null; try { String resourcePath = toResourcePath(scriptPath); Resource resource = getResourceResolver().getResource(resourcePath); if (resource.exists()) { is = resource.getInputStream(); } } catch (IOException e) { throw new PlatformRuntimeException( "Unable to load script: " + scriptPath, e); } return is; }