Search in sources :

Example 1 with ResourceType

use of org.apache.jackrabbit.webdav.property.ResourceType in project jackrabbit by apache.

the class DavResourceImpl method initProperties.

/**
     * Fill the set of properties
     */
protected void initProperties() {
    if (!exists() || propsInitialized) {
        return;
    }
    try {
        config.getPropertyManager().exportProperties(getPropertyExportContext(), isCollection());
    } catch (RepositoryException e) {
        log.warn("Error while accessing resource properties", e);
    }
    // set (or reset) fundamental properties
    if (getDisplayName() != null) {
        properties.add(new DefaultDavProperty<String>(DavPropertyName.DISPLAYNAME, getDisplayName()));
    }
    if (isCollection()) {
        properties.add(new ResourceType(ResourceType.COLLECTION));
        // Windows XP support
        properties.add(new DefaultDavProperty<String>(DavPropertyName.ISCOLLECTION, "1"));
    } else {
        properties.add(new ResourceType(ResourceType.DEFAULT_RESOURCE));
        // Windows XP support
        properties.add(new DefaultDavProperty<String>(DavPropertyName.ISCOLLECTION, "0"));
    }
    if (rfc4122Uri != null) {
        properties.add(new HrefProperty(BindConstants.RESOURCEID, rfc4122Uri, true));
    }
    Set<ParentElement> parentElements = getParentElements();
    if (!parentElements.isEmpty()) {
        properties.add(new ParentSet(parentElements));
    }
    /* set current lock information. If no lock is set to this resource,
        an empty lock discovery will be returned in the response. */
    properties.add(new LockDiscovery(getLock(Type.WRITE, Scope.EXCLUSIVE)));
    /* lock support information: all locks are lockable. */
    SupportedLock supportedLock = new SupportedLock();
    supportedLock.addEntry(Type.WRITE, Scope.EXCLUSIVE);
    properties.add(supportedLock);
    propsInitialized = true;
}
Also used : ParentSet(org.apache.jackrabbit.webdav.bind.ParentSet) HrefProperty(org.apache.jackrabbit.webdav.property.HrefProperty) SupportedLock(org.apache.jackrabbit.webdav.lock.SupportedLock) RepositoryException(javax.jcr.RepositoryException) ResourceType(org.apache.jackrabbit.webdav.property.ResourceType) ParentElement(org.apache.jackrabbit.webdav.bind.ParentElement) LockDiscovery(org.apache.jackrabbit.webdav.lock.LockDiscovery)

Example 2 with ResourceType

use of org.apache.jackrabbit.webdav.property.ResourceType in project jackrabbit by apache.

the class VersionHistoryResourceImpl method initProperties.

//--------------------------------------------------------------------------
/**
     * Fill the property set for this resource.
     */
@Override
protected void initProperties() {
    if (!propsInitialized) {
        super.initProperties();
        // change resource type defined by default item collection
        properties.add(new ResourceType(new int[] { ResourceType.COLLECTION, ResourceType.VERSION_HISTORY }));
        // required root-version property for version-history resource
        try {
            String rootVersionHref = getLocatorFromNode(((VersionHistory) getNode()).getRootVersion()).getHref(false);
            properties.add(new HrefProperty(VersionHistoryResource.ROOT_VERSION, rootVersionHref, false));
        } catch (RepositoryException e) {
            log.error(e.getMessage());
        }
        // required, protected version-set property for version-history resource
        try {
            VersionIterator vIter = ((VersionHistory) getNode()).getAllVersions();
            ArrayList<Version> l = new ArrayList<Version>();
            while (vIter.hasNext()) {
                l.add(vIter.nextVersion());
            }
            properties.add(getHrefProperty(VersionHistoryResource.VERSION_SET, l.toArray(new Version[l.size()]), true, false));
        } catch (RepositoryException e) {
            log.error(e.getMessage());
        }
    }
}
Also used : HrefProperty(org.apache.jackrabbit.webdav.property.HrefProperty) Version(javax.jcr.version.Version) ArrayList(java.util.ArrayList) VersionIterator(javax.jcr.version.VersionIterator) ResourceType(org.apache.jackrabbit.webdav.property.ResourceType) RepositoryException(javax.jcr.RepositoryException) VersionHistory(javax.jcr.version.VersionHistory)

