Examples of DAVResourceURI


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

                livePropElement != DAVElement.BASELINE_RELATIVE_PATH) {
            return DAVInsertPropAction.NOT_SUPP;
        }

        String value = null;
        DAVResourceURI uri = resource.getResourceURI();
        if (livePropElement == DAVElement.GET_LAST_MODIFIED || livePropElement == DAVElement.CREATION_DATE) {
            if (resource.getType() == DAVResourceType.PRIVATE && resource.getKind() == DAVResourceKind.VCC) {
                return DAVInsertPropAction.NOT_SUPP;
            }
           
            if (livePropElement == DAVElement.CREATION_DATE) {
                try {
                    value = SVNDate.formatDate(getLastModifiedTime2(resource));
                } catch (SVNException svne) {
                    return DAVInsertPropAction.NOT_DEF;
                }
            } else if (livePropElement == DAVElement.GET_LAST_MODIFIED) {
                try {
                    value = SVNDate.formatRFC1123Date(getLastModifiedTime2(resource));
                } catch (SVNException svne) {
                    return DAVInsertPropAction.NOT_DEF;
                }
            }
            value = SVNEncodingUtil.xmlEncodeCDATA(value, true);
        } else if (livePropElement == DAVElement.CREATOR_DISPLAY_NAME) {
            if (resource.getType() == DAVResourceType.PRIVATE && resource.getKind() == DAVResourceKind.VCC) {
                return DAVInsertPropAction.NOT_SUPP;
            }
           
            long committedRev = -1;
            if (resource.isBaseLined() && resource.getType() == DAVResourceType.VERSION) {
                committedRev = resource.getRevision();
            } else if (resource.getType() == DAVResourceType.REGULAR || resource.getType() == DAVResourceType.WORKING ||
                    resource.getType() == DAVResourceType.VERSION) {
                try {
                    committedRev = resource.getCreatedRevisionUsingFS(null);
                } catch (SVNException svne) {
                    value = "###error###";
                }
            } else {
                return DAVInsertPropAction.NOT_SUPP;
            }
           
            String lastAuthor = null;
            try {
                lastAuthor = resource.getAuthor(committedRev);
            } catch (SVNException svne) {
                value = "###error###";
            }
           
            if (lastAuthor == null) {
                return DAVInsertPropAction.NOT_DEF;
            }
           
            value = SVNEncodingUtil.xmlEncodeCDATA(lastAuthor, true);
        } else if (livePropElement == DAVElement.GET_CONTENT_LANGUAGE) {
            return DAVInsertPropAction.NOT_SUPP;
        } else if (livePropElement == DAVElement.GET_CONTENT_LENGTH) {
            if (resource.isCollection() || resource.isBaseLined()) {
                return DAVInsertPropAction.NOT_SUPP;
            }

            long fileSize = 0;
            try {
                fileSize = resource.getContentLength(null);
                value = String.valueOf(fileSize);
            } catch (SVNException e) {
                value = "0";
            }
        } else if (livePropElement == DAVElement.GET_CONTENT_TYPE) {
            if (resource.isBaseLined() && resource.getType() == DAVResourceType.VERSION) {
                return DAVInsertPropAction.NOT_SUPP;
            }
           
            if (resource.getType() == DAVResourceType.PRIVATE && resource.getKind() == DAVResourceKind.VCC) {
                return DAVInsertPropAction.NOT_SUPP;
            }
           
            if (resource.isCollection()) {
                value = DAVResource.DEFAULT_COLLECTION_CONTENT_TYPE;
            } else {
                SVNPropertyValue contentType = null;
                try {
                    contentType = resource.getProperty(null, SVNProperty.MIME_TYPE);
                } catch (SVNException svne) {
                    //
                }
               
                if (contentType != null) {
                    value = contentType.getString();
                } else if (!resource.isSVNClient() && getRequest().getContentType() != null) {
                    value = getRequest().getContentType();
                } else {
                    value = DAVResource.DEFAULT_FILE_CONTENT_TYPE;
                }

                try {
                    SVNPropertiesManager.validateMimeType(value);
                } catch (SVNException svne) {
                    return DAVInsertPropAction.NOT_DEF;
                }
            }
        } else if (livePropElement == DAVElement.GET_ETAG) {
            if (resource.getType() == DAVResourceType.PRIVATE && resource.getKind() == DAVResourceKind.VCC) {
                return DAVInsertPropAction.NOT_SUPP;
            }
           
            value = resource.getETag();
        } else if (livePropElement == DAVElement.AUTO_VERSION) {
            if (getConfig().isAutoVersioning()) {
                value = DEFAULT_AUTOVERSION_LINE;
            } else {
                return DAVInsertPropAction.NOT_DEF;
            }
        } else if (livePropElement == DAVElement.BASELINE_COLLECTION) {
            if (resource.getType() != DAVResourceType.VERSION || !resource.isBaseLined()) {
                return DAVInsertPropAction.NOT_SUPP;
            }
            value = DAVPathUtil.buildURI(uri.getContext(), DAVResourceKind.BASELINE_COLL, resource.getRevision(), null,
                    true);
        } else if (livePropElement == DAVElement.CHECKED_IN) {
            String s = null;
            if (resource.getType() == DAVResourceType.PRIVATE && resource.getKind() == DAVResourceKind.VCC) {
                long revNum = -1;
                try {
                    revNum = resource.getLatestRevision();
                    s = DAVPathUtil.buildURI(uri.getContext(), DAVResourceKind.BASELINE, revNum, null, false);
                    StringBuffer buf = SVNXMLUtil.openCDataTag(SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.HREF.getName(), s,
                            null, true, true, null);
                    value = buf.toString();
                } catch (SVNException svne) {
                    value = "###error###";
                }
            } else if (resource.getType() != DAVResourceType.REGULAR) {
                return DAVInsertPropAction.NOT_SUPP;
            } else {
                long revToUse = DAVServletUtil.getSafeCreatedRevision((FSRevisionRoot) resource.getRoot(), uri.getPath());
                s = DAVPathUtil.buildURI(uri.getContext(), DAVResourceKind.VERSION, revToUse, uri.getPath(), false);
                StringBuffer buf = SVNXMLUtil.openCDataTag(SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.HREF.getName(), s,
                        null, true, true, null);
                value = buf.toString();
            }
        } else if (livePropElement == DAVElement.VERSION_CONTROLLED_CONFIGURATION) {
            if (resource.getType() != DAVResourceType.REGULAR) {
                return DAVInsertPropAction.NOT_SUPP;
            }
            value = DAVPathUtil.buildURI(uri.getContext(), DAVResourceKind.VCC, -1, null, true);
        } else if (livePropElement == DAVElement.VERSION_NAME) {
            if (resource.getType() != DAVResourceType.VERSION && !resource.isVersioned()) {
                return DAVInsertPropAction.NOT_SUPP;
            }
           
            if (resource.getType() == DAVResourceType.PRIVATE && resource.getKind() == DAVResourceKind.VCC) {
                return DAVInsertPropAction.NOT_SUPP;
            }
           
            if (resource.isBaseLined()) {
                value = String.valueOf(resource.getRevision());
            } else {
                try {
                    long committedRev = resource.getCreatedRevisionUsingFS(null);
                    value = String.valueOf(committedRev);
                    value = SVNEncodingUtil.xmlEncodeCDATA(value, true);
                } catch (SVNException svne) {
                    value = "###error###";
                }   
            }
        } else if (livePropElement == DAVElement.BASELINE_RELATIVE_PATH) {
            if (resource.getType() != DAVResourceType.REGULAR) {
                return DAVInsertPropAction.NOT_SUPP;
            }
            value = SVNEncodingUtil.xmlEncodeCDATA(DAVPathUtil.dropLeadingSlash(uri.getPath()), true);
        } else if (livePropElement == DAVElement.MD5_CHECKSUM) {
            if (!resource.isCollection() && !resource.isBaseLined() && (resource.getType() == DAVResourceType.REGULAR ||
                    resource.getType() == DAVResourceType.VERSION || resource.getType() == DAVResourceType.WORKING)) {
                try {
                    value = resource.getMD5Checksum(null);
View Full Code Here

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

        myOwner = owner;
        myResource = resource;
    }

    public static DAVPropertiesProvider createPropertiesProvider(DAVResource resource, ServletDAVHandler owner) throws DAVException {
        DAVResourceURI resourceURI = resource.getResourceURI();
        if (resourceURI.getURI() == null) {
            throw new DAVException("INTERNAL DESIGN ERROR: resource must define its URI.", HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 0);
        }
       
        DAVPropertiesProvider provider = new DAVPropertiesProvider(true, owner, resource);
        return provider;
View Full Code Here

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

                } else {
                    SVNRepository repos = myResource.getRepository();
                    repos.setRevisionPropertyValue(myResource.getRevision(), reposPropName, null);
                }
            } else {
                DAVResourceURI resourceURI = myResource.getResourceURI();
                FSCommitter committer = getCommitter();
                committer.changeNodeProperty(resourceURI.getPath(), reposPropName, null);
            }
        } catch (SVNException svne) {
            throw DAVException.convertError(svne.getErrorMessage(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "could not remove a property", null);
        }
        myProperties = null;
View Full Code Here

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

                    SVNRepository repos = myResource.getRepository();
                    repos.setRevisionPropertyValue(myResource.getRevision(), reposPropName, value);
                    //TODO: maybe add logging here
                }
            } else {
                DAVResourceURI resourceURI = myResource.getResourceURI();
                FSCommitter committer = getCommitter();
                committer.changeNodeProperty(resourceURI.getPath(), reposPropName, value);
            }
        } catch (SVNException svne) {
            throw DAVException.convertError(svne.getErrorMessage(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR, null, null);
        }
       
View Full Code Here

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

                    SVNLogType.NETWORK, Level.FINE, null, DAVXMLUtil.SVN_DAV_ERROR_TAG, DAVElement.SVN_DAV_ERROR_NAMESPACE,
                    SVNErrorCode.UNSUPPORTED_FEATURE.getCode(), null);
        }
       
        DAVResource versionResource = null;
        DAVResourceURI resourceURI = resource.getResourceURI();
        String sharedActivity = DAVServlet.getSharedActivity();
        if (sharedActivity != null && sharedActivity.equals(resource.getActivityID())) {
            String sharedTxnName = DAVServletUtil.getTxn(resource.getActivitiesDB(), sharedActivity);
            if (sharedTxnName == null) {
                throw new DAVException("Cannot look up a txn_name by activity", HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 0);
            }
           
            if (resource.getTxnName() != null && !sharedTxnName.equals(resource.getTxnName())) {
                throw new DAVException("Internal txn_name doesn't match autoversioning transaction.", HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 0);
            }
           
            if (resource.getTxnInfo() == null) {
                throw new DAVException("Autoversioning txn isn't open when it should be.", HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 0);
            }
           
            DAVServletUtil.setAutoRevisionProperties(resource);
            FSCommitter committer = getCommitter(resource.getFSFS(), resource.getRoot(), resource.getTxnInfo(), resource.getLockTokens(),
                    resource.getUserName());
           
            StringBuffer conflictPath = new StringBuffer();
            long newRev = SVNRepository.INVALID_REVISION;
            try {
                newRev = committer.commitTxn(true, true, null, conflictPath);
            } catch (SVNException svne) {
                try {
                    FSCommitter.abortTransaction(resource.getFSFS(), resource.getTxnInfo().getTxnId());
                } catch (SVNException svne2) {
                    //ignore
                }
                String message = null;
                Object[] objects = null;
                if (svne.getErrorMessage().getErrorCode() == SVNErrorCode.FS_CONFLICT) {
                    message = "A conflict occurred during the CHECKIN processing. The problem occurred with  the \"{0}\" resource.";
                    objects = new Object[] { conflictPath.toString() };
                } else {
                    message = "An error occurred while committing the transaction.";
                }
               
                DAVServletUtil.deleteActivity(resource, sharedActivity);
                DAVServlet.setSharedActivity(null);
                throw DAVException.convertError(svne.getErrorMessage(), HttpServletResponse.SC_CONFLICT, message, objects);
            }
           
            DAVServletUtil.deleteActivity(resource, sharedActivity);
            if (createVersionResource) {
                String uri = DAVPathUtil.buildURI(resourceURI.getContext(), DAVResourceKind.VERSION, newRev, resourceURI.getPath(), false);
                versionResource = DAVVersionResourceHelper.createVersionResource(resource, uri);
            }
        }
       
        resource.setTxnName(null);
