From: <die...@us...> - 2010-07-01 07:32:23
|
Revision: 2776 http://openutils.svn.sourceforge.net/openutils/?rev=2776&view=rev Author: diego_schivo Date: 2010-07-01 07:32:15 +0000 (Thu, 01 Jul 2010) Log Message: ----------- MEDIA-145 class moved Modified Paths: -------------- trunk/openutils-mgnlcriteria/src/test/resources/crit-repository/jackrabbit-acl-search-index-test-configuration.xml Added Paths: ----------- trunk/openutils-mgnlcriteria/src/main/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/lucene/ trunk/openutils-mgnlcriteria/src/main/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/lucene/AclSearchIndex.java Removed Paths: ------------- trunk/openutils-mgnlcriteria/src/main/java/org/apache/jackrabbit/core/query/lucene/AclSearchIndex.java Added: trunk/openutils-mgnlcriteria/src/main/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/lucene/AclSearchIndex.java =================================================================== --- trunk/openutils-mgnlcriteria/src/main/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/lucene/AclSearchIndex.java (rev 0) +++ trunk/openutils-mgnlcriteria/src/main/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/lucene/AclSearchIndex.java 2010-07-01 07:32:15 UTC (rev 2776) @@ -0,0 +1,109 @@ +/** + * + * Magnolia Criteria API (http://www.openmindlab.com/lab/products/mgnlcriteria.html) + * Copyright (C)2009 - 2010, Openmind S.r.l. http://www.openmindonline.it + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package net.sourceforge.openutils.mgnlcriteria.jcr.query.lucene; + +import java.lang.reflect.Field; +import java.util.List; + +import javax.jcr.RepositoryException; + +import org.apache.jackrabbit.core.SessionImpl; +import org.apache.jackrabbit.core.query.lucene.AclQueryDecorator; +import org.apache.jackrabbit.core.query.lucene.LuceneQueryBuilder; +import org.apache.jackrabbit.core.query.lucene.SearchIndex; +import org.apache.jackrabbit.spi.commons.query.DefaultQueryNodeFactory; +import org.apache.jackrabbit.spi.commons.query.QueryNodeVisitor; +import org.apache.jackrabbit.spi.commons.query.QueryRootNode; +import org.apache.lucene.search.Query; + + +/** + * Supports magnolia security at the lucene level by encoding acl rules as constraints in the lucene query. + * @author dschivo + * @version $Id$ + */ +public class AclSearchIndex extends SearchIndex +{ + + private final AclQueryNodeFactory aclQueryNodeFactory = new AclQueryNodeFactory(VALID_SYSTEM_INDEX_NODE_TYPE_NAMES); + + /** + * {@inheritDoc} + */ + @Override + protected DefaultQueryNodeFactory getQueryNodeFactory() + { + return aclQueryNodeFactory; + } + + /** + * Builds a specialized root node of the query tree, enabling decoration of the lucene query with acl constraints. + * @author dschivo + * @version $Id$ + */ + class AclQueryNodeFactory extends DefaultQueryNodeFactory + { + + /** + * + */ + public AclQueryNodeFactory(List validJcrSystemNodeTypeNames) + { + super(validJcrSystemNodeTypeNames); + } + + /** + * {@inheritDoc} + */ + @Override + public QueryRootNode createQueryRootNode() + { + return new QueryRootNode() + { + + /** + * {@inheritDoc} + */ + @Override + public Object accept(QueryNodeVisitor visitor, Object data) throws RepositoryException + { + // the lucene query without acl constraints + Query luceneQuery = (Query) super.accept(visitor, data); + try + { + // retrieves the session + Field sessionField = LuceneQueryBuilder.class.getDeclaredField("session"); + sessionField.setAccessible(true); + SessionImpl session = (SessionImpl) sessionField.get(visitor); + + // adds acl constraints + AclQueryDecorator decorator = new AclQueryDecorator(session, AclSearchIndex.this); + return decorator.applyAcl(luceneQuery); + } + catch (Throwable e) + { + throw new RepositoryException(e); + } + } + }; + } + } + +} Property changes on: trunk/openutils-mgnlcriteria/src/main/java/net/sourceforge/openutils/mgnlcriteria/jcr/query/lucene/AclSearchIndex.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Deleted: trunk/openutils-mgnlcriteria/src/main/java/org/apache/jackrabbit/core/query/lucene/AclSearchIndex.java =================================================================== --- trunk/openutils-mgnlcriteria/src/main/java/org/apache/jackrabbit/core/query/lucene/AclSearchIndex.java 2010-07-01 07:27:35 UTC (rev 2775) +++ trunk/openutils-mgnlcriteria/src/main/java/org/apache/jackrabbit/core/query/lucene/AclSearchIndex.java 2010-07-01 07:32:15 UTC (rev 2776) @@ -1,106 +0,0 @@ -/** - * - * Magnolia Criteria API (http://www.openmindlab.com/lab/products/mgnlcriteria.html) - * Copyright (C)2009 - 2010, Openmind S.r.l. http://www.openmindonline.it - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -package org.apache.jackrabbit.core.query.lucene; - -import java.lang.reflect.Field; -import java.util.List; - -import javax.jcr.RepositoryException; - -import org.apache.jackrabbit.core.SessionImpl; -import org.apache.jackrabbit.spi.commons.query.DefaultQueryNodeFactory; -import org.apache.jackrabbit.spi.commons.query.QueryNodeVisitor; -import org.apache.jackrabbit.spi.commons.query.QueryRootNode; -import org.apache.lucene.search.Query; - - -/** - * Supports magnolia security at the lucene level by encoding acl rules as constraints in the lucene query. - * @author dschivo - * @version $Id$ - */ -public class AclSearchIndex extends SearchIndex -{ - - private final AclQueryNodeFactory aclQueryNodeFactory = new AclQueryNodeFactory(VALID_SYSTEM_INDEX_NODE_TYPE_NAMES); - - /** - * {@inheritDoc} - */ - @Override - protected DefaultQueryNodeFactory getQueryNodeFactory() - { - return aclQueryNodeFactory; - } - - /** - * Builds a specialized root node of the query tree, enabling decoration of the lucene query with acl constraints. - * @author dschivo - * @version $Id$ - */ - class AclQueryNodeFactory extends DefaultQueryNodeFactory - { - - /** - * - */ - public AclQueryNodeFactory(List validJcrSystemNodeTypeNames) - { - super(validJcrSystemNodeTypeNames); - } - - /** - * {@inheritDoc} - */ - @Override - public QueryRootNode createQueryRootNode() - { - return new QueryRootNode() - { - - /** - * {@inheritDoc} - */ - @Override - public Object accept(QueryNodeVisitor visitor, Object data) throws RepositoryException - { - // the lucene query without acl constraints - Query luceneQuery = (Query) super.accept(visitor, data); - try - { - // retrieves the session - Field sessionField = LuceneQueryBuilder.class.getDeclaredField("session"); - sessionField.setAccessible(true); - SessionImpl session = (SessionImpl) sessionField.get(visitor); - - // adds acl constraints - AclQueryDecorator decorator = new AclQueryDecorator(session, AclSearchIndex.this); - return decorator.applyAcl(luceneQuery); - } - catch (Throwable e) - { - throw new RepositoryException(e); - } - } - }; - } - } - -} Modified: trunk/openutils-mgnlcriteria/src/test/resources/crit-repository/jackrabbit-acl-search-index-test-configuration.xml =================================================================== --- trunk/openutils-mgnlcriteria/src/test/resources/crit-repository/jackrabbit-acl-search-index-test-configuration.xml 2010-07-01 07:27:35 UTC (rev 2775) +++ trunk/openutils-mgnlcriteria/src/test/resources/crit-repository/jackrabbit-acl-search-index-test-configuration.xml 2010-07-01 07:32:15 UTC (rev 2776) @@ -19,7 +19,7 @@ <param name="loadFactor" value="0.3" /> <param name="persistent" value="false" /> </PersistenceManager> - <SearchIndex class="org.apache.jackrabbit.core.query.lucene.AclSearchIndex"> + <SearchIndex class="net.sourceforge.openutils.mgnlcriteria.jcr.query.lucene.AclSearchIndex"> <param name="indexingConfiguration" value="${rep.home}/../../test-classes/crit-repository/indexing_configuration.xml" /> <param name="path" value="${wsp.home}/index" /> <param name="useCompoundFile" value="false" /><!-- lasciare a false solo per i tests --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |