This repository has been archived by the owner on Oct 11, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
only show tags in tags dropdown list that have been used on pages tha…
…t are actually visible to the user; speed up PagePermissionFilter
- Loading branch information
Showing
9 changed files
with
297 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
de.blizzy.documentr/src/main/java/de/blizzy/documentr/search/AbstractDocIdsCollector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
documentr - Edit, maintain, and present software documentation on the web. | ||
Copyright (C) 2012 Maik Schreiber | ||
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 de.blizzy.documentr.search; | ||
|
||
import java.util.BitSet; | ||
|
||
import org.apache.lucene.search.Collector; | ||
|
||
abstract class AbstractDocIdsCollector extends Collector { | ||
protected BitSet docIds = new BitSet(); | ||
|
||
BitSet getDocIds() { | ||
return docIds; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
de.blizzy.documentr/src/main/java/de/blizzy/documentr/search/AllDocIdsCollector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
documentr - Edit, maintain, and present software documentation on the web. | ||
Copyright (C) 2012 Maik Schreiber | ||
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 de.blizzy.documentr.search; | ||
|
||
import org.apache.lucene.index.AtomicReaderContext; | ||
import org.apache.lucene.search.Scorer; | ||
|
||
class AllDocIdsCollector extends AbstractDocIdsCollector { | ||
private int docBase; | ||
|
||
@Override | ||
public void setScorer(Scorer scorer) { | ||
} | ||
|
||
@Override | ||
public void collect(int doc) { | ||
docIds.set(docBase + doc); | ||
} | ||
|
||
@Override | ||
public void setNextReader(AtomicReaderContext context) { | ||
docBase = context.docBase; | ||
} | ||
|
||
@Override | ||
public boolean acceptsDocsOutOfOrder() { | ||
return true; | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
...lizzy.documentr/src/main/java/de/blizzy/documentr/search/InaccessibleDocIdsCollector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
documentr - Edit, maintain, and present software documentation on the web. | ||
Copyright (C) 2012 Maik Schreiber | ||
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 de.blizzy.documentr.search; | ||
|
||
import java.io.IOException; | ||
import java.util.Set; | ||
|
||
import org.apache.lucene.document.Document; | ||
import org.apache.lucene.index.AtomicReader; | ||
import org.apache.lucene.index.AtomicReaderContext; | ||
import org.springframework.security.core.Authentication; | ||
|
||
import com.google.common.collect.Sets; | ||
|
||
import de.blizzy.documentr.access.DocumentrPermissionEvaluator; | ||
import de.blizzy.documentr.access.Permission; | ||
|
||
class InaccessibleDocIdsCollector extends AbstractDocIdsCollector { | ||
private static final Set<String> FIELDS = Sets.newHashSet(PageIndex.PROJECT, PageIndex.BRANCH, PageIndex.PATH); | ||
|
||
private Authentication authentication; | ||
private Permission permission; | ||
private DocumentrPermissionEvaluator permissionEvaluator; | ||
private AtomicReader reader; | ||
private int docBase; | ||
|
||
InaccessibleDocIdsCollector(Authentication authentication, Permission permission, | ||
DocumentrPermissionEvaluator permissionEvaluator) { | ||
|
||
this.authentication = authentication; | ||
this.permission = permission; | ||
this.permissionEvaluator = permissionEvaluator; | ||
} | ||
|
||
@Override | ||
public void setScorer(org.apache.lucene.search.Scorer scorer) { | ||
} | ||
|
||
@Override | ||
public void setNextReader(AtomicReaderContext context) { | ||
reader = context.reader(); | ||
docBase = context.docBase; | ||
} | ||
|
||
@Override | ||
public void collect(int doc) throws IOException { | ||
Document document = reader.document(doc, FIELDS); | ||
String projectName = document.get(PageIndex.PROJECT); | ||
String branchName = document.get(PageIndex.BRANCH); | ||
String path = document.get(PageIndex.PATH); | ||
if (!permissionEvaluator.hasPagePermission(authentication, projectName, branchName, path, permission)) { | ||
docIds.set(docBase + doc); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean acceptsDocsOutOfOrder() { | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.