Package org.tmatesoft.svn.core.internal.server.dav

Examples of org.tmatesoft.svn.core.internal.server.dav.DAVException


                throw dave;
            }
           
            if (parentResource == null || !parentResource.exists()) {
                autoCheckIn(resource, true, false, info);
                throw new DAVException("Missing one or more intermediate collections. Cannot create resource {0}.",
                        new Object[] { SVNEncodingUtil.xmlEncodeCDATA(resource.getResourceURI().getRequestURI()) },
                        HttpServletResponse.SC_CONFLICT, 0);
            }
           
            info.setParentResource(parentResource);
           
            if (parentResource.isVersioned() && !parentResource.isWorking()) {
                boolean checkOutParent = false;
                try {
                    checkOutParent = canAutoCheckOut(parentResource, lockProvider, parentResource.getAutoVersion());
                } catch (DAVException dave) {
                    autoCheckIn(resource, true, false, info);
                    throw dave;
                }
               
                if (!checkOutParent) {
                    autoCheckIn(resource, true, false, info);
                    throw new DAVException("<DAV:cannot-modify-checked-in-parent>", HttpServletResponse.SC_CONFLICT, 0);
                }
              
                try {
                    checkOut(parentResource, true, false, false, null);
                } catch (DAVException dave) {
                    autoCheckIn(resource, true, false, info);
                    throw new DAVException("Unable to auto-checkout parent collection. Cannot create resource {0}.",
                            new Object[] { resource.getResourceURI().getRequestURI() }, HttpServletResponse.SC_CONFLICT, dave, 0);
                }
               
                info.setParentCheckedOut(true);
            }
        }
       
        if (isParentOnly) {
            return info;
        }
       
        if (!resource.exists() && resource.getAutoVersion() == DAVAutoVersion.ALWAYS) {
            try {
                resource.versionControl(null);
            } catch (DAVException dave) {
                autoCheckIn(resource, true, false, info);
                throw new DAVException("Unable to create versioned resource {0}.",
                        new Object[] { SVNEncodingUtil.xmlEncodeCDATA(resource.getResourceURI().getRequestURI()) },
                        HttpServletResponse.SC_CONFLICT, dave, 0);
            }
           
            info.setResourceVersioned(true);
        }
       
        if (resource.isVersioned() && !resource.isWorking()) {
            boolean checkOutResource = false;
            try {
                checkOutResource = canAutoCheckOut(resource, lockProvider, resource.getAutoVersion());
            } catch (DAVException dave) {
                autoCheckIn(resource, true, false, info);
                throw dave;
            }
           
            if (!checkOutResource) {
                autoCheckIn(resource, true, false, info);
                throw new DAVException("<DAV:cannot-modify-version-controlled-content>", HttpServletResponse.SC_CONFLICT, 0);
            }
           
            try {
                checkOut(resource, true, false, false, null);
            } catch (DAVException dave) {
                autoCheckIn(resource, true, false, info);
                throw new DAVException("Unable to checkout resource {0}.",
                        new Object[] { SVNEncodingUtil.xmlEncodeCDATA(resource.getResourceURI().getRequestURI()) },
                        HttpServletResponse.SC_CONFLICT, 0);
            }
           
            info.setResourceCheckedOut(true);
View Full Code Here


            }
           
            try {
                lock = lockProvider[0].getLock(resource);
            } catch (DAVException dave) {
                throw new DAVException("The locks could not be queried for determining auto-versioning behavior.", null,
                        HttpServletResponse.SC_INTERNAL_SERVER_ERROR, dave, 0);
            }
           
            if (lock != null) {
                autoCheckOut = true;
View Full Code Here

            if (resource != null) {
                if (info.isResourceCheckedOut()) {
                    try {
                        uncheckOut(resource);
                    } catch (DAVException dave) {
                        throw new DAVException("Unable to undo auto-checkout of resource {0}.",
                                new Object[] { SVNEncodingUtil.xmlEncodeCDATA(resource.getResourceURI().getRequestURI()) },
                                HttpServletResponse.SC_INTERNAL_SERVER_ERROR, null, SVNLogType.NETWORK, Level.FINE, dave, null, null, 0, null);
                    }
                }
               
                if (info.isResourceVersioned()) {
                    try {
                        removeResource(resource);
                    } catch (DAVException dave) {
                        throw new DAVException("Unable to undo auto-version-control of resource {0}.",
                                new Object[] { SVNEncodingUtil.xmlEncodeCDATA(resource.getResourceURI().getRequestURI()) },
                                HttpServletResponse.SC_INTERNAL_SERVER_ERROR, null, SVNLogType.NETWORK, Level.FINE, dave, null, null, 0, null);
                    }
                }
            }
           
            if (info.getParentResource() != null && info.isParentCheckedOut()) {
                try {
                    uncheckOut(info.getParentResource());
                } catch (DAVException dave) {
                    throw new DAVException("Unable to undo auto-checkout of parent collection {0}.",
                            new Object[] { SVNEncodingUtil.xmlEncodeCDATA(info.getParentResource().getResourceURI().getRequestURI()) },
                            HttpServletResponse.SC_INTERNAL_SERVER_ERROR, null, SVNLogType.NETWORK, Level.FINE, dave, null, null, 0, null);
                }
            }
            return;
        }
       
        if (resource != null && resource.isWorking() && (unlock || info.isResourceCheckedOut())) {
            DAVAutoVersion autoVersion = resource.getAutoVersion();
            if (autoVersion == DAVAutoVersion.ALWAYS || (unlock && autoVersion == DAVAutoVersion.LOCKED)) {
                try {
                    checkIn(resource, false, false);
                } catch (DAVException dave) {
                    throw new DAVException("Unable to auto-checkin resource {0}.",
                            new Object[] { SVNEncodingUtil.xmlEncodeCDATA(resource.getResourceURI().getRequestURI()) },
                            HttpServletResponse.SC_INTERNAL_SERVER_ERROR, null, SVNLogType.NETWORK, Level.FINE, dave, null, null, 0, null);
                }
            }
        }
       
        if (!unlock && info.isParentCheckedOut() && info.getParentResource() != null &&
                info.getParentResource().getType() == DAVResourceType.WORKING) {
            DAVAutoVersion autoVersion = info.getParentResource().getAutoVersion();
            if (autoVersion == DAVAutoVersion.ALWAYS) {
                try {
                    checkIn(info.getParentResource(), false, false);
                } catch (DAVException dave) {
                    throw new DAVException("Unable to auto-checkin parent collection {0}.",
                            new Object[] { SVNEncodingUtil.xmlEncodeCDATA(info.getParentResource().getResourceURI().getRequestURI()) },
                            HttpServletResponse.SC_INTERNAL_SERVER_ERROR, null, SVNLogType.NETWORK, Level.FINE, dave, null, null, 0, null);
                }
            }
        }
