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 RepositoryServiceImpl method internalGetPrivilegeDefinitions.
private PrivilegeDefinition[] internalGetPrivilegeDefinitions(SessionInfo sessionInfo, String uri) throws RepositoryException {
DavPropertyNameSet nameSet = new DavPropertyNameSet();
nameSet.add(SecurityConstants.SUPPORTED_PRIVILEGE_SET);
HttpPropfind request = null;
try {
request = new HttpPropfind(uri, nameSet, DEPTH_0);
HttpResponse response = executeRequest(sessionInfo, request);
request.checkSuccess(response);
MultiStatusResponse[] mresponses = request.getResponseBodyAsMultiStatus(response).getResponses();
if (mresponses.length < 1) {
throw new PathNotFoundException("Unable to retrieve privileges definitions.");
}
DavPropertyName displayName = SecurityConstants.SUPPORTED_PRIVILEGE_SET;
DavProperty<?> p = mresponses[0].getProperties(DavServletResponse.SC_OK).get(displayName);
if (p == null) {
return new PrivilegeDefinition[0];
} else {
// build PrivilegeDefinition(s) from the supported-privileges dav property
Map<Name, SupportedPrivilege> spMap = new HashMap<Name, SupportedPrivilege>();
fillSupportedPrivilegeMap(new SupportedPrivilegeSetProperty(p).getValue(), spMap, getNameFactory());
List<PrivilegeDefinition> pDefs = new ArrayList<PrivilegeDefinition>();
for (Name privilegeName : spMap.keySet()) {
SupportedPrivilege sp = spMap.get(privilegeName);
Set<Name> aggrnames = null;
SupportedPrivilege[] aggregates = sp.getSupportedPrivileges();
if (aggregates != null && aggregates.length > 0) {
aggrnames = new HashSet<Name>();
for (SupportedPrivilege aggregate : aggregates) {
Name aggregateName = nameFactory.create(aggregate.getPrivilege().getNamespace().getURI(), aggregate.getPrivilege().getName());
aggrnames.add(aggregateName);
}
}
PrivilegeDefinition def = new PrivilegeDefinitionImpl(privilegeName, sp.isAbstract(), aggrnames);
pDefs.add(def);
}
return pDefs.toArray(new PrivilegeDefinition[pDefs.size()]);
}
} catch (IOException e) {
throw new RepositoryException(e);
} catch (DavException e) {
throw ExceptionConverter.generate(e);
} finally {
if (request != null) {
request.releaseConnection();
}
}
}
use of org.apache.jackrabbit.webdav.property.DavPropertyNameSet in project jackrabbit by apache.
the class RepositoryServiceImpl method internalSetNamespaces.
/**
*
* @param sessionInfo
* @param namespaces
* @throws NamespaceException
* @throws UnsupportedRepositoryOperationException
* @throws AccessDeniedException
* @throws RepositoryException
*/
private void internalSetNamespaces(SessionInfo sessionInfo, Map<String, String> namespaces) throws RepositoryException {
DavPropertySet setProperties = new DavPropertySet();
setProperties.add(createNamespaceProperty(namespaces));
HttpProppatch request = null;
try {
String uri = uriResolver.getWorkspaceUri(sessionInfo.getWorkspaceName());
request = new HttpProppatch(uri, setProperties, new DavPropertyNameSet());
initMethod(request, sessionInfo, true);
HttpResponse response = executeRequest(sessionInfo, request);
request.checkSuccess(response);
} catch (IOException e) {
throw new RepositoryException(e);
} catch (DavException e) {
throw ExceptionConverter.generate(e);
} finally {
if (request != null) {
request.releaseConnection();
}
}
}
Aggregations