mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Merge pull request #218 from KevinVdV/DS-1272
[DS-1272] Enable Discovery By Default for the XMLUI
This commit is contained in:
@@ -289,6 +289,10 @@
|
||||
<groupId>commons-pool</groupId>
|
||||
<artifactId>commons-pool</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-validator</groupId>
|
||||
<artifactId>commons-validator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>mail</artifactId>
|
||||
|
@@ -16,6 +16,7 @@ import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.time.DateFormatUtils;
|
||||
import org.apache.commons.validator.UrlValidator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.solr.client.solrj.SolrQuery;
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
@@ -43,6 +44,7 @@ import org.dspace.utils.DSpace;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.MalformedURLException;
|
||||
import java.sql.SQLException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -89,21 +91,33 @@ public class SolrServiceImpl implements SearchService, IndexingService {
|
||||
private CommonsHttpSolrServer solr = null;
|
||||
|
||||
|
||||
protected CommonsHttpSolrServer getSolr() throws java.net.MalformedURLException, org.apache.solr.client.solrj.SolrServerException
|
||||
protected CommonsHttpSolrServer getSolr()
|
||||
{
|
||||
if ( solr == null)
|
||||
{
|
||||
String solrService = new DSpace().getConfigurationService().getProperty("discovery.search.server") ;
|
||||
|
||||
log.debug("Solr URL: " + solrService);
|
||||
UrlValidator urlValidator = new UrlValidator();
|
||||
if(urlValidator.isValid(solrService))
|
||||
{
|
||||
try {
|
||||
log.debug("Solr URL: " + solrService);
|
||||
solr = new CommonsHttpSolrServer(solrService);
|
||||
|
||||
solr.setBaseURL(solrService);
|
||||
solr.setBaseURL(solrService);
|
||||
|
||||
SolrQuery solrQuery = new SolrQuery()
|
||||
.setQuery("search.resourcetype:2 AND search.resourceid:1");
|
||||
SolrQuery solrQuery = new SolrQuery()
|
||||
.setQuery("search.resourcetype:2 AND search.resourceid:1");
|
||||
|
||||
solr.query(solrQuery);
|
||||
solr.query(solrQuery);
|
||||
} catch (MalformedURLException e) {
|
||||
log.error("Error while initialinging solr server", e);
|
||||
} catch (SolrServerException e) {
|
||||
log.error("Error while initialinging solr server", e);
|
||||
}
|
||||
}else{
|
||||
log.error("Error while initializing solr, invalid url: " + solrService);
|
||||
}
|
||||
}
|
||||
|
||||
return solr;
|
||||
@@ -255,10 +269,12 @@ public class SolrServiceImpl implements SearchService, IndexingService {
|
||||
throws SQLException, IOException {
|
||||
|
||||
try {
|
||||
getSolr().deleteByQuery("handle:\""+handle+"\"");
|
||||
if(commit)
|
||||
{
|
||||
getSolr().commit();
|
||||
if(getSolr() != null){
|
||||
getSolr().deleteByQuery("handle:\"" + handle + "\"");
|
||||
if(commit)
|
||||
{
|
||||
getSolr().commit();
|
||||
}
|
||||
}
|
||||
} catch (SolrServerException e)
|
||||
{
|
||||
@@ -354,7 +370,10 @@ public class SolrServiceImpl implements SearchService, IndexingService {
|
||||
context.removeCached(community, community.getID());
|
||||
}
|
||||
|
||||
getSolr().commit();
|
||||
if(getSolr() != null)
|
||||
{
|
||||
getSolr().commit();
|
||||
}
|
||||
|
||||
} catch (Exception e)
|
||||
{
|
||||
@@ -379,6 +398,10 @@ public class SolrServiceImpl implements SearchService, IndexingService {
|
||||
|
||||
try
|
||||
{
|
||||
if(getSolr() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (force)
|
||||
{
|
||||
getSolr().deleteByQuery("search.resourcetype:[2 TO 4]");
|
||||
@@ -433,6 +456,10 @@ public class SolrServiceImpl implements SearchService, IndexingService {
|
||||
public void optimize()
|
||||
{
|
||||
try {
|
||||
if(getSolr() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
System.out.println("SOLR Search Optimize -- Process Started:"+start);
|
||||
getSolr().optimize();
|
||||
@@ -516,6 +543,10 @@ public class SolrServiceImpl implements SearchService, IndexingService {
|
||||
QueryResponse rsp;
|
||||
|
||||
try {
|
||||
if(getSolr() == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
rsp = getSolr().query(query);
|
||||
} catch (SolrServerException e)
|
||||
{
|
||||
@@ -598,7 +629,10 @@ public class SolrServiceImpl implements SearchService, IndexingService {
|
||||
protected void writeDocument(SolrInputDocument doc) throws IOException {
|
||||
|
||||
try {
|
||||
getSolr().add(doc);
|
||||
if(getSolr() != null)
|
||||
{
|
||||
getSolr().add(doc);
|
||||
}
|
||||
} catch (SolrServerException e)
|
||||
{
|
||||
log.error(e.getMessage(), e);
|
||||
@@ -1437,6 +1471,9 @@ public class SolrServiceImpl implements SearchService, IndexingService {
|
||||
|
||||
public DiscoverResult search(Context context, DiscoverQuery discoveryQuery, boolean includeWithdrawn) throws SearchServiceException {
|
||||
try {
|
||||
if(getSolr() == null){
|
||||
return new DiscoverResult();
|
||||
}
|
||||
SolrQuery solrQuery = resolveToSolrQuery(context, discoveryQuery, includeWithdrawn);
|
||||
|
||||
|
||||
@@ -1594,6 +1631,11 @@ public class SolrServiceImpl implements SearchService, IndexingService {
|
||||
|
||||
|
||||
public InputStream searchJSON(Context context, DiscoverQuery discoveryQuery, String jsonIdentifier) throws SearchServiceException {
|
||||
if(getSolr() == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
SolrQuery solrQuery = resolveToSolrQuery(context, discoveryQuery, false);
|
||||
//We use json as out output type
|
||||
solrQuery.setParam("json.nl", "map");
|
||||
@@ -1601,7 +1643,7 @@ public class SolrServiceImpl implements SearchService, IndexingService {
|
||||
solrQuery.setParam(CommonParams.WT, "json");
|
||||
|
||||
StringBuilder urlBuilder = new StringBuilder();
|
||||
urlBuilder.append(solr.getBaseURL()).append("/select?");
|
||||
urlBuilder.append(getSolr().getBaseURL()).append("/select?");
|
||||
urlBuilder.append(solrQuery.toString());
|
||||
|
||||
try {
|
||||
@@ -1757,21 +1799,18 @@ public class SolrServiceImpl implements SearchService, IndexingService {
|
||||
|
||||
/** Simple means to return the search result as an InputStream */
|
||||
public java.io.InputStream searchAsInputStream(DiscoverQuery query) throws SearchServiceException, java.io.IOException {
|
||||
try {
|
||||
org.apache.commons.httpclient.methods.GetMethod method =
|
||||
new org.apache.commons.httpclient.methods.GetMethod(getSolr().getHttpClient().getHostConfiguration().getHostURL() + "");
|
||||
|
||||
method.setQueryString(query.toString());
|
||||
|
||||
getSolr().getHttpClient().executeMethod(method);
|
||||
|
||||
return method.getResponseBodyAsStream();
|
||||
|
||||
} catch (org.apache.solr.client.solrj.SolrServerException e)
|
||||
if(getSolr() == null)
|
||||
{
|
||||
throw new SearchServiceException(e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
org.apache.commons.httpclient.methods.GetMethod method =
|
||||
new org.apache.commons.httpclient.methods.GetMethod(getSolr().getHttpClient().getHostConfiguration().getHostURL() + "");
|
||||
|
||||
method.setQueryString(query.toString());
|
||||
|
||||
getSolr().getHttpClient().executeMethod(method);
|
||||
|
||||
return method.getResponseBodyAsStream();
|
||||
}
|
||||
|
||||
public List<DSpaceObject> search(Context context, String query, int offset, int max, String... filterquery)
|
||||
@@ -1783,6 +1822,11 @@ public class SolrServiceImpl implements SearchService, IndexingService {
|
||||
{
|
||||
|
||||
try {
|
||||
if(getSolr() == null)
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
SolrQuery solrQuery = new SolrQuery();
|
||||
solrQuery.setQuery(query);
|
||||
solrQuery.setFields("search.resourceid", "search.resourcetype");
|
||||
@@ -1902,6 +1946,10 @@ public class SolrServiceImpl implements SearchService, IndexingService {
|
||||
solrQuery.setParam(MoreLikeThisParams.DOC_COUNT, String.valueOf(mltConfig.getMax()));
|
||||
solrQuery.setParam(MoreLikeThisParams.MIN_WORD_LEN, String.valueOf(mltConfig.getMinWordLength()));
|
||||
|
||||
if(getSolr() == null)
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
QueryResponse rsp = getSolr().query(solrQuery);
|
||||
NamedList mltResults = (NamedList) rsp.getResponse().get("moreLikeThis");
|
||||
if(mltResults != null && mltResults.get(item.getType() + "-" + item.getID()) != null)
|
||||
@@ -2097,7 +2145,10 @@ public class SolrServiceImpl implements SearchService, IndexingService {
|
||||
@Override
|
||||
public void commit() throws SearchServiceException {
|
||||
try {
|
||||
getSolr().commit();
|
||||
if(getSolr() != null)
|
||||
{
|
||||
getSolr().commit();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new SearchServiceException(e.getMessage(), e);
|
||||
}
|
||||
|
@@ -10,8 +10,6 @@ package org.dspace.app.xmlui.aspect.artifactbrowser;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.apache.cocoon.caching.CacheableProcessingComponent;
|
||||
import org.apache.cocoon.util.HashUtil;
|
||||
@@ -25,11 +23,8 @@ import org.dspace.app.xmlui.wing.WingException;
|
||||
import org.dspace.app.xmlui.wing.element.Body;
|
||||
import org.dspace.app.xmlui.wing.element.Division;
|
||||
import org.dspace.app.xmlui.wing.element.ReferenceSet;
|
||||
import org.dspace.app.xmlui.wing.element.List;
|
||||
import org.dspace.app.xmlui.wing.element.PageMeta;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.browse.BrowseException;
|
||||
import org.dspace.browse.BrowseIndex;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
@@ -55,19 +50,6 @@ public class CollectionViewer extends AbstractDSpaceTransformer implements Cache
|
||||
public static final Message T_untitled =
|
||||
message("xmlui.general.untitled");
|
||||
|
||||
private static final Message T_head_browse =
|
||||
message("xmlui.ArtifactBrowser.CollectionViewer.head_browse");
|
||||
|
||||
private static final Message T_browse_titles =
|
||||
message("xmlui.ArtifactBrowser.CollectionViewer.browse_titles");
|
||||
|
||||
private static final Message T_browse_authors =
|
||||
message("xmlui.ArtifactBrowser.CollectionViewer.browse_authors");
|
||||
|
||||
private static final Message T_browse_dates =
|
||||
message("xmlui.ArtifactBrowser.CollectionViewer.browse_dates");
|
||||
|
||||
|
||||
/** Cached validity object */
|
||||
private SourceValidity validity;
|
||||
|
||||
@@ -218,41 +200,10 @@ public class CollectionViewer extends AbstractDSpaceTransformer implements Cache
|
||||
home.setHead(name);
|
||||
}
|
||||
|
||||
// The search / browse box.
|
||||
// The search / browse box placeholder, this division will be populated either in the browse or discovery aspect
|
||||
{
|
||||
// TODO: move browse stuff out of here
|
||||
Division search = home.addDivision("collection-search-browse",
|
||||
home.addDivision("collection-search-browse",
|
||||
"secondary search-browse");
|
||||
|
||||
// Browse by list
|
||||
Division browseDiv = search.addDivision("collection-browse","secondary browse");
|
||||
List browse = browseDiv.addList("collection-browse", List.TYPE_SIMPLE,
|
||||
"collection-browse");
|
||||
browse.setHead(T_head_browse);
|
||||
String url = contextPath + "/handle/" + collection.getHandle();
|
||||
|
||||
try
|
||||
{
|
||||
// Get a Map of all the browse tables
|
||||
BrowseIndex[] bis = BrowseIndex.getBrowseIndices();
|
||||
for (BrowseIndex bix : bis)
|
||||
{
|
||||
// Create a Map of the query parameters for this link
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
|
||||
queryParams.put("type", bix.getName());
|
||||
|
||||
// Add a link to this browse
|
||||
browse.addItemXref(super.generateURL(url + "/browse", queryParams),
|
||||
message("xmlui.ArtifactBrowser.Navigation.browse_" + bix.getName()));
|
||||
}
|
||||
}
|
||||
catch (BrowseException bex)
|
||||
{
|
||||
browse.addItemXref(url + "/browse?type=title",T_browse_titles);
|
||||
browse.addItemXref(url + "/browse?type=author",T_browse_authors);
|
||||
browse.addItemXref(url + "/browse?type=dateissued",T_browse_dates);
|
||||
}
|
||||
}
|
||||
|
||||
// Add the reference
|
||||
|
@@ -10,8 +10,6 @@ package org.dspace.app.xmlui.aspect.artifactbrowser;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.apache.cocoon.caching.CacheableProcessingComponent;
|
||||
import org.apache.cocoon.util.HashUtil;
|
||||
@@ -25,12 +23,9 @@ import org.dspace.app.xmlui.wing.WingException;
|
||||
import org.dspace.app.xmlui.wing.element.Body;
|
||||
import org.dspace.app.xmlui.wing.element.Division;
|
||||
import org.dspace.app.xmlui.wing.element.ReferenceSet;
|
||||
import org.dspace.app.xmlui.wing.element.List;
|
||||
import org.dspace.app.xmlui.wing.element.Reference;
|
||||
import org.dspace.app.xmlui.wing.element.PageMeta;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.browse.BrowseException;
|
||||
import org.dspace.browse.BrowseIndex;
|
||||
import org.dspace.browse.ItemCountException;
|
||||
import org.dspace.browse.ItemCounter;
|
||||
import org.dspace.content.Collection;
|
||||
@@ -59,20 +54,7 @@ public class CommunityViewer extends AbstractDSpaceTransformer implements Cachea
|
||||
public static final Message T_untitled =
|
||||
message("xmlui.general.untitled");
|
||||
|
||||
private static final Message T_head_browse =
|
||||
message("xmlui.ArtifactBrowser.CommunityViewer.head_browse");
|
||||
|
||||
private static final Message T_browse_titles =
|
||||
message("xmlui.ArtifactBrowser.CommunityViewer.browse_titles");
|
||||
|
||||
private static final Message T_browse_authors =
|
||||
message("xmlui.ArtifactBrowser.CommunityViewer.browse_authors");
|
||||
|
||||
private static final Message T_browse_dates =
|
||||
message("xmlui.ArtifactBrowser.CommunityViewer.browse_dates");
|
||||
|
||||
|
||||
private static final Message T_head_sub_communities =
|
||||
private static final Message T_head_sub_communities =
|
||||
message("xmlui.ArtifactBrowser.CommunityViewer.head_sub_communities");
|
||||
|
||||
private static final Message T_head_sub_collections =
|
||||
@@ -261,42 +243,10 @@ public class CommunityViewer extends AbstractDSpaceTransformer implements Cachea
|
||||
home.setHead(name);
|
||||
}
|
||||
|
||||
// The search / browse box.
|
||||
// The search / browse box placeholder, this division will be populated either in the browse or discovery aspect
|
||||
{
|
||||
Division search = home.addDivision("community-search-browse",
|
||||
home.addDivision("community-search-browse",
|
||||
"secondary search-browse");
|
||||
|
||||
|
||||
// TODO: move browse stuff out of here
|
||||
// Browse by list
|
||||
Division browseDiv = search.addDivision("community-browse","secondary browse");
|
||||
List browse = browseDiv.addList("community-browse", List.TYPE_SIMPLE,
|
||||
"community-browse");
|
||||
browse.setHead(T_head_browse);
|
||||
String url = contextPath + "/handle/" + community.getHandle();
|
||||
|
||||
try
|
||||
{
|
||||
// Get a Map of all the browse tables
|
||||
BrowseIndex[] bis = BrowseIndex.getBrowseIndices();
|
||||
for (BrowseIndex bix : bis)
|
||||
{
|
||||
// Create a Map of the query parameters for this link
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
|
||||
queryParams.put("type", bix.getName());
|
||||
|
||||
// Add a link to this browse
|
||||
browse.addItemXref(super.generateURL(url + "/browse", queryParams),
|
||||
message("xmlui.ArtifactBrowser.Navigation.browse_" + bix.getName()));
|
||||
}
|
||||
}
|
||||
catch (BrowseException bex)
|
||||
{
|
||||
browse.addItemXref(url + "/browse?type=title",T_browse_titles);
|
||||
browse.addItemXref(url + "/browse?type=author",T_browse_authors);
|
||||
browse.addItemXref(url + "/browse?type=dateissued",T_browse_dates);
|
||||
}
|
||||
}
|
||||
|
||||
// Add main reference:
|
||||
|
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* 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.app.xmlui.aspect.browseArtifacts;
|
||||
|
||||
import org.apache.cocoon.ProcessingException;
|
||||
import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
|
||||
import org.dspace.app.xmlui.utils.HandleUtil;
|
||||
import org.dspace.app.xmlui.wing.Message;
|
||||
import org.dspace.app.xmlui.wing.WingException;
|
||||
import org.dspace.app.xmlui.wing.element.Body;
|
||||
import org.dspace.app.xmlui.wing.element.Division;
|
||||
import org.dspace.app.xmlui.wing.element.List;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.browse.BrowseException;
|
||||
import org.dspace.browse.BrowseIndex;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Renders the browse links for a collection
|
||||
*
|
||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||
* @author Mark Diggory (markd at atmire dot com)
|
||||
* @author Ben Bosman (ben at atmire dot com)
|
||||
*/
|
||||
public class CollectionBrowse extends AbstractDSpaceTransformer {
|
||||
|
||||
private static final Message T_head_browse =
|
||||
message("xmlui.ArtifactBrowser.CollectionViewer.head_browse");
|
||||
|
||||
private static final Message T_browse_titles =
|
||||
message("xmlui.ArtifactBrowser.CollectionViewer.browse_titles");
|
||||
|
||||
private static final Message T_browse_authors =
|
||||
message("xmlui.ArtifactBrowser.CollectionViewer.browse_authors");
|
||||
|
||||
private static final Message T_browse_dates =
|
||||
message("xmlui.ArtifactBrowser.CollectionViewer.browse_dates");
|
||||
|
||||
@Override
|
||||
public void addBody(Body body) throws SAXException, WingException, SQLException, IOException, AuthorizeException, ProcessingException {
|
||||
DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
|
||||
if (!(dso instanceof Collection))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Set up the major variables
|
||||
Collection collection = (Collection) dso;
|
||||
|
||||
Division home = body.addDivision("collection-home", "primary repository collection");
|
||||
|
||||
Division search = home.addDivision("collection-search-browse",
|
||||
"secondary search-browse");
|
||||
|
||||
// Browse by list
|
||||
Division browseDiv = search.addDivision("collection-browse", "secondary browse");
|
||||
List browse = browseDiv.addList("collection-browse", List.TYPE_SIMPLE,
|
||||
"collection-browse");
|
||||
browse.setHead(T_head_browse);
|
||||
String url = contextPath + "/handle/" + collection.getHandle();
|
||||
|
||||
try {
|
||||
// Get a Map of all the browse tables
|
||||
BrowseIndex[] bis = BrowseIndex.getBrowseIndices();
|
||||
for (BrowseIndex bix : bis) {
|
||||
// Create a Map of the query parameters for this link
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
|
||||
queryParams.put("type", bix.getName());
|
||||
|
||||
// Add a link to this browse
|
||||
browse.addItemXref(generateURL(url + "/browse", queryParams),
|
||||
message("xmlui.ArtifactBrowser.Navigation.browse_" + bix.getName()));
|
||||
}
|
||||
} catch (BrowseException bex) {
|
||||
browse.addItemXref(url + "/browse?type=title", T_browse_titles);
|
||||
browse.addItemXref(url + "/browse?type=author", T_browse_authors);
|
||||
browse.addItemXref(url + "/browse?type=dateissued", T_browse_dates);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* 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.app.xmlui.aspect.browseArtifacts;
|
||||
|
||||
import org.apache.cocoon.ProcessingException;
|
||||
import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
|
||||
import org.dspace.app.xmlui.utils.HandleUtil;
|
||||
import org.dspace.app.xmlui.wing.Message;
|
||||
import org.dspace.app.xmlui.wing.WingException;
|
||||
import org.dspace.app.xmlui.wing.element.Body;
|
||||
import org.dspace.app.xmlui.wing.element.Division;
|
||||
import org.dspace.app.xmlui.wing.element.List;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.browse.BrowseException;
|
||||
import org.dspace.browse.BrowseIndex;
|
||||
import org.dspace.content.Community;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Renders the browse links for a community
|
||||
*
|
||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||
* @author Mark Diggory (markd at atmire dot com)
|
||||
* @author Ben Bosman (ben at atmire dot com)
|
||||
*/
|
||||
public class CommunityBrowse extends AbstractDSpaceTransformer {
|
||||
|
||||
private static final Message T_head_browse =
|
||||
message("xmlui.ArtifactBrowser.CommunityViewer.head_browse");
|
||||
|
||||
private static final Message T_browse_titles =
|
||||
message("xmlui.ArtifactBrowser.CommunityViewer.browse_titles");
|
||||
|
||||
private static final Message T_browse_authors =
|
||||
message("xmlui.ArtifactBrowser.CommunityViewer.browse_authors");
|
||||
|
||||
private static final Message T_browse_dates =
|
||||
message("xmlui.ArtifactBrowser.CommunityViewer.browse_dates");
|
||||
|
||||
@Override
|
||||
public void addBody(Body body) throws SAXException, WingException, SQLException, IOException, AuthorizeException, ProcessingException {
|
||||
DSpaceObject dso = HandleUtil.obtainHandle(objectModel);
|
||||
if (!(dso instanceof Community))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Set up the major variables
|
||||
Community community = (Community) dso;
|
||||
|
||||
Division home = body.addDivision("community-home", "primary repository community");
|
||||
|
||||
Division search = home.addDivision("community-search-browse",
|
||||
"secondary search-browse");
|
||||
|
||||
// Browse by list
|
||||
Division browseDiv = search.addDivision("community-browse", "secondary browse");
|
||||
List browse = browseDiv.addList("community-browse", List.TYPE_SIMPLE,
|
||||
"community-browse");
|
||||
browse.setHead(T_head_browse);
|
||||
String url = contextPath + "/handle/" + community.getHandle();
|
||||
|
||||
try {
|
||||
// Get a Map of all the browse tables
|
||||
BrowseIndex[] bis = BrowseIndex.getBrowseIndices();
|
||||
for (BrowseIndex bix : bis) {
|
||||
// Create a Map of the query parameters for this link
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
|
||||
queryParams.put("type", bix.getName());
|
||||
|
||||
// Add a link to this browse
|
||||
browse.addItemXref(generateURL(url + "/browse", queryParams),
|
||||
message("xmlui.ArtifactBrowser.Navigation.browse_" + bix.getName()));
|
||||
}
|
||||
} catch (BrowseException bex) {
|
||||
browse.addItemXref(url + "/browse?type=title", T_browse_titles);
|
||||
browse.addItemXref(url + "/browse?type=author", T_browse_authors);
|
||||
browse.addItemXref(url + "/browse?type=dateissued", T_browse_dates);
|
||||
}
|
||||
}
|
||||
}
|
@@ -23,6 +23,8 @@ collections / items / and bitstreams.
|
||||
<map:transformer name="CommunityBrowser" src="org.dspace.app.xmlui.aspect.artifactbrowser.CommunityBrowser"/>
|
||||
<map:transformer name="CommunityRecentSubmissions" src="org.dspace.app.xmlui.aspect.artifactbrowser.CommunityRecentSubmissions"/>
|
||||
<map:transformer name="CollectionRecentSubmissions" src="org.dspace.app.xmlui.aspect.artifactbrowser.CollectionRecentSubmissions"/>
|
||||
<map:transformer name="CommunityBrowse" src="org.dspace.app.xmlui.aspect.browseArtifacts.CommunityBrowse"/>
|
||||
<map:transformer name="CollectionBrowse" src="org.dspace.app.xmlui.aspect.browseArtifacts.CollectionBrowse"/>
|
||||
<map:transformer name="ConfigurableBrowse" src="org.dspace.app.xmlui.aspect.artifactbrowser.ConfigurableBrowse"/>
|
||||
<map:transformer name="StaticPage" src="org.dspace.app.xmlui.aspect.browseArtifacts.StaticPage"/>
|
||||
</map:transformers>
|
||||
@@ -81,12 +83,14 @@ collections / items / and bitstreams.
|
||||
|
||||
<map:match type="HandleTypeMatcher" pattern="community">
|
||||
<map:match pattern="handle/*/*">
|
||||
<map:transform type="CommunityBrowse"/>
|
||||
<map:transform type="CommunityRecentSubmissions"/>
|
||||
</map:match>
|
||||
</map:match>
|
||||
|
||||
<map:match type="HandleTypeMatcher" pattern="collection">
|
||||
<map:match pattern="handle/*/*">
|
||||
<map:transform type="CollectionBrowse"/>
|
||||
<map:transform type="CollectionRecentSubmissions"/>
|
||||
</map:match>
|
||||
</map:match>
|
||||
|
@@ -639,7 +639,7 @@ event.dispatcher.default.class = org.dspace.event.BasicDispatcher
|
||||
# uncomment below and comment out original property to enable discovery indexing
|
||||
# event.dispatcher.default.consumers = versioning, search, browse, discovery, eperson, harvester
|
||||
#
|
||||
event.dispatcher.default.consumers = versioning, search, browse, eperson, harvester
|
||||
event.dispatcher.default.consumers = versioning, search, browse, discovery, eperson, harvester
|
||||
|
||||
# The noindex dispatcher will not create search or browse indexes (useful for batch item imports)
|
||||
event.dispatcher.noindex.class = org.dspace.event.BasicDispatcher
|
||||
@@ -1101,7 +1101,8 @@ webui.browse.link.1 = author:dc.contributor.*
|
||||
recent.submissions.sort-option = dateaccessioned
|
||||
|
||||
# how many recent submissions should be displayed at any one time
|
||||
recent.submissions.count = 5
|
||||
# Set to 0 since discovery uses a separate configuration for this
|
||||
recent.submissions.count = 0
|
||||
|
||||
# tell the community and collection pages that we are using the Recent
|
||||
# Submissions code
|
||||
|
@@ -82,7 +82,7 @@
|
||||
<!-- Base DSpace XMLUI Aspects for Display, Browse, Search, Admin, Login and Submission -->
|
||||
<aspect name="Displaying Artifacts" path="resource://aspects/ViewArtifacts/" />
|
||||
<aspect name="Browsing Artifacts" path="resource://aspects/BrowseArtifacts/" />
|
||||
<aspect name="Searching Artifacts" path="resource://aspects/SearchArtifacts/" />
|
||||
<aspect name="Discovery" path="resource://aspects/Discovery/" />
|
||||
<aspect name="Administration" path="resource://aspects/Administrative/" />
|
||||
<aspect name="E-Person" path="resource://aspects/EPerson/" />
|
||||
<aspect name="Submission and Workflow" path="resource://aspects/Submission/" />
|
||||
@@ -115,14 +115,14 @@
|
||||
<!-- ==============
|
||||
Search Engines
|
||||
============== -->
|
||||
<!-- By default, DSpace uses a basic (Lucene based) search engine (see SearchArtifacts aspect above) -->
|
||||
<!--
|
||||
To enable Discovery (faceted/filtered search), uncomment this aspect.
|
||||
Also make sure to comment out the above 'SearchArtifacts' aspect
|
||||
To enable the old lucene based search (no facets, filters), uncomment this aspect.
|
||||
Also make sure to comment out the above 'Discovery' aspect
|
||||
(in the "Basic Features/Aspects" group) as leaving it on together
|
||||
with Discovery will cause UI overlap issues
|
||||
with Searching Artifacts aspect will cause UI overlap issues
|
||||
-->
|
||||
<!-- <aspect name="Discovery" path="resource://aspects/Discovery/" /> -->
|
||||
<!--<aspect name="Searching Artifacts" path="resource://aspects/SearchArtifacts/" />-->
|
||||
|
||||
|
||||
<!-- ==============
|
||||
SWORDv1 Client
|
||||
|
5
pom.xml
5
pom.xml
@@ -697,6 +697,11 @@
|
||||
<artifactId>commons-pool</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-validator</groupId>
|
||||
<artifactId>commons-validator</artifactId>
|
||||
<version>1.4.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-validator</groupId>
|
||||
<artifactId>commons-validator</artifactId>
|
||||
|
Reference in New Issue
Block a user