-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2771 from Micheleboychuk/DS-4504_UpdatePerformanc…
…eFindingCollections DS-4504 Performance issues with finding Collections a user can submit to
- Loading branch information
Showing
8 changed files
with
524 additions
and
14 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
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
76 changes: 76 additions & 0 deletions
76
...ce-api/src/main/java/org/dspace/discovery/SolrServiceIndexCollectionSubmittersPlugin.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,76 @@ | ||
/** | ||
* The contents of this file are subject to the license and copyright | ||
* detailed in the LICENSE and NOTICE files at the root of the source | ||
* tree and available online at | ||
* | ||
* http://www.dspace.org/license/ | ||
*/ | ||
package org.dspace.discovery; | ||
|
||
import java.sql.SQLException; | ||
import java.util.List; | ||
|
||
import org.apache.logging.log4j.Logger; | ||
import org.apache.solr.common.SolrInputDocument; | ||
import org.dspace.authorize.ResourcePolicy; | ||
import org.dspace.authorize.service.AuthorizeService; | ||
import org.dspace.content.Collection; | ||
import org.dspace.content.Community; | ||
import org.dspace.content.factory.ContentServiceFactory; | ||
import org.dspace.core.Constants; | ||
import org.dspace.core.Context; | ||
import org.dspace.core.LogManager; | ||
import org.dspace.discovery.indexobject.IndexableCollection; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
/** | ||
* The purpose of this plugin is to index all ADD type resource policies related to collections. | ||
* | ||
* @author Mykhaylo Boychuk (at 4science.it) | ||
*/ | ||
public class SolrServiceIndexCollectionSubmittersPlugin implements SolrServiceIndexPlugin { | ||
|
||
private static final Logger log = org.apache.logging.log4j.LogManager | ||
.getLogger(SolrServiceIndexCollectionSubmittersPlugin.class); | ||
|
||
@Autowired(required = true) | ||
protected AuthorizeService authorizeService; | ||
|
||
@Override | ||
public void additionalIndex(Context context, IndexableObject idxObj, SolrInputDocument document) { | ||
if (idxObj instanceof IndexableCollection) { | ||
Collection col = ((IndexableCollection) idxObj).getIndexedObject(); | ||
if (col != null) { | ||
try { | ||
String fieldValue = null; | ||
Community parent = (Community) ContentServiceFactory.getInstance().getDSpaceObjectService(col) | ||
.getParentObject(context, col); | ||
while (parent != null) { | ||
if (parent.getAdministrators() != null) { | ||
fieldValue = "g" + parent.getAdministrators().getID(); | ||
document.addField("submit", fieldValue); | ||
} | ||
parent = (Community) ContentServiceFactory.getInstance().getDSpaceObjectService(parent) | ||
.getParentObject(context, parent); | ||
} | ||
List<ResourcePolicy> policies = authorizeService.getPoliciesActionFilter(context, col, | ||
Constants.ADD); | ||
for (ResourcePolicy resourcePolicy : policies) { | ||
if (resourcePolicy.getGroup() != null) { | ||
fieldValue = "g" + resourcePolicy.getGroup().getID(); | ||
} else { | ||
fieldValue = "e" + resourcePolicy.getEPerson().getID(); | ||
|
||
} | ||
document.addField("submit", fieldValue); | ||
context.uncacheEntity(resourcePolicy); | ||
} | ||
} catch (SQLException e) { | ||
log.error(LogManager.getHeader(context, "Error while indexing resource policies", | ||
"Collection: (id " + col.getID() + " type " + col.getName() + ")" )); | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
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.