Examples of DAVElement


Examples of org.tmatesoft.svn.core.internal.io.dav.DAVElement

    }
   
    private DAVInsertPropAction insertCoreLiveProperty(DAVResource resource, DAVInsertPropAction propAction,
            LivePropertySpecification livePropSpec, StringBuffer buffer) throws DAVException {
        DAVInsertPropAction inserted = DAVInsertPropAction.NOT_DEF;
        DAVElement livePropElement = livePropSpec.getPropertyName();
        String value = null;
        if (livePropElement == DAVElement.LOCK_DISCOVERY) {
            if (myLocksProvider != null) {
                DAVLock lock = null;
                try {
                    lock = myLocksProvider.getLock(resource);
                } catch (DAVException dave) {
                    throw new DAVException("DAV:lockdiscovery could not be determined due to a problem fetching the locks for this resource.",
                            dave.getResponseCode(), dave, 0);
                }
               
                if (lock == null) {
                    value = "";
                } else {
                    value = DAVLockInfoProvider.getActiveLockXML(lock);
                }
            }
        } else if (livePropElement == DAVElement.SUPPORTED_LOCK) {
            if (myLocksProvider != null) {
                value = myLocksProvider.getSupportedLock(resource);
            }
        } else if (livePropElement == DAVElement.GET_CONTENT_TYPE) {
            //TODO: get content type from a response when imitating a GET request?
        } else if (livePropElement == DAVElement.GET_CONTENT_LANGUAGE) {
            //TODO: get Content-Language from a response when imitating a GET request?
        }
       
        if (value != null) {
            if (propAction == DAVInsertPropAction.INSERT_SUPPORTED) {
                SVNXMLUtil.openXMLTag(SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.SUPPORTED_LIVE_PROPERTY.getName(), SVNXMLUtil.XML_STYLE_NORMAL,
                        "D:name", livePropElement.getName(), buffer);
            } else if (propAction == DAVInsertPropAction.INSERT_VALUE && !"".equals(value)) {
                SVNXMLUtil.openCDataTag(SVNXMLUtil.DAV_NAMESPACE_PREFIX, livePropElement.getName(), value, null, false, false, buffer);
            } else {
                SVNXMLUtil.openXMLTag(SVNXMLUtil.DAV_NAMESPACE_PREFIX, livePropElement.getName(), SVNXMLUtil.XML_STYLE_SELF_CLOSING, null, buffer);
            }
            inserted = propAction;
        }
        return inserted;
    }
View Full Code Here

