Package org.apache.catalina

Examples of org.apache.catalina.WebResource


     */
    protected InputStream findXsltInputStream(WebResource directory)
        throws IOException {

        if (localXsltFile != null) {
            WebResource resource = resources.getResource(
                    directory.getWebappPath() + localXsltFile);
            if (resource.isFile()) {
                InputStream is = resource.getInputStream();
                if (is != null) {
                    return is;
                }
            }
            if (debug > 10) {
View Full Code Here


                    // Rule 4c -- Welcome resources processing
                    //            for physical folder
                    if (mappingData.wrapper == null
                        && contextVersion.resources != null) {
                        String pathStr = path.toString();
                        WebResource file =
                                contextVersion.resources.getResource(pathStr);
                        if (file != null && file.isFile()) {
                            internalMapExtensionWrapper(extensionWrappers, path,
                                                        mappingData, true);
                            if (mappingData.wrapper == null
                                && contextVersion.defaultWrapper != null) {
                                mappingData.wrapper =
                                    contextVersion.defaultWrapper.object;
                                mappingData.requestPath.setChars
                                    (path.getBuffer(), path.getStart(),
                                     path.getLength());
                                mappingData.wrapperPath.setChars
                                    (path.getBuffer(), path.getStart(),
                                     path.getLength());
                                mappingData.requestPath.setString(pathStr);
                                mappingData.wrapperPath.setString(pathStr);
                            }
                        }
                    }
                }

                path.setOffset(servletPath);
                path.setEnd(pathEnd);
            }

        }

        /* welcome file processing - take 2
         * Now that we have looked for welcome files with a physical
         * backing, now look for an extension mapping listed
         * but may not have a physical backing to it. This is for
         * the case of index.jsf, index.do, etc.
         * A watered down version of rule 4
         */
        if (mappingData.wrapper == null) {
            boolean checkWelcomeFiles = checkJspWelcomeFiles;
            if (!checkWelcomeFiles) {
                char[] buf = path.getBuffer();
                checkWelcomeFiles = (buf[pathEnd - 1] == '/');
            }
            if (checkWelcomeFiles) {
                for (int i = 0; (i < contextVersion.welcomeResources.length)
                         && (mappingData.wrapper == null); i++) {
                    path.setOffset(pathOffset);
                    path.setEnd(pathEnd);
                    path.append(contextVersion.welcomeResources[i], 0,
                                contextVersion.welcomeResources[i].length());
                    path.setOffset(servletPath);
                    internalMapExtensionWrapper(extensionWrappers, path,
                                                mappingData, false);
                }

                path.setOffset(servletPath);
                path.setEnd(pathEnd);
            }
        }


        // Rule 7 -- Default servlet
        if (mappingData.wrapper == null && !checkJspWelcomeFiles) {
            if (contextVersion.defaultWrapper != null) {
                mappingData.wrapper = contextVersion.defaultWrapper.object;
                mappingData.requestPath.setChars
                    (path.getBuffer(), path.getStart(), path.getLength());
                mappingData.wrapperPath.setChars
                    (path.getBuffer(), path.getStart(), path.getLength());
            }
            // Redirection to a folder
            char[] buf = path.getBuffer();
            if (contextVersion.resources != null && buf[pathEnd -1 ] != '/') {
                String pathStr = path.toString();
                WebResource file =
                        contextVersion.resources.getResource(pathStr);
                if (file != null && file.isDirectory()) {
                    // Note: this mutates the path: do not do any processing
                    // after this (since we set the redirectPath, there
                    // shouldn't be any)
                    path.setOffset(pathOffset);
                    path.append('/');
View Full Code Here

        if (!resources.getState().isAvailable()) {
            resources.start();
        }

        if (effectiveMajorVersion >=3 && addWebinfClassesResources) {
            WebResource webinfClassesResource = resources.getResource(
                    "/WEB-INF/classes/META-INF/resources");
            if (webinfClassesResource.isDirectory()) {
                getResources().createWebResourceSet(
                        WebResourceRoot.ResourceSetType.RESOURCE_JAR, "/",
                        webinfClassesResource.getURL(), "/");
            }
        }
    }
View Full Code Here

        // therefore is not valid
        if (resources == null) return false;
        // Find the Manifest for the Web Application
        InputStream inputStream = null;
        try {
            WebResource resource =
                    resources.getResource("/META-INF/MANIFEST.MF");
            if (resource.isFile()) {
                inputStream = resource.getInputStream();
                Manifest manifest = new Manifest(inputStream);
                inputStream.close();
                inputStream = null;
                ManifestResource mre = new ManifestResource
                    (sm.getString("extensionValidator.web-application-manifest"),
View Full Code Here

    //------------------------------------------------------------ getResource()

    @Test
    public final void testGetResourceRoot() {
        WebResource webResource = resourceRoot.getResource(getMount() + "/");
        Assert.assertTrue(webResource.isDirectory());
        String expected;
        if (getMount().length() > 0) {
            expected = getMount().substring(1);
        } else {
            expected = "";
        }
        Assert.assertEquals(expected, webResource.getName());
        Assert.assertEquals(getMount() + "/", webResource.getWebappPath());
    }
View Full Code Here

        Assert.assertEquals(getMount() + "/", webResource.getWebappPath());
    }

    @Test
    public final void testGetResourceDirA() {
        WebResource webResource = resourceRoot.getResource(getMount() + "/d1");
        Assert.assertTrue(webResource.isDirectory());
        Assert.assertEquals("d1", webResource.getName());
        Assert.assertEquals(getMount() + "/d1/", webResource.getWebappPath());
    }
View Full Code Here

        Assert.assertEquals(getMount() + "/d1/", webResource.getWebappPath());
    }

    @Test
    public final void testGetResourceDirB() {
        WebResource webResource = resourceRoot.getResource(getMount() + "/d1/");
        Assert.assertTrue(webResource.isDirectory());
        Assert.assertEquals("d1", webResource.getName());
        Assert.assertEquals(getMount() + "/d1/", webResource.getWebappPath());
    }
View Full Code Here

        Assert.assertEquals(getMount() + "/d1/", webResource.getWebappPath());
    }

    @Test
    public final void testGetResourceFile() {
        WebResource webResource =
                resourceRoot.getResource(getMount() + "/d1/d1-f1.txt");
        Assert.assertTrue(webResource.isFile());
        Assert.assertEquals("d1-f1.txt", webResource.getName());
        Assert.assertEquals(
                getMount() + "/d1/d1-f1.txt", webResource.getWebappPath());
    }
View Full Code Here

                getMount() + "/d1/d1-f1.txt", webResource.getWebappPath());
    }

    @Test
    public final void testGetResourceCaseSensitive() {
        WebResource webResource =
                resourceRoot.getResource(getMount() + "/d1/d1-F1.txt");
        Assert.assertFalse(webResource.exists());
    }
View Full Code Here

        Assert.assertFalse(webResource.exists());
    }

    @Test
    public final void testGetResourceTraversal() {
        WebResource webResource = null;
        try {
            webResource = resourceRoot.getResource(getMount() + "/../");
        } catch (IllegalArgumentException iae) {
            // Expected if mount point is zero length
            Assert.assertTrue(getMount().length() == 0);
            return;
        }

        Assert.assertFalse(webResource.exists());
    }
View Full Code Here

TOP

Related Classes of org.apache.catalina.WebResource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.