use of org.apache.jackrabbit.webdav.xml.Namespace in project jackrabbit by apache.
the class JcrUserPrivilegesPropertyTest method getExpected.
private Set<Privilege> getExpected(AccessControlManager acMgr, Session s) throws RepositoryException {
Set<Privilege> expected = new HashSet<Privilege>();
for (javax.jcr.security.Privilege p : acMgr.getPrivileges(testRoot)) {
String localName = Text.getLocalName(p.getName());
String prefix = Text.getNamespacePrefix(p.getName());
Namespace ns = (prefix.isEmpty()) ? Namespace.EMPTY_NAMESPACE : Namespace.getNamespace(prefix, s.getNamespaceURI(prefix));
expected.add(Privilege.getPrivilege(localName, ns));
}
return expected;
}
use of org.apache.jackrabbit.webdav.xml.Namespace in project jackrabbit by apache.
the class JcrUserPrivilegesProperty method asDavProperty.
public CurrentUserPrivilegeSetProperty asDavProperty() throws RepositoryException {
List<Privilege> davPrivs = new ArrayList<Privilege>();
for (javax.jcr.security.Privilege privilege : session.getAccessControlManager().getPrivileges(absPath)) {
String privilegeName = privilege.getName();
String prefix = Text.getNamespacePrefix(privilegeName);
Namespace ns = (prefix.isEmpty()) ? Namespace.EMPTY_NAMESPACE : Namespace.getNamespace(prefix, session.getNamespaceURI(prefix));
davPrivs.add(Privilege.getPrivilege(Text.getLocalName(privilegeName), ns));
}
return new CurrentUserPrivilegeSetProperty(davPrivs.toArray(new Privilege[davPrivs.size()]));
}
use of org.apache.jackrabbit.webdav.xml.Namespace in project jackrabbit by apache.
the class ExpandPropertyReport method getResponse.
/**
* Builds a <code>MultiStatusResponse</code> for the given resource respecting
* the properties specified. Any property that represents a {@link HrefProperty}
* is expanded: It's name equals the name of a valid {@link HrefProperty}.
* However the value of that given property (consisting of one or multiple DAV:href elements)
* is replaced by the Xml representation of a separate
* {@link MultiStatusResponse multistatus responses} for the
* resource referenced by the given DAV:href elements. The responses may
* themselves have properties, which are defined by the separate list.
*
* @param res
* @param propertyElements
* @return <code>MultiStatusResponse</code> for the given resource.
* @see ExpandProperty
*/
private MultiStatusResponse getResponse(DavResource res, Iterator<Element> propertyElements) {
MultiStatusResponse resp = new MultiStatusResponse(res.getHref(), null);
while (propertyElements.hasNext()) {
Element propertyElem = propertyElements.next();
// retrieve the localName present in the "name" attribute
String nameAttr = propertyElem.getAttribute(ATTR_NAME);
if (nameAttr == null || "".equals(nameAttr)) {
// NOTE: this is not valid according to the DTD
continue;
}
// retrieve the namespace present in the "namespace" attribute
// NOTE: if this attribute is missing the DAV: namespace represents the default.
String namespaceAttr = propertyElem.getAttribute(ATTR_NAMESPACE);
Namespace namespace = (namespaceAttr != null) ? Namespace.getNamespace(namespaceAttr) : NAMESPACE;
DavPropertyName propName = DavPropertyName.create(nameAttr, namespace);
DavProperty<?> p = res.getProperty(propName);
if (p != null) {
if (p instanceof HrefProperty && res instanceof DeltaVResource) {
ElementIterator it = DomUtil.getChildren(propertyElem, XML_PROPERTY, NAMESPACE);
resp.add(new ExpandProperty((DeltaVResource) res, (HrefProperty) p, it));
} else {
resp.add(p);
}
} else {
resp.add(propName, DavServletResponse.SC_NOT_FOUND);
}
}
return resp;
}
use of org.apache.jackrabbit.webdav.xml.Namespace in project jackrabbit by apache.
the class SubscriptionImpl method serializeInfoMap.
protected static void serializeInfoMap(Element eventElem, Session session, Map<?, ?> map) {
// info
Element info = DomUtil.addChildElement(eventElem, XML_EVENTINFO, NAMESPACE);
Map<?, ?> m = map;
for (Map.Entry<?, ?> entry : m.entrySet()) {
try {
String key = entry.getKey().toString();
Namespace ns = Namespace.EMPTY_NAMESPACE;
int colon = key.indexOf(':');
if (colon >= 0) {
String prefix = key.substring(0, colon);
String localname = key.substring(colon + 1);
ns = Namespace.getNamespace(prefix, session.getNamespaceURI(prefix));
key = localname;
}
Object value = entry.getValue();
if (value != null) {
DomUtil.addChildElement(info, key, ns, value.toString());
} else {
DomUtil.addChildElement(info, key, ns);
}
} catch (RepositoryException nse) {
log.error("Internal error while getting namespaceUri, info map field skipped for {}", entry.getKey());
}
}
}
use of org.apache.jackrabbit.webdav.xml.Namespace in project jackrabbit by apache.
the class JcrSupportedPrivilegesProperty method createSupportedPrivilege.
private SupportedPrivilege createSupportedPrivilege(Privilege privilege) throws RepositoryException {
String privilegeName = privilege.getName();
String localName = Text.getLocalName(privilegeName);
String prefix = Text.getNamespacePrefix(privilegeName);
Namespace ns = (prefix.isEmpty()) ? Namespace.EMPTY_NAMESPACE : Namespace.getNamespace(prefix, session.getNamespaceURI(prefix));
org.apache.jackrabbit.webdav.security.Privilege davPrivilege = org.apache.jackrabbit.webdav.security.Privilege.getPrivilege(localName, ns);
SupportedPrivilege[] aggregates = (privilege.isAggregate()) ? getDeclaredAggregates(privilege) : null;
SupportedPrivilege sp = new SupportedPrivilege(davPrivilege, null, null, privilege.isAbstract(), aggregates);
if (!aggregated.contains(privilegeName)) {
supportedPrivileges.put(privilegeName, sp);
}
return sp;
}
Aggregations