You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by kw...@apache.org on 2017/03/30 11:33:25 UTC
svn commit: r1789498 -
/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/resource/AuthorizableValueMap.java
Author: kwin
Date: Thu Mar 30 11:33:24 2017
New Revision: 1789498
URL: http://svn.apache.org/viewvc?rev=1789498&view=rev
Log:
SLING-6753 expose underlying repository path of authorizable as well
Modified:
sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/resource/AuthorizableValueMap.java
Modified: sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/resource/AuthorizableValueMap.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/resource/AuthorizableValueMap.java?rev=1789498&r1=1789497&r2=1789498&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/resource/AuthorizableValueMap.java (original)
+++ sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/resource/AuthorizableValueMap.java Thu Mar 30 11:33:24 2017
@@ -32,6 +32,7 @@ import java.util.Set;
import javax.jcr.Property;
import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
import javax.jcr.Value;
import javax.jcr.ValueFormatException;
@@ -54,9 +55,9 @@ public class AuthorizableValueMap implem
private static final String MEMBER_OF_KEY = "memberOf";
- private static final Logger LOG = LoggerFactory.getLogger(AuthorizableValueMap.class);
+ private static final String PATH_KEY = "path";
- private Logger logger = LoggerFactory.getLogger(AuthorizableValueMap.class);
+ private static final Logger LOG = LoggerFactory.getLogger(AuthorizableValueMap.class);
private boolean fullyRead;
@@ -154,12 +155,14 @@ public class AuthorizableValueMap implem
return getMembers((Group) authorizable, false);
}
if (key.equals(MEMBER_OF_KEY)) {
- return getMemberships(authorizable, true);
+ return getMemberships(true);
}
if (key.equals(DECLARED_MEMBER_OF_KEY)) {
- return getMemberships(authorizable, false);
+ return getMemberships(false);
+ }
+ if (key.equals(PATH_KEY)) {
+ return getPath();
}
-
if (authorizable.hasProperty(key)) {
final Value[] property = authorizable.getProperty(key);
final Object value = valuesToJavaObject(property);
@@ -226,10 +229,14 @@ public class AuthorizableValueMap implem
cache.put(MEMBERS_KEY, getMembers((Group) authorizable, true));
cache.put(DECLARED_MEMBERS_KEY, getMembers((Group) authorizable, false));
}
- cache.put(MEMBER_OF_KEY, getMemberships(authorizable, true));
- cache.put(DECLARED_MEMBER_OF_KEY, getMemberships(authorizable, false));
+ cache.put(MEMBER_OF_KEY, getMemberships(true));
+ cache.put(DECLARED_MEMBER_OF_KEY, getMemberships(false));
- // only direct properties are supported here
+ String path = getPath();
+ if (path != null) {
+ cache.put(PATH_KEY, path);
+ }
+ // only direct property
Iterator<String> pi = authorizable.getPropertyNames();
while (pi.hasNext()) {
String key = (String) pi.next();
@@ -311,10 +318,10 @@ public class AuthorizableValueMap implem
}
} catch (ValueFormatException vfe) {
- logger.info("converToType: Cannot convert value of " + name
+ LOG.info("converToType: Cannot convert value of " + name
+ " to " + type, vfe);
} catch (RepositoryException re) {
- logger.info("converToType: Cannot get value of " + name, re);
+ LOG.info("converToType: Cannot get value of " + name, re);
}
// fall back to nothing
@@ -396,7 +403,7 @@ public class AuthorizableValueMap implem
return results.toArray(new String[results.size()]);
}
- private String[] getMemberships(Authorizable authorizable, boolean includeAll) throws RepositoryException {
+ private String[] getMemberships(boolean includeAll) throws RepositoryException {
List<String> results = new ArrayList<String>();
for (Iterator<Group> it = includeAll ? authorizable.memberOf() : authorizable.declaredMemberOf();
it.hasNext();) {
@@ -406,6 +413,15 @@ public class AuthorizableValueMap implem
return results.toArray(new String[results.size()]);
}
+ private String getPath() throws RepositoryException {
+ try {
+ return authorizable.getPath();
+ } catch (UnsupportedRepositoryOperationException e) {
+ LOG.debug("Could not retrieve path of authorizable {}", authorizable, e);
+ return null;
+ }
+ }
+
public static class LazyInputStream extends InputStream {
/** The JCR Value from which the input stream is requested on demand */