Examples of org.tmatesoft.svn.core.internal.io.dav.DAVElement

        if (!livePropSpec.isSVNSupported()) {
            //this is a core WebDAV live prop
            return insertCoreLiveProperty(resource, propAction, livePropSpec, buffer);
        }
       
        DAVElement livePropElement = livePropSpec.getPropertyName();
        if (!resource.exists() && livePropElement != DAVElement.VERSION_CONTROLLED_CONFIGURATION &&
                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);
                    if (value == null) {
                        return DAVInsertPropAction.NOT_SUPP;
                    }
                } catch (SVNException svne) {
                    value = "###error###";
                }
            } else {
                return DAVInsertPropAction.NOT_SUPP;
            }
        } else if (livePropElement == DAVElement.REPOSITORY_UUID) {
            try {
                value = resource.getRepositoryUUID(false);
            } catch (SVNException svne) {
                value = "###error###";
            }
        } else if (livePropElement == DAVElement.DEADPROP_COUNT) {
            if (resource.getType() != DAVResourceType.REGULAR) {
                return DAVInsertPropAction.NOT_SUPP;
            }
           
            SVNProperties props = null;
            try {
                props = resource.getSVNProperties(null);
                int deadPropertiesCount = props.size();
                value = String.valueOf(deadPropertiesCount);
            } catch (SVNException svne) {
                value = "###error###";
            }
        } else if (livePropElement == DAVElement.RESOURCE_TYPE) {
            if (resource.getType() == DAVResourceType.VERSION) {
                if (resource.isBaseLined()) {
                    StringBuffer buf = SVNXMLUtil.openXMLTag(SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.BASELINE.getName(),
                            SVNXMLUtil.XML_STYLE_SELF_CLOSING | SVNXMLUtil.XML_STYLE_PROTECT_CDATA, null, null);
                    value = buf.toString();
                   
                }
            } else if (resource.getType() == DAVResourceType.REGULAR || resource.getType() == DAVResourceType.WORKING) {
                if (resource.isCollection()) {
                    StringBuffer buf = SVNXMLUtil.openXMLTag(SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.COLLECTION.getName(),
                            SVNXMLUtil.XML_STYLE_SELF_CLOSING | SVNXMLUtil.XML_STYLE_PROTECT_CDATA, null, null);
                    value = buf.toString();
                } else {
                    value = "";
                }
            } else if (resource.getType() == DAVResourceType.HISTORY) {
                StringBuffer buf = SVNXMLUtil.openXMLTag(SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.VERSION_HISTORY.getName(),
                        SVNXMLUtil.XML_STYLE_SELF_CLOSING | SVNXMLUtil.XML_STYLE_PROTECT_CDATA, null, null);
                value = buf.toString();
            } else if (resource.getType() == DAVResourceType.WORKSPACE) {
                StringBuffer buf = SVNXMLUtil.openXMLTag(SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.COLLECTION.getName(),
                        SVNXMLUtil.XML_STYLE_SELF_CLOSING | SVNXMLUtil.XML_STYLE_PROTECT_CDATA, null, null);
                value = buf.toString();
            } else if (resource.getType() == DAVResourceType.ACTIVITY) {
                StringBuffer buf = SVNXMLUtil.openXMLTag(SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.ACTIVITY.getName(),
                        SVNXMLUtil.XML_STYLE_SELF_CLOSING | SVNXMLUtil.XML_STYLE_PROTECT_CDATA, null, null);
                value = buf.toString();
            } else {
                return DAVInsertPropAction.NOT_DEF;
            }
        } else if (livePropElement == DAVElement.COMMENT || livePropElement == DAVElement.CREATOR_DISPLAY_NAME ||
                livePropElement == DAVElement.DISPLAY_NAME || livePropElement == DAVElement.SOURCE) {
            return DAVInsertPropAction.NOT_DEF;
        } else {
            return DAVInsertPropAction.NOT_SUPP;
        }

        int ind = NAMESPACES.indexOf(livePropElement.getNamespace());
        String prefix = "lp" + ind;
        if (propAction == DAVInsertPropAction.INSERT_NAME ||
                (propAction == DAVInsertPropAction.INSERT_VALUE && (value == null || value.length() == 0))) {
            SVNXMLUtil.openXMLTag(prefix, livePropElement.getName(), SVNXMLUtil.XML_STYLE_SELF_CLOSING, null, buffer);
        } else if (propAction == DAVInsertPropAction.INSERT_VALUE) {
            SVNXMLUtil.openCDataTag(prefix, livePropElement.getName(), value, null, false, false, buffer);
        } else {
            Map attrs = new HashMap();
            attrs.put("D:name", livePropElement.getName());
            attrs.put("D:namespace", livePropElement.getNamespace());
            SVNXMLUtil.openXMLTag(SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.SUPPORTED_LIVE_PROPERTY.getName(),
                    SVNXMLUtil.XML_STYLE_SELF_CLOSING, attrs, buffer);
        }
       
        return propAction;
View Full Code Here