Example 3 with ResourceType

use of org.apache.jackrabbit.webdav.property.ResourceType in project jackrabbit by apache.

the class VersionHistoryItemCollection method initProperties.

/**
     * Fill the property set for this resource.
     */
@Override
protected void initProperties() {
    super.initProperties();
    // change resource type defined by default item collection
    properties.add(new ResourceType(ResourceType.VERSION_HISTORY));
    // jcr specific property pointing to the node this history belongs to
    try {
        properties.add(new DefaultDavProperty<String>(JCR_VERSIONABLEUUID, ((VersionHistory) item).getVersionableIdentifier()));
    } catch (RepositoryException e) {
        log.error(e.getMessage());
    }
}
Also used : ResourceType(org.apache.jackrabbit.webdav.property.ResourceType) RepositoryException(javax.jcr.RepositoryException) VersionHistory(javax.jcr.version.VersionHistory)

Example 4 with ResourceType

use of org.apache.jackrabbit.webdav.property.ResourceType in project jackrabbit by apache.

the class AbstractResource method initProperties.

/**
     * Fill the set of default properties
     */
protected void initProperties() {
    if (getDisplayName() != null) {
        properties.add(new DefaultDavProperty<String>(DavPropertyName.DISPLAYNAME, getDisplayName()));
    }
    if (isCollection()) {
        properties.add(new ResourceType(ResourceType.COLLECTION));
        // Windows XP support
        properties.add(new DefaultDavProperty<String>(DavPropertyName.ISCOLLECTION, "1"));
    } else {
        properties.add(new ResourceType(ResourceType.DEFAULT_RESOURCE));
        // Windows XP support
        properties.add(new DefaultDavProperty<String>(DavPropertyName.ISCOLLECTION, "0"));
    }
    // todo: add etag
    // default last modified
    String lastModified = IOUtil.getLastModified(getModificationTime());
    properties.add(new DefaultDavProperty<String>(DavPropertyName.GETLASTMODIFIED, lastModified));
    // default creation time
    properties.add(new DefaultDavProperty<String>(DavPropertyName.CREATIONDATE, getCreationDate()));
    // supported lock property
    properties.add(supportedLock);
    // set current lock information. If no lock is applied to this resource,
    // an empty xlockdiscovery will be returned in the response.
    properties.add(new LockDiscovery(getLocks()));
    // name of the jcr workspace
    properties.add(new DefaultDavProperty<String>(ItemResourceConstants.JCR_WORKSPACE_NAME, getRepositorySession().getWorkspace().getName()));
}
Also used : ResourceType(org.apache.jackrabbit.webdav.property.ResourceType) LockDiscovery(org.apache.jackrabbit.webdav.lock.LockDiscovery)

Aggregations

ResourceType (org.apache.jackrabbit.webdav.property.ResourceType)4 RepositoryException (javax.jcr.RepositoryException)3 VersionHistory (javax.jcr.version.VersionHistory)2 LockDiscovery (org.apache.jackrabbit.webdav.lock.LockDiscovery)2 HrefProperty (org.apache.jackrabbit.webdav.property.HrefProperty)2 ArrayList (java.util.ArrayList)1 Version (javax.jcr.version.Version)1 VersionIterator (javax.jcr.version.VersionIterator)1 ParentElement (org.apache.jackrabbit.webdav.bind.ParentElement)1 ParentSet (org.apache.jackrabbit.webdav.bind.ParentSet)1 SupportedLock (org.apache.jackrabbit.webdav.lock.SupportedLock)1