Package org.mortbay.resource

Examples of org.mortbay.resource.Resource


            configure(webxml.toString());
      
        String overrideDescriptor=getWebAppContext().getOverrideDescriptor();
        if(overrideDescriptor!=null&&overrideDescriptor.length()>0)
        {
            Resource orideResource=Resource.newSystemResource(overrideDescriptor);
            if(orideResource==null)
                orideResource=Resource.newResource(overrideDescriptor);
            _xmlParser.setValidating(false);
            configure(orideResource.getURL().toString());
        }
    }
View Full Code Here


    protected URL findWebXml() throws IOException, MalformedURLException
    {
        String descriptor=getWebAppContext().getDescriptor();
        if (descriptor!=null)
        {
            Resource web= Resource.newResource(descriptor);
            if (web.exists()&& !web.isDirectory())
                return web.getURL();
        }

        Resource web_inf=getWebAppContext().getWebInf();
        if(web_inf!=null && web_inf.isDirectory())
        {
            // do web.xml file
            Resource web=web_inf.addPath("web.xml");
            if(web.exists())
                return web.getURL();
            Log.debug("No WEB-INF/web.xml in "+getWebAppContext().getWar()
                    +". Serving files and default/dynamic servlets only");
        }
        return null;
    }
View Full Code Here

        HTAccess ht=null;

        try
        {
            Resource resource=null;
            String directory=pathInContext.endsWith("/")?pathInContext:URIUtil.parentPath(pathInContext);

            // Look for htAccess resource
            while (directory!=null)
            {
                String htPath=directory+_accessFile;
                resource=((ContextHandler)getProtegee()).getResource(htPath);
                if (log.isDebugEnabled())
                    log.debug("directory="+directory+" resource="+resource,null,null);

                if (resource!=null&&resource.exists()&&!resource.isDirectory())
                    break;
                resource=null;
                directory=URIUtil.parentPath(directory);
            }

            boolean haveHtAccess=true;

            // Try default directory
            if (resource==null&&_default!=null)
            {
                resource=Resource.newResource(_default);
                if (!resource.exists()||resource.isDirectory())
                    haveHtAccess=false;
            }
            if (resource==null)
                haveHtAccess=false;

            // prevent access to htaccess files
            if (pathInContext.endsWith(_accessFile)
                // extra security
                ||pathInContext.endsWith(_accessFile+"~")||pathInContext.endsWith(_accessFile+".bak"))
            {
                response.sendError(HttpServletResponse.SC_FORBIDDEN);
                base_request.setHandled(true);
                return;
            }

            if (haveHtAccess)
            {
                if (log.isDebugEnabled())
                    log.debug("HTACCESS="+resource,null,null);

                ht=(HTAccess)_htCache.get(resource);
                if (ht==null||ht.getLastModified()!=resource.lastModified())
                {
                    ht=new HTAccess(resource);
                    _htCache.put(resource,ht);
                    if (log.isDebugEnabled())
                        log.debug("HTCache loaded "+ht,null,null);
View Full Code Here

        StringBuffer classpath=new StringBuffer();
        for (int i=0;i<urls.length;i++)
        {
            try
            {
                Resource resource = Resource.newResource(urls[i]);
                File file=resource.getFile();
                if (file.exists())
                {
                    if (classpath.length()>0)
                        classpath.append(File.pathSeparatorChar);
                    classpath.append(file.getAbsolutePath());
View Full Code Here

            return null;

        try
        {
            path=URIUtil.canonicalPath(path);
            Resource resource=_baseResource.addPath(path);
            return resource;
        }
        catch(Exception e)
        {
            Log.ignore(e);
View Full Code Here

    public Set getResourcePaths(String path)
    {          
        try
        {
            path=URIUtil.canonicalPath(path);
            Resource resource=getResource(path);
           
            if (resource!=null && resource.exists())
            {
                if (!path.endsWith(URIUtil.SLASH))
                    path=path+URIUtil.SLASH;
               
                String[] l=resource.list();
                if (l!=null)
                {
                    HashSet set = new HashSet();
                    for(int i=0;i<l.length;i++)
                        set.add(path+l[i]);
View Full Code Here

       
        try
        {
            if (!getWebXmlFile().exists())
            {
                Resource resource = webAppConfig.getBaseResource().addPath("WEB-INF/web.xml");
                if(!resource.exists())
                {
                   
                    throw new MojoExecutionException( "web.xml does not exist at location "
                            + webXmlFile.getCanonicalPath());
                }
View Full Code Here

            // Include runtime and compile time libraries, and possibly test libs too
            if(artifact.getType().equals("war"))
            {
                try
                {
                    Resource r = Resource.newResource("jar:" + artifact.getFile().toURL().toString() + "!/");
                    overlays.add(r);
                    getExtraScanTargets().add(artifact.getFile());
                }
                catch(Exception e)
                {
                    throw new RuntimeException(e);
                }
                continue;
            }
            if (((!Artifact.SCOPE_PROVIDED.equals(artifact.getScope())) && (!Artifact.SCOPE_TEST.equals( artifact.getScope())))
                    ||
                (useTestClasspath && Artifact.SCOPE_TEST.equals( artifact.getScope())))
            {
                dependencyFiles.add(artifact.getFile());
                getLog().debug( "Adding artifact " + artifact.getFile().getName() + " for WEB-INF/lib " );  
            }
        }
        if(!overlays.isEmpty() && !isEqual(overlays, _overlays))
        {
            try
            {
                Resource resource = _overlays==null ? webAppConfig.getBaseResource() : null;
                ResourceCollection rc = new ResourceCollection();
                if(resource==null)
                {
                    // nothing configured, so we automagically enable the overlays                   
                    int size = overlays.size()+1;
                    Resource[] resources = new Resource[size];
                    resources[0] = Resource.newResource(getWebAppSourceDirectory().toURL());
                    for(int i=1; i<size; i++)
                    {
                        resources[i] = (Resource)overlays.get(i-1);
                        getLog().info("Adding overlay: " + resources[i]);
                    }
                    rc.setResources(resources);
                }               
                else
                {                   
                    if(resource instanceof ResourceCollection)
                    {
                        // there was a preconfigured ResourceCollection ... append the artifact wars
                        Resource[] old = ((ResourceCollection)resource).getResources();
                        int size = old.length + overlays.size();
                        Resource[] resources = new Resource[size];
                        System.arraycopy(old, 0, resources, 0, old.length);
                        for(int i=old.length,j=0; i<size; i++,j++)
                        {
                            resources[i] = (Resource)overlays.get(j);
                            getLog().info("Adding overlay: " + resources[i]);
                        }
                        rc.setResources(resources);
                    }
                    else
                    {
                        // baseResource was already configured w/c could be src/main/webapp
                        if(!resource.isDirectory() && String.valueOf(resource.getFile()).endsWith(".war"))
                        {
                            // its a war                           
                            resource = Resource.newResource("jar:" + resource.getURL().toString() + "!/");
                        }
                        int size = overlays.size()+1;
                        Resource[] resources = new Resource[size];
                        resources[0] = resource;
                        for(int i=1; i<size; i++)
View Full Code Here

      }

      String overrideDescriptor = getWebAppContext().getOverrideDescriptor();
      if (overrideDescriptor != null && overrideDescriptor.length() > 0)
      {
         Resource orideResource = Resource.newSystemResource(overrideDescriptor);
         if (orideResource == null)
         {
            orideResource = Resource.newResource(overrideDescriptor);
         }
         _xmlParser.setValidating(false);
         configure(orideResource.getURL().toString());
      }

      // FIXME support multiple web-fragment.xml files
      Resource webFragment = Resource.newSystemResource("META-INF/web-fragment.xml");
      if (webFragment != null)
      {
         _xmlParser.setValidating(false);
         configure(webFragment.getURL().toString());
      }

      // logic from AbstractConfiguration
      bindUserTransaction();
View Full Code Here

            else if(path.charAt(0)!='/')
                path = URIUtil.SLASH + path;
               
            try
            {
                Resource resource=ContextHandler.this.getResource(path);
                if(resource!=null)
                {
                    File file = resource.getFile();
                    if (file!=null)
                        return file.getCanonicalPath();
                }
            }
            catch (Exception e)
View Full Code Here

TOP

Related Classes of org.mortbay.resource.Resource

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.