@Override protected WebResourceSet createMainResourceSet() { final Path docBase = config.docBase(); assert docBase.isAbsolute(); final String docBaseStr = docBase.toString(); getContext().setDocBase(docBaseStr); if (Files.isDirectory(docBase)) { return new DirResourceSet(this, "/", docBaseStr, "/"); } final Optional<String> jarRootOpt = config.jarRoot(); if (jarRootOpt.isPresent()) { // If docBase is a JAR file final String jarRoot = jarRootOpt.get(); if ("/".equals(jarRoot)) { return new JarResourceSet(this, "/", docBaseStr, "/"); } else { return new JarSubsetResourceSet(this, "/", docBaseStr, "/", jarRoot); } } throw new IllegalArgumentException(sm.getString("standardRoot.startInvalidMain", docBaseStr)); } }
String internalPath) { super(internalPath); setRoot(root); setWebAppMount(webAppMount); setBase(base); if (getRoot().getState().isAvailable()) { try { start(); } catch (LifecycleException e) { throw new IllegalStateException(e);
@Override public boolean mkdir(String path) { checkPath(path); String webAppMount = getWebAppMount(); if (path.startsWith(webAppMount)) { File f = file(path.substring(webAppMount.length()), false); if (f == null) { return false; } return f.mkdir(); } else { return false; } }
@Override public WebResource getResource(String path) { checkPath(path); String webAppMount = getWebAppMount(); WebResourceRoot root = getRoot(); if (path.startsWith(webAppMount)) { File f = file(path.substring(webAppMount.length()), false); if (f == null) { return new EmptyResource(root, path); } if (!f.exists()) { return new EmptyResource(root, path, f); } if (f.isDirectory() && path.charAt(path.length() - 1) != '/') { path = path + '/'; } return new FileResource(root, path, f, isReadOnly(), getManifest()); } else { return new EmptyResource(root, path); } }
@Override public boolean mkdir(String path) { checkPath(path); if (isReadOnly()) { return false; } String webAppMount = getWebAppMount(); if (path.startsWith(webAppMount)) { File f = file(path.substring(webAppMount.length()), false); if (f == null) { return false; } return f.mkdir(); } else { return false; } }
@Override public WebResource getResource(String path) { checkPath(path); String webAppMount = getWebAppMount(); WebResourceRoot root = getRoot(); if (path.startsWith(webAppMount)) { File f = file(path.substring(webAppMount.length()), false); if (f == null) { return new EmptyResource(root, path); } if (!f.exists()) { return new EmptyResource(root, path, f); } if (f.isDirectory() && path.charAt(path.length() - 1) != '/') { path = path += '/'; } return new FileResource(root, path, f); } else { return new EmptyResource(root, path); } }
@Override protected void initInternal() throws LifecycleException { super.initInternal(); // Is this an exploded web application? if (getWebAppMount().equals("")) { // Look for a manifest File mf = file("META-INF/MANIFEST.MF", true); if (mf != null && mf.isFile()) { try (FileInputStream fis = new FileInputStream(mf)) { setManifest(new Manifest(fis)); } catch (IOException e) { log.warn(sm.getString("dirResourceSet.manifestFail", mf.getAbsolutePath()), e); } } } } }
String internalPath) { super(internalPath); setRoot(root); setWebAppMount(webAppMount); setBase(base); if (getRoot().getState().isAvailable()) { try { start(); } catch (LifecycleException e) { throw new IllegalStateException(e);
@Override public String[] list(String path) { checkPath(path); String webAppMount = getWebAppMount(); if (path.startsWith(webAppMount)) { File f = file(path.substring(webAppMount.length()), true); if (f == null) { return EMPTY_STRING_ARRAY;
@Override public WebResource getResource(String path) { checkPath(path); String webAppMount = getWebAppMount(); WebResourceRoot root = getRoot(); if (path.startsWith(webAppMount)) { File f = file(path.substring(webAppMount.length()), false); if (f == null) { return new EmptyResource(root, path); } if (!f.exists()) { return new EmptyResource(root, path, f); } if (f.isDirectory() && path.charAt(path.length() - 1) != '/') { path = path + '/'; } return new FileResource(root, path, f, isReadOnly(), getManifest()); } else { return new EmptyResource(root, path); } }
@Override public boolean mkdir(String path) { checkPath(path); if (isReadOnly()) { return false; } String webAppMount = getWebAppMount(); if (path.startsWith(webAppMount)) { File f = file(path.substring(webAppMount.length()), false); if (f == null) { return false; } return f.mkdir(); } else { return false; } }
@Override protected void initInternal() throws LifecycleException { super.initInternal(); // Is this an exploded web application? if (getWebAppMount().equals("")) { // Look for a manifest File mf = file("META-INF/MANIFEST.MF", true); if (mf != null && mf.isFile()) { try (FileInputStream fis = new FileInputStream(mf)) { setManifest(new Manifest(fis)); } catch (IOException e) { log.warn(sm.getString("dirResourceSet.manifestFail", mf.getAbsolutePath()), e); } } } } }
protected WebResourceSet createMainResourceSet() { String docBase = context.getDocBase(); WebResourceSet mainResourceSet; if (docBase == null) { mainResourceSet = new EmptyResourceSet(this); } else { File f = new File(docBase); if (!f.isAbsolute()) { f = new File(((Host)context.getParent()).getAppBaseFile(), f.getPath()); } if (f.isDirectory()) { mainResourceSet = new DirResourceSet(this, "/", f.getAbsolutePath(), "/"); } else if(f.isFile() && docBase.endsWith(".war")) { mainResourceSet = new WarResourceSet(this, "/", f.getAbsolutePath()); } else { throw new IllegalArgumentException( sm.getString("standardRoot.startInvalidMain", f.getAbsolutePath())); } } return mainResourceSet; }
String internalPath) { super(internalPath); setRoot(root); setWebAppMount(webAppMount); setBase(base); if (getRoot().getState().isAvailable()) { try { start(); } catch (LifecycleException e) { throw new IllegalStateException(e);
@Override public String[] list(String path) { checkPath(path); String webAppMount = getWebAppMount(); if (path.startsWith(webAppMount)) { File f = file(path.substring(webAppMount.length()), true); if (f == null) { return EMPTY_STRING_ARRAY;
@Override public boolean write(String path, InputStream is, boolean overwrite) { checkPath(path); if (isReadOnly()) { return false; String webAppMount = getWebAppMount(); if (path.startsWith(webAppMount)) { dest = file(path.substring(webAppMount.length()), false); if (dest == null) { return false;
protected WebResourceSet createMainResourceSet() { String docBase = context.getDocBase(); WebResourceSet mainResourceSet; if (docBase == null) { mainResourceSet = new EmptyResourceSet(this); } else { File f = new File(docBase); if (!f.isAbsolute()) { f = new File(((Host)context.getParent()).getAppBaseFile(), f.getPath()); } if (f.isDirectory()) { mainResourceSet = new DirResourceSet(this, "/", f.getAbsolutePath(), "/"); } else if(f.isFile() && docBase.endsWith(".war")) { mainResourceSet = new WarResourceSet(this, "/", f.getAbsolutePath()); } else { throw new IllegalArgumentException( sm.getString("standardRoot.startInvalidMain", f.getAbsolutePath())); } } return mainResourceSet; }
@Override public String[] list(String path) { checkPath(path); String webAppMount = getWebAppMount(); if (path.startsWith(webAppMount)) { File f = file(path.substring(webAppMount.length()), true); if (f == null) { return EMPTY_STRING_ARRAY;
@Override public boolean write(String path, InputStream is, boolean overwrite) { checkPath(path); if (isReadOnly()) { return false; String webAppMount = getWebAppMount(); if (path.startsWith(webAppMount)) { dest = file(path.substring(webAppMount.length()), false); if (dest == null) { return false;
private void addConfiguredDocBases(final StandardContext standardContext, final ContextInfo contextInfo) { if (contextInfo.appInfo.path != null) { // add external web resources final String contextPath = standardContext.getServletContext().getContextPath(); final String name = contextPath.isEmpty() ? "ROOT" : contextPath.substring(1); final String webResources = SystemInstance.get().getProperty("tomee." + name + ".docBases", contextInfo.appInfo.properties.getProperty("docBases")); if (webResources != null) { for (final String alt : webResources.trim().split(",")) { final String trim = alt.trim(); if (trim.isEmpty()) { continue; } if (!new File(trim).isDirectory()) { logger.warning("Can't add docBase which are not directory: " + trim); continue; } final WebResourceRoot root = standardContext.getResources(); root.addPreResources(new DirResourceSet(root, "/", trim, "/")); } } } }