Merge remote-tracking branch 'upstream/master' into DS-2784-jersey2

Conflicts:
	dspace-rest/src/main/java/org/dspace/rest/HandleResource.java
This commit is contained in:
aleksanderkotbury
2015-12-24 13:49:27 +01:00
10 changed files with 189 additions and 12 deletions

View File

@@ -0,0 +1,90 @@
/**
* 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.util.List;
import org.apache.solr.common.SolrInputDocument;
import org.dspace.content.Bitstream;
import org.dspace.content.Bundle;
import org.dspace.content.DSpaceObject;
import org.dspace.content.Item;
import org.dspace.core.Context;
/**
* This plugin adds three fields to the solr index to make a facet with/without
* content in the ORIGINAL Bundle possible (like full text, images...). It is
* activated simply by adding this class as a bean to discovery.xml.
*
* The facet is added to Discovery in the usual way (create a searchFilter bean
* and add it to the expected place) just with an empty list of used metadata
* fields because there are none.
*
* @author Christian Scheible <christian.scheible@uni-konstanz.de>
*
*/
public class SolrServiceContentInOriginalBundleFilterPlugin implements SolrServiceIndexPlugin
{
@Override
public void additionalIndex(Context context, DSpaceObject dso, SolrInputDocument document)
{
if (dso instanceof Item)
{
Item item = (Item) dso;
boolean hasOriginalBundleWithContent = hasOriginalBundleWithContent(item);
// _keyword and _filter because
// they are needed in order to work as a facet and filter.
if (!hasOriginalBundleWithContent)
{
// no content in the original bundle
document.addField("has_content_in_original_bundle", false);
document.addField("has_content_in_original_bundle_keyword", false);
document.addField("has_content_in_original_bundle_filter", false);
}
else
{
document.addField("has_content_in_original_bundle", true);
document.addField("has_content_in_original_bundle_keyword", true);
document.addField("has_content_in_original_bundle_filter", true);
}
}
}
/**
* Checks whether the given item has a bundle with the name ORIGINAL
* containing at least one bitstream.
*
* @param item
* to check
* @return true if there is at least on bitstream in the bundle named
* ORIGINAL, otherwise false
*/
private boolean hasOriginalBundleWithContent(Item item)
{
List<Bundle> bundles;
bundles = item.getBundles();
if (bundles != null)
{
for (Bundle curBundle : bundles)
{
String bName = curBundle.getName();
if ((bName != null) && bName.equals("ORIGINAL"))
{
List<Bitstream> bitstreams = curBundle.getBitstreams();
if (bitstreams != null && bitstreams.size() > 0)
{
return true;
}
}
}
}
return false;
}
}

View File

