Examples of DirContext


Examples of javax.naming.directory.DirContext

        }

        String path = getRelativePath(req);

        // Retrieve the resources
        DirContext resources = getResources(req);

        if (resources == null) {
            resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            return;
        }

        boolean exists = true;
        try {
            resources.lookup(path);
        } catch (NamingException e) {
            exists = false;
        }

        boolean result = true;

        // Temp. content file used to support partial PUT
        File contentFile = null;

        // Input stream for temp. content file used to support partial PUT
        //FileInputStream contentFileInStream = null;

        //ResourceInfo resourceInfo = new ResourceInfo(path, resources);
        Range range = parseContentRange(req, resp);

        InputStream resourceInputStream = null;

        // Append data specified in ranges to existing content for this
        // resource - create a temp. file on the local filesystem to
        // perform this operation
        // Assume just one range is specified for now
        if (range != null) {
            contentFile = executePartialPut(req, range, path);
            resourceInputStream = new FileInputStream(contentFile);
        } else {
            resourceInputStream = req.getInputStream();
        }

        try {
            Resource newResource = new Resource(resourceInputStream);
            if (exists) {
                resources.rebind(path, newResource);
            } else {
                resources.bind(path, newResource);
            }
        } catch(NamingException e) {
            result = false;
        }
View Full Code Here

