mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
cleaning up
This commit is contained in:
@@ -114,25 +114,25 @@ websvc.opensearch.enable = true
|
||||
# context for html request URLs - change only for non-standard servlet mapping
|
||||
websvc.opensearch.uicontext = simple-search
|
||||
# context for RSS/Atom request URLs - change only for non-standard servlet mapping
|
||||
websvc.opensearch.svccontext = open-search/
|
||||
#websvc.opensearch.svccontext = open-search/
|
||||
# present autodiscovery link in every page head
|
||||
websvc.opensearch.autolink = true
|
||||
#websvc.opensearch.autolink = true
|
||||
# number of hours to retain results before recalculating
|
||||
websvc.opensearch.validity = 48
|
||||
#websvc.opensearch.validity = 48
|
||||
# short name used in browsers for search service
|
||||
# should be 16 or fewer characters
|
||||
websvc.opensearch.shortname = DS7 OpenSearch
|
||||
#websvc.opensearch.shortname = DS7 OpenSearch
|
||||
# longer (up to 48 characters) name
|
||||
websvc.opensearch.longname = DSpace 7 OpenSearch Service
|
||||
#websvc.opensearch.longname = DSpace 7 OpenSearch Service
|
||||
# brief service description
|
||||
websvc.opensearch.description = OpenSearch Service for DSpace 7
|
||||
#websvc.opensearch.description = OpenSearch Service for DSpace 7
|
||||
# location of favicon for service, if any must be 16X16 pixels
|
||||
websvc.opensearch.faviconurl = http://www.dspace.org/images/favicon.ico
|
||||
#websvc.opensearch.faviconurl = http://www.dspace.org/images/favicon.ico
|
||||
# sample query - should return results
|
||||
websvc.opensearch.samplequery = cats
|
||||
#websvc.opensearch.samplequery = cats
|
||||
# tags used to describe search service
|
||||
websvc.opensearch.tags = IR DSpace
|
||||
#websvc.opensearch.tags = IR DSpace
|
||||
# result formats offered - use 1 or more comma-separated from: html,atom,rss
|
||||
# NB: html is required for autodiscovery in browsers to function,
|
||||
# and must be the first in the list if present
|
||||
websvc.opensearch.formats = html,atom,rss
|
||||
#websvc.opensearch.formats = html,atom,rss
|
||||
|
@@ -106,20 +106,17 @@ public class OpenSearchController implements ErrorController {
|
||||
log.debug("Searching for " + query + " in format " + format);
|
||||
|
||||
// do some sanity checking
|
||||
// TODO: make that work correctly
|
||||
if (!openSearchService.getFormats().contains(format)) {
|
||||
String err = "Format " + format + " is not supported.";
|
||||
response.setContentType("text/html");
|
||||
response.setContentLength(err.length());
|
||||
response.getWriter().write(err);
|
||||
//response.sendError(HttpServletResponse.SC_BAD_REQUEST);
|
||||
//return "error";
|
||||
}
|
||||
|
||||
// then the rest - we are processing the query
|
||||
DSpaceObject container = null;
|
||||
|
||||
// TODO: support pagination parameters
|
||||
// support pagination parameters
|
||||
DiscoverQuery queryArgs = new DiscoverQuery();
|
||||
queryArgs.setQuery(query);
|
||||
queryArgs.setStart(start);
|
||||
@@ -160,6 +157,7 @@ public class OpenSearchController implements ErrorController {
|
||||
} else {
|
||||
log.debug("OpenSearch Service is disabled");
|
||||
String err = "OpenSearch Service is disabled";
|
||||
response.setStatus(404);
|
||||
response.setContentType("text/html");
|
||||
response.setContentLength(err.length());
|
||||
response.getWriter().write(err);
|
||||
@@ -187,6 +185,7 @@ public class OpenSearchController implements ErrorController {
|
||||
} else {
|
||||
log.debug("OpenSearch Service is disabled");
|
||||
String err = "OpenSearch Service is disabled";
|
||||
response.setStatus(404);
|
||||
response.setContentType("text/html");
|
||||
response.setContentLength(err.length());
|
||||
response.getWriter().write(err);
|
||||
|
@@ -7,35 +7,10 @@
|
||||
*/
|
||||
package org.dspace.app.opensearch;
|
||||
|
||||
/*
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.hamcrest.Matchers.hasItem;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
*/
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
/*
|
||||
import org.dspace.app.rest.OpenSearchController;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.app.rest.builder.CollectionBuilder;
|
||||
import org.dspace.app.rest.builder.CommunityBuilder;
|
||||
import org.dspace.app.rest.builder.GroupBuilder;
|
||||
import org.dspace.app.rest.builder.ItemBuilder;
|
||||
import org.dspace.app.rest.matcher.BrowseEntryResourceMatcher;
|
||||
import org.dspace.app.rest.matcher.BrowseIndexMatcher;
|
||||
import org.dspace.app.rest.matcher.ItemMatcher;
|
||||
import org.dspace.app.util.service.OpenSearchService;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.eperson.Group;
|
||||
*/
|
||||
|
||||
import org.dspace.app.rest.test.AbstractControllerIntegrationTest;
|
||||
|
||||
import org.dspace.services.ConfigurationService;
|
||||
@@ -46,7 +21,6 @@ import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Integration test to test the /opensearch endpoint
|
||||
* (Class has to start or end with IT to be picked up by the failsafe plugin)
|
||||
*
|
||||
* @author Oliver Goldschmidt (o dot goldschmidt at tuhh dot de)
|
||||
*/
|
||||
@@ -56,15 +30,9 @@ public class OpenSearchControllerDisabledTest extends AbstractControllerIntegrat
|
||||
|
||||
@Before
|
||||
public void init() throws Exception {
|
||||
// disable OpenSearch by configuration to test the disabled behaviour although its active in test config
|
||||
configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
configurationService.setProperty("websvc.opensearch.enable", false);
|
||||
/*
|
||||
System.out.println("Testing OpenSearch");
|
||||
MockHttpServletResponse resp2 = getClient().perform(get("/opensearch/search")
|
||||
.param("query", "dog"))
|
||||
.andReturn().getResponse();
|
||||
System.out.println("Response from Test 2: "+resp2.getContentAsString());
|
||||
*/
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -72,29 +40,11 @@ System.out.println("Response from Test 2: "+resp2.getContentAsString());
|
||||
//When we call the root endpoint
|
||||
getClient().perform(get("/opensearch/search")
|
||||
.param("query", "dog"))
|
||||
//The status has to be 200 OK
|
||||
.andExpect(status().isOk())
|
||||
//We expect the content type to be "application/hal+json;charset=UTF-8"
|
||||
//The status has to be 404 Not Found
|
||||
.andExpect(status().isNotFound())
|
||||
//We expect the content type to be "application/html"
|
||||
.andExpect(content().contentType("text/html"))
|
||||
/*
|
||||
//Our default Discovery config has 4 browse indexes so we expect this to be reflected in the page
|
||||
// object
|
||||
.andExpect(jsonPath("$.page.size", is(20)))
|
||||
.andExpect(jsonPath("$.page.totalElements", is(4)))
|
||||
.andExpect(jsonPath("$.page.totalPages", is(1)))
|
||||
.andExpect(jsonPath("$.page.number", is(0)))
|
||||
|
||||
//The array of browse index should have a size 4
|
||||
.andExpect(jsonPath("$._embedded.browses", hasSize(4)))
|
||||
|
||||
//Check that all (and only) the default browse indexes are present
|
||||
.andExpect(jsonPath("$._embedded.browses", containsInAnyOrder(
|
||||
BrowseIndexMatcher.dateIssuedBrowseIndex("asc"),
|
||||
BrowseIndexMatcher.contributorBrowseIndex("asc"),
|
||||
BrowseIndexMatcher.titleBrowseIndex("asc"),
|
||||
BrowseIndexMatcher.subjectBrowseIndex("asc")
|
||||
)))
|
||||
*/
|
||||
.andExpect(content().string("OpenSearch Service is disabled"))
|
||||
;
|
||||
}
|
||||
|
||||
@@ -102,99 +52,10 @@ System.out.println("Response from Test 2: "+resp2.getContentAsString());
|
||||
public void serviceDocumentTest() throws Exception {
|
||||
//When we call the root endpoint
|
||||
getClient().perform(get("/opensearch/service"))
|
||||
//The status has to be 200 OK
|
||||
.andExpect(status().isOk())
|
||||
//The status has to be 404 Not Found
|
||||
.andExpect(status().isNotFound())
|
||||
.andExpect(content().contentType("text/html"))
|
||||
//We expect the content type to be "application/hal+json;charset=UTF-8"
|
||||
// .andExpect(content().contentType(contentType))
|
||||
/*
|
||||
//Check that the JSON root matches the expected browse index
|
||||
.andExpect(jsonPath("$", BrowseIndexMatcher.titleBrowseIndex("asc")))
|
||||
*/
|
||||
.andExpect(content().string("OpenSearch Service is disabled"))
|
||||
;
|
||||
}
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void findItemsWithOU() throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
//** GIVEN **
|
||||
//1. A community-collection structure with one parent community with sub-community and two collections.
|
||||
parentCommunity = CommunityBuilder.createCommunity(context)
|
||||
.withName("Parent Community")
|
||||
.build();
|
||||
Community child1 = CommunityBuilder.createSubCommunity(context, parentCommunity)
|
||||
.withName("Sub Community")
|
||||
.build();
|
||||
Collection col1 = CollectionBuilder.createCollection(context, child1).withName("Collection 1").build();
|
||||
Collection col2 = CollectionBuilder.createCollection(context, child1).withName("Collection 2").build();
|
||||
|
||||
//2. Three public items that are readable by Anonymous with different subjects
|
||||
Item publicItem1 = ItemBuilder.createItem(context, col1)
|
||||
.withTitle("Public item 1")
|
||||
.withIssueDate("2017-10-17")
|
||||
.withAuthor("Smith, Donald").withAuthor("Doe, John")
|
||||
.withSubject("ExtraEntry")
|
||||
.build();
|
||||
|
||||
Item publicItem2 = ItemBuilder.createItem(context, col2)
|
||||
.withTitle("Public item 2")
|
||||
.withIssueDate("2016-02-13")
|
||||
.withAuthor("Smith, Maria").withAuthor("Doe, Jane")
|
||||
.withSubject("TestingForMore").withSubject("ExtraEntry")
|
||||
.build();
|
||||
|
||||
Item publicItem3 = ItemBuilder.createItem(context, col2)
|
||||
.withTitle("Public item 2")
|
||||
.withIssueDate("2016-02-13")
|
||||
.withAuthor("Smith, Maria").withAuthor("Doe, Jane")
|
||||
.withSubject("AnotherTest").withSubject("TestingForMore")
|
||||
.withSubject("ExtraEntry")
|
||||
.build();
|
||||
|
||||
//** WHEN **
|
||||
//An anonymous user browses this endpoint to find which subjects are currently in the repository
|
||||
getClient().perform(get("/api/discover/browses/subject/entries"))
|
||||
|
||||
//** THEN **
|
||||
//The status has to be 200
|
||||
.andExpect(status().isOk())
|
||||
|
||||
//We expect the content type to be "application/hal+json;charset=UTF-8"
|
||||
.andExpect(content().contentType(contentType))
|
||||
.andExpect(jsonPath("$.page.size", is(20)))
|
||||
//Check that there are indeed 3 different subjects
|
||||
.andExpect(jsonPath("$.page.totalElements", is(3)))
|
||||
//Check the embedded resources and that they're sorted alphabetically
|
||||
//Check that the subject matches as expected
|
||||
//Verify that they're sorted alphabetically
|
||||
.andExpect(jsonPath("$._embedded.browseEntries",
|
||||
contains(BrowseEntryResourceMatcher.matchBrowseEntry("AnotherTest", 1),
|
||||
BrowseEntryResourceMatcher.matchBrowseEntry("ExtraEntry", 3),
|
||||
BrowseEntryResourceMatcher.matchBrowseEntry("TestingForMore", 2)
|
||||
)));
|
||||
|
||||
getClient().perform(get("/api/discover/browses/subject/entries")
|
||||
.param("sort", "value,desc"))
|
||||
|
||||
//** THEN **
|
||||
//The status has to be 200
|
||||
.andExpect(status().isOk())
|
||||
.andDo(MockMvcResultHandlers.print())
|
||||
//We expect the content type to be "application/hal+json;charset=UTF-8"
|
||||
.andExpect(content().contentType(contentType))
|
||||
.andExpect(jsonPath("$.page.size", is(20)))
|
||||
//Check that there are indeed 3 different subjects
|
||||
.andExpect(jsonPath("$.page.totalElements", is(3)))
|
||||
//Check the embedded resources and that they're sorted alphabetically
|
||||
//Check that the subject matches as expected
|
||||
//Verify that they're sorted alphabetically
|
||||
.andExpect(jsonPath("$._embedded.browseEntries",
|
||||
contains(BrowseEntryResourceMatcher.matchBrowseEntry("TestingForMore", 2),
|
||||
BrowseEntryResourceMatcher.matchBrowseEntry("ExtraEntry", 3),
|
||||
BrowseEntryResourceMatcher.matchBrowseEntry("AnotherTest", 1)
|
||||
)));
|
||||
}
|
||||
*/
|
||||
}
|
@@ -7,36 +7,11 @@
|
||||
*/
|
||||
package org.dspace.app.opensearch;
|
||||
|
||||
/*
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.hamcrest.Matchers.hasItem;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
*/
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.xpath;
|
||||
|
||||
/*
|
||||
import org.dspace.app.rest.OpenSearchController;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.app.rest.builder.CollectionBuilder;
|
||||
import org.dspace.app.rest.builder.CommunityBuilder;
|
||||
import org.dspace.app.rest.builder.GroupBuilder;
|
||||
import org.dspace.app.rest.builder.ItemBuilder;
|
||||
import org.dspace.app.rest.matcher.BrowseEntryResourceMatcher;
|
||||
import org.dspace.app.rest.matcher.BrowseIndexMatcher;
|
||||
import org.dspace.app.rest.matcher.ItemMatcher;
|
||||
import org.dspace.app.util.service.OpenSearchService;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.eperson.Group;
|
||||
*/
|
||||
|
||||
import org.dspace.app.rest.test.AbstractControllerIntegrationTest;
|
||||
|
||||
import org.dspace.services.ConfigurationService;
|
||||
@@ -60,13 +35,6 @@ public class OpenSearchControllerTest extends AbstractControllerIntegrationTest
|
||||
// override the configuration settings here if other settings are required for test
|
||||
// configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
// configurationService.setProperty("websvc.opensearch.enable", true);
|
||||
/*
|
||||
System.out.println("Testing OpenSearch");
|
||||
MockHttpServletResponse resp2 = getClient().perform(get("/opensearch/search")
|
||||
.param("query", "cats"))
|
||||
.andReturn().getResponse();
|
||||
System.out.println("Response from Test 2: "+resp2.getContentAsString());
|
||||
*/
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -118,20 +86,19 @@ public class OpenSearchControllerTest extends AbstractControllerIntegrationTest
|
||||
// and the contentType has to be an opensearchdescription
|
||||
.andExpect(content().contentType("application/opensearchdescription+xml;charset=UTF-8"))
|
||||
// and there need to be some values taken from the test configuration
|
||||
.andExpect(xpath("OpenSearchDescription/ShortName").string("DS7 OpenSearch"))
|
||||
.andExpect(xpath("OpenSearchDescription/LongName").string("DSpace 7 OpenSearch Service"))
|
||||
.andExpect(xpath("OpenSearchDescription/Description").string("OpenSearch Service for DSpace 7"))
|
||||
.andExpect(xpath("OpenSearchDescription/ShortName").string("DS7 OpenSearch"))
|
||||
.andExpect(xpath("OpenSearchDescription/ShortName").string("DSpace"))
|
||||
.andExpect(xpath("OpenSearchDescription/LongName").string("DSpace at My University"))
|
||||
.andExpect(xpath("OpenSearchDescription/Description").string("DSpace at My University DSpace repository"))
|
||||
;
|
||||
/* Expected response for the service document is:
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
|
||||
<ShortName>DS7 OpenSearch</ShortName>
|
||||
<LongName>DSpace 7 OpenSearch Service</LongName>
|
||||
<Description>OpenSearch Service for DSpace 7</Description>
|
||||
<ShortName>DSpace</ShortName>
|
||||
<LongName>DSpace at My University</LongName>
|
||||
<Description>DSpace at My University DSpace repository</Description>
|
||||
<InputEncoding>UTF-8</InputEncoding>
|
||||
<OutputEncoding>UTF-8</OutputEncoding>
|
||||
<Query role="example" searchTerms="cats" />
|
||||
<Query role="example" searchTerms="photosyntesis" />
|
||||
<Tags>IR DSpace</Tags>
|
||||
<Contact>dspace-help@myu.edu</Contact>
|
||||
<Image height="16" width="16" type="image/vnd.microsoft.icon">http://www.dspace.org/images/favicon.ico</Image>
|
||||
|
@@ -199,9 +199,3 @@ db.schema = public
|
||||
# Authentication by Password (encrypted in DSpace's database). See authentication-password.cfg for default configuration.
|
||||
# Enabled by default in authentication.cfg
|
||||
#plugin.sequence.org.dspace.authenticate.AuthenticationMethod = org.dspace.authenticate.PasswordAuthentication
|
||||
|
||||
#### OpenSearch Settings ####
|
||||
# NB: for result data formatting, OpenSearch uses Syndication Feed Settings
|
||||
# so even if Syndication Feeds are not enabled, they must be configured
|
||||
# enable open search
|
||||
websvc.opensearch.enable = true
|
||||
|
@@ -22,7 +22,7 @@ log.dir=${dspace.dir}/log
|
||||
# Log level for all DSpace-specific code (org.dspace.*)
|
||||
# Possible values (from most to least info): DEBUG, INFO, WARN, ERROR, FATAL
|
||||
# Defaults to INFO
|
||||
loglevel.dspace=DEBUG
|
||||
loglevel.dspace=INFO
|
||||
|
||||
# loglevel.other
|
||||
# Log level for other third-party tools/APIs used by DSpace
|
||||
|
Reference in New Issue
Block a user