@@ -568,12 +568,9 @@ public class SolrLoggerServiceImpl implements SolrLoggerService, InitializingBea
{
Community comm = (Community) dso;
List<Community> parentCommunities = comm.getParentCommunities();
while (CollectionUtils.isNotEmpty(parentCommunities))
{
for (int i = 0; i < parentCommunities.size(); i++) {
Community community = parentCommunities.get(i);
doc1.addField("owningComm", comm.getID());
}
for (Community parent : parentCommunities) {
doc1.addField("owningComm", parent.getID());
storeParents(doc1, parent);
}
}
else if (dso instanceof Collection)

View File

@@ -875,6 +875,9 @@ jsp.search.facet.refine = Discover
jsp.search.facet.refine.author = Author
jsp.search.facet.refine.subject = Subject
jsp.search.facet.refine.dateIssued = Date issued
jsp.search.facet.refine.has_content_in_original_bundle = Has File(s)
jsp.search.facet.refine.value_has_content_in_original_bundle_true = Yes
jsp.search.facet.refine.value.has_content_in_original_bundle_false = False
jsp.search.facet.refine.previous = < previous
jsp.search.facet.refine.next = next >
jsp.search.facet.narrow = Filter by {0}
@@ -893,6 +896,7 @@ jsp.search.filter.op.contains = Contains
jsp.search.filter.op.notcontains = Not Contains
jsp.search.filter.op.authority = ID
jsp.search.filter.op.notauthority = Not ID
jsp.search.filter.has_content_in_original_bundle = Has File(s)
jsp.sherpa.title = SHERPA/RoMEO Publisher Policy Database
jsp.sherpa.loading = <p>Fetching policy information from the SHERPA/RoMEO database</p><img alt="loading" src="{0}/sherpa/image/ajax-loader-big.gif" />
jsp.sherpa.heading = <p class="sherpaDisclaimer"><a href="http://www.sherpa.ac.uk/romeo.php" target="_blank"><img align="left" src="{0}/sherpa/image/romeosmall.gif" width="100" height="54" alt="SHERPA/RoMEO Database" border="0"></a> All SHERPA/RoMEO information is correct to the best of our knowledge but should not be relied upon for legal advice. SHERPA cannot be held responsible for the re-use of RoMEO data, or for alternative interpretations which are derived from this information.</p>

View File

@@ -40,13 +40,14 @@ public class HandleResource extends Resource {
protected AuthorizeService authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
private static Logger log = Logger.getLogger(HandleResource.class);
private static org.dspace.core.Context context;
@GET
@Path("/{prefix}/{suffix}")
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public org.dspace.rest.common.DSpaceObject getObject(@PathParam("prefix") String prefix, @PathParam("suffix") String suffix, @QueryParam("expand") String expand, @javax.ws.rs.core.Context HttpHeaders headers) {
DSpaceObject dSpaceObject = new DSpaceObject();
org.dspace.core.Context context = null;
try {
context = createContext(getUser(headers));
@@ -62,20 +63,23 @@ public class HandleResource extends Resource {
switch(dso.getType()) {
case Constants.COMMUNITY:
dSpaceObject = new Community((org.dspace.content.Community) dso, servletContext, expand, context);
return dSpaceObject;
break;
case Constants.COLLECTION:
dSpaceObject = new Collection((org.dspace.content.Collection) dso, servletContext, expand, context, null, null);
return dSpaceObject;
break;
case Constants.ITEM:
dSpaceObject = new Item((org.dspace.content.Item) dso, servletContext, expand, context);
return dSpaceObject;
break;
default:
dSpaceObject = new DSpaceObject(dso, servletContext);
return dSpaceObject;
break;
}
} else {
throw new WebApplicationException(Response.Status.UNAUTHORIZED);
}
context.complete();
} catch (SQLException e) {
log.error(e.getMessage());
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
@@ -88,7 +92,7 @@ public class HandleResource extends Resource {
processFinally(context);
}
//Not sure where I was missing a return..
return dSpaceObject;
}
}

View File

@@ -0,0 +1,32 @@
/**
* 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.utils;
import org.dspace.app.util.AbstractDSpaceWebapp;
/**
* An MBean to identify this web application.
*
* @author Bram Luyten <bram@atmire.com>
*/
public class DSpaceWebapp
extends AbstractDSpaceWebapp
{
public DSpaceWebapp()
{
super("REST");
}
@Override
public boolean isUI()
{
return false;
}
}

View File

@@ -141,5 +141,18 @@
</xsl:if>
</xsl:template>
<!-- Replacing has content in original bundle lables (true,false) in Discover section with i18n elements -->
<xsl:template match="//dri:list[@id='aspect.discovery.SidebarFacetsTransformer.list.has_content_in_original_bundle']/dri:item//text()">
<xsl:choose>
<xsl:when test="substring-before(.,' ') = 'true'">
<i18n:text>xmlui.ArtifactBrowser.AdvancedSearch.value_has_content_in_original_bundle_true</i18n:text>
</xsl:when>
<xsl:otherwise>
<i18n:text>xmlui.ArtifactBrowser.AdvancedSearch.value_has_content_in_original_bundle_false</i18n:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text> </xsl:text>
<xsl:value-of select="substring-after(.,' ')"/>
</xsl:template>
</xsl:stylesheet>

View File

@@ -43,6 +43,10 @@
<message key="xmlui.ArtifactBrowser.AdvancedSearch.type_dc.type_filter">Content Type</message>
<message key="xmlui.ArtifactBrowser.AdvancedSearch.type_dc.date.issued">Date Issued</message>
<message key="xmlui.ArtifactBrowser.AdvancedSearch.type_dateIssued">Date Issued</message>
<message key="xmlui.ArtifactBrowser.AdvancedSearch.type_has_content_in_original_bundle">Has File(s)</message>
<message key="xmlui.ArtifactBrowser.AdvancedSearch.value_has_content_in_original_bundle_true">Yes</message>
<message key="xmlui.ArtifactBrowser.AdvancedSearch.value_has_content_in_original_bundle_false">No</message>
<!-- Site Level Recently Added Content -->
@@ -95,6 +99,7 @@
<message key="xmlui.ArtifactBrowser.SimpleSearch.filter.title">Title</message>
<message key="xmlui.ArtifactBrowser.SimpleSearch.filter.dateIssued">Date issued</message>
<message key="xmlui.ArtifactBrowser.SimpleSearch.filter.has_content_in_original_bundle">Has File(s)</message>
<message key="xmlui.dri2xhtml.structural.pagination-info.nototal">Now showing items {0}-{1}</message>

View File

@@ -65,5 +65,18 @@
</li>
</xsl:template>
<!-- Replacing has content in original bundle facet lables (true,false) in Discover section with i18n elements -->
<xsl:template match="//dri:list[@id='aspect.discovery.SidebarFacetsTransformer.list.has_content_in_original_bundle']/dri:item//text()">
<xsl:choose>
<xsl:when test="substring-before(.,' ') = 'true'">
<i18n:text>xmlui.ArtifactBrowser.AdvancedSearch.value_has_content_in_original_bundle_true</i18n:text>
</xsl:when>
<xsl:otherwise>
<i18n:text>xmlui.ArtifactBrowser.AdvancedSearch.value_has_content_in_original_bundle_false</i18n:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text> </xsl:text>
<xsl:value-of select="substring-after(.,' ')"/>
</xsl:template>
</xsl:stylesheet>

View File

@@ -31,6 +31,9 @@
<bean id="solrBrowseIndexer" scope="prototype"
class="org.dspace.browse.SolrBrowseCreateDAO">
</bean>
<!-- Additional indexing plugin make filtering by has content in original bundle (like pdf's, images) posible via SOLR -->
<bean id="hasContentInOriginalBundle" class="org.dspace.discovery.SolrServiceContentInOriginalBundleFilterPlugin"/>
<!--Bean that is used for mapping communities/collections to certain discovery configurations.-->
<bean id="org.dspace.discovery.configuration.DiscoveryConfigurationService" class="org.dspace.discovery.configuration.DiscoveryConfigurationService">
@@ -98,6 +101,7 @@
<ref bean="searchFilterAuthor" />
<ref bean="searchFilterSubject" />
<ref bean="searchFilterIssued" />
<ref bean="searchFilterContentInOriginalBundle"/>
</list>
</property>
<!-- Set TagCloud configuration per discovery configuration -->
@@ -109,6 +113,7 @@
<ref bean="searchFilterAuthor" />
<ref bean="searchFilterSubject" />
<ref bean="searchFilterIssued" />
<ref bean="searchFilterContentInOriginalBundle"/>
</list>
</property>
<!--The sort filters for the discovery search-->
@@ -203,6 +208,7 @@
<ref bean="searchFilterAuthor" />
<ref bean="searchFilterSubject" />
<ref bean="searchFilterIssued" />
<ref bean="searchFilterContentInOriginalBundle"/>
</list>
</property>
<!-- Set TagCloud configuration per discovery configuration -->
@@ -214,6 +220,7 @@
<ref bean="searchFilterAuthor" />
<ref bean="searchFilterSubject" />
<ref bean="searchFilterIssued" />
<ref bean="searchFilterContentInOriginalBundle"/>
</list>
</property>
<!--The sort filters for the discovery search (same as defaultConfiguration above)-->
@@ -404,6 +411,16 @@
<property name="type" value="date"/>
<property name="sortOrder" value="VALUE"/>
</bean>
<bean id="searchFilterContentInOriginalBundle" class="org.dspace.discovery.configuration.DiscoverySearchFilterFacet">
<property name="indexFieldName" value="has_content_in_original_bundle"/>
<property name="metadataFields">
<list/>
</property>
<property name="facetLimit" value="2"/>
<property name="type" value="standard"/>
<property name="sortOrder" value="VALUE"/>
</bean>
<!--Sort properties-->
<bean id="sortTitle" class="org.dspace.discovery.configuration.DiscoverySortFieldConfiguration">

View File

@@ -537,6 +537,8 @@
<field name="read" type="string" indexed="true" stored="true" omitNorms="true" multiValued="true" docValues="true" />
<field name="has_content_in_original_bundle" type="string" indexed="true" stored="true" omitNorms="true" multiValued="true" docValues="true" />
<!-- Community and collection hierarchy of the Item of interest (candidate for hierarchical facetting ) -->
<field name="location" type="lowerCaseSort" indexed="true" stored="true" multiValued="true" required="false" omitNorms="true" />
<field name="location.comm" type="lowerCaseSort" indexed="true" stored="true" multiValued="true" required="false" omitNorms="true" />