Package org.apache.slide.webdav

Examples of org.apache.slide.webdav.WebdavException


                    responseBodyNeeded = true;
            }
            catch(JDOMException e ){
                int statusCode = WebdavStatus.SC_BAD_REQUEST;
                sendError( statusCode, e );
                throw new WebdavException( statusCode );
            }
            catch( IOException e ){
                int statusCode = WebdavStatus.SC_INTERNAL_SERVER_ERROR;
                sendError( statusCode, e );
                throw new WebdavException( statusCode );
            }
        }
    }
View Full Code Here


                xmlOut.output(new Document(ore), resp.getWriter());
            }
            catch( IOException e ) {
                int statusCode = WebdavStatus.SC_INTERNAL_SERVER_ERROR;
                sendError( statusCode, e );
                throw new WebdavException( statusCode );
            }
        }
    }
View Full Code Here

            label = labelName.getText();
        }
        catch (IOException  e){
            int statusCode = WebdavStatus.SC_INTERNAL_SERVER_ERROR;
            sendError( statusCode, e );
            throw new WebdavException( statusCode );
        }
        catch (JDOMException  e){
            int statusCode = WebdavStatus.SC_BAD_REQUEST;
            sendError( statusCode, e );
            throw new WebdavException( statusCode );
        }
    }
View Full Code Here

        // check lock-null resources
        try {
            if (isLockNull(resourcePath)) {
                int statusCode = WebdavStatus.SC_NOT_FOUND;
                sendError( statusCode, "lock-null resource", new Object[]{resourcePath} );
                throw new WebdavException( statusCode );
            }
        }
        catch (ServiceAccessException e) {
            int statusCode = getErrorCode((Exception)e);
            sendError( statusCode, e );
            throw new WebdavException( statusCode );
        }
       
        isCollection = isCollection(resourcePath);
        try {
            labelResource(resourcePath);
        }
        catch (NestedSlideException nestedSlideException) {
            // If it's not a collection, we don't want to give a 207,
            // because it's silly, and it confuses many clients (such as
            // MS Web Folders).
            if (generateMultiStatusResponse(isCollection, nestedSlideException, requestUri)) {
                String errorMessage = generateErrorMessage(nestedSlideException);
                // Write it on the servlet writer
                resp.setStatus(WebdavStatus.SC_MULTI_STATUS);
                try {
                    resp.setContentType(TEXT_XML_UTF_8);
                    resp.getWriter().write(errorMessage);
                } catch(IOException ex) {
                    // Critical error ... Servlet container is dead or something
                    int statusCode = WebdavStatus.SC_INTERNAL_SERVER_ERROR;
                    sendError( statusCode, ex );
                    throw new WebdavException( statusCode );
                }
            } else {
                // Returning 207 on non-collection requests is generally
                // considered bad. So let's not do it, since this way
                // makes clients generally behave better.
                SlideException exception = (SlideException)nestedSlideException.enumerateExceptions().nextElement();
                if (exception instanceof PreconditionViolationException) {
                    try {
                        sendPreconditionViolation((PreconditionViolationException)exception);
                    } catch(IOException ex) {
                        // Critical error ... Servlet container is dead or something
                        int statusCode = WebdavStatus.SC_INTERNAL_SERVER_ERROR;
                        sendError( statusCode, ex );
                        throw new WebdavException( statusCode );
                    }
                }
                else {
                    int statusCode = getErrorCode( exception );
                    sendError( statusCode, exception );
                    throw new WebdavException( statusCode );
                }
            }
            //
            // make sure the transaction is aborted
            // throw any WebDAV exception to indicate the transaction wants to be aborted
            //
            throw new WebdavException(WebdavStatus.SC_ACCEPTED, false);
        }
        finally {
            resp.setHeader(H_CACHE_CONTROL, NO_CACHE);
        }
    }
