use of org.apache.jackrabbit.webdav.property.DavPropertyNameSet in project jackrabbit by apache.
the class DavPropertyTest method testReferenceableNode.
public void testReferenceableNode() throws Exception {
NodeId nid = getNodeId("/test");
Batch b = rs.createBatch(si, nid);
b.setMixins(nid, new Name[] { NameConstants.MIX_REFERENCEABLE });
rs.submit(b);
String uri = rs.getItemUri(nid, si);
DavPropertyNameSet set = doPropFindNames(uri);
DavPropertyNameSet expected = new DavPropertyNameSet(BASE_SET);
expected.addAll(EXISTING_ITEM_BASE_SET);
expected.addAll(NODE_SET);
expected.add(OrderingConstants.ORDERING_TYPE);
expected.add(JCR_PARENT);
expected.add(JCR_UUID);
/*
Expected property names
{DAV:}getlastmodified
{DAV:}ordering-type
{http://www.day.com/jcr/webdav/1.0}definition
{DAV:}comment
{http://www.day.com/jcr/webdav/1.0}references
{http://www.day.com/jcr/webdav/1.0}parent
{DAV:}displayname
{http://www.day.com/jcr/webdav/1.0}workspaceName
{http://www.day.com/jcr/webdav/1.0}subscriptiondiscovery
{http://www.day.com/jcr/webdav/1.0}uuid
{http://www.day.com/jcr/webdav/1.0}name
{DAV:}current-user-privilege-set
{http://www.day.com/jcr/webdav/1.0}primarynodetype
{DAV:}lockdiscovery
{DAV:}resourcetype
{DAV:}workspace
{http://www.day.com/jcr/webdav/1.0}depth
{http://www.day.com/jcr/webdav/1.0}index
{DAV:}supportedlock
{DAV:}supported-method-set
{DAV:}iscollection
{http://www.day.com/jcr/webdav/1.0}weakreferences
{DAV:}creator-displayname
{DAV:}getcontenttype
{DAV:}creationdate
{DAV:}supported-report-set
{http://www.day.com/jcr/webdav/1.0}mixinnodetypes
{http://www.day.com/jcr/webdav/1.0}path
*/
assertPropertyNames(expected, set);
DavPropertyNameSet all = doPropFindAll(uri);
expected.remove(DeltaVConstants.COMMENT);
expected.remove(DeltaVConstants.CREATOR_DISPLAYNAME);
expected.remove(DeltaVConstants.SUPPORTED_METHOD_SET);
expected.remove(DeltaVConstants.SUPPORTED_REPORT_SET);
expected.remove(DeltaVConstants.WORKSPACE);
expected.remove(SecurityConstants.CURRENT_USER_PRIVILEGE_SET);
expected.remove(ObservationConstants.SUBSCRIPTIONDISCOVERY);
expected.remove(OrderingConstants.ORDERING_TYPE);
expected.remove(JCR_DEFINITION);
expected.remove(JCR_INDEX);
expected.remove(JCR_REFERENCES);
expected.remove(JCR_WEAK_REFERENCES);
expected.remove(JCR_UUID);
/*
Expected all-props
{DAV:}getlastmodified
{http://www.day.com/jcr/webdav/1.0}depth
{http://www.day.com/jcr/webdav/1.0}workspaceName
{DAV:}displayname
{http://www.day.com/jcr/webdav/1.0}parent
{DAV:}supportedlock
{DAV:}iscollection
{DAV:}getcontenttype
{http://www.day.com/jcr/webdav/1.0}name
{DAV:}creationdate
{http://www.day.com/jcr/webdav/1.0}mixinnodetypes
{http://www.day.com/jcr/webdav/1.0}path
{http://www.day.com/jcr/webdav/1.0}primarynodetype
{DAV:}lockdiscovery
{DAV:}resourcetype
*/
assertPropertyNames(expected, all);
DavPropertyNameSet props = new DavPropertyNameSet();
props.add(DeltaVConstants.COMMENT);
props.add(DeltaVConstants.CREATOR_DISPLAYNAME);
props.add(DeltaVConstants.SUPPORTED_METHOD_SET);
props.add(DeltaVConstants.SUPPORTED_REPORT_SET);
props.add(DeltaVConstants.WORKSPACE);
props.add(SecurityConstants.CURRENT_USER_PRIVILEGE_SET);
props.add(ObservationConstants.SUBSCRIPTIONDISCOVERY);
props.add(OrderingConstants.ORDERING_TYPE);
props.add(JCR_DEFINITION);
props.add(JCR_INDEX);
props.add(JCR_REFERENCES);
props.add(JCR_WEAK_REFERENCES);
props.add(JCR_UUID);
DavPropertyNameSet result = doPropFindByProp(uri, props);
assertPropertyNames(props, result);
}
use of org.apache.jackrabbit.webdav.property.DavPropertyNameSet in project jackrabbit by apache.
the class DavPropertyTest method testVersion.
public void testVersion() throws Exception {
NodeId nid = getNodeId("/test");
Batch b = rs.createBatch(si, nid);
b.setMixins(nid, new Name[] { NameConstants.MIX_VERSIONABLE });
rs.submit(b);
NodeId vID = rs.checkin(si, nid);
String uri = rs.getItemUri(vID, si);
DavPropertyNameSet set = doPropFindNames(uri);
DavPropertyNameSet expected = new DavPropertyNameSet(BASE_SET);
expected.addAll(EXISTING_ITEM_BASE_SET);
expected.addAll(NODE_SET);
expected.addAll(VERSION_SET);
expected.add(JCR_PARENT);
expected.add(JCR_UUID);
/*
Expected property names
{DAV:}getlastmodified
{DAV:}version-name
{http://www.day.com/jcr/webdav/1.0}definition
{DAV:}comment
{http://www.day.com/jcr/webdav/1.0}references
{http://www.day.com/jcr/webdav/1.0}parent
{DAV:}displayname
{http://www.day.com/jcr/webdav/1.0}workspaceName
{http://www.day.com/jcr/webdav/1.0}subscriptiondiscovery
{http://www.day.com/jcr/webdav/1.0}uuid
{DAV:}checkout-set
{DAV:}predecessor-set
{http://www.day.com/jcr/webdav/1.0}name
{DAV:}current-user-privilege-set
{http://www.day.com/jcr/webdav/1.0}primarynodetype
{DAV:}version-history
{DAV:}successor-set
{DAV:}lockdiscovery
{DAV:}resourcetype
{DAV:}workspace
{http://www.day.com/jcr/webdav/1.0}depth
{http://www.day.com/jcr/webdav/1.0}index
{DAV:}label-name-set
{DAV:}supportedlock
{DAV:}supported-method-set
{DAV:}iscollection
{http://www.day.com/jcr/webdav/1.0}weakreferences
{DAV:}creator-displayname
{DAV:}getcontenttype
{DAV:}creationdate
{DAV:}supported-report-set
{http://www.day.com/jcr/webdav/1.0}mixinnodetypes
{http://www.day.com/jcr/webdav/1.0}path
*/
assertPropertyNames(expected, set);
DavPropertyNameSet all = doPropFindAll(uri);
expected.remove(DeltaVConstants.COMMENT);
expected.remove(DeltaVConstants.CREATOR_DISPLAYNAME);
expected.remove(DeltaVConstants.SUPPORTED_METHOD_SET);
expected.remove(DeltaVConstants.SUPPORTED_REPORT_SET);
expected.remove(DeltaVConstants.WORKSPACE);
expected.remove(SecurityConstants.CURRENT_USER_PRIVILEGE_SET);
expected.remove(ObservationConstants.SUBSCRIPTIONDISCOVERY);
expected.remove(JCR_DEFINITION);
expected.remove(JCR_INDEX);
expected.remove(JCR_REFERENCES);
expected.remove(JCR_WEAK_REFERENCES);
expected.remove(JCR_UUID);
expected.remove(VersionResource.VERSION_NAME);
expected.remove(VersionResource.LABEL_NAME_SET);
expected.remove(VersionResource.PREDECESSOR_SET);
expected.remove(VersionResource.SUCCESSOR_SET);
expected.remove(VersionResource.VERSION_HISTORY);
expected.remove(VersionResource.CHECKOUT_SET);
/*
Expected all-props
{DAV:}getlastmodified
{http://www.day.com/jcr/webdav/1.0}depth
{http://www.day.com/jcr/webdav/1.0}workspaceName
{DAV:}displayname
{http://www.day.com/jcr/webdav/1.0}parent
{DAV:}supportedlock
{DAV:}iscollection
{DAV:}getcontenttype
{http://www.day.com/jcr/webdav/1.0}name
{DAV:}creationdate
{http://www.day.com/jcr/webdav/1.0}mixinnodetypes
{http://www.day.com/jcr/webdav/1.0}path
{http://www.day.com/jcr/webdav/1.0}primarynodetype
{DAV:}lockdiscovery
{DAV:}resourcetype
*/
assertPropertyNames(expected, all);
DavPropertyNameSet props = new DavPropertyNameSet();
props.add(DeltaVConstants.COMMENT);
props.add(DeltaVConstants.CREATOR_DISPLAYNAME);
props.add(DeltaVConstants.SUPPORTED_METHOD_SET);
props.add(DeltaVConstants.SUPPORTED_REPORT_SET);
props.add(DeltaVConstants.WORKSPACE);
props.add(SecurityConstants.CURRENT_USER_PRIVILEGE_SET);
props.add(ObservationConstants.SUBSCRIPTIONDISCOVERY);
props.add(JCR_DEFINITION);
props.add(JCR_INDEX);
props.add(JCR_REFERENCES);
props.add(JCR_WEAK_REFERENCES);
props.add(JCR_UUID);
props.add(VersionResource.VERSION_NAME);
props.add(VersionResource.LABEL_NAME_SET);
props.add(VersionResource.PREDECESSOR_SET);
props.add(VersionResource.SUCCESSOR_SET);
props.add(VersionResource.VERSION_HISTORY);
props.add(VersionResource.CHECKOUT_SET);
DavPropertyNameSet result = doPropFindByProp(uri, props);
assertPropertyNames(props, result);
}
use of org.apache.jackrabbit.webdav.property.DavPropertyNameSet in project jackrabbit by apache.
the class DavPropertyTest method testRepositoryRoot.
public void testRepositoryRoot() throws Exception {
DavPropertyNameSet names = doPropFindNames(repoURI);
DavPropertyNameSet expected = new DavPropertyNameSet(BASE_SET);
/*
Expected property names
{DAV:}getlastmodified
{DAV:}creator-displayname
{DAV:}comment
{DAV:}creationdate
{DAV:}supported-report-set
{DAV:}displayname
{DAV:}supportedlock
{http://www.day.com/jcr/webdav/1.0}workspaceName
{DAV:}resourcetype
{DAV:}lockdiscovery
{DAV:}supported-method-set
{DAV:}iscollection
*/
assertPropertyNames(expected, names);
DavPropertyNameSet all = doPropFindAll(repoURI);
expected.remove(DeltaVConstants.COMMENT);
expected.remove(DeltaVConstants.CREATOR_DISPLAYNAME);
expected.remove(DeltaVConstants.SUPPORTED_METHOD_SET);
expected.remove(DeltaVConstants.SUPPORTED_REPORT_SET);
/*
Expected all-props
{DAV:}getlastmodified
{DAV:}creationdate
{DAV:}displayname
{DAV:}supportedlock
{http://www.day.com/jcr/webdav/1.0}workspaceName
{DAV:}resourcetype
{DAV:}lockdiscovery
{DAV:}iscollection
*/
assertPropertyNames(expected, all);
DavPropertyNameSet props = new DavPropertyNameSet();
props.add(DeltaVConstants.COMMENT);
props.add(DeltaVConstants.CREATOR_DISPLAYNAME);
props.add(DeltaVConstants.SUPPORTED_METHOD_SET);
props.add(DeltaVConstants.SUPPORTED_REPORT_SET);
DavPropertyNameSet result = doPropFindByProp(repoURI, props);
assertPropertyNames(props, result);
}
use of org.apache.jackrabbit.webdav.property.DavPropertyNameSet in project jackrabbit by apache.
the class RFC4918PropfindTest method testPropfindInclude.
public void testPropfindInclude() throws IOException, DavException, URISyntaxException {
String testuri = this.root + "iftest";
int status;
try {
HttpPut put = new HttpPut(testuri);
put.setEntity(new StringEntity("1"));
status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
assertEquals("status: " + status, 201, status);
DavPropertyNameSet names = new DavPropertyNameSet();
names.add(DeltaVConstants.COMMENT);
HttpPropfind propfind = new HttpPropfind(testuri, DavConstants.PROPFIND_ALL_PROP_INCLUDE, names, 0);
HttpResponse resp = this.client.execute(propfind, this.context);
status = resp.getStatusLine().getStatusCode();
assertEquals(207, status);
MultiStatus multistatus = propfind.getResponseBodyAsMultiStatus(resp);
MultiStatusResponse[] responses = multistatus.getResponses();
assertEquals(1, responses.length);
MultiStatusResponse response = responses[0];
DavPropertySet found = response.getProperties(200);
DavPropertySet notfound = response.getProperties(404);
assertTrue(found.contains(DeltaVConstants.COMMENT) || notfound.contains(DeltaVConstants.COMMENT));
} finally {
delete(testuri);
}
}
use of org.apache.jackrabbit.webdav.property.DavPropertyNameSet in project jackrabbit by apache.
the class WebdavRequestImpl method parsePropFindRequest.
/**
* Parse the propfind request body in order to determine the type of the propfind
* and the set of requested property.
* NOTE: An empty 'propfind' request body will be treated as request for all
* property according to the specification.
*/
private void parsePropFindRequest() throws DavException {
propfindProps = new DavPropertyNameSet();
Document requestDocument = getRequestDocument();
// propfind httpRequest with empty body >> retrieve all property
if (requestDocument == null) {
return;
}
// propfind httpRequest with invalid body
Element root = requestDocument.getDocumentElement();
if (!XML_PROPFIND.equals(root.getLocalName())) {
log.info("PropFind-Request has no <propfind> tag.");
throw new DavException(DavServletResponse.SC_BAD_REQUEST, "PropFind-Request has no <propfind> tag.");
}
DavPropertyNameSet include = null;
ElementIterator it = DomUtil.getChildren(root);
int propfindTypeFound = 0;
while (it.hasNext()) {
Element child = it.nextElement();
String nodeName = child.getLocalName();
if (NAMESPACE.getURI().equals(child.getNamespaceURI())) {
if (XML_PROP.equals(nodeName)) {
propfindType = PROPFIND_BY_PROPERTY;
propfindProps = new DavPropertyNameSet(child);
propfindTypeFound += 1;
} else if (XML_PROPNAME.equals(nodeName)) {
propfindType = PROPFIND_PROPERTY_NAMES;
propfindTypeFound += 1;
} else if (XML_ALLPROP.equals(nodeName)) {
propfindType = PROPFIND_ALL_PROP;
propfindTypeFound += 1;
} else if (XML_INCLUDE.equals(nodeName)) {
include = new DavPropertyNameSet();
ElementIterator pit = DomUtil.getChildren(child);
while (pit.hasNext()) {
include.add(DavPropertyName.createFromXml(pit.nextElement()));
}
}
}
}
if (propfindTypeFound > 1) {
log.info("Multiple top-level propfind instructions");
throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Multiple top-level propfind instructions");
}
if (include != null) {
if (propfindType == PROPFIND_ALL_PROP) {
// special case: allprop with include extension
propfindType = PROPFIND_ALL_PROP_INCLUDE;
propfindProps = include;
} else {
throw new DavException(DavServletResponse.SC_BAD_REQUEST, "<include> goes only with <allprop>");
}
}
}
Aggregations