@Override public InputStream getInputStream() throws ResourceException { try { return springDelegate.getInputStream(); } catch (IOException e) { throw new ResourceException(e); } }
workingCopyDirectory = workingCopy; } catch (ResourceException e) { throw new IllegalArgumentException(e.getMessage()); log.error("Resource file " + resourceFile + " does not exist in SVN working copy directory " + workingCopy.getAbsolutePath()); throw new ResourceException("Resource file " + resourceFile + " does not exist in SVN working copy directory " + workingCopy.getAbsolutePath());
@Override public InputStream getInputStream() throws ResourceException { try { return springDelegate.getInputStream(); } catch (IOException e) { throw new ResourceException(e); } }
/** * Constructor. * * @param resourceURI file: URI to the file * * @throws ResourceException thrown if the resource path is null or empty * * @since 1.2.0 */ public FilesystemResource(URI resourceURI) throws ResourceException { super(); if (resourceURI == null) { throw new ResourceException("Resource URL may not be null"); } resource = new File(resourceURI); }
/** * Constructor. * * @param resourceURI the file: URI to the file for this resource * @param resourceFilter filter to apply to this resource * * @throws ResourceException thrown if the resource path is null or empty * * @since 1.2.0 * @deprecated use {@link #setResourceFilter(ResourceFilter)} instead */ public FilesystemResource(URI resourceURI, ResourceFilter resourceFilter) throws ResourceException { super(resourceFilter); if (resourceURI == null) { throw new ResourceException("Resource URI may not be null"); } resource = new File(resourceURI); }
/** * Saves a resource to the backing file. * * @param resource the string representation of the resource * * @throws ResourceException thrown if the resource backing file can not be written to */ protected void saveToResourceFile(byte[] resource) throws ResourceException { try { FileOutputStream out = new FileOutputStream(resourceFile); out.write(resource); } catch (IOException e) { throw new ResourceException("Unable to write resource to backing file " + resourceFile.getAbsolutePath(), e); } } }
/** {@inheritDoc} */ public DateTime getLastModifiedTime() throws ResourceException { if (!resource.exists()) { throw new ResourceException("Resource file does not exist: " + resource.getAbsolutePath()); } return new DateTime(resource.lastModified(), ISOChronology.getInstanceUTC()); }
@Override public DateTime getLastModifiedTime() throws ResourceException { try { return new DateTime(springDelegate.lastModified()); } catch (IOException e) { throw new ResourceException(e); } }
/** {@inheritDoc} */ public InputStream getInputStream() throws ResourceException { try { FileInputStream ins = new FileInputStream(resource); return applyFilter(ins); } catch (FileNotFoundException e) { throw new ResourceException("Resource file does not exist: " + resource.getAbsolutePath()); } }
/** {@inheritDoc} */ public InputStream getInputStream() throws ResourceException { try { InputStream ins = resource.openStream(); return applyFilter(ins); } catch (IOException e) { throw new ResourceException("Unable to open resource: " + resource); } }
@Override public DateTime getLastModifiedTime() throws ResourceException { try { return new DateTime(springDelegate.lastModified()); } catch (IOException e) { throw new ResourceException(e); } }
public SpringResourceWrapperOpenSAMLResource(Resource springDelegate) throws ResourceException { this.springDelegate = springDelegate; if (!exists()) { throw new ResourceException("Wrapper resource does not exist: " + springDelegate); } }
/** * Constructor. * * @param path the path to the file for this resource * * @throws ResourceException thrown if the resource path is null or empty or if the resource does not exist */ public ClasspathResource(String path) throws ResourceException { super(); if (DatatypeHelper.isEmpty(path)) { throw new ResourceException("Resource path may not be null or empty"); } resource = getClass().getResource(path); if (resource == null) { throw new ResourceException("Classpath resource does not exist: " + path); } lastModTime = new DateTime(); }
/** * Constructor. * * @param resourcePath the path to the file for this resource * * @throws ResourceException thrown if the resource path is null or empty */ public FilesystemResource(String resourcePath) throws ResourceException { super(); if (DatatypeHelper.isEmpty(resourcePath)) { throw new ResourceException("Resource path may not be null or empty"); } resource = new File(resourcePath); }
/** * Constructor. * * @param path the path to the file for this resource * @param resourceFilter filter to apply to this resource * * @throws ResourceException thrown if the resource path is null or empty or if the resource does not exist * * @deprecated use {@link #setResourceFilter(ResourceFilter)} instead */ public ClasspathResource(String path, ResourceFilter resourceFilter) throws ResourceException { super(resourceFilter); if (DatatypeHelper.isEmpty(path)) { throw new ResourceException("Resource path may not be null or empty"); } resource = getClass().getResource(path); if (resource == null) { throw new ResourceException("Classpath resource does not exist: " + path); } lastModTime = new DateTime(); }
/** * Constructor. * * @param resourcePath the path to the file for this resource * @param resourceFilter filter to apply to this resource * * @throws ResourceException thrown if the resource path is null or empty * * @deprecated use {@link #setResourceFilter(ResourceFilter)} instead */ public FilesystemResource(String resourcePath, ResourceFilter resourceFilter) throws ResourceException { super(resourceFilter); if (DatatypeHelper.isEmpty(resourcePath)) { throw new ResourceException("Resource path may not be null or empty"); } resource = new File(resourcePath); }
props.load(new FileInputStream(propertyFilePath)); } catch (IOException e) { throw new ResourceException("Unable to read property file", e); return new ByteArrayInputStream(resourceString.getBytes()); } catch (IOException e) { throw new ResourceException("Unable to read contents of resource", e);
if (directory == null) { log.error("SVN working copy directory may not be null"); throw new ResourceException("SVN working copy directory may not be null"); log.error("SVN working copy direction " + directory.getAbsolutePath() + " does not exist and could not be created"); throw new ResourceException("SVN working copy direction " + directory.getAbsolutePath() + " does not exist and could not be created"); throw new ResourceException("SVN working copy location " + directory.getAbsolutePath() + " is not a directory"); throw new ResourceException("SVN working copy directory " + directory.getAbsolutePath() + " can not be read by this process"); log.error("SVN working copy directory " + directory.getAbsolutePath() + " can not be written to by this process"); throw new ResourceException("SVN working copy directory " + directory.getAbsolutePath() + " can not be written to by this process");
/** {@inheritDoc} */ public InputStream getInputStream() throws ResourceException { checkoutOrUpdateResource(); try { return applyFilter(new FileInputStream(getResourceFile())); } catch (IOException e) { String erroMsg = "Unable to read resource file " + resourceFileName + " from local working copy " + workingCopyDirectory.getAbsolutePath(); log.error(erroMsg, e); throw new ResourceException(erroMsg, e); } }
/** {@inheritDoc} */ public DateTime getLastModifiedTime() throws ResourceException { try { return super.getLastModifiedTime(); } catch (ResourceException e) { log.warn("HTTP resource '{}' was inaccessible for getLastModifiedTime(), trying backing file '{}'", getLocation(), resourceFile.getAbsolutePath()); long lastModifiedTime = resourceFile.lastModified(); if (lastModifiedTime == 0) { throw new ResourceException("URL resource is not reachable and backing file is not readable"); } return new DateTime(lastModifiedTime, ISOChronology.getInstanceUTC()); } }