use of org.apache.jackrabbit.webdav.property.DavProperty in project jackrabbit by apache.
the class VersionControlledItemCollection method getProperty.
@Override
public DavProperty<?> getProperty(DavPropertyName name) {
DavProperty prop = super.getProperty(name);
if (prop == null && isVersionControlled()) {
Node n = (Node) item;
// workspace property already set in AbstractResource.initProperties()
try {
if (VERSION_HISTORY.equals(name)) {
// DAV:version-history (computed)
String vhHref = getLocatorFromItem(n.getVersionHistory()).getHref(true);
prop = new HrefProperty(VERSION_HISTORY, vhHref, true);
} else if (CHECKED_OUT.equals(name) && n.isCheckedOut()) {
// DAV:checked-out property (protected)
String baseVHref = getLocatorFromItem(n.getBaseVersion()).getHref(true);
prop = new HrefProperty(CHECKED_OUT, baseVHref, true);
} else if (CHECKED_IN.equals(name) && !n.isCheckedOut()) {
// DAV:checked-in property (protected)
String baseVHref = getLocatorFromItem(n.getBaseVersion()).getHref(true);
prop = new HrefProperty(CHECKED_IN, baseVHref, 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 AbstractItemResource method getProperty.
@Override
public DavProperty<?> getProperty(DavPropertyName name) {
DavProperty prop = super.getProperty(name);
if (prop == null) {
if (JCR_DEFINITION.equals(name)) {
if (exists()) {
try {
// protected 'definition' property revealing the item definition
ItemDefinitionImpl val;
if (item.isNode()) {
val = NodeDefinitionImpl.create(((Node) item).getDefinition());
} else {
val = PropertyDefinitionImpl.create(((Property) item).getDefinition());
}
prop = new DefaultDavProperty<ItemDefinitionImpl>(JCR_DEFINITION, val, true);
} catch (RepositoryException e) {
// should not get here
log.error("Error while accessing item definition: " + e.getMessage());
}
}
} else if (JCR_ISNEW.equals(name)) {
// transaction resource additional protected properties
if (exists() && item.isNew()) {
prop = new DefaultDavProperty<String>(JCR_ISNEW, null, true);
}
} else if (JCR_ISMODIFIED.equals(name)) {
// transaction resource additional protected properties
if (exists() && item.isModified()) {
prop = new DefaultDavProperty<String>(JCR_ISMODIFIED, null, true);
}
} else if (ObservationConstants.SUBSCRIPTIONDISCOVERY.equals(name)) {
// observation resource
prop = subsMgr.getSubscriptionDiscovery(this);
}
}
return prop;
}
use of org.apache.jackrabbit.webdav.property.DavProperty in project jackrabbit by apache.
the class DefaultHandler method importProperties.
public Map<? extends PropEntry, ?> importProperties(PropertyImportContext importContext, boolean isCollection) throws RepositoryException {
if (!canImport(importContext, isCollection)) {
throw new RepositoryException("PropertyHandler " + getName() + " failed import properties");
}
// loop over List and remember all properties and propertyNames
// that failed to be imported (set or remove).
Map<PropEntry, RepositoryException> failures = new HashMap<PropEntry, RepositoryException>();
List<? extends PropEntry> changeList = importContext.getChangeList();
// for collections the import-root is the target node where properties
// are altered. in contrast 'non-collections' are with the handler
// represented by 'file' nodes, that must have a jcr:content child
// node, which holds all properties except jcr:created.
// -> see canImport for the corresponding assertions
Node cn = (Node) importContext.getImportRoot();
if (!isCollection && cn.hasNode(JcrConstants.JCR_CONTENT)) {
cn = cn.getNode(JcrConstants.JCR_CONTENT);
}
if (changeList != null) {
for (PropEntry propEntry : changeList) {
try {
if (propEntry instanceof DavPropertyName) {
// remove
DavPropertyName propName = (DavPropertyName) propEntry;
removeJcrProperty(propName, cn);
} else if (propEntry instanceof DavProperty) {
// add or modify property
DavProperty<?> prop = (DavProperty<?>) propEntry;
setJcrProperty(prop, cn);
} else {
// ignore any other entry in the change list
log.error("unknown object in change list: " + propEntry.getClass().getName());
}
} catch (RepositoryException e) {
failures.put(propEntry, e);
}
}
}
if (failures.isEmpty()) {
setLastModified(cn, IOUtil.UNDEFINED_LENGTH);
}
return failures;
}
use of org.apache.jackrabbit.webdav.property.DavProperty in project jackrabbit by apache.
the class WebdavRequestImpl method parsePropPatchRequest.
/**
* Parse the PROPPATCH request body.
*/
private void parsePropPatchRequest() throws DavException {
proppatchSet = new DavPropertySet();
proppatchList = new ArrayList<PropEntry>();
Document requestDocument = getRequestDocument();
if (requestDocument == null) {
throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Invalid request body.");
}
Element root = requestDocument.getDocumentElement();
if (!DomUtil.matches(root, XML_PROPERTYUPDATE, NAMESPACE)) {
log.warn("PropPatch-Request has no <DAV:propertyupdate> tag.");
throw new DavException(DavServletResponse.SC_BAD_REQUEST, "PropPatch-Request has no <propertyupdate> tag.");
}
ElementIterator it = DomUtil.getChildren(root);
while (it.hasNext()) {
Element el = it.nextElement();
if (DomUtil.matches(el, XML_SET, NAMESPACE)) {
Element propEl = DomUtil.getChildElement(el, XML_PROP, NAMESPACE);
if (propEl != null) {
ElementIterator properties = DomUtil.getChildren(propEl);
while (properties.hasNext()) {
DavProperty<?> davProp = DefaultDavProperty.createFromXml(properties.nextElement());
proppatchSet.add(davProp);
proppatchList.add(davProp);
}
}
} else if (DomUtil.matches(el, XML_REMOVE, NAMESPACE)) {
Element propEl = DomUtil.getChildElement(el, XML_PROP, NAMESPACE);
if (propEl != null) {
ElementIterator properties = DomUtil.getChildren(propEl);
while (properties.hasNext()) {
DavProperty<?> davProp = DefaultDavProperty.createFromXml(properties.nextElement());
proppatchSet.add(davProp);
proppatchList.add(davProp.getName());
}
}
} else {
log.debug("Unknown element in DAV:propertyupdate: " + el.getNodeName());
// unknown child elements are ignored
}
}
}
use of org.apache.jackrabbit.webdav.property.DavProperty in project jackrabbit by apache.
the class BindTest method getParentSet.
private DavProperty getParentSet(String uri) throws IOException, DavException, URISyntaxException {
DavPropertyNameSet names = new DavPropertyNameSet();
names.add(BindConstants.PARENTSET);
HttpPropfind propfind = new HttpPropfind(uri, names, 0);
HttpResponse response = this.client.execute(propfind, this.context);
int status = response.getStatusLine().getStatusCode();
assertEquals(207, status);
MultiStatus multistatus = propfind.getResponseBodyAsMultiStatus(response);
MultiStatusResponse[] responses = multistatus.getResponses();
assertEquals(1, responses.length);
DavProperty parentset = responses[0].getProperties(200).get(BindConstants.PARENTSET);
assertNotNull(parentset);
return parentset;
}
Aggregations