View Full Code Here

        // check lock-null resources
        try {
            if (isLockNull(sourceUri)) {
                int statusCode = WebdavStatus.SC_NOT_FOUND;
                sendError( statusCode, "lock-null resource", new Object[]{sourceUri} );
                throw new WebdavException( statusCode );
            }
        }
        catch (ServiceAccessException e) {
            int statusCode = getErrorCode((Exception)e);
            sendError( statusCode, e );
            throw new WebdavException( statusCode );
        }
       
        // check destination URI
        UriHandler destUh = UriHandler.getUriHandler(destinationUri);
        if( VersionControlMethod.VERSIONCONTROL_EXCLUDEPATH != null && VersionControlMethod.VERSIONCONTROL_EXCLUDEPATH.length() > 0 ) {
            UriHandler exUh = UriHandler.getUriHandler( VersionControlMethod.VERSIONCONTROL_EXCLUDEPATH );
            if( exUh.isAncestorOf(destUh) )
                isInVersioncontrolExcludePath = true;
        }
       
        if (destUh.isRestrictedUri()) {
            boolean sendError = true;
            if( destUh.isWorkspaceUri()        ||
               destUh.isWorkingresourceUri()
              ) {
                // COPY on existing WSs or WRs is *not* restricted !!!
                try {
                    content.retrieve(slideToken, destinationUri);
                    sendError = false;
                }
                catch( ServiceAccessException x ) {
                    int statusCode = getErrorCode((SlideException)x);
                    sendError( statusCode, x );
                    throw new WebdavException( statusCode );
                }
                catch( SlideException x ) {};
            }
            if( sendError ) {
                int statusCode = WebdavStatus.SC_FORBIDDEN;
                sendError( statusCode, getClass().getName()+".restrictedDestinationUri", new Object[]{destinationUri} );
                throw new WebdavException( statusCode );
            }
        }
       
        try {
            // compare resource types of source and destination
            boolean sameResourceType = isSameResourcetype();
            int depth = requestHeaders.getDepth(INFINITY);
            if (depth != 0 && depth != INFINITY) {
                int sc = WebdavStatus.SC_PRECONDITION_FAILED;
                sendError( sc, "Invalid header Depth: "+depth );
                throw new WebdavException( sc );
            }
           
            boolean recursive = (depth == INFINITY);
           
            if (overwrite && sameResourceType) {
                macroParameters = new MacroParameters(recursive, true, false);
            }
            else if (overwrite && !sameResourceType) {
                macroParameters = new MacroParameters(recursive, true, true);
            }
            else {
                macroParameters = new MacroParameters(recursive, false, false);
            }
           
            boolean destinationExistsBefore = exists( destinationUri );
           
            if (!overwrite && destinationExistsBefore) {
                int statusCode = WebdavStatus.SC_PRECONDITION_FAILED;
                sendError( statusCode, getClass().getName()+".noOverwrite", new Object[]{destinationUri} );
                throw new WebdavException( statusCode );
            }
           
            macro.copy(slideToken, sourceUri, destinationUri, macroParameters, this, this, null, this);
           
            if (overwrite && destinationExistsBefore) {
                resp.setStatus(WebdavStatus.SC_NO_CONTENT);
            } else {
                resp.setStatus(WebdavStatus.SC_CREATED);
            }
        } catch (MacroException e) {
            if(generateMultiStatusResponse(isCollection, e, requestUri)) {
                String errorMessage = generateErrorMessage(e);
                // Write it on the servlet writer
                resp.setStatus(WebdavStatus.SC_MULTI_STATUS);
                try {
                    resp.setContentType(TEXT_XML_UTF_8);
                    resp.getWriter().write(errorMessage);
                } catch(IOException ex) {
                    // Critical error ... Servlet container is dead or something
                    int statusCode = WebdavStatus.SC_INTERNAL_SERVER_ERROR;
                    sendError( statusCode, e );
                    throw new WebdavException( statusCode );
                }
            } else {
                // Returning 207 on non-collection requests is generally
                // considered bad. So let's not do it, since this way
                // makes clients generally behave better.
                SlideException exception = (SlideException)e.enumerateExceptions().nextElement();
                if (exception instanceof PreconditionViolationException) {
                    try {
                        sendPreconditionViolation((PreconditionViolationException)exception);
                    } catch(IOException ex) {
                        // Critical error ... Servlet container is dead or something
                        int statusCode = WebdavStatus.SC_INTERNAL_SERVER_ERROR;
                        sendError( statusCode, e );
                        throw new WebdavException( statusCode );
                    }
                }
                else {
                    int statusCode = getErrorCode( exception );
                    sendError( statusCode, exception );
                    throw new WebdavException( statusCode );
                }
            }
            //
            // make sure the transaction is aborted
            // throw any WebDAV exception to indicate the transaction wants to be aborted
            //
            throw new WebdavException(WebdavStatus.SC_ACCEPTED, false);
        }
        catch (WebdavException e) {
            throw e;
        }
        catch (SlideException e) {
            int statusCode = getErrorCode( e );
            sendError( statusCode, e );
            throw new WebdavException( statusCode );
        }
    }