View Full Code Here

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

            } catch (SVNException svne) {
                //ignore
            }
        }
       
        DAVResourceURI resourceURI = resource.getResourceURI();
        if (resourceURI.getActivityID() != null) {
            try {
                DAVServletUtil.deleteActivity(resource, resourceURI.getActivityID());
            } catch (DAVException dave) {
                //ignore
            }
            DAVServlet.setSharedActivity(null);
        }
View Full Code Here

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

            }
        }
    }
   
    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());
            return;
        }
       
        if (resourceType == DAVResourceType.REGULAR) {
            checkOut(resource, true, false, false, null);
        }
       
        if (SVNRevision.isValidRevisionNumber(resource.getVersion())) {
            long createdRevision = SVNRepository.INVALID_REVISION;
            try {
                createdRevision = resource.getCreatedRevisionUsingFS(null);
            } catch (SVNException svne) {
                throw DAVException.convertError(svne.getErrorMessage(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                        "Could not get created rev of resource", null);
            }
           
            if (resource.getVersion() < createdRevision) {
                SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_OUT_OF_DATE, "Item ''{0}'' is out of date",
                        uri.getPath());
                throw DAVException.convertError(err, HttpServletResponse.SC_CONFLICT, "Can''t DELETE out-of-date resource", null);
            }
        }
       
        //MERGE requests send can provide locks in a request body,
        //COPY, MOVE requests do not, so check for the valid xml exists
        if (getDAVRequest() != null) {
            Map locks = parseLocks(getDAVRequest().getRootElement(), uri.getPath());
            if (!locks.isEmpty()) {
                resource.setLockTokens(locks.values());
            }
        }
       
        FSCommitter committer = getCommitter(resource.getFSFS(), resource.getRoot(), resource.getTxnInfo(), resource.getLockTokens(),
                resource.getUserName());
        try {
            committer.deleteNode(uri.getPath());
        } catch (SVNException svne) {
            throw DAVException.convertError(svne.getErrorMessage(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                    "Could not delete the resource", null);
        }
       
View Full Code Here

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

        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 {
View Full Code Here

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

        }
        return davLock;
    }
       
    public void removeLock(DAVResource resource, String lockToken) throws DAVException {
        DAVResourceURI resourceURI = resource.getResourceURI();
        if (resourceURI.getPath() == null) {
            return;
        }
       
        if (isKeepLocks()) {
            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.