FileResource containerResources = new FileResource(classes.toURI()); ctx.getMetaData().addContainerResource(containerResources);
@Override public void copyTo(File destination) throws IOException { if (isDirectory()) { IO.copyDir(getFile(),destination); } else { if (destination.exists()) throw new IllegalArgumentException(destination+" exists"); IO.copy(getFile(),destination); } }
@Override public Resource addPath(String path) throws IOException, MalformedURLException { assertValidPath(path); path = org.eclipse.jetty.util.URIUtil.canonicalPath(path); if (path==null) throw new MalformedURLException(); if ("/".equals(path)) return this; return new FileResource(_file, path); }
public FileResource(File file) { assertValidPath(file.toString()); _file=file; try { _uri = normalizeURI(_file, _file.toURI()); } catch (URISyntaxException e) { throw new InvalidPathException(_file.toString(), e.getMessage()) { { initCause(e); } }; } _alias=checkFileAlias(_uri,_file); }
@Override public URL getAlias() { if (__checkAliases && !_aliasChecked) { try { String abs=_file.getAbsolutePath(); String can=_file.getCanonicalPath(); if (abs.length()!=can.length() || !abs.equals(can)) _alias=Resource.toURL(new File(can)); _aliasChecked=true; if (_alias!=null && LOG.isDebugEnabled()) { LOG.debug("ALIAS abs="+abs); LOG.debug("ALIAS can="+can); } } catch(Exception e) { LOG.warn(Log.EXCEPTION,e); return getURL(); } } return _alias; }
checkConnection(); Permission perm = _connection.getPermission(); _file = new File(perm==null?url.getFile():perm.getName());
@Override public void doStart() throws Exception { Context scontext = ContextHandler.getCurrentContext(); _context = (scontext==null?null:scontext.getContextHandler()); if (_context!=null) _aliases=_context.isAliases(); if (!_aliases && !FileResource.getCheckAliases()) throw new IllegalStateException("Alias checking disabled"); super.doStart(); }
public FileResource(URI uri) { File file=new File(uri); _file=file; try { URI file_uri = _file.toURI(); _uri = normalizeURI(_file, uri); assertValidPath(file.toString()); // Is it a URI alias? if (!URIUtil.equalsIgnoreEncodings(_uri.toASCIIString(), file_uri.toString())) _alias = _file.toURI(); else _alias = checkFileAlias(_uri, _file); } catch (URISyntaxException e) { throw new InvalidPathException(_file.toString(), e.getMessage()) { { initCause(e); } }; } }
@Override public URL getAlias() { if (__checkAliases && !_aliasChecked) { try { String abs=_file.getAbsolutePath(); String can=_file.getCanonicalPath(); if (abs.length()!=can.length() || !abs.equals(can)) _alias=Resource.toURL(new File(can)); _aliasChecked=true; if (_alias!=null && LOG.isDebugEnabled()) { LOG.debug("ALIAS abs="+abs); LOG.debug("ALIAS can="+can); } } catch(Exception e) { LOG.warn(Log.EXCEPTION,e); return getURL(); } } return _alias; }
checkConnection(); Permission perm = _connection.getPermission(); _file = new File(perm==null?url.getFile():perm.getName());
@Override public void doStart() throws Exception { Context scontext = ContextHandler.getCurrentContext(); _context = (scontext==null?null:scontext.getContextHandler()); if (_context!=null) _aliases=_context.isAliases(); if (!_aliases && !FileResource.getCheckAliases()) throw new IllegalStateException("Alias checking disabled"); super.doStart(); }
public static Resource newResource(File file) { return new FileResource(file); }
@Override public void copyTo(File destination) throws IOException { if (isDirectory()) { IO.copyDir(getFile(),destination); } else { if (destination.exists()) throw new IllegalArgumentException(destination+" exists"); IO.copy(getFile(),destination); } }
@Override public Resource addPath(String path) throws IOException, MalformedURLException { assertValidPath(path); path = org.eclipse.jetty.util.URIUtil.canonicalPath(path); if (path==null) throw new MalformedURLException(); if ("/".equals(path)) return this; return new FileResource(_file, path); }
assertValidPath(file.toString()); _uri=normalizeURI(_file,url.toURI()); _alias=checkFileAlias(_uri,_file);
@Override public URL getAlias() { if (!_aliasChecked) { try { String abs=_file.getAbsolutePath(); String can=_file.getCanonicalPath(); if (abs.length()!=can.length() || !abs.equals(can)) _alias=Resource.toURL(new File(can)); _aliasChecked=true; if (_alias!=null && LOG.isDebugEnabled()) { LOG.debug("ALIAS abs="+abs); LOG.debug("ALIAS can="+can); } } catch(Exception e) { LOG.warn(Log.EXCEPTION,e); return getURL(); } } return _alias; }
checkConnection(); Permission perm = _connection.getPermission(); _file = new File(perm==null?url.getFile():perm.getName());