public static byte[] bytes(URL url) throws IOException { return bytes(url.openStream()); }
public static byte[] bytes(URL url) throws IOException { return bytes(url.openStream()); }
@Override public Timestamped<Resource> getResource(Node file) throws IOException { if (file.url == null) { throw new IOException("Cannot find file " + file.getPath()); } // URLConnection conn = file.url.openConnection(); long lastModified = conn.getLastModified(); byte[] bytes = Tools.bytes(conn.getInputStream()); return new Timestamped<Resource>(lastModified, new Resource(bytes, Charset.defaultCharset())); }
@Override public Timestamped<Resource> getResource(String file) throws IOException { URL url = getURL(file); URLConnection conn = url.openConnection(); long lastModified = conn.getLastModified(); byte[] bytes = Tools.bytes(conn.getInputStream()); return new Timestamped<Resource>(lastModified, new Resource(bytes, Charset.defaultCharset())); }
@Override public Timestamped<Resource> getResource(Node file) throws IOException { if (file.url == null) { throw new IOException("Cannot find file " + file.getPath()); } // URLConnection conn = file.url.openConnection(); long lastModified = conn.getLastModified(); byte[] bytes = Tools.bytes(conn.getInputStream()); return new Timestamped<Resource>(lastModified, new Resource(bytes, Charset.defaultCharset())); }
@Override public Timestamped<Resource> getResource(String file) throws IOException { URL url = getURL(file); URLConnection conn = url.openConnection(); long lastModified = conn.getLastModified(); byte[] bytes = Tools.bytes(conn.getInputStream()); return new Timestamped<Resource>(lastModified, new Resource(bytes, Charset.defaultCharset())); }
@Override protected long stampOf(P file) throws IOException { juzu.impl.common.Timestamped<Resource> resource = fs.getResource(file); InputStream in = resource.getObject().getInputStream(); byte[] bytes = Tools.bytes(in); return Tools.md5(bytes); }
@Override protected long stampOf(P file) throws IOException { juzu.impl.common.Timestamped<Resource> resource = fs.getResource(file); InputStream in = resource.getObject().getInputStream(); byte[] bytes = Tools.bytes(in); return Tools.md5(bytes); }
public void unmarshall(String mediaType, ClientContext context, Iterable<Map.Entry<ContextualParameter, Object>> contextualArguments, Map<String, RequestParameter> parameterArguments) throws IOException { byte[] data = Tools.bytes(context.getInputStream()); Foo foo = new Foo(data); for (Map.Entry<ContextualParameter, Object> parameter : contextualArguments) { if (parameter.getKey().getType().equals(Foo.class)) { parameter.setValue(foo); break; } } } }
public void unmarshall(String mediaType, ClientContext context, Iterable<Map.Entry<ContextualParameter, Object>> contextualArguments, Map<String, RequestParameter> parameterArguments) throws IOException { byte[] data = Tools.bytes(context.getInputStream()); Foo foo = new Foo(data); for (Map.Entry<ContextualParameter, Object> parameter : contextualArguments) { if (parameter.getKey().getType().equals(Foo.class)) { parameter.setValue(foo); break; } } } }
@Override public Timestamped<Resource> resolveResource(Path.Absolute path) { FileObject resource = owner.application.resolveResource(path); if (resource != null) { try { byte[] bytes = Tools.bytes(resource.openInputStream()); long lastModified = resource.getLastModified(); return new Timestamped<Resource>(lastModified, new Resource(bytes, Charset.defaultCharset())); } catch (Exception e) { env.info("Could not get resource content " + path.getCanonical(), e); } } return null; }
@Override public Timestamped<Resource> resolveResource(Path.Absolute path) { FileObject resource = owner.application.resolveResource(path); if (resource != null) { try { byte[] bytes = Tools.bytes(resource.openInputStream()); long lastModified = resource.getLastModified(); return new Timestamped<Resource>(lastModified, new Resource(bytes, Charset.defaultCharset())); } catch (Exception e) { env.info("Could not get resource content " + path.getCanonical(), e); } } return null; }