View Full Code Here

   
    protected void removeResource(DAVResource resource) throws DAVException {
        DAVResourceURI uri = resource.getResourceURI();
        DAVResourceType resourceType = uri.getType();
        if (resourceType != DAVResourceType.REGULAR && resourceType != DAVResourceType.WORKING && resourceType != DAVResourceType.ACTIVITY) {
            throw new DAVException("DELETE called on invalid resource type.", HttpServletResponse.SC_METHOD_NOT_ALLOWED, 0);
        }
       
        DAVConfig config = getConfig();
        if (resourceType == DAVResourceType.REGULAR && !config.isAutoVersioning()) {
            throw new DAVException("DELETE called on regular resource, but autoversioning is not active.",
                    HttpServletResponse.SC_METHOD_NOT_ALLOWED, 0);
        }
       
        if (resourceType == DAVResourceType.ACTIVITY) {
            DAVServletUtil.deleteActivity(resource, uri.getActivityID());
View Full Code Here

        return null;
    }

    protected void createdCollection(DAVResource resource) throws DAVException {
        if (resource.getType() != DAVResourceType.WORKING && resource.getType() != DAVResourceType.REGULAR) {
            throw new DAVException("Collections can only be created within a working or regular collection [at this time].",
                    HttpServletResponse.SC_METHOD_NOT_ALLOWED, 0);
        }
       
        if (resource.getType() == DAVResourceType.REGULAR && !getConfig().isAutoVersioning()) {
            throw new DAVException("MKCOL called on regular resource, but autoversioning is not active.",
                    HttpServletResponse.SC_METHOD_NOT_ALLOWED, 0);
        }
       
        if (resource.getType() == DAVResourceType.REGULAR) {
            checkOut(resource, true, false, false, null);
View Full Code Here

            }
        } else if (resourceState == DAVResourceState.NULL) {
            try {
                lockProvider.inheritLocks(resource, true);
            } catch (DAVException dave) {
                throw new DAVException("The resource was created successfully, but there was a problem inheriting locks from the parent resource.",
                        dave.getResponseCode(), dave, 0);
            }
        }
    }