View Full Code Here

            catch (JDOMException e) {
                resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
                resp.setContentType (TEXT_XML_UTF_8);
                createErrorResult (SearchQueryResult.STATUS_BAD_QUERY,
                                   e.getMessage());
                throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
            }
            catch (InvalidQueryException e) {
                resp.setStatus(WebdavStatus.SC_UNPROCESSABLE_ENTITY);
                resp.setContentType (TEXT_XML_UTF_8);
                createErrorResult (SearchQueryResult.STATUS_UNPROCESSABLE_ENTITY,
                                   e.getMessage());
                throw new WebdavException(WebdavStatus.SC_UNPROCESSABLE_ENTITY);
            }
            catch (BadGatewayException e) {
                resp.setStatus(WebdavStatus.SC_BAD_GATEWAY);
                resp.setContentType (TEXT_XML_UTF_8);
                createErrorResult (SearchQueryResult.STATUS_BAD_GATEWAY,
                                   e.getMessage());
                throw new WebdavException(WebdavStatus.SC_BAD_GATEWAY);
            }
            catch (InvalidScopeException e) {
                resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
                resp.setContentType (TEXT_XML_UTF_8);
                createErrorResult (SearchQueryResult.STATUS_INVALID_SCOPE,
                                   e.getMessage());
               
                throw new WebdavException (WebdavStatus.SC_BAD_REQUEST);
            }
            catch (BadQueryException e) {
                resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
                resp.setContentType (TEXT_XML_UTF_8);
                createErrorResult (SearchQueryResult.STATUS_BAD_QUERY,
                                   e.getMessage());
                throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
            }
            catch (AccessDeniedException e) {
               
                String contextPath = req.getContextPath() ;
                AccessDeniedException ade = new AccessDeniedException
                    (contextPath + e.getObjectUri(),
                     contextPath + e.getSubjectUri(),
                     contextPath + e.getActionUri());
               
                String msg = ade.getMessage();
                resp.setStatus(WebdavStatus.SC_FORBIDDEN);
                resp.setContentType (TEXT_XML_UTF_8);
                createErrorResult (SearchQueryResult.STATUS_FORBIDDEN, msg);
                throw new WebdavException(WebdavStatus.SC_FORBIDDEN);
            }
            catch (ObjectNotFoundException e) {
                resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
                resp.setContentType (TEXT_XML_UTF_8);
                createErrorResult (SearchQueryResult.STATUS_INVALID_SCOPE,
                                   "scope " + slidePath + " is invalid");
               
                throw new WebdavException (WebdavStatus.SC_BAD_REQUEST);
            }
            catch (SlideException e) {
                e.printStackTrace();
            }
        }
        else {
            resp.setStatus(WebdavStatus.SC_BAD_REQUEST);
            resp.setContentType (TEXT_XML_UTF_8);
            createErrorResult (SearchQueryResult.STATUS_BAD_QUERY, "SEARCH not implemented on this server");
            throw new WebdavException(WebdavStatus.SC_BAD_REQUEST);
        }
    }
View Full Code Here

                    (WebdavStatus.SC_NOT_FOUND,
                     WebdavStatus.getStatusText(WebdavStatus.SC_NOT_FOUND));
            } catch(IOException ex) {
                ex.printStackTrace();
            }
            throw new WebdavException(WebdavStatus.SC_NOT_FOUND);
        } catch (Exception e) {
            // e.printStackTrace();
            resp.setStatus(getErrorCode(e))// no special handling needed
            throw new WebdavException(WebdavStatus.SC_ACCEPTED, false); // abort the TA
        }
    }
View Full Code Here

        }
        catch (IOException e) {
            System.err.println(e.getMessage());
            e.printStackTrace();
            resp.setStatus(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
            throw new WebdavException
                (WebdavStatus.SC_INTERNAL_SERVER_ERROR);
        }
    }
View Full Code Here

            segment = MethodUtil.getChildText(content, E_SEGMENT);
        }
        catch (IOException e) {  // TODO: merge exception handling into jdom access methods
            int statusCode = WebdavStatus.SC_INTERNAL_SERVER_ERROR;
            sendError( statusCode, e );
            throw new WebdavException( statusCode );
        }
        catch (JDOMException e) {  // TODO: merge exception handling into jdom access methods
            int statusCode = WebdavStatus.SC_BAD_REQUEST;
            sendError( statusCode, e );
            throw new WebdavException( statusCode );
        }
       
        collectionUri = requestUri;
        if (collectionUri == null) {
            collectionUri = "/";
View Full Code Here

        // check lock-null resources
        try {
            if (isLockNull(collectionUri)) {
                int statusCode = WebdavStatus.SC_NOT_FOUND;
                sendError( statusCode, "lock-null resource", new Object[]{collectionUri} );
                throw new WebdavException( statusCode );
            }
        }
        catch (ServiceAccessException e) {
            int statusCode = getErrorCode((Exception)e);
            sendError( statusCode, e );
            throw new WebdavException( statusCode );
        }

        try {
            checkPreconditions();
            structure.removeBinding( slideToken, collectionNode, segment );
        }
        catch (ObjectLockedException e) {
            ViolatedPrecondition violatedPrecondition;
            if (collectionUri.equals(e.getObjectUri())) {
                violatedPrecondition =
                    new ViolatedPrecondition(C_LOCKED_UPDATE_ALLOWED, WebdavStatus.SC_LOCKED);
            }
            else {
                violatedPrecondition =
                    new ViolatedPrecondition(C_PROTECTED_URL_DELETION_ALLOWED, WebdavStatus.SC_CONFLICT);
            }
            sendPreconditionViolation(
                new PreconditionViolationException(violatedPrecondition, collectionNode.getUri())
            );
        }
        catch (PreconditionViolationException e) {
            sendPreconditionViolation(e);
            throw e;
        }
        catch (Exception e) {
            int statusCode = getErrorCode( e );
            sendError( statusCode, e );
            throw new WebdavException( statusCode );
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.slide.webdav.WebdavException

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.