private File getFile(String path) throws NotFound { if (path == null) return rootDir; File f = new File(rootDir.getAbsolutePath() + '/' + path); if (f.exists()) return f; throw new NotFound("File not found."); }
/** * Constructor. * * @param msg The message. Can be <jk>null</jk>. */ public NotFound(String msg) { super(msg); setStatus(CODE); }
private File getFile(String path) throws NotFound { if (path == null) return logDir; File f = new File(logDir.getAbsolutePath() + '/' + path); if (f.exists()) return f; throw new NotFound("File not found."); }
/** * Constructor. * * @param msg The message. Can be <jk>null</jk>. */ public NotFound(String msg) { super(msg); setStatus(CODE); }
private File getFile(String path) throws NotFound { if (path == null) return logDir; File f = new File(logDir.getAbsolutePath() + '/' + path); if (f.exists()) return f; throw new NotFound("File not found."); }
/** * Constructor. * * @param msg The message. Can be <jk>null</jk>. */ public NotFound(String msg) { super(msg); setStatus(CODE); }
private File getFile(String path) throws NotFound { if (path == null) return rootDir; File f = new File(rootDir.getAbsolutePath() + '/' + path); if (f.exists()) return f; throw new NotFound("File not found."); }
@RestMethod( name=DELETE, path="/{id}", summary="Delete a photo by ID" ) public String deletePhoto(@Path("id") String id) throws NotFound { Photo p = photos.remove(id); if (p == null) throw new NotFound("Photo not found"); return "OK"; }
@RestMethod( name=DELETE, path="/{id}", summary="Delete a photo by ID" ) public String deletePhoto(@Path("id") String id) throws NotFound { Photo p = photos.remove(id); if (p == null) throw new NotFound("Photo not found"); return "OK"; }
/** * Return the <code>Class</code> given it's name if it exists in the services map. */ private RemoteInterfaceMeta getInterfaceClass(String javaInterface) throws NotFound, Exception { RemoteInterfaceMeta rm = serviceMap.get(javaInterface); if (rm == null) { for (Class<?> c : getServiceMap().keySet()) { if (c.getName().equals(javaInterface)) { rm = new RemoteInterfaceMeta(c, null); serviceMap.put(javaInterface, rm); return rm; } } throw new NotFound("Interface class not found"); } return rm; } }
/** * Return the <code>Class</code> given it's name if it exists in the services map. */ private RemoteInterfaceMeta getInterfaceClass(String javaInterface) throws NotFound, Exception { RemoteInterfaceMeta rm = serviceMap.get(javaInterface); if (rm == null) { for (Class<?> c : getServiceMap().keySet()) { if (c.getName().equals(javaInterface)) { rm = new RemoteInterfaceMeta(c, null); serviceMap.put(javaInterface, rm); return rm; } } throw new NotFound("Interface class not found"); } return rm; } }
/** * Return the <code>Class</code> given it's name if it exists in the services map. */ private RemoteInterfaceMeta getInterfaceClass(String javaInterface) throws NotFound, Exception { RemoteInterfaceMeta rm = serviceMap.get(javaInterface); if (rm == null) { for (Class<?> c : getServiceMap().keySet()) { if (c.getName().equals(javaInterface)) { rm = new RemoteInterfaceMeta(c, null); serviceMap.put(javaInterface, rm); return rm; } } throw new NotFound("Interface class not found"); } return rm; } }
@RestMethod public void notFound() { throw new NotFound(t); } @RestMethod public void notImplemented() { throw new NotImplemented(t); }
@RestMethod public void notFound() { throw new NotFound(t, "foo {0}", "bar"); } @RestMethod public void notImplemented() { throw new NotImplemented(t, "foo {0}", "bar"); }
@RestMethod public void notFound() { throw new NotFound(); } @RestMethod public void notImplemented() { throw new NotImplemented(); }
@RestMethod( name=GET, path="/{id}", serializers=ImageSerializer.class, summary="Get a photo by ID", description="Shows how to use a custom serializer to serialize a BufferedImage object to a stream." ) @Response( schema=@Schema(type="file") ) public BufferedImage getPhoto(@Path("id") String id) throws NotFound { Photo p = photos.get(id); if (p == null) throw new NotFound("Photo not found"); return p.image; }
@RestMethod public void notFound() { throw new NotFound("foo {0}", "bar"); } @RestMethod public void notImplemented() { throw new NotImplemented("foo {0}", "bar"); }
String p = urlDecode(trimSlashes(pathInfo)); if (p.indexOf("..") != -1) throw new NotFound("Invalid path"); StreamResource sr = null; for (StaticFileMapping sfm : staticFiles) {
@RestMethod( name=GET, path="/{id}", serializers=ImageSerializer.class, summary="Get a photo by ID", description="Shows how to use a custom serializer to serialize a BufferedImage object to a stream." ) @Response( schema=@Schema(type="file") ) public BufferedImage getPhoto(@Path("id") String id) throws NotFound { Photo p = photos.get(id); if (p == null) throw new NotFound("Photo not found"); return p.image; }
String p = urlDecode(trimSlashes(pathInfo)); if (p.indexOf("..") != -1) throw new NotFound("Invalid path"); StreamResource sr = null; for (StaticFileMapping sfm : staticFiles) {