Search in sources :

Example 1 with DavProperty

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

the class RepositoryServiceImpl method buildNodeInfo.

private NodeInfoImpl buildNodeInfo(String baseUri, MultiStatusResponse nodeResponse, NodeId parentId, DavPropertySet propSet, SessionInfo sessionInfo, NamePathResolver resolver) throws RepositoryException {
    NodeId id = uriResolver.buildNodeId(parentId, baseUri, nodeResponse, sessionInfo.getWorkspaceName(), getNamePathResolver(sessionInfo));
    NodeInfoImpl nInfo = new NodeInfoImpl(id, propSet, resolver);
    DavProperty p = propSet.get(JcrRemotingConstants.JCR_REFERENCES_LN, ItemResourceConstants.NAMESPACE);
    if (p != null) {
        HrefProperty refProp = new HrefProperty(p);
        for (String propertyHref : refProp.getHrefs()) {
            PropertyId propertyId = uriResolver.getPropertyId(propertyHref, sessionInfo);
            nInfo.addReference(propertyId);
        }
    }
    return nInfo;
}
Also used : HrefProperty(org.apache.jackrabbit.webdav.property.HrefProperty) NodeId(org.apache.jackrabbit.spi.NodeId) DefaultDavProperty(org.apache.jackrabbit.webdav.property.DefaultDavProperty) DavProperty(org.apache.jackrabbit.webdav.property.DavProperty) PropertyId(org.apache.jackrabbit.spi.PropertyId)

Example 2 with DavProperty

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

the class VersionHistoryItemCollection method getProperty.

@Override
public DavProperty<?> getProperty(DavPropertyName name) {
    DavProperty prop = super.getProperty(name);
    if (prop == null) {
        // required, protected version-set property for version-history resource
        try {
            if (ROOT_VERSION.equals(name)) {
                // required root-version property for version-history resource
                String rootVersionHref = getLocatorFromItem(((VersionHistory) item).getRootVersion()).getHref(true);
                prop = new HrefProperty(ROOT_VERSION, rootVersionHref, true);
            } else if (VERSION_SET.equals(name)) {
                VersionIterator vIter = ((VersionHistory) item).getAllVersions();
                prop = getHrefProperty(VERSION_SET, vIter, true);
            }
        } catch (RepositoryException e) {
            log.error(e.getMessage());
        }
    }
    return prop;
}
Also used : HrefProperty(org.apache.jackrabbit.webdav.property.HrefProperty) DavProperty(org.apache.jackrabbit.webdav.property.DavProperty) DefaultDavProperty(org.apache.jackrabbit.webdav.property.DefaultDavProperty) VersionIterator(javax.jcr.version.VersionIterator) RepositoryException(javax.jcr.RepositoryException) VersionHistory(javax.jcr.version.VersionHistory)

Example 3 with DavProperty

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

the class VersionItemCollection method getProperty.

