use of javax.annotation.CheckForNull in project jackrabbit-oak by apache.
the class UserPrincipalProvider method getPrincipalName.
@CheckForNull
private static String getPrincipalName(@Nonnull Tree tree) {
PropertyState principalName = tree.getProperty(UserConstants.REP_PRINCIPAL_NAME);
if (principalName != null) {
return principalName.getValue(STRING);
} else {
String msg = "Authorizable without principal name " + UserUtil.getAuthorizableId(tree);
log.warn(msg);
return null;
}
}
use of javax.annotation.CheckForNull in project jackrabbit-oak by apache.
the class UserPrincipalProvider method readGroupsFromCache.
@CheckForNull
private Set<Group> readGroupsFromCache(@Nonnull Tree authorizableNode) {
Tree principalCache = authorizableNode.getChild(CacheConstants.REP_CACHE);
if (!principalCache.exists()) {
log.debug("No group cache at " + authorizableNode.getPath());
return null;
}
if (isValidCache(principalCache)) {
log.debug("Reading group membership at " + authorizableNode.getPath());
String str = TreeUtil.getString(principalCache, CacheConstants.REP_GROUP_PRINCIPAL_NAMES);
if (str == null || str.isEmpty()) {
return new HashSet<Group>(1);
}
Set<Group> groups = new HashSet<Group>();
for (String s : Text.explode(str, ',')) {
final String name = Text.unescape(s);
groups.add(new CachedGroupPrincipal(name));
}
return groups;
} else {
log.debug("Expired group cache for " + authorizableNode.getPath());
return null;
}
}
use of javax.annotation.CheckForNull in project jackrabbit-oak by apache.
the class SecondaryStoreCache method getDocumentNodeState.
@CheckForNull
@Override
public AbstractDocumentNodeState getDocumentNodeState(String path, RevisionVector rootRevision, RevisionVector lastRev) {
//TODO We might need skip the calls if they occur due to SecondaryStoreObserver
//doing the diff or in the startup when we try to sync the state
PathFilter.Result result = pathFilter.filter(path);
if (result != PathFilter.Result.INCLUDE) {
unknownPaths.mark();
return null;
}
if (!DelegatingDocumentNodeState.hasMetaProps(store.getRoot())) {
return null;
}
AbstractDocumentNodeState currentRoot = DelegatingDocumentNodeState.wrap(store.getRoot(), differ);
//not have the matching result
if (lastRev.compareTo(currentRoot.getLastRevision()) > 0) {
return null;
}
AbstractDocumentNodeState nodeState = findByMatchingLastRev(currentRoot, path, lastRev);
if (nodeState != null) {
headRevMatched.mark();
return nodeState;
}
AbstractDocumentNodeState matchingRoot = findMatchingRoot(rootRevision);
if (matchingRoot != null) {
NodeState state = NodeStateUtils.getNode(matchingRoot, path);
if (state.exists()) {
AbstractDocumentNodeState docState = asDocState(state);
prevRevMatched.mark();
return docState;
}
}
knownMissed.mark();
return null;
}
use of javax.annotation.CheckForNull in project jackrabbit-oak by apache.
the class SecondaryStoreCache method findByMatchingLastRev.
@CheckForNull
private AbstractDocumentNodeState findByMatchingLastRev(AbstractDocumentNodeState root, String path, RevisionVector lastRev) {
NodeState state = root;
for (String name : PathUtils.elements(path)) {
state = state.getChildNode(name);
if (!state.exists()) {
return null;
}
//requested lastRev is > current node lastRev then no need to check further
if (lastRev.compareTo(asDocState(state).getLastRevision()) > 0) {
return null;
}
}
AbstractDocumentNodeState docState = asDocState(state);
if (lastRev.equals(docState.getLastRevision())) {
headRevMatched.mark();
return docState;
}
return null;
}
use of javax.annotation.CheckForNull in project jackrabbit-oak by apache.
the class IndexUtils method getAsyncLaneName.
@CheckForNull
public static String getAsyncLaneName(NodeState idxState, String indexPath) {
PropertyState async = idxState.getProperty(IndexConstants.ASYNC_PROPERTY_NAME);
if (async != null) {
Set<String> asyncNames = Sets.newHashSet(async.getValue(Type.STRINGS));
asyncNames.remove(IndexConstants.INDEXING_MODE_NRT);
asyncNames.remove(IndexConstants.INDEXING_MODE_SYNC);
checkArgument(!asyncNames.isEmpty(), "No valid async name found for " + "index [%s], definition %s", indexPath, idxState);
return Iterables.getOnlyElement(asyncNames);
}
return null;
}
Aggregations