Examples of javax.naming.directory.DirContext

        String path = getRelativePath(req);

        // Retrieve the Catalina context
        // Retrieve the resources
        DirContext resources = getResources(req);

        if (resources == null) {
            resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            return;
        }

        boolean exists = true;
        try {
            resources.lookup(path);
        } catch (NamingException e) {
            exists = false;
        }

        if (exists) {
            boolean result = true;
            try {
                resources.unbind(path);
            } catch (NamingException e) {
                result = false;
            }
            if (result) {
                resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
View Full Code Here

Examples of javax.naming.directory.DirContext

                log("DefaultServlet.serveResource:  Serving resource '" +
                    path + "' headers only");
        }

        // Retrieve the Catalina context and Resources implementation
        DirContext resources = getResources(request);
        ResourceInfo resourceInfo = new ResourceInfo(path, resources);

        if (!resourceInfo.exists) {
            response.sendError(HttpServletResponse.SC_NOT_FOUND,
                               request.getRequestURI());
View Full Code Here

Examples of javax.naming.directory.DirContext

        sb.append("</tr>");

        try {

            // Render the directory entries within this directory
            DirContext directory = resourceInfo.directory;
            NamingEnumeration enumeration =
                resourceInfo.resources.list(resourceInfo.path);
            boolean shade = false;
            while (enumeration.hasMoreElements()) {
View Full Code Here

Examples of javax.naming.directory.DirContext

//          resp.sendError(WebdavStatus.SC_LOCKED);
//          return;
//      }

      // Check if operation allowed by OLAT VFS security callback
      DirContext resources = getResources(req);
      VFSDirContext vfsContext = (VFSDirContext) resources;
      String path = getRelativePath(req);
      if (!vfsContext.canWrite(path)) {
        resp.sendError(WebdavStatus.SC_FORBIDDEN);
        return;         
View Full Code Here

Examples of javax.naming.directory.DirContext

        resp.addHeader("DAV", "1,2");
        String methodsAllowed = null;

        // Retrieve the resources
        DirContext resources = getResources(req);

        if (resources == null) {
            resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            return;
        }

        boolean exists = true;
        Object object = null;
        try {
            object = resources.lookup(path);
        } catch (NamingException e) {
            exists = false;
        }

        if (!exists) {
View Full Code Here

Examples of javax.naming.directory.DirContext

            }

        }

        // Retrieve the resources
        DirContext resources = getResources(req);

        if (resources == null) {
            resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            return;
        }

        boolean exists = true;
        Object object = null;
        try {
            object = resources.lookup(path);
        } catch (NamingException e) {
            exists = false;
            int slash = path.lastIndexOf('/');
            if (slash != -1) {
                String parentPath = path.substring(0, slash);
                Vector currentLockNullResources =
                    (Vector) lockNullResources.get(parentPath);
                if (currentLockNullResources != null) {
                    Enumeration lockNullResourcesList =
                        currentLockNullResources.elements();
                    while (lockNullResourcesList.hasMoreElements()) {
                        String lockNullPath = (String)
                            lockNullResourcesList.nextElement();
                        if (lockNullPath.equals(path)) {
                            resp.setStatus(WebdavStatus.SC_MULTI_STATUS);
                            resp.setContentType("text/xml; charset=UTF-8");
                            // Create multistatus object
                            XMLWriter generatedXML =
                                new XMLWriter(resp.getWriter());
                            generatedXML.writeXMLHeader();
                            generatedXML.writeElement
                                (null, "multistatus"
                                 + generateNamespaceDeclarations(),
                                 XMLWriter.OPENING);
                            parseLockNullProperties
                                (req, generatedXML, lockNullPath, type,
                                 properties);
                            generatedXML.writeElement(null, "multistatus",
                                                      XMLWriter.CLOSING);
                            generatedXML.sendData();
                            return;
                        }
                    }
                }
            }
        }

        if (!exists) {
            resp.sendError(HttpServletResponse.SC_NOT_FOUND, path);
            return;
        }

        resp.setStatus(WebdavStatus.SC_MULTI_STATUS);

        resp.setContentType("text/xml; charset=UTF-8");

        // Create multistatus object
        XMLWriter generatedXML = new XMLWriter(resp.getWriter());
        generatedXML.writeXMLHeader();

        generatedXML.writeElement(null, "multistatus"
                                  + generateNamespaceDeclarations(),
                                  XMLWriter.OPENING);

        if (depth == 0) {
            parseProperties(req, resources, generatedXML, path, type,
                            properties);
        } else {
            // The stack always contains the object of the current level
            Stack stack = new Stack();
            stack.push(path);

            // Stack of the objects one level below
            Stack stackBelow = new Stack();

            while ((!stack.isEmpty()) && (depth >= 0)) {

                String currentPath = (String) stack.pop();
                parseProperties(req, resources, generatedXML, currentPath,
                                type, properties);

                try {
                    object = resources.lookup(currentPath);
                } catch (NamingException e) {
                    continue;
                }

                if ((object instanceof DirContext) && (depth > 0)) {

                    try {
                        NamingEnumeration enumeration = resources.list(currentPath);
                        while (enumeration.hasMoreElements()) {
                            NameClassPair ncPair =
                                (NameClassPair) enumeration.nextElement();
                            String newPath = currentPath;
                            if (!(newPath.endsWith("/")))
View Full Code Here

Examples of javax.naming.directory.DirContext

            resp.sendError(WebdavStatus.SC_FORBIDDEN);
            return;
        }
       
        // Check if operation allowed by OLAT VFS security callback
        DirContext resources = getResources(req);
        VFSDirContext vfsContext = (VFSDirContext) resources;
        String path = getRelativePath(req);
        if (!vfsContext.canWrite(path)) {
          resp.sendError(WebdavStatus.SC_FORBIDDEN);
          return;         
View Full Code Here

Examples of javax.naming.directory.DirContext

            resp.sendError(WebdavStatus.SC_FORBIDDEN);
            return;
        }
       
        // Check if operation allowed by OLAT VFS security callback
        DirContext resources = getResources(req);
        VFSDirContext vfsContext = (VFSDirContext) resources;
        String path = getRelativePath(req);
        if (!vfsContext.canWrite(path)) {
          resp.sendError(WebdavStatus.SC_FORBIDDEN);
          return;         
        }

        if (isLocked(req)) {
            resp.sendError(WebdavStatus.SC_LOCKED);
            return;
        }

        path = getRelativePath(req);

        if ((path.toUpperCase().startsWith("/WEB-INF")) ||
            (path.toUpperCase().startsWith("/META-INF"))) {
            resp.sendError(WebdavStatus.SC_FORBIDDEN);
            return;
        }

        // Retrieve the resources
        resources = getResources(req);

        if (resources == null) {
            resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            return;
        }

        // Check if operation allowed by OLAT VFS security callback
        vfsContext = (VFSDirContext) resources;
        if (!vfsContext.canWrite(path)) {
          resp.sendError(WebdavStatus.SC_FORBIDDEN);
          return;         
        }
       
        boolean exists = true;
        try {
            resources.lookup(path);
        } catch (NamingException e) {
            exists = false;
        }

        // Can't create a collection if a resource already exists at the given
        // path
        if (exists) {
            resp.sendError(WebdavStatus.SC_METHOD_NOT_ALLOWED);
            return;
        }

        boolean result = true;
        try {
            resources.createSubcontext(path);
        } catch (NameAlreadyBoundException e) {
            result = false;
        } catch (NamingException e) {
            result = false;
        }
View Full Code Here

Examples of javax.naming.directory.DirContext

            resp.sendError(WebdavStatus.SC_FORBIDDEN);
            return;
        }

        // Check if operation allowed by OLAT VFS security callback
        DirContext resources = getResources(req);
        VFSDirContext vfsContext = (VFSDirContext) resources;
        String path = getRelativePath(req);
        if (!vfsContext.canDelete(path)) {
          resp.sendError(WebdavStatus.SC_FORBIDDEN);
          return;         
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.