@Override
public DavProperty<?> getProperty(DavPropertyName name) {
    DavProperty prop = super.getProperty(name);
    if (prop == null && exists()) {
        Version v = (Version) item;
        try {
            if (VERSION_NAME.equals(name)) {
                // required, protected DAV:version-name property
                prop = new DefaultDavProperty<String>(VERSION_NAME, v.getName(), true);
            } else if (VERSION_HISTORY.equals(name)) {
                // required DAV:version-history (computed) property
                String vhHref = getLocatorFromItem(getVersionHistoryItem()).getHref(true);
                prop = new HrefProperty(VERSION_HISTORY, vhHref, true);
            } else if (PREDECESSOR_SET.equals(name)) {
                // required DAV:predecessor-set (protected) property
                prop = getHrefProperty(VersionResource.PREDECESSOR_SET, v.getPredecessors(), true);
            } else if (SUCCESSOR_SET.equals(name)) {
                // required DAV:successor-set (computed) property
                prop = getHrefProperty(SUCCESSOR_SET, v.getSuccessors(), true);
            } else if (LABEL_NAME_SET.equals(name)) {
                // required, protected DAV:label-name-set property
                String[] labels = getVersionHistoryItem().getVersionLabels(v);
                prop = new LabelSetProperty(labels);
            } else if (CHECKOUT_SET.equals(name)) {
                // required DAV:checkout-set (computed) property
                PropertyIterator it = v.getReferences();
                List<Node> nodeList = new ArrayList<Node>();
                while (it.hasNext()) {
                    Property p = it.nextProperty();
                    if (JcrConstants.JCR_BASEVERSION.equals(p.getName())) {
                        Node n = p.getParent();
                        if (n.isCheckedOut()) {
                            nodeList.add(n);
                        }
                    }
                }
                prop = getHrefProperty(CHECKOUT_SET, nodeList.toArray(new Node[nodeList.size()]), true);
            }
        } catch (RepositoryException e) {
            log.error(e.getMessage());
        }
    }
    return prop;
}
Also used : LabelSetProperty(org.apache.jackrabbit.webdav.version.LabelSetProperty) Node(javax.jcr.Node) DefaultDavProperty(org.apache.jackrabbit.webdav.property.DefaultDavProperty) DavProperty(org.apache.jackrabbit.webdav.property.DavProperty) PropertyIterator(javax.jcr.PropertyIterator) RepositoryException(javax.jcr.RepositoryException) HrefProperty(org.apache.jackrabbit.webdav.property.HrefProperty) Version(javax.jcr.version.Version) ArrayList(java.util.ArrayList) List(java.util.List) Property(javax.jcr.Property) DefaultDavProperty(org.apache.jackrabbit.webdav.property.DefaultDavProperty) HrefProperty(org.apache.jackrabbit.webdav.property.HrefProperty) LabelSetProperty(org.apache.jackrabbit.webdav.version.LabelSetProperty) DavProperty(org.apache.jackrabbit.webdav.property.DavProperty)

Example 4 with DavProperty

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

the class DefaultItemCollection method getProperty.

@Override
public DavProperty<?> getProperty(DavPropertyName name) {
    DavProperty prop = super.getProperty(name);
    if (prop == null && exists()) {
        Node n = (Node) item;
        // add node-specific resource properties
        try {
            if (JCR_INDEX.equals(name)) {
                prop = new DefaultDavProperty<Integer>(JCR_INDEX, n.getIndex(), true);
            } else if (JCR_REFERENCES.equals(name)) {
                prop = getHrefProperty(JCR_REFERENCES, n.getReferences(), true);
            } else if (JCR_WEAK_REFERENCES.equals(name)) {
                prop = getHrefProperty(JCR_WEAK_REFERENCES, n.getWeakReferences(), true);
            } else if (JCR_UUID.equals(name)) {
                if (isReferenceable()) {
                    prop = new DefaultDavProperty<String>(JCR_UUID, n.getUUID(), true);
                }
            } else if (JCR_PRIMARYITEM.equals(name)) {
                if (hasPrimaryItem()) {
                    Item primaryItem = n.getPrimaryItem();
                    prop = getHrefProperty(JCR_PRIMARYITEM, new Item[] { primaryItem }, true);
                }
            } else if (OrderingConstants.ORDERING_TYPE.equals(name) && isOrderable()) {
                // property defined by RFC 3648: this resource always has custom ordering!                    
                prop = new OrderingType(OrderingConstants.ORDERING_TYPE_CUSTOM);
            } else if (SecurityConstants.SUPPORTED_PRIVILEGE_SET.equals(name)) {
                prop = new JcrSupportedPrivilegesProperty(getRepositorySession(), n.getPath()).asDavProperty();
            } else if (SecurityConstants.CURRENT_USER_PRIVILEGE_SET.equals(name)) {
                prop = new JcrUserPrivilegesProperty(getRepositorySession(), n.getPath()).asDavProperty();
            }
        } catch (RepositoryException e) {
            log.error("Failed to retrieve node-specific property: " + e);
        }
    }
    return prop;
}
Also used : Item(javax.jcr.Item) DefaultDavProperty(org.apache.jackrabbit.webdav.property.DefaultDavProperty) Node(javax.jcr.Node) DefaultDavProperty(org.apache.jackrabbit.webdav.property.DefaultDavProperty) DavProperty(org.apache.jackrabbit.webdav.property.DavProperty) OrderingType(org.apache.jackrabbit.webdav.ordering.OrderingType) RepositoryException(javax.jcr.RepositoryException) JcrSupportedPrivilegesProperty(org.apache.jackrabbit.webdav.jcr.security.JcrSupportedPrivilegesProperty) JcrUserPrivilegesProperty(org.apache.jackrabbit.webdav.jcr.security.JcrUserPrivilegesProperty)