Examples of org.tmatesoft.svn.core.internal.io.dav.DAVElement

            String sendAll = getRootElementAttributeValue("send-all");
            setSendAll(sendAll != null && Boolean.valueOf(sendAll).booleanValue());
            DAVElementProperty rootElement = getRootElement();
            for (Iterator iterator = rootElement.getChildren().iterator(); iterator.hasNext();) {
                DAVElementProperty property = (DAVElementProperty) iterator.next();
                DAVElement element = property.getName();
                if (element == TARGET_REVISION) {
                    assertNullCData(element, property);
                    String value = property.getFirstValue(true);
                    try {
                        setRevision(Long.parseLong(value));
View Full Code Here

Examples of org.tmatesoft.svn.core.internal.io.dav.DAVElement

        DAVElementProperty rootElement = request.getRootElement();
        List children = rootElement.getChildren();
        for (Iterator iterator = children.iterator(); iterator.hasNext();) {
            DAVElementProperty childElement = (DAVElementProperty) iterator.next();
            DAVElement childElementName = childElement.getName();
            if (!DAVElement.SVN_NAMESPACE.equals(childElementName.getNamespace())) {
                continue;
            }
           
            if (childElementName == ScmDAVElement.PATH) {
                path = childElement.getFirstValue(false);
View Full Code Here

Examples of org.tmatesoft.svn.core.internal.io.dav.DAVElement

        DAVElementProperty rootElement = getRootElement();
        List rootChildren = rootElement.getChildren();
        if (rootChildren != null) {
            for (Iterator childrenIter = rootChildren.iterator(); childrenIter.hasNext();) {
                DAVElementProperty childElement = (DAVElementProperty) childrenIter.next();
                DAVElement childElementName = childElement.getName();
                if (!DAVElement.SVN_NAMESPACE.equals(childElementName.getNamespace())) {
                    continue;
                }
               
                if (childElementName == ScmDAVElement.PEG_REVISION) {
                    try {
View Full Code Here

Examples of org.tmatesoft.svn.core.internal.io.dav.DAVElement

        List namespaces = getNamespaces();
        if (namespaces == null || !namespaces.contains(DAVElement.SVN_NAMESPACE)) {
            return pathsToLockTokens;
        }
       
        DAVElement rootElementName = rootElement.getName();
        DAVElementProperty child = null;
        if (rootElementName == DAVElement.SVN_LOCK_TOKEN_LIST) {
            child = rootElement;
        } else {
            List children = rootElement.getChildren();
View Full Code Here

Examples of org.tmatesoft.svn.core.internal.io.dav.DAVElement

    protected void init() throws SVNException {
        DAVElementProperty rootElement = getRootElement();
        List children = rootElement.getChildren();
        for (Iterator iterator = children.iterator(); iterator.hasNext();) {
            DAVElementProperty childElement = (DAVElementProperty) iterator.next();
            DAVElement childElementName = childElement.getName();
            if (!DAVElement.SVN_NAMESPACE.equals(childElementName.getNamespace())) {
                continue;
            }
            if (childElementName == ScmDAVElement.PATH) {
                String path = childElement.getFirstValue(false);
                DAVPathUtil.testCanonical(path);
View Full Code Here

Examples of org.tmatesoft.svn.core.internal.io.dav.DAVElement

    protected void init() throws SVNException {
        List children = getRootElement().getChildren();
        for (Iterator iterator = children.iterator(); iterator.hasNext();) {
            DAVElementProperty property = (DAVElementProperty) iterator.next();
            DAVElement element = property.getName();
            if (element == ScmDAVElement.REVISION) {
                try {
                    setRevision(Long.parseLong(property.getFirstValue(true)));
                } catch (NumberFormatException nfe) {
                    SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, nfe), SVNLogType.NETWORK);
View Full Code Here

Examples of org.tmatesoft.svn.core.internal.io.dav.DAVElement

        }
        myProperties = null;
    }
   
    public void storeProperty(DAVElementProperty property) throws DAVException {
        DAVElement propName = property.getName();
        String propValue = property.getFirstValue(false);
        String reposPropName = getReposPropName(propName);
        SVNPropertyValue value = null;
        Map attributes = property.getAttributes();
        if (attributes != null) {
View Full Code Here

Examples of org.tmatesoft.svn.core.internal.io.dav.DAVElement

        }
       
        Collection propNames = new ArrayList();
        for (Iterator namesIter = myProperties.nameSet().iterator(); namesIter.hasNext();) {
            String propName = (String) namesIter.next();
            DAVElement propElementName = null;
            if (propName.startsWith(SVNProperty.SVN_PREFIX)) {
                propElementName = DAVElement.getElement(DAVElement.SVN_SVN_PROPERTY_NAMESPACE,
                        propName.substring(SVNProperty.SVN_PREFIX.length()));
            } else {
                propElementName = DAVElement.getElement(DAVElement.SVN_CUSTOM_PROPERTY_NAMESPACE, propName);
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.