View Full Code Here

    }

    //TODO: unused?
    protected void handleError(DAVException error, DAVResponse response) {
        if (response == null) {
            DAVException stackErr = error;
            while (stackErr != null && stackErr.getTagName() == null) {
                stackErr = stackErr.getPreviousException();
            }
           
            if (stackErr != null && stackErr.getTagName() != null) {
                myResponse.setContentType(DEFAULT_XML_CONTENT_TYPE);
               
                StringBuffer errorMessageBuffer = new StringBuffer();
                errorMessageBuffer.append('\n');
                errorMessageBuffer.append("<D:error xmlns:D=\"DAV:\"");
               
                if (stackErr.getMessage() != null) {
                    errorMessageBuffer.append(" xmlns:m=\"http://apache.org/dav/xmlns\"");
                }
               
                if (stackErr.getNameSpace() != null) {
                    errorMessageBuffer.append(" xmlns:C=\"");
                    errorMessageBuffer.append(stackErr.getNameSpace());
                    errorMessageBuffer.append("\">\n<C:");
                    errorMessageBuffer.append(stackErr.getTagName());
                    errorMessageBuffer.append("/>");
                } else {
                    errorMessageBuffer.append(">\n<D:");
                    errorMessageBuffer.append(stackErr.getTagName());
                    errorMessageBuffer.append("/>");
                }
               
                if (stackErr.getMessage() != null) {
                   
                }

            }
        }
View Full Code Here

        DAVGetDeletedRevisionRequest request = getDeletedRevisionRequest();
        String relPath = request.getPath();
        long pegRev = request.getPegRevision();
        long endRev = request.getEndRevision();
        if (relPath == null || !SVNRevision.isValidRevisionNumber(pegRev) || !SVNRevision.isValidRevisionNumber(endRev)) {
            throw new DAVException("Not all parameters passed.", null, HttpServletResponse.SC_BAD_REQUEST, null, SVNLogType.NETWORK, Level.FINE,
                    null, DAVXMLUtil.SVN_DAV_ERROR_TAG, DAVElement.SVN_DAV_ERROR_NAMESPACE, 0, null);
        }
       
        DAVResourceURI resourceURI = getDAVResource().getResourceURI();
        String path = relPath;
        if (!path.startsWith("/")) {
            path = SVNPathUtil.append(resourceURI.getPath(), relPath);   
        }
       
        SVNRepository repository = getDAVResource().getRepository();
        long deletedRev = SVNRepository.INVALID_REVISION;
        try {
            deletedRev = repository.getDeletedRevision(path, pegRev, endRev);
        } catch (SVNException svne) {
            throw new DAVException("Could not find revision path was deleted.", HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 0);
        }
       
        writeXMLHeader(null);
        StringBuffer xmlBuffer = SVNXMLUtil.openCDataTag(SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.VERSION_NAME.getName(), String.valueOf(deletedRev), null);
        write(xmlBuffer);
View Full Code Here

        DAVMergeRequest requestXMLObject = getMergeRequest()
        DAVElementProperty rootElement = requestXMLObject.getRoot();
        DAVElementProperty sourceElement = rootElement.getChild(DAVElement.SOURCE);
        if (sourceElement == null) {
            throw new DAVException("The DAV:merge element must contain a DAV:source element.", HttpServletResponse.SC_BAD_REQUEST, 0);
        }
       
        DAVElementProperty hrefElement = sourceElement.getChild(DAVElement.HREF);
        if (hrefElement == null) {
            throw new DAVException("The DAV:source element must contain a DAV:href element.", HttpServletResponse.SC_BAD_REQUEST, 0);
        }
       
        String source = hrefElement.getFirstValue(false);
        URI uri = null;
        try {
            uri = DAVServletUtil.lookUpURI(source, getRequest(), false);
        } catch (DAVException dave) {
            if (dave.getResponseCode() == HttpServletResponse.SC_BAD_REQUEST) {
                throw dave;
            }
            response(dave.getMessage(), DAVServlet.getStatusLine(dave.getResponseCode()), dave.getResponseCode());
        }

        String path = uri.getPath();
        DAVRepositoryManager manager = getRepositoryManager();
        String resourceContext = manager.getResourceContext();
       
        if (!path.startsWith(resourceContext)) {
            throw new DAVException("Destination url starts with a wrong context", HttpServletResponse.SC_BAD_REQUEST, 0);
        }
       
        //TODO: cut away the servlet context part
        path = path.substring(resourceContext.length());
        DAVResource srcResource = getRequestedDAVResource(false, false, path);

        //NOTE: for now this all are no-ops, just commented them for a while
        //boolean noAutoMerge = rootElement.hasChild(DAVElement.NO_AUTO_MERGE);
        //boolean noCheckOut = rootElement.hasChild(DAVElement.NO_CHECKOUT);
        //DAVElementProperty propElement = rootElement.getChild(DAVElement.PROP);
       
        DAVResource resource = getRequestedDAVResource(false, false);
        if (!resource.exists()) {
            sendError(HttpServletResponse.SC_NOT_FOUND, null);
            return;
        }
       
        setResponseHeader(CACHE_CONTROL_HEADER, CACHE_CONTROL_VALUE);
        String response = null;
        try {
            response = merge(resource, srcResource);
        } catch (DAVException dave) {
            throw new DAVException("Could not MERGE resource \"{0}\" into \"{1}\".", new Object[] { SVNEncodingUtil.xmlEncodeCDATA(source),
                    SVNEncodingUtil.xmlEncodeCDATA(getURI()) }, dave.getResponseCode(), null, SVNLogType.NETWORK, Level.FINE, dave, null,
                    null, 0, null);
        }

        try {
            setResponseContentLength(response.getBytes(UTF8_ENCODING).length);
        } catch (UnsupportedEncodingException e) {
        }

        try {
            getResponseWriter().write(response);
        } catch (IOException ioe) {
            throw new DAVException(ioe.getMessage(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR, SVNErrorCode.IO_ERROR.getCode());
        }
    }
View Full Code Here

    }

    private String merge(DAVResource targetResource, DAVResource sourceResource) throws DAVException {
        boolean disableMergeResponse = false;
        if (sourceResource.getType() != DAVResourceType.ACTIVITY) {
            throw new DAVException("MERGE can only be performed using an activity as the source [at this time].", null,
                    HttpServletResponse.SC_METHOD_NOT_ALLOWED, null, SVNLogType.NETWORK, Level.FINE, null, DAVXMLUtil.SVN_DAV_ERROR_TAG,
                    DAVElement.SVN_DAV_ERROR_NAMESPACE, SVNErrorCode.INCORRECT_PARAMS.getCode(), null);
        }
       
        Map locks = parseLocks(getMergeRequest().getRootElement(), targetResource.getResourceURI().getPath());
View Full Code Here

TOP

Related Classes of org.tmatesoft.svn.core.internal.server.dav.DAVException

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.