You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@rya.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/05/31 14:32:04 UTC

[jira] [Commented] (RYA-119) Add visibility support to MongoDB

    [ https://issues.apache.org/jira/browse/RYA-119?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16031242#comment-16031242 ] 

ASF GitHub Bot commented on RYA-119:
------------------------------------

Github user meiercaleb commented on a diff in the pull request:

    https://github.com/apache/incubator-rya/pull/124#discussion_r119368692
  
    --- Diff: dao/mongodb.rya/src/main/java/org/apache/rya/mongodb/iter/RyaStatementCursorIterator.java ---
    @@ -22,83 +40,83 @@
     
     import info.aduna.iteration.CloseableIteration;
     
    -import java.util.Iterator;
    -import java.util.Map.Entry;
    -import java.util.Set;
    -
    -import org.apache.rya.api.RdfCloudTripleStoreUtils;
    -import org.apache.rya.api.domain.RyaStatement;
    -import org.apache.rya.api.persist.RyaDAOException;
    -import org.apache.rya.mongodb.dao.MongoDBStorageStrategy;
    -
    -import org.calrissian.mango.collect.CloseableIterable;
    -import org.openrdf.query.BindingSet;
    -
    -import com.mongodb.DBCollection;
    -import com.mongodb.DBCursor;
    -import com.mongodb.DBObject;
    -
     public class RyaStatementCursorIterator implements CloseableIteration<RyaStatement, RyaDAOException> {
    -
    -	private DBCollection coll;
    -	private Iterator<DBObject> queryIterator;
    -	private DBCursor currentCursor;
    -	private MongoDBStorageStrategy strategy;
    -	private Long maxResults;
    -
    -	public RyaStatementCursorIterator(DBCollection coll, Set<DBObject> queries, MongoDBStorageStrategy strategy) {
    -		this.coll = coll;
    -		this.queryIterator = queries.iterator();
    -		this.strategy = strategy;
    -	}
    -
    -	@Override
    -	public boolean hasNext() {
    -		if (!currentCursorIsValid()) {
    -			findNextValidCursor();
    -		}
    -		return currentCursorIsValid();
    -	}
    -
    -	@Override
    -	public RyaStatement next() {
    -		if (!currentCursorIsValid()) {
    -			findNextValidCursor();
    -		}
    -		if (currentCursorIsValid()) {
    -			// convert to Rya Statement
    -			DBObject queryResult = currentCursor.next();
    -			RyaStatement statement = strategy.deserializeDBObject(queryResult);
    -			return statement;
    -		}
    -		return null;
    -	}
    -	
    -	private void findNextValidCursor() {
    -		while (queryIterator.hasNext()){
    -			DBObject currentQuery = queryIterator.next();
    -			currentCursor = coll.find(currentQuery);
    -			if (currentCursor.hasNext()) break;
    -		}
    -	}
    -	
    -	private boolean currentCursorIsValid() {
    -		return (currentCursor != null) && currentCursor.hasNext();
    -	}
    -
    -
    -	public void setMaxResults(Long maxResults) {
    -		this.maxResults = maxResults;
    -	}
    -
    -	@Override
    -	public void close() throws RyaDAOException {
    -		// TODO don't know what to do here
    -	}
    -
    -	@Override
    -	public void remove() throws RyaDAOException {
    -		next();
    -	}
    -
    +    private static final Logger log = Logger.getLogger(RyaStatementCursorIterator.class);
    +
    +    private final DBCollection coll;
    +    private final Iterator<DBObject> queryIterator;
    +    private Iterator<DBObject> resultsIterator;
    +    private final MongoDBStorageStrategy<RyaStatement> strategy;
    +    private Long maxResults;
    +    private final Authorizations auths;
    +
    +    public RyaStatementCursorIterator(final DBCollection coll, final Set<DBObject> queries, final MongoDBStorageStrategy<RyaStatement> strategy, final MongoDBRdfConfiguration conf) {
    +        this.coll = coll;
    +        this.queryIterator = queries.iterator();
    +        this.strategy = strategy;
    +        if (conf != null) {
    +            this.auths = conf.getAuthorizations();
    +        } else {
    +            auths = MongoDbRdfConstants.ALL_AUTHORIZATIONS;
    +        }
    +    }
    +
    +    @Override
    +    public boolean hasNext() {
    +        if (!currentCursorIsValid()) {
    +            findNextValidCursor();
    +        }
    +        return currentCursorIsValid();
    +    }
    +
    +    @Override
    +    public RyaStatement next() {
    +        if (!currentCursorIsValid()) {
    +            findNextValidCursor();
    +        }
    +        if (currentCursorIsValid()) {
    +            // convert to Rya Statement
    +            final DBObject queryResult = resultsIterator.next();
    +            final RyaStatement statement = strategy.deserializeDBObject(queryResult);
    +            return statement;
    +        }
    +        return null;
    +    }
    +
    +    private void findNextValidCursor() {
    +        while (queryIterator.hasNext()){
    +            final DBObject currentQuery = queryIterator.next();
    +
    +            // Executing redact aggregation to only return documents the user
    +            // has access to.
    +            final List<DBObject> pipeline = new ArrayList<>();
    +            pipeline.add(new BasicDBObject("$match", currentQuery));
    +            pipeline.addAll(AggregationUtil.createRedactPipeline(auths));
    +            log.debug(pipeline);
    +            final AggregationOutput output = coll.aggregate(pipeline);
    +            resultsIterator = output.results().iterator();
    +            if (resultsIterator.hasNext()) {
    +                break;
    +            }
    +        }
    +    }
    +
    +    private boolean currentCursorIsValid() {
    +        return (resultsIterator != null) && resultsIterator.hasNext();
    +    }
    +
    +
    +    public void setMaxResults(final Long maxResults) {
    +        this.maxResults = maxResults;
    +    }
    +
    +    @Override
    +    public void close() throws RyaDAOException {
    +        // TODO don't know what to do here
    --- End diff --
    
    This PR was prematurely closed.


> Add visibility support to MongoDB
> ---------------------------------
>
>                 Key: RYA-119
>                 URL: https://issues.apache.org/jira/browse/RYA-119
>             Project: Rya
>          Issue Type: Improvement
>          Components: dao
>    Affects Versions: 3.2.10
>            Reporter: Andrew Smith
>            Assignee: Eric White
>
> Currently, when querying mongo, visibility is ignored.  Need to add support for visibility when querying mongo.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)