Search in sources :

Example 41 with CheckForNull

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;
    }
}
Also used : PropertyState(org.apache.jackrabbit.oak.api.PropertyState) CheckForNull(javax.annotation.CheckForNull)

Example 42 with CheckForNull

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;
    }
}
Also used : Group(java.security.acl.Group) Tree(org.apache.jackrabbit.oak.api.Tree) HashSet(java.util.HashSet) CheckForNull(javax.annotation.CheckForNull)

Example 43 with CheckForNull

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;
}
Also used : PathFilter(org.apache.jackrabbit.oak.plugins.index.PathFilter) NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) AbstractDocumentNodeState(org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState) AbstractDocumentNodeState(org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState) CheckForNull(javax.annotation.CheckForNull)

Example 44 with CheckForNull

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;
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) AbstractDocumentNodeState(org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState) AbstractDocumentNodeState(org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState) CheckForNull(javax.annotation.CheckForNull)

Example 45 with CheckForNull

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;
}
Also used : PropertyState(org.apache.jackrabbit.oak.api.PropertyState) CheckForNull(javax.annotation.CheckForNull)

Aggregations

CheckForNull (javax.annotation.CheckForNull)149 IOException (java.io.IOException)18 Tree (org.apache.jackrabbit.oak.api.Tree)16 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)12 ArrayList (java.util.ArrayList)9 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)9 Stopwatch (com.google.common.base.Stopwatch)8 UnsupportedCallbackException (javax.security.auth.callback.UnsupportedCallbackException)8 Date (java.util.Date)7 SnapshotDto (org.sonar.db.component.SnapshotDto)7 Period (org.sonar.server.computation.task.projectanalysis.period.Period)7 File (java.io.File)6 SQLException (java.sql.SQLException)6 DocumentStoreException (org.apache.jackrabbit.oak.plugins.document.DocumentStoreException)6 ExecutionException (java.util.concurrent.ExecutionException)5 ValidationModel (org.apache.sling.validation.model.ValidationModel)5 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)4 Root (org.apache.jackrabbit.oak.api.Root)4 Utils.resolveCommitRevision (org.apache.jackrabbit.oak.plugins.document.util.Utils.resolveCommitRevision)4 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)4