Example 5 with DavProperty

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

the class DefaultItemResource method internalSetProperty.

/**
     * Internal method that performs the setting or adding of properties
     *
     * @param property
     * @throws DavException
     * @see #setProperty(DavProperty)
     * @see #alterProperties(List)
     */
private void internalSetProperty(DavProperty<?> property) throws DavException {
    if (!exists()) {
        throw new DavException(DavServletResponse.SC_NOT_FOUND);
    }
    try {
        Property prop = (Property) item;
        int defaultType = prop.getType();
        ValueFactory vfact = getRepositorySession().getValueFactory();
        ValuesProperty vp = new ValuesProperty(property, defaultType, vfact);
        if (property.getName().equals(JCR_VALUE)) {
            prop.setValue(vp.getJcrValue(vp.getValueType(), vfact));
        } else if (property.getName().equals(JCR_VALUES)) {
            prop.setValue(vp.getJcrValues());
        } else {
            throw new DavException(DavServletResponse.SC_CONFLICT);
        }
    } catch (RepositoryException e) {
        throw new JcrDavException(e);
    }
}
Also used : DavException(org.apache.jackrabbit.webdav.DavException) ValuesProperty(org.apache.jackrabbit.webdav.jcr.property.ValuesProperty) RepositoryException(javax.jcr.RepositoryException) ValueFactory(javax.jcr.ValueFactory) LengthsProperty(org.apache.jackrabbit.webdav.jcr.property.LengthsProperty) Property(javax.jcr.Property) DefaultDavProperty(org.apache.jackrabbit.webdav.property.DefaultDavProperty) DavProperty(org.apache.jackrabbit.webdav.property.DavProperty) ValuesProperty(org.apache.jackrabbit.webdav.jcr.property.ValuesProperty)

Aggregations

DavProperty (org.apache.jackrabbit.webdav.property.DavProperty)16 DefaultDavProperty (org.apache.jackrabbit.webdav.property.DefaultDavProperty)13 RepositoryException (javax.jcr.RepositoryException)11 Node (javax.jcr.Node)6 HrefProperty (org.apache.jackrabbit.webdav.property.HrefProperty)6 PropEntry (org.apache.jackrabbit.webdav.property.PropEntry)5 Property (javax.jcr.Property)4 MultiStatusResponse (org.apache.jackrabbit.webdav.MultiStatusResponse)4 DavException (org.apache.jackrabbit.webdav.DavException)3 DavPropertyName (org.apache.jackrabbit.webdav.property.DavPropertyName)3 Session (javax.jcr.Session)2 Version (javax.jcr.version.Version)2 HttpResponse (org.apache.http.HttpResponse)2 MultiStatus (org.apache.jackrabbit.webdav.MultiStatus)2 HttpPropfind (org.apache.jackrabbit.webdav.client.methods.HttpPropfind)2 LengthsProperty (org.apache.jackrabbit.webdav.jcr.property.LengthsProperty)2 ValuesProperty (org.apache.jackrabbit.webdav.jcr.property.ValuesProperty)2 JcrSupportedPrivilegesProperty (org.apache.jackrabbit.webdav.jcr.security.JcrSupportedPrivilegesProperty)2 JcrUserPrivilegesProperty (org.apache.jackrabbit.webdav.jcr.security.JcrUserPrivilegesProperty)2 DavPropertyNameSet (org.apache.jackrabbit.webdav.property.DavPropertyNameSet)2