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;
}
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;
}
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;
}
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;
}
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);
}
}
Aggregations