diff --git a/Dockerfile.jdk8 b/Dockerfile.jdk8 index afe2285f49..b5c108d129 100644 --- a/Dockerfile.jdk8 +++ b/Dockerfile.jdk8 @@ -54,10 +54,7 @@ EXPOSE 8080 8009 ENV JAVA_OPTS=-Xmx2000m -RUN ln -s $DSPACE_INSTALL/webapps/solr /usr/local/tomcat/webapps/solr && \ +RUN mv /usr/local/tomcat/webapps/ROOT /usr/local/tomcat/webapps/ROOT.bk && \ + ln -s $DSPACE_INSTALL/webapps/spring-rest /usr/local/tomcat/webapps/ROOT && \ ln -s $DSPACE_INSTALL/webapps/spring-rest /usr/local/tomcat/webapps/spring-rest && \ - ln -s $DSPACE_INSTALL/webapps/rest /usr/local/tomcat/webapps/rest && \ - ln -s $DSPACE_INSTALL/webapps/oai /usr/local/tomcat/webapps/oai && \ - ln -s $DSPACE_INSTALL/webapps/rdf /usr/local/tomcat/webapps/rdf && \ - ln -s $DSPACE_INSTALL/webapps/sword /usr/local/tomcat/webapps/sword && \ - ln -s $DSPACE_INSTALL/webapps/swordv2 /usr/local/tomcat/webapps/swordv2 + ln -s $DSPACE_INSTALL/webapps/rest /usr/local/tomcat/webapps/rest diff --git a/Dockerfile.jdk8-test b/Dockerfile.jdk8-test index 01697a045c..54ef4d105f 100644 --- a/Dockerfile.jdk8-test +++ b/Dockerfile.jdk8-test @@ -54,16 +54,11 @@ EXPOSE 8080 8009 ENV JAVA_OPTS=-Xmx2000m -RUN ln -s $DSPACE_INSTALL/webapps/solr /usr/local/tomcat/webapps/solr && \ +RUN mv /usr/local/tomcat/webapps/ROOT /usr/local/tomcat/webapps/ROOT.bk && \ + ln -s $DSPACE_INSTALL/webapps/spring-rest /usr/local/tomcat/webapps/ROOT && \ ln -s $DSPACE_INSTALL/webapps/spring-rest /usr/local/tomcat/webapps/spring-rest && \ - ln -s $DSPACE_INSTALL/webapps/rest /usr/local/tomcat/webapps/rest && \ - ln -s $DSPACE_INSTALL/webapps/oai /usr/local/tomcat/webapps/oai && \ - ln -s $DSPACE_INSTALL/webapps/rdf /usr/local/tomcat/webapps/rdf && \ - ln -s $DSPACE_INSTALL/webapps/sword /usr/local/tomcat/webapps/sword && \ - ln -s $DSPACE_INSTALL/webapps/swordv2 /usr/local/tomcat/webapps/swordv2 + ln -s $DSPACE_INSTALL/webapps/rest /usr/local/tomcat/webapps/rest -COPY dspace/src/main/docker/test/solr_web.xml $DSPACE_INSTALL/webapps/solr/WEB-INF/web.xml COPY dspace/src/main/docker/test/rest_web.xml $DSPACE_INSTALL/webapps/rest/WEB-INF/web.xml -RUN sed -i -e "s|\${dspace.dir}|$DSPACE_INSTALL|" $DSPACE_INSTALL/webapps/solr/WEB-INF/web.xml && \ - sed -i -e "s|\${dspace.dir}|$DSPACE_INSTALL|" $DSPACE_INSTALL/webapps/rest/WEB-INF/web.xml +RUN sed -i -e "s|\${dspace.dir}|$DSPACE_INSTALL|" $DSPACE_INSTALL/webapps/rest/WEB-INF/web.xml diff --git a/dspace-api/src/main/java/org/dspace/app/requestitem/RequestItem.java b/dspace-api/src/main/java/org/dspace/app/requestitem/RequestItem.java index d96cbbb5a4..8a77a591b7 100644 --- a/dspace-api/src/main/java/org/dspace/app/requestitem/RequestItem.java +++ b/dspace-api/src/main/java/org/dspace/app/requestitem/RequestItem.java @@ -78,7 +78,7 @@ public class RequestItem implements ReloadableEntity { private Date request_date = null; @Column(name = "accept_request") - private Boolean accept_request = null; + private boolean accept_request; /** * Protected constructor, create object using: @@ -88,6 +88,7 @@ public class RequestItem implements ReloadableEntity { protected RequestItem() { } + @Override public Integer getID() { return requestitem_id; } diff --git a/dspace-api/src/main/java/org/dspace/storage/rdbms/DatabaseRegistryUpdater.java b/dspace-api/src/main/java/org/dspace/storage/rdbms/DatabaseRegistryUpdater.java index 0f4e92fdda..c9e126f8fa 100644 --- a/dspace-api/src/main/java/org/dspace/storage/rdbms/DatabaseRegistryUpdater.java +++ b/dspace-api/src/main/java/org/dspace/storage/rdbms/DatabaseRegistryUpdater.java @@ -8,10 +8,17 @@ package org.dspace.storage.rdbms; import java.io.File; +import java.io.IOException; import java.sql.Connection; +import java.sql.SQLException; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.TransformerException; import org.dspace.administer.MetadataImporter; +import org.dspace.administer.RegistryImportException; import org.dspace.administer.RegistryLoader; +import org.dspace.authorize.AuthorizeException; +import org.dspace.content.NonUniqueMetadataException; import org.dspace.core.Context; import org.dspace.services.ConfigurationService; import org.dspace.services.factory.DSpaceServicesFactory; @@ -21,6 +28,7 @@ import org.flywaydb.core.api.MigrationInfo; import org.flywaydb.core.api.callback.FlywayCallback; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.xml.sax.SAXException; /** * This is a FlywayCallback class which automatically updates the @@ -49,7 +57,7 @@ public class DatabaseRegistryUpdater implements FlywayCallback { private static final Logger log = LoggerFactory.getLogger(DatabaseRegistryUpdater.class); /** - * Method to actually update our registries from latest configs + * Method to actually update our registries from latest configuration files. */ private void updateRegistries() { ConfigurationService config = DSpaceServicesFactory.getInstance().getConfigurationService(); @@ -63,35 +71,32 @@ public class DatabaseRegistryUpdater implements FlywayCallback { + "registries" + File.separator; // Load updates to Bitstream format registry (if any) - log.info("Updating Bitstream Format Registry based on " + base + "bitstream-formats.xml"); + log.info("Updating Bitstream Format Registry based on {}bitstream-formats.xml", base); RegistryLoader.loadBitstreamFormats(context, base + "bitstream-formats.xml"); // Load updates to Metadata schema registries (if any) - log.info("Updating Metadata Registries based on metadata type configs in " + base); - MetadataImporter.loadRegistry(base + "dublin-core-types.xml", true); - MetadataImporter.loadRegistry(base + "dcterms-types.xml", true); - MetadataImporter.loadRegistry(base + "local-types.xml", true); - MetadataImporter.loadRegistry(base + "relationship-formats.xml", true); - MetadataImporter.loadRegistry(base + "person-types.xml", true); - MetadataImporter.loadRegistry(base + "project-types.xml", true); - MetadataImporter.loadRegistry(base + "orgunit-types.xml", true); - MetadataImporter.loadRegistry(base + "journal-types.xml", true); - MetadataImporter.loadRegistry(base + "journalissue-types.xml", true); - MetadataImporter.loadRegistry(base + "journalvolume-types.xml", true); - MetadataImporter.loadRegistry(base + "eperson-types.xml", true); - MetadataImporter.loadRegistry(base + "sword-metadata.xml", true); + log.info("Updating Metadata Registries based on metadata type configs in {}", base); + for (String namespaceFile: config.getArrayProperty("registry.metadata.load")) { + log.info("Reading {}", namespaceFile); + MetadataImporter.loadRegistry(base + namespaceFile, true); + } // Check if XML Workflow is enabled in workflow.cfg if (WorkflowServiceFactory.getInstance().getWorkflowService() instanceof XmlWorkflowService) { // If so, load in the workflow metadata types as well - MetadataImporter.loadRegistry(base + "workflow-types.xml", true); + String workflowTypes = "workflow-types.xml"; + log.info("Reading {}", workflowTypes); + MetadataImporter.loadRegistry(base + workflowTypes, true); } context.restoreAuthSystemState(); // Commit changes and close context context.complete(); log.info("All Bitstream Format Regitry and Metadata Registry updates were completed."); - } catch (Exception e) { + } catch (IOException | SQLException | ParserConfigurationException + | TransformerException | RegistryImportException + | AuthorizeException | NonUniqueMetadataException + | SAXException e) { log.error("Error attempting to update Bitstream Format and/or Metadata Registries", e); throw new RuntimeException("Error attempting to update Bitstream Format and/or Metadata Registries", e); } finally { diff --git a/dspace-oai/pom.xml b/dspace-oai/pom.xml index 1fa6631274..0e7f2bd0eb 100644 --- a/dspace-oai/pom.xml +++ b/dspace-oai/pom.xml @@ -1,9 +1,9 @@ 4.0.0 dspace-oai - war + jar DSpace OAI-PMH - DSpace OAI-PMH Web Application and API + DSpace OAI-PMH Extension dspace-parent @@ -16,34 +16,19 @@ ${basedir}/.. 3.2.10 - 2.0.1 + + 5.86.1.RELEASE - - org.apache.maven.plugins - maven-war-plugin - - true - - WEB-INF/lib/*.jar - WEB-INF/lib/*.jar - - true - - - - prepare-package - - - com.mycila license-maven-plugin - src/main/webapp/** + + src/main/resources/** **/*.xsl @@ -106,74 +91,63 @@ org.apache.commons commons-lang3 - - log4j - log4j - - - org.slf4j - slf4j-log4j12 - + + log4j + log4j + + + org.slf4j + slf4j-log4j12 + + + + org.codehaus.woodstox + wstx-asl + - + javax.inject javax.inject 1 + + - org.springframework - spring-webmvc - ${spring.version} - - - org.springframework - spring-beans - ${spring.version} - - - org.springframework - spring-context - ${spring.version} - - - org.springframework - spring-web - ${spring.version} + org.springframework.boot + spring-boot-starter + ${spring-boot.version} + + + org.springframework.boot + spring-boot-starter-logging + + - com.lyncode - jtwig-spring + org.jtwig + jtwig-spring-boot-starter ${jtwig.version} + - com.google.guava - guava + org.springframework.boot + spring-boot-starter-web + - org.javassist - javassist + org.ow2.asm + asm + - org.apache.commons - commons-lang3 + org.springframework.boot + spring-boot-configuration-processor - - javax.servlet - servlet-api - - - log4j - log4j - - - org.slf4j - slf4j-log4j12 - @@ -283,7 +257,7 @@ org.parboiled parboiled-core - 1.1.6 + 1.1.7 test @@ -293,24 +267,4 @@ test - - - - DSpace @ Lyncode - dspace@lyncode.com - Lyncode - http://www.lyncode.com - - - helix84 - Ivan Másar - helix84@centrum.sk - - - Ariel J. Lira - arieljlira@gmail.com - SeDiCI - http://sedici.unlp.edu.ar - - diff --git a/dspace-oai/src/main/java/org/dspace/app/configuration/OAIWebConfig.java b/dspace-oai/src/main/java/org/dspace/app/configuration/OAIWebConfig.java new file mode 100644 index 0000000000..806ecf9d07 --- /dev/null +++ b/dspace-oai/src/main/java/org/dspace/app/configuration/OAIWebConfig.java @@ -0,0 +1,75 @@ +/** + * 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.configuration; +import static java.lang.Integer.MAX_VALUE; + +import org.dspace.xoai.app.BasicConfiguration; +import org.dspace.xoai.services.api.xoai.ItemRepositoryResolver; +import org.dspace.xoai.services.impl.xoai.DSpaceItemRepositoryResolver; +import org.jtwig.spring.JtwigViewResolver; +import org.jtwig.spring.boot.config.JtwigViewResolverConfigurer; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +/** + * OAI-PMH webapp configuration. Replaces the old web.xml + *

+ * This @Configuration class is automatically discovered by Spring Boot via a @ComponentScan + * on the org.dspace.app.configuration package. + *

+ * + * + * @author Tim Donohue + */ +@Configuration +// Import additional configuration and beans from BasicConfiguration +@Import(BasicConfiguration.class) +// Scan for controllers in this package +@ComponentScan("org.dspace.xoai.controller") +public class OAIWebConfig extends WebMvcConfigurerAdapter implements JtwigViewResolverConfigurer { + + // Path where OAI is deployed. Defaults to "oai" + // NOTE: deployment on this path is handled by org.dspace.xoai.controller.DSpaceOAIDataProvider + @Value("${oai.path:oai}") + private String oaiPath; + + private static final String TWIG_HTML_EXTENSION = ".twig.html"; + private static final String VIEWS_LOCATION = "classpath:/templates/"; + + /** + * Ensure all resources under src/main/resources/static/ directory are available + * off the /{oai.path}/static subpath + **/ + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("/" + oaiPath + "/static/**") + .addResourceLocations("classpath:/static/") + .setCachePeriod(MAX_VALUE); + } + + /** + * Configure the Jtwig template engine for Spring Boot + * Ensures Jtwig looks for templates in proper location with proper extension + **/ + @Override + public void configure(JtwigViewResolver viewResolver) { + viewResolver.setPrefix(VIEWS_LOCATION); + viewResolver.setSuffix(TWIG_HTML_EXTENSION); + } + + @Bean + public ItemRepositoryResolver xoaiItemRepositoryResolver() { + return new DSpaceItemRepositoryResolver(); + } +} + diff --git a/dspace-oai/src/main/java/org/dspace/xoai/app/DSpaceWebappConfiguration.java b/dspace-oai/src/main/java/org/dspace/xoai/app/DSpaceWebappConfiguration.java deleted file mode 100644 index 8ad41abb65..0000000000 --- a/dspace-oai/src/main/java/org/dspace/xoai/app/DSpaceWebappConfiguration.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * 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.xoai.app; - -import static java.lang.Integer.MAX_VALUE; - -import com.lyncode.jtwig.mvc.JtwigViewResolver; -import org.dspace.xoai.services.api.xoai.ItemRepositoryResolver; -import org.dspace.xoai.services.impl.xoai.DSpaceItemRepositoryResolver; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.web.servlet.ViewResolver; -import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; - -@Import( { - BasicConfiguration.class -}) -@Configuration -@EnableWebMvc -@ComponentScan("org.dspace.xoai.controller") -public class DSpaceWebappConfiguration extends WebMvcConfigurerAdapter { - private static final String TWIG_HTML_EXTENSION = ".twig.html"; - private static final String VIEWS_LOCATION = "/WEB-INF/views/"; - - @Override - public void addResourceHandlers(ResourceHandlerRegistry registry) { - registry.addResourceHandler("/static/**") - .addResourceLocations("/static/") - .setCachePeriod(MAX_VALUE); - } - - @Override - public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) { - configurer.enable(); - } - - @Bean - public ViewResolver viewResolver() { - JtwigViewResolver viewResolver = new JtwigViewResolver(); - viewResolver.setPrefix(VIEWS_LOCATION); - viewResolver.setSuffix(TWIG_HTML_EXTENSION); - viewResolver.setCached(false); - - return viewResolver; - } - - @Bean - public ItemRepositoryResolver xoaiItemRepositoryResolver() { - return new DSpaceItemRepositoryResolver(); - } - -} diff --git a/dspace-oai/src/main/java/org/dspace/xoai/controller/DSpaceOAIDataProvider.java b/dspace-oai/src/main/java/org/dspace/xoai/controller/DSpaceOAIDataProvider.java index 96e82d8eae..212f1e3406 100644 --- a/dspace-oai/src/main/java/org/dspace/xoai/controller/DSpaceOAIDataProvider.java +++ b/dspace-oai/src/main/java/org/dspace/xoai/controller/DSpaceOAIDataProvider.java @@ -40,6 +40,7 @@ import org.dspace.xoai.services.api.xoai.ItemRepositoryResolver; import org.dspace.xoai.services.api.xoai.SetRepositoryResolver; import org.dspace.xoai.services.impl.xoai.DSpaceResumptionTokenFormatter; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.PathVariable; @@ -49,6 +50,10 @@ import org.springframework.web.bind.annotation.RequestMapping; * @author Lyncode Development Team (dspace at lyncode dot com) */ @Controller +// Use the configured "oai.path" for all requests, or "/oai" by default +@RequestMapping("/${oai.path:oai}") +// Only enable this controller if "oai.enabled=true" +@ConditionalOnProperty("oai.enabled") public class DSpaceOAIDataProvider { private static final Logger log = getLogger(DSpaceOAIDataProvider.class); @@ -67,7 +72,7 @@ public class DSpaceOAIDataProvider { private DSpaceResumptionTokenFormatter resumptionTokenFormat = new DSpaceResumptionTokenFormatter(); - @RequestMapping("/") + @RequestMapping({"", "/"}) public String indexAction(HttpServletResponse response, Model model) throws ServletException { try { XOAIManager manager = xoaiManagerResolver.getManager(); diff --git a/dspace-oai/src/main/java/org/dspace/xoai/services/impl/DSpaceEarliestDateResolver.java b/dspace-oai/src/main/java/org/dspace/xoai/services/impl/DSpaceEarliestDateResolver.java index de8dc0d4ad..ba51c62d1b 100644 --- a/dspace-oai/src/main/java/org/dspace/xoai/services/impl/DSpaceEarliestDateResolver.java +++ b/dspace-oai/src/main/java/org/dspace/xoai/services/impl/DSpaceEarliestDateResolver.java @@ -10,6 +10,8 @@ package org.dspace.xoai.services.impl; import java.sql.SQLException; import java.util.Date; +import javax.persistence.NoResultException; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.dspace.content.MetadataValue; @@ -30,11 +32,16 @@ public class DSpaceEarliestDateResolver implements EarliestDateResolver { @Override public Date getEarliestDate(Context context) throws InvalidMetadataFieldException, SQLException { - String query = "SELECT MIN(text_value) as value FROM metadatavalue WHERE metadata_field_id = ?"; - MetadataValueService metadataValueService = ContentServiceFactory.getInstance().getMetadataValueService(); - MetadataValue minimum = metadataValueService.getMinimum(context, - fieldResolver.getFieldID(context, "dc.date.available")); + MetadataValue minimum = null; + try { + minimum = metadataValueService.getMinimum(context, + fieldResolver.getFieldID(context, "dc.date.available")); + } catch (NoResultException e) { + // This error only occurs if no metadataFields of this type exist (i.e. no minimum exists) + // It can be safely ignored in this scenario, as it implies the DSpace is empty. + } + if (null != minimum) { String str = minimum.getValue(); try { diff --git a/dspace-oai/src/main/java/org/dspace/xoai/services/impl/xoai/DSpaceRepositoryConfiguration.java b/dspace-oai/src/main/java/org/dspace/xoai/services/impl/xoai/DSpaceRepositoryConfiguration.java index 979520c199..fe7fbdbfd0 100644 --- a/dspace-oai/src/main/java/org/dspace/xoai/services/impl/xoai/DSpaceRepositoryConfiguration.java +++ b/dspace-oai/src/main/java/org/dspace/xoai/services/impl/xoai/DSpaceRepositoryConfiguration.java @@ -27,6 +27,8 @@ import org.dspace.xoai.services.api.EarliestDateResolver; import org.dspace.xoai.services.api.config.ConfigurationService; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; +import org.springframework.web.util.UriComponentsBuilder; /** * @author Lyncode Development Team (dspace at lyncode dot com) @@ -68,17 +70,27 @@ public class DSpaceRepositoryConfiguration implements RepositoryConfiguration { public String getBaseUrl() { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()) .getRequest(); + + // Parse the current OAI "context" path out of the last HTTP request. + // (e.g. for "http://mydspace.edu/oai/request", the oaiContextPath is "request") + UriComponentsBuilder builder = ServletUriComponentsBuilder.fromRequest(request); + List pathSegments = builder.buildAndExpand().getPathSegments(); + String oaiContextPath = pathSegments.get(pathSegments.size() - 1); + if (baseUrl == null) { baseUrl = configurationService.getProperty("oai.url"); if (baseUrl == null) { log.warn( "{ OAI 2.0 :: DSpace } Not able to retrieve the oai.url property from oai.cfg. Falling back to " + "request address"); + // initialize baseUrl to a fallback "oai.url" which is the current request with OAI context removed. baseUrl = request.getRequestURL().toString() - .replace(request.getPathInfo(), ""); + .replace(oaiContextPath, ""); } } - return baseUrl + request.getPathInfo(); + + // BaseURL is the path of OAI with the current OAI context appended + return baseUrl + "/" + oaiContextPath; } @Override diff --git a/dspace-oai/src/main/webapp/static/css/bootstrap-theme.css b/dspace-oai/src/main/resources/static/css/bootstrap-theme.css similarity index 100% rename from dspace-oai/src/main/webapp/static/css/bootstrap-theme.css rename to dspace-oai/src/main/resources/static/css/bootstrap-theme.css diff --git a/dspace-oai/src/main/webapp/static/css/bootstrap-theme.min.css b/dspace-oai/src/main/resources/static/css/bootstrap-theme.min.css similarity index 100% rename from dspace-oai/src/main/webapp/static/css/bootstrap-theme.min.css rename to dspace-oai/src/main/resources/static/css/bootstrap-theme.min.css diff --git a/dspace-oai/src/main/webapp/static/css/bootstrap.css b/dspace-oai/src/main/resources/static/css/bootstrap.css similarity index 100% rename from dspace-oai/src/main/webapp/static/css/bootstrap.css rename to dspace-oai/src/main/resources/static/css/bootstrap.css diff --git a/dspace-oai/src/main/webapp/static/css/bootstrap.min.css b/dspace-oai/src/main/resources/static/css/bootstrap.min.css similarity index 100% rename from dspace-oai/src/main/webapp/static/css/bootstrap.min.css rename to dspace-oai/src/main/resources/static/css/bootstrap.min.css diff --git a/dspace-oai/src/main/webapp/static/css/style.css b/dspace-oai/src/main/resources/static/css/style.css similarity index 100% rename from dspace-oai/src/main/webapp/static/css/style.css rename to dspace-oai/src/main/resources/static/css/style.css diff --git a/dspace-oai/src/main/webapp/static/fonts/glyphicons-halflings-regular.eot b/dspace-oai/src/main/resources/static/fonts/glyphicons-halflings-regular.eot similarity index 100% rename from dspace-oai/src/main/webapp/static/fonts/glyphicons-halflings-regular.eot rename to dspace-oai/src/main/resources/static/fonts/glyphicons-halflings-regular.eot diff --git a/dspace-oai/src/main/webapp/static/fonts/glyphicons-halflings-regular.svg b/dspace-oai/src/main/resources/static/fonts/glyphicons-halflings-regular.svg similarity index 100% rename from dspace-oai/src/main/webapp/static/fonts/glyphicons-halflings-regular.svg rename to dspace-oai/src/main/resources/static/fonts/glyphicons-halflings-regular.svg diff --git a/dspace-oai/src/main/webapp/static/fonts/glyphicons-halflings-regular.ttf b/dspace-oai/src/main/resources/static/fonts/glyphicons-halflings-regular.ttf similarity index 100% rename from dspace-oai/src/main/webapp/static/fonts/glyphicons-halflings-regular.ttf rename to dspace-oai/src/main/resources/static/fonts/glyphicons-halflings-regular.ttf diff --git a/dspace-oai/src/main/webapp/static/fonts/glyphicons-halflings-regular.woff b/dspace-oai/src/main/resources/static/fonts/glyphicons-halflings-regular.woff similarity index 100% rename from dspace-oai/src/main/webapp/static/fonts/glyphicons-halflings-regular.woff rename to dspace-oai/src/main/resources/static/fonts/glyphicons-halflings-regular.woff diff --git a/dspace-oai/src/main/webapp/static/img/lyncode.png b/dspace-oai/src/main/resources/static/img/lyncode.png similarity index 100% rename from dspace-oai/src/main/webapp/static/img/lyncode.png rename to dspace-oai/src/main/resources/static/img/lyncode.png diff --git a/dspace-oai/src/main/webapp/static/js/bootstrap.js b/dspace-oai/src/main/resources/static/js/bootstrap.js similarity index 100% rename from dspace-oai/src/main/webapp/static/js/bootstrap.js rename to dspace-oai/src/main/resources/static/js/bootstrap.js diff --git a/dspace-oai/src/main/webapp/static/js/bootstrap.min.js b/dspace-oai/src/main/resources/static/js/bootstrap.min.js similarity index 100% rename from dspace-oai/src/main/webapp/static/js/bootstrap.min.js rename to dspace-oai/src/main/resources/static/js/bootstrap.min.js diff --git a/dspace-oai/src/main/webapp/static/js/jquery.js b/dspace-oai/src/main/resources/static/js/jquery.js similarity index 100% rename from dspace-oai/src/main/webapp/static/js/jquery.js rename to dspace-oai/src/main/resources/static/js/jquery.js diff --git a/dspace-oai/src/main/webapp/static/lyncode.png b/dspace-oai/src/main/resources/static/lyncode.png similarity index 100% rename from dspace-oai/src/main/webapp/static/lyncode.png rename to dspace-oai/src/main/resources/static/lyncode.png diff --git a/dspace-oai/src/main/webapp/static/style.xsl b/dspace-oai/src/main/resources/static/style.xsl similarity index 100% rename from dspace-oai/src/main/webapp/static/style.xsl rename to dspace-oai/src/main/resources/static/style.xsl diff --git a/dspace-oai/src/main/webapp/WEB-INF/views/index.twig.html b/dspace-oai/src/main/resources/templates/index.twig.html similarity index 74% rename from dspace-oai/src/main/webapp/WEB-INF/views/index.twig.html rename to dspace-oai/src/main/resources/templates/index.twig.html index fc530902a3..0045d8f5e5 100644 --- a/dspace-oai/src/main/webapp/WEB-INF/views/index.twig.html +++ b/dspace-oai/src/main/resources/templates/index.twig.html @@ -6,6 +6,12 @@ http://www.dspace.org/license/ +#} +{# + + DSpace OAI default index template. To override this template, place a customized version in + the [webapp]/WEB-INF/classes/templates/ folder, and reboot your servlet engine. + #} @@ -13,8 +19,8 @@ DSpace OAI-PMH Data Provider - - + + @@ -24,9 +30,9 @@ - - - + + + @@ -56,11 +62,11 @@

@@ -73,11 +79,11 @@

Design by Lyncode

- Lyncode + Lyncode

- \ No newline at end of file + diff --git a/dspace-oai/src/main/webapp/WEB-INF/spring/applicationContext.xml b/dspace-oai/src/main/webapp/WEB-INF/spring/applicationContext.xml deleted file mode 100644 index 0b6f2cde61..0000000000 --- a/dspace-oai/src/main/webapp/WEB-INF/spring/applicationContext.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dspace-oai/src/main/webapp/WEB-INF/web.xml b/dspace-oai/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index d731a0c659..0000000000 --- a/dspace-oai/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - XOAI Data Provider - - - The location of the DSpace home directory - dspace.dir - ${dspace.dir} - - - - log4jConfiguration - ${dspace.dir}/config/log4j2.xml - The location of the Log4J configuration - - - - - - contextConfigLocation - /WEB-INF/spring/*.xml - - - - - org.dspace.app.util.DSpaceContextListener - - - - - - org.dspace.servicemanager.servlet.DSpaceKernelServletContextListener - - - - - - org.dspace.app.util.DSpaceWebappListener - - - - - org.springframework.web.context.ContextLoaderListener - - - - oai - org.springframework.web.servlet.DispatcherServlet - - - contextClass - - org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - - - - contextConfigLocation - org.dspace.xoai.app.DSpaceWebappConfiguration - - - - - - oai - /* - - - diff --git a/dspace-oai/src/test/java/org/dspace/xoai/tests/DSpaceBasicTestConfiguration.java b/dspace-oai/src/test/java/org/dspace/xoai/tests/DSpaceBasicTestConfiguration.java index e50f2f969d..7b81468a8e 100644 --- a/dspace-oai/src/test/java/org/dspace/xoai/tests/DSpaceBasicTestConfiguration.java +++ b/dspace-oai/src/test/java/org/dspace/xoai/tests/DSpaceBasicTestConfiguration.java @@ -10,11 +10,9 @@ package org.dspace.xoai.tests; import static org.mockito.Mockito.mock; import org.dspace.xoai.services.api.FieldResolver; -import org.dspace.xoai.services.api.config.ConfigurationService; import org.dspace.xoai.services.api.context.ContextService; import org.dspace.xoai.services.api.xoai.DSpaceFilterResolver; import org.dspace.xoai.services.impl.xoai.BaseDSpaceFilterResolver; -import org.dspace.xoai.tests.helpers.stubs.StubbedConfigurationService; import org.dspace.xoai.tests.helpers.stubs.StubbedFieldResolver; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -29,14 +27,6 @@ public class DSpaceBasicTestConfiguration { return new BaseDSpaceFilterResolver(); } - - private StubbedConfigurationService configurationService = new StubbedConfigurationService(); - - @Bean - public ConfigurationService configurationService() { - return configurationService; - } - @Bean public ContextService contextService() { return mock(ContextService.class); diff --git a/dspace-oai/src/test/java/org/dspace/xoai/tests/DSpaceTestConfiguration.java b/dspace-oai/src/test/java/org/dspace/xoai/tests/DSpaceTestConfiguration.java deleted file mode 100644 index bc526cdf53..0000000000 --- a/dspace-oai/src/test/java/org/dspace/xoai/tests/DSpaceTestConfiguration.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * 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.xoai.tests; - -import com.lyncode.xoai.dataprovider.services.api.ItemRepository; -import com.lyncode.xoai.dataprovider.services.api.ResourceResolver; -import com.lyncode.xoai.dataprovider.services.api.SetRepository; -import org.dspace.core.Context; -import org.dspace.xoai.services.api.EarliestDateResolver; -import org.dspace.xoai.services.api.cache.XOAICacheService; -import org.dspace.xoai.services.api.config.XOAIManagerResolver; -import org.dspace.xoai.services.api.context.ContextService; -import org.dspace.xoai.services.api.context.ContextServiceException; -import org.dspace.xoai.services.api.xoai.IdentifyResolver; -import org.dspace.xoai.services.api.xoai.ItemRepositoryResolver; -import org.dspace.xoai.services.api.xoai.SetRepositoryResolver; -import org.dspace.xoai.services.impl.cache.DSpaceEmptyCacheService; -import org.dspace.xoai.services.impl.xoai.DSpaceIdentifyResolver; -import org.dspace.xoai.tests.helpers.stubs.StubbedEarliestDateResolver; -import org.dspace.xoai.tests.helpers.stubs.StubbedResourceResolver; -import org.dspace.xoai.tests.helpers.stubs.StubbedSetRepository; -import org.dspace.xoai.tests.helpers.stubs.StubbedXOAIManagerResolver; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; -import org.springframework.web.servlet.ViewResolver; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; -import org.springframework.web.servlet.view.InternalResourceViewResolver; - -@Import(DSpaceBasicTestConfiguration.class) -@Configuration -@EnableWebMvc -public class DSpaceTestConfiguration extends WebMvcConfigurerAdapter { - private static final String TWIG_HTML_EXTENSION = ".twig.html"; - private static final String VIEWS_LOCATION = "/WEB-INF/views/"; - - - @Bean - public ContextService contextService() { - return new ContextService() { - @Override - public Context getContext() throws ContextServiceException { - return null; - } - }; - } - - private StubbedResourceResolver resourceResolver = new StubbedResourceResolver(); - - @Bean - public ResourceResolver resourceResolver() { - return resourceResolver; - } - - @Bean - public ViewResolver viewResolver() { - InternalResourceViewResolver viewResolver = new InternalResourceViewResolver(); - viewResolver.setPrefix(VIEWS_LOCATION); - viewResolver.setSuffix(TWIG_HTML_EXTENSION); -// viewResolver.setCached(true); -// viewResolver.setTheme(null); - - return viewResolver; - } - - - @Bean - public XOAIManagerResolver xoaiManagerResolver() { - return new StubbedXOAIManagerResolver(); - } - - @Bean - public XOAICacheService xoaiCacheService() { - return new DSpaceEmptyCacheService(); - } - - private StubbedSetRepository setRepository = new StubbedSetRepository(); - - @Bean - StubbedSetRepository setRepository() { - return setRepository; - } - - @Bean - public ItemRepositoryResolver itemRepositoryResolver() { - return new ItemRepositoryResolver() { - @Override - public ItemRepository getItemRepository() throws ContextServiceException { - try { - return null; - } catch (Exception e) { - throw new ContextServiceException(e); - } - } - }; - } - - @Bean - public SetRepositoryResolver setRepositoryResolver() { - return new SetRepositoryResolver() { - @Override - public SetRepository getSetRepository() throws ContextServiceException { - return setRepository; - } - }; - } - - @Bean - public IdentifyResolver identifyResolver() { - return new DSpaceIdentifyResolver(); - } - - @Bean - public EarliestDateResolver earliestDateResolver() { - return new StubbedEarliestDateResolver(); - } -} diff --git a/dspace-oai/src/test/java/org/dspace/xoai/tests/helpers/HttpRequestBuilder.java b/dspace-oai/src/test/java/org/dspace/xoai/tests/helpers/HttpRequestBuilder.java deleted file mode 100644 index 153b05576e..0000000000 --- a/dspace-oai/src/test/java/org/dspace/xoai/tests/helpers/HttpRequestBuilder.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * 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.xoai.tests.helpers; - -import java.net.URI; -import java.net.URISyntaxException; -import javax.servlet.http.HttpServletRequest; - -import org.springframework.mock.web.MockHttpServletRequest; - -public class HttpRequestBuilder { - private MockHttpServletRequest request = new MockHttpServletRequest(); - - public HttpRequestBuilder withUrl(String url) { - try { - URI uri = new URI(url); - } catch (URISyntaxException e) { - // ASD - } - return this; - } - - public HttpRequestBuilder usingGetMethod() { - request.setMethod("GET"); - return this; - } - - public HttpServletRequest build() { - - return request; - } -} diff --git a/dspace-oai/src/test/java/org/dspace/xoai/tests/helpers/SyntacticSugar.java b/dspace-oai/src/test/java/org/dspace/xoai/tests/helpers/SyntacticSugar.java deleted file mode 100644 index a6cd3a3249..0000000000 --- a/dspace-oai/src/test/java/org/dspace/xoai/tests/helpers/SyntacticSugar.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * 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.xoai.tests.helpers; - -public class SyntacticSugar { - - /** - * Default constructor - */ - private SyntacticSugar() { } - - public static T given(T elem) { - return elem; - } - - public static T the(T elem) { - return elem; - } - - public static T and(T elem) { - return elem; - } -} diff --git a/dspace-oai/src/test/java/org/dspace/xoai/tests/helpers/stubs/ItemRepositoryBuilder.java b/dspace-oai/src/test/java/org/dspace/xoai/tests/helpers/stubs/ItemRepositoryBuilder.java deleted file mode 100644 index c01580e990..0000000000 --- a/dspace-oai/src/test/java/org/dspace/xoai/tests/helpers/stubs/ItemRepositoryBuilder.java +++ /dev/null @@ -1,183 +0,0 @@ -/** - * 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.xoai.tests.helpers.stubs; - -import static com.lyncode.xoai.dataprovider.core.Granularity.Second; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.sql.SQLException; -import java.text.ParseException; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import javax.xml.stream.XMLStreamException; - -import com.lyncode.xoai.builders.dataprovider.ElementBuilder; -import com.lyncode.xoai.builders.dataprovider.MetadataBuilder; -import com.lyncode.xoai.dataprovider.exceptions.MetadataBindException; -import com.lyncode.xoai.dataprovider.exceptions.WritingXmlException; -import com.lyncode.xoai.dataprovider.xml.XmlOutputContext; -import com.lyncode.xoai.dataprovider.xml.xoai.Metadata; -import org.apache.solr.client.solrj.SolrClient; -import org.apache.solr.client.solrj.SolrServerException; -import org.apache.solr.common.SolrInputDocument; - -public class ItemRepositoryBuilder { - private final SolrClient solrServer; - - public ItemRepositoryBuilder(SolrClient solrServer) { - this.solrServer = solrServer; - } - - public ItemRepositoryBuilder withItem(DSpaceItemBuilder builder) { - try { - solrServer.add(index(builder)); - solrServer.commit(); - } catch (MetadataBindException | WritingXmlException | IOException - | SQLException | ParseException | XMLStreamException - | SolrServerException e) { - throw new RuntimeException(e); - } - return this; - } - - - private SolrInputDocument index(DSpaceItemBuilder item) - throws SQLException, MetadataBindException, ParseException, XMLStreamException, WritingXmlException { - SolrInputDocument doc = new SolrInputDocument(); - - doc.addField("item.id", item.getId()); - doc.addField("item.public", item.isPublic()); - doc.addField("item.lastmodified", item.getLastModifiedDate()); - doc.addField("item.submitter", item.getSubmitter()); - doc.addField("item.handle", item.getHandle()); - doc.addField("item.deleted", item.isDeleted()); - - for (String col : item.getCollections()) { - doc.addField("item.collections", col); - } - - for (String col : item.getCommunities()) { - doc.addField("item.communities", col); - } - - ByteArrayOutputStream out = new ByteArrayOutputStream(); - XmlOutputContext context = XmlOutputContext.emptyContext(out, Second); - item.getMetadata().write(context); - context.getWriter().flush(); - context.getWriter().close(); - doc.addField("item.compile", out.toString()); - - return doc; - } - - public static class DSpaceItemBuilder { - private final List collections = new ArrayList<>(); - private final List communities = new ArrayList<>(); - private final MetadataBuilder metadataBuilder = new MetadataBuilder(); - private String handle; - private int id; - private String submitter; - private Date lastModifiedDate; - private boolean deleted; - private boolean aPublic = true; - - - public DSpaceItemBuilder withLastModifiedDate(Date lastModifiedDate) { - this.lastModifiedDate = lastModifiedDate; - return this; - } - - public DSpaceItemBuilder withCollection(String colName) { - collections.add(colName); - return this; - } - - public DSpaceItemBuilder withCommunity(String comName) { - communities.add(comName); - return this; - } - - public DSpaceItemBuilder whichSsPublic() { - aPublic = true; - return this; - } - - public DSpaceItemBuilder whichSsPrivate() { - aPublic = false; - return this; - } - - public DSpaceItemBuilder whichIsDeleted() { - this.deleted = true; - return this; - } - - public DSpaceItemBuilder whichIsNotDeleted() { - this.deleted = false; - return this; - } - - public DSpaceItemBuilder withMetadata(String schema, String element, String value) { - metadataBuilder.withElement(new ElementBuilder().withName(schema).withField(element, value).build()); - return this; - } - - public String getHandle() { - return handle; - } - - public DSpaceItemBuilder withHandle(String handle) { - this.handle = handle; - return this; - } - - public DSpaceItemBuilder withSubmitter(String submitter) { - this.submitter = submitter; - return this; - } - - public DSpaceItemBuilder withId(int id) { - this.id = id; - return this; - } - - public int getId() { - return id; - } - - public String getSubmitter() { - return submitter; - } - - public Date getLastModifiedDate() { - return lastModifiedDate; - } - - public List getCollections() { - return collections; - } - - public List getCommunities() { - return communities; - } - - public Metadata getMetadata() { - return metadataBuilder.build(); - } - - public boolean isDeleted() { - return deleted; - } - - public boolean isPublic() { - return aPublic; - } - } -} diff --git a/dspace-oai/src/test/java/org/dspace/xoai/tests/helpers/stubs/StubbedConfigurationService.java b/dspace-oai/src/test/java/org/dspace/xoai/tests/helpers/stubs/StubbedConfigurationService.java deleted file mode 100644 index c6e7a3cc99..0000000000 --- a/dspace-oai/src/test/java/org/dspace/xoai/tests/helpers/stubs/StubbedConfigurationService.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * 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.xoai.tests.helpers.stubs; - -import java.util.HashMap; -import java.util.Map; - -import org.dspace.xoai.services.api.config.ConfigurationService; - -public class StubbedConfigurationService implements ConfigurationService { - private Map values = new HashMap(); - - - public StubbedConfigurationService hasBooleanProperty(String key, boolean value) { - values.put(key, value); - return this; - } - - public StubbedConfigurationService hasBooleanProperty(String module, String key, boolean value) { - values.put(module + "." + key, value); - return this; - } - - public StubbedConfigurationService hasProperty(String key, String value) { - values.put(key, value); - return this; - } - - public StubbedConfigurationService withoutProperty(String key) { - values.remove(key); - return this; - } - - public StubbedConfigurationService hasProperty(String module, String key, String value) { - values.put(module + "." + key, value); - return this; - } - - @Override - public String getProperty(String key) { - return (String) values.get(key); - } - - @Override - public String getProperty(String module, String key) { - return (String) values.get(module + "." + key); - } - - @Override - public boolean getBooleanProperty(String module, String key, boolean defaultValue) { - Boolean value = (Boolean) values.get(module + "." + key); - if (value == null) { - return defaultValue; - } else { - return value; - } - } -} diff --git a/dspace-oai/src/test/java/org/dspace/xoai/tests/helpers/stubs/StubbedEarliestDateResolver.java b/dspace-oai/src/test/java/org/dspace/xoai/tests/helpers/stubs/StubbedEarliestDateResolver.java deleted file mode 100644 index a585e1427e..0000000000 --- a/dspace-oai/src/test/java/org/dspace/xoai/tests/helpers/stubs/StubbedEarliestDateResolver.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * 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.xoai.tests.helpers.stubs; - -import java.sql.SQLException; -import java.util.Date; - -import org.dspace.core.Context; -import org.dspace.xoai.exceptions.InvalidMetadataFieldException; -import org.dspace.xoai.services.api.EarliestDateResolver; - -public class StubbedEarliestDateResolver implements EarliestDateResolver { - private Date date = new Date(); - - public StubbedEarliestDateResolver is(Date date) { - this.date = date; - return this; - } - - @Override - public Date getEarliestDate(Context context) throws InvalidMetadataFieldException, SQLException { - return date; - } -} diff --git a/dspace-oai/src/test/java/org/dspace/xoai/tests/helpers/stubs/StubbedResourceResolver.java b/dspace-oai/src/test/java/org/dspace/xoai/tests/helpers/stubs/StubbedResourceResolver.java deleted file mode 100644 index 464f8fc487..0000000000 --- a/dspace-oai/src/test/java/org/dspace/xoai/tests/helpers/stubs/StubbedResourceResolver.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * 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.xoai.tests.helpers.stubs; - -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerFactory; - -import com.lyncode.xoai.dataprovider.services.api.ResourceResolver; - -public class StubbedResourceResolver implements ResourceResolver { - private static TransformerFactory factory = TransformerFactory.newInstance(); - - private Map inputStreamMap = new HashMap(); - private Map transformerMap = new HashMap(); - - @Override - public InputStream getResource(String path) throws IOException { - return inputStreamMap.get(path); - } - - @Override - public Transformer getTransformer(String path) throws IOException, TransformerConfigurationException { - return transformerMap.get(path); - } - - public StubbedResourceResolver hasIdentityTransformerFor(String path) { - try { - transformerMap.put(path, factory.newTransformer()); - } catch (TransformerConfigurationException e) { - throw new RuntimeException(e); - } - return this; - } -} diff --git a/dspace-oai/src/test/java/org/dspace/xoai/tests/helpers/stubs/StubbedSetRepository.java b/dspace-oai/src/test/java/org/dspace/xoai/tests/helpers/stubs/StubbedSetRepository.java deleted file mode 100644 index 8432633e7b..0000000000 --- a/dspace-oai/src/test/java/org/dspace/xoai/tests/helpers/stubs/StubbedSetRepository.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * 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.xoai.tests.helpers.stubs; - -import static java.lang.Math.min; -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; - -import java.util.ArrayList; -import java.util.List; - -import com.lyncode.xoai.dataprovider.core.ListSetsResult; -import com.lyncode.xoai.dataprovider.core.Set; -import com.lyncode.xoai.dataprovider.services.api.SetRepository; - -public class StubbedSetRepository implements SetRepository { - private List sets = new ArrayList(); - private boolean supports = false; - - @Override - public boolean supportSets() { - return supports; - } - - @Override - public ListSetsResult retrieveSets(int offset, int length) { - if (offset > sets.size()) { - return new ListSetsResult(false, new ArrayList(), sets.size()); - } - return new ListSetsResult(offset + length < sets.size(), - sets.subList(offset, min(offset + length, sets.size())), sets.size()); - } - - @Override - public boolean exists(String setSpec) { - for (Set set : sets) { - if (set.getSetSpec().equals(setSpec)) { - return true; - } - } - - return false; - } - - public StubbedSetRepository doesSupportSets() { - this.supports = true; - return this; - } - - public StubbedSetRepository doesNotSupportSets() { - this.supports = false; - return this; - } - - public StubbedSetRepository withSet(String name, String spec) { - this.sets.add(new Set(spec, name)); - return this; - } - - public StubbedSetRepository withRandomlyGeneratedSets(int number) { - for (int i = 0; i < number; i++) { - this.sets.add(new Set(randomAlphabetic(10), randomAlphabetic(10))); - } - return this; - } - - public void clear() { - this.sets.clear(); - } -} diff --git a/dspace-oai/src/test/java/org/dspace/xoai/tests/helpers/stubs/StubbedXOAIManagerResolver.java b/dspace-oai/src/test/java/org/dspace/xoai/tests/helpers/stubs/StubbedXOAIManagerResolver.java deleted file mode 100644 index f0d3275f74..0000000000 --- a/dspace-oai/src/test/java/org/dspace/xoai/tests/helpers/stubs/StubbedXOAIManagerResolver.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * 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.xoai.tests.helpers.stubs; - -import com.lyncode.xoai.dataprovider.core.XOAIManager; -import com.lyncode.xoai.dataprovider.exceptions.ConfigurationException; -import com.lyncode.xoai.dataprovider.services.api.ResourceResolver; -import com.lyncode.xoai.dataprovider.xml.xoaiconfig.Configuration; -import org.dspace.xoai.services.api.config.XOAIManagerResolver; -import org.dspace.xoai.services.api.config.XOAIManagerResolverException; -import org.dspace.xoai.services.api.xoai.DSpaceFilterResolver; -import org.springframework.beans.factory.annotation.Autowired; - -public class StubbedXOAIManagerResolver implements XOAIManagerResolver { - @Autowired - ResourceResolver resourceResolver; - @Autowired - DSpaceFilterResolver filterResolver; - - private Configuration builder = new Configuration(); - - public Configuration configuration() { - return builder; - } - - @Override - public XOAIManager getManager() throws XOAIManagerResolverException { - try { - return new XOAIManager(filterResolver, resourceResolver, builder); - } catch (ConfigurationException e) { - throw new XOAIManagerResolverException(e); - } - } -} diff --git a/dspace-oai/src/test/java/org/dspace/xoai/tests/integration/xoai/AbstractDSpaceTest.java b/dspace-oai/src/test/java/org/dspace/xoai/tests/integration/xoai/AbstractDSpaceTest.java deleted file mode 100644 index d9824d8c53..0000000000 --- a/dspace-oai/src/test/java/org/dspace/xoai/tests/integration/xoai/AbstractDSpaceTest.java +++ /dev/null @@ -1,186 +0,0 @@ -/** - * 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.xoai.tests.integration.xoai; - -import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup; - -import java.util.Date; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import javax.xml.xpath.XPathExpressionException; - -import com.lyncode.builder.MapBuilder; -import com.lyncode.xoai.dataprovider.services.api.ResourceResolver; -import com.lyncode.xoai.dataprovider.services.impl.BaseDateProvider; -import com.lyncode.xoai.dataprovider.xml.xoaiconfig.Configuration; -import com.lyncode.xoai.dataprovider.xml.xoaiconfig.FormatConfiguration; -import org.apache.solr.client.solrj.SolrClient; -import org.dspace.xoai.controller.DSpaceOAIDataProvider; -import org.dspace.xoai.services.api.EarliestDateResolver; -import org.dspace.xoai.services.api.FieldResolver; -import org.dspace.xoai.services.api.config.ConfigurationService; -import org.dspace.xoai.services.api.config.XOAIManagerResolver; -import org.dspace.xoai.tests.DSpaceTestConfiguration; -import org.dspace.xoai.tests.helpers.stubs.ItemRepositoryBuilder; -import org.dspace.xoai.tests.helpers.stubs.StubbedConfigurationService; -import org.dspace.xoai.tests.helpers.stubs.StubbedEarliestDateResolver; -import org.dspace.xoai.tests.helpers.stubs.StubbedFieldResolver; -import org.dspace.xoai.tests.helpers.stubs.StubbedResourceResolver; -import org.dspace.xoai.tests.helpers.stubs.StubbedSetRepository; -import org.dspace.xoai.tests.helpers.stubs.StubbedXOAIManagerResolver; -import org.junit.After; -import org.junit.Before; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.web.WebAppConfiguration; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.ResultMatcher; -import org.springframework.test.web.servlet.result.MockMvcResultMatchers; -import org.springframework.test.web.servlet.result.XpathResultMatchers; -import org.springframework.web.context.WebApplicationContext; - - -@RunWith(SpringJUnit4ClassRunner.class) -@WebAppConfiguration -@ContextConfiguration(classes = {DSpaceTestConfiguration.class, DSpaceOAIDataProvider.class}) -public abstract class AbstractDSpaceTest { - private static final BaseDateProvider baseDateProvider = new BaseDateProvider(); - @Autowired - WebApplicationContext wac; - private MockMvc mockMvc; - - private StubbedXOAIManagerResolver xoaiManagerResolver; - private StubbedConfigurationService configurationService; - private StubbedFieldResolver databaseService; - private StubbedEarliestDateResolver earliestDateResolver; - private StubbedSetRepository setRepository; - private StubbedResourceResolver resourceResolver; - private SolrClient solrServer; - - @Before - public void setup() { - xoaiManagerResolver = (StubbedXOAIManagerResolver) this.wac.getBean(XOAIManagerResolver.class); - configurationService = (StubbedConfigurationService) this.wac.getBean(ConfigurationService.class); - databaseService = (StubbedFieldResolver) this.wac.getBean(FieldResolver.class); - earliestDateResolver = (StubbedEarliestDateResolver) this.wac.getBean(EarliestDateResolver.class); - setRepository = this.wac.getBean(StubbedSetRepository.class); - setRepository.clear(); -// solrServer = this.wac.getBean(SolrServer.class); - resourceResolver = (StubbedResourceResolver) this.wac.getBean(ResourceResolver.class); - xoaiManagerResolver.configuration(); - } - - @After - public void teardown() { - // Nullify all resources so that JUnit will clean them up - xoaiManagerResolver = null; - configurationService = null; - databaseService = null; - earliestDateResolver = null; - setRepository = null; - resourceResolver = null; - mockMvc = null; - solrServer = null; - } - - protected MockMvc againstTheDataProvider() { - if (this.mockMvc == null) { - this.mockMvc = webAppContextSetup(this.wac).build(); - } - return this.mockMvc; - } - - protected Configuration theConfiguration() { - return xoaiManagerResolver.configuration(); - } - - protected StubbedConfigurationService theDSpaceConfiguration() { - return configurationService; - } - - protected StubbedFieldResolver theDatabase() { - return databaseService; - } - - protected StubbedEarliestDateResolver theEarlistEarliestDate() { - return earliestDateResolver; - } - - protected XpathResultMatchers oaiXPath(String xpath) throws XPathExpressionException { - return MockMvcResultMatchers.xpath(this.replaceXpath(xpath), new MapBuilder() - .withPair("o", "http://www.openarchives.org/OAI/2.0/") - .build()); - } - - private String replaceXpath(String xpath) { - int offset = 0; - String newXpath = ""; - Pattern pattern = Pattern.compile("/[^/]+"); - Matcher matcher = pattern.matcher(xpath); - while (matcher.find()) { - if (matcher.start() > offset) { - newXpath += xpath.substring(offset, matcher.start()); - } - if (!matcher.group().contains(":") && !matcher.group().startsWith("/@")) { - newXpath += "/o:" + matcher.group().substring(1); - } else { - newXpath += matcher.group(); - } - offset = matcher.end() + 1; - } - - return newXpath; - } - - protected String representationOfDate(Date date) { - return baseDateProvider.format(date); - } - - protected StubbedSetRepository theSetRepository() { - return setRepository; - } - - protected com.lyncode.xoai.dataprovider.xml.xoaiconfig.ContextConfiguration aContext(String baseUrl) { - return new com.lyncode.xoai.dataprovider.xml.xoaiconfig.ContextConfiguration(baseUrl); - } - - protected XpathResultMatchers responseDate() throws XPathExpressionException { - return oaiXPath("/OAI-PMH/responseDate"); - } - - protected ResultMatcher verb(org.hamcrest.Matcher matcher) throws XPathExpressionException { - return oaiXPath("/OAI-PMH/request/@verb").string(matcher); - } - - protected XpathResultMatchers resumptionToken() throws XPathExpressionException { - return oaiXPath("//resumptionToken"); - } - - protected StubbedResourceResolver theResourseResolver() { - return resourceResolver; - } - - protected FormatConfiguration aFormat(String id) { - return new FormatConfiguration(id); - } - - protected ItemRepositoryBuilder.DSpaceItemBuilder anItem() { - return new ItemRepositoryBuilder.DSpaceItemBuilder(); - } - - private ItemRepositoryBuilder itemRepositoryBuilder; - - public ItemRepositoryBuilder theItemRepository() { - if (itemRepositoryBuilder == null) { - itemRepositoryBuilder = new ItemRepositoryBuilder(solrServer); - } - return itemRepositoryBuilder; - } -} \ No newline at end of file diff --git a/dspace-oai/src/test/java/org/dspace/xoai/tests/integration/xoai/IdentifyTest.java b/dspace-oai/src/test/java/org/dspace/xoai/tests/integration/xoai/IdentifyTest.java deleted file mode 100644 index f49e4e07e2..0000000000 --- a/dspace-oai/src/test/java/org/dspace/xoai/tests/integration/xoai/IdentifyTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * 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.xoai.tests.integration.xoai; - -import static org.dspace.xoai.tests.helpers.SyntacticSugar.and; -import static org.dspace.xoai.tests.helpers.SyntacticSugar.given; -import static org.hamcrest.core.Is.is; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.util.Date; - -import org.junit.Test; - -public class IdentifyTest extends AbstractDSpaceTest { - - public static final Date EARLIEST_DATE = new Date(); - - @Test - public void requestForIdentifyWithoutRequiredConfigurationAdminEmailSetShouldFail() throws Exception { - given(theDSpaceConfiguration() - .withoutProperty("mail.admin")); - and(given(theConfiguration().withContextConfigurations(aContext("request")))); - - againstTheDataProvider().perform(get("/request?verb=Identify")) - .andExpect(status().isInternalServerError()); - } - - @Test - public void requestForIdentifyShouldReturnTheConfiguredValues() throws Exception { - given(theDSpaceConfiguration() - .hasProperty("dspace.name", "Test") - .hasProperty("mail.admin", "test@test.com")); - - and(given(theEarlistEarliestDate().is(EARLIEST_DATE))); - and(given(theConfiguration().withContextConfigurations(aContext("request")))); - - againstTheDataProvider().perform(get("/request?verb=Identify")) - .andExpect(status().isOk()) - .andExpect(oaiXPath("//repositoryName").string("Test")) - .andExpect(oaiXPath("//adminEmail").string("test@test.com")) - .andExpect( - oaiXPath("//earliestDatestamp").string(is(representationOfDate(EARLIEST_DATE)))); - } -} diff --git a/dspace-oai/src/test/java/org/dspace/xoai/tests/integration/xoai/ListSetsTest.java b/dspace-oai/src/test/java/org/dspace/xoai/tests/integration/xoai/ListSetsTest.java deleted file mode 100644 index 282d6a6c9d..0000000000 --- a/dspace-oai/src/test/java/org/dspace/xoai/tests/integration/xoai/ListSetsTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * 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.xoai.tests.integration.xoai; - -import static org.dspace.xoai.tests.helpers.SyntacticSugar.and; -import static org.dspace.xoai.tests.helpers.SyntacticSugar.given; -import static org.hamcrest.core.Is.is; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import org.junit.Test; - -public class ListSetsTest extends AbstractDSpaceTest { - @Test - public void listSetsWithLessSetsThenMaxSetsPerPage() throws Exception { - given(theConfiguration() - .withMaxListSetsSize(100) - .withContextConfigurations(aContext("request"))); - and(given(theSetRepository() - .doesSupportSets() - .withSet("name", "spec"))); - - againstTheDataProvider().perform(get("/request?verb=ListSets")) - .andExpect(status().isOk()) - .andDo(print()) - .andExpect(responseDate().exists()) - .andExpect(verb(is("ListSets"))) - .andExpect(oaiXPath("//set").nodeCount(1)) - .andExpect(oaiXPath("//set/setSpec").string("spec")) - .andExpect(oaiXPath("//set/setName").string("name")) - .andExpect(resumptionToken().doesNotExist()); - } - - @Test - public void listSetsWithMoreSetsThenMaxSetsPerPage() throws Exception { - given(theConfiguration() - .withMaxListSetsSize(10) - .withContextConfigurations(aContext("request"))); - - and(given(theSetRepository() - .doesSupportSets() - .withRandomlyGeneratedSets(20))); - - againstTheDataProvider().perform(get("/request?verb=ListSets")) - .andExpect(status().isOk()) - .andExpect(responseDate().exists()) - .andExpect(verb(is("ListSets"))) - .andExpect(oaiXPath("//set").nodeCount(10)) - .andExpect(resumptionToken().string("////10")) - .andExpect(oaiXPath("//resumptionToken/@completeListSize").number(Double.valueOf(20))); - - and(againstTheDataProvider().perform(get("/request?verb=ListSets&resumptionToken=////10")) - .andExpect(status().isOk()) - .andExpect(responseDate().exists()) - .andExpect(verb(is("ListSets"))) - .andExpect(oaiXPath("//set").nodeCount(10)) - .andExpect(resumptionToken().string(""))); - } -} diff --git a/dspace-oai/src/test/java/org/dspace/xoai/tests/integration/xoai/OAIContextTest.java b/dspace-oai/src/test/java/org/dspace/xoai/tests/integration/xoai/OAIContextTest.java deleted file mode 100644 index ef875e1896..0000000000 --- a/dspace-oai/src/test/java/org/dspace/xoai/tests/integration/xoai/OAIContextTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * 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.xoai.tests.integration.xoai; - -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import org.junit.Test; - -public class OAIContextTest extends AbstractDSpaceTest { - public static final String ROOT_URL = "/"; - - @Test - public void requestToRootShouldGiveListOfContextsWithBadRequestError() throws Exception { - againstTheDataProvider().perform(get(ROOT_URL)) - .andDo(print()) - .andExpect(status().isBadRequest()) - .andExpect(model().attributeExists("contexts")); - } - - @Test - public void requestForUnknownContextShouldGiveListOfContextsWithBadRequestError() throws Exception { - againstTheDataProvider().perform(get("/unexistentContext")) - .andDo(print()) - .andExpect(status().isBadRequest()) - .andExpect(model().attributeExists("contexts")); - } -} diff --git a/dspace-rdf/pom.xml b/dspace-rdf/pom.xml index 1d5c68ab91..03959f9cdb 100644 --- a/dspace-rdf/pom.xml +++ b/dspace-rdf/pom.xml @@ -2,9 +2,9 @@ 4.0.0 org.dspace dspace-rdf - war + jar DSpace RDF - Parent project for the RDF API and Webapp + DSpace RDF (Linked Data) Extension org.dspace @@ -57,20 +57,17 @@ dspace-services - + - org.springframework - spring-core - - - - org.springframework - spring-context - - - - org.springframework - spring-web + org.springframework.boot + spring-boot-starter + ${spring-boot.version} + + + org.springframework.boot + spring-boot-starter-logging + + diff --git a/dspace-rdf/src/main/java/org/dspace/app/configuration/RDFWebConfig.java b/dspace-rdf/src/main/java/org/dspace/app/configuration/RDFWebConfig.java new file mode 100644 index 0000000000..15b991af0a --- /dev/null +++ b/dspace-rdf/src/main/java/org/dspace/app/configuration/RDFWebConfig.java @@ -0,0 +1,56 @@ +/** + * 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.configuration; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.web.servlet.ServletRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * RDF webapp configuration. Replaces the old web.xml + *

+ * This @Configuration class is automatically discovered by Spring via a @ComponentScan. + *

+ * All RDF web configurations (beans) can be enabled or disabled by setting "rdf.enabled" + * to true or false, respectively (in your DSpace configuration). Default is "false". + *

+ * All @Value annotated configurations below can also be overridden in your DSpace configuration. + * + * @author Tim Donohue + */ +@Configuration +public class RDFWebConfig { + // Path where RDF should be deployed (when enabled). Defaults to "rdf" + @Value("${rdf.path:rdf}") + private String rdfPath; + + // Servlet Beans. All of the below bean definitions map servlets to respond to specific URL patterns + // These are the combined equivalent of and in web.xml + // All beans are only loaded when rdf.enabled = true + + @Bean + @ConditionalOnProperty("rdf.enabled") + public ServletRegistrationBean rdfSerializationBean() { + ServletRegistrationBean bean = new ServletRegistrationBean( new org.dspace.rdf.providing.DataProviderServlet(), + "/" + rdfPath + "/handle/*"); + bean.setLoadOnStartup(1); + return bean; + } + + @Bean + @ConditionalOnProperty("rdf.enabled") + public ServletRegistrationBean rdfLocalURIRedirectionBean() { + ServletRegistrationBean bean = new ServletRegistrationBean( + new org.dspace.rdf.providing.LocalURIRedirectionServlet(), "/" + rdfPath + "/resource/*"); + bean.setLoadOnStartup(1); + return bean; + } +} + diff --git a/dspace-rdf/src/main/webapp/WEB-INF/web.xml b/dspace-rdf/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index c15ec675f3..0000000000 --- a/dspace-rdf/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - RDF Data Provider - - - - The location of the DSpace home directory - - dspace.dir - ${dspace.dir} - - - - log4jConfiguration - ${dspace.dir}/config/log4j2.xml - - The location of the Log4J configuration - - - - - dspace.request - org.dspace.utils.servlet.DSpaceWebappServletFilter - - - - dspace.request - /* - - - - org.dspace.app.util.DSpaceContextListener - - - - org.dspace.servicemanager.servlet.DSpaceKernelServletContextListener - - - - rdf-serialization - org.dspace.rdf.providing.DataProviderServlet - - - - local-uri-redirection - org.dspace.rdf.providing.LocalURIRedirectionServlet - - - - - rdf-serialization - /handle/* - - - - local-uri-redirection - /resource/* - - diff --git a/dspace-spring-rest/pom.xml b/dspace-spring-rest/pom.xml index 5862b50a8e..6b6fbb7911 100644 --- a/dspace-spring-rest/pom.xml +++ b/dspace-spring-rest/pom.xml @@ -27,9 +27,10 @@ @ org.dspace.app.rest.Application - 1.4.4.RELEASE - 2.2.0 - + + 2.4.0 + + 6.2 @@ -255,6 +256,26 @@ org.dspace dspace-services + + + + + org.dspace + dspace-oai + + + org.dspace + dspace-rdf + + + org.dspace + dspace-sword + + + org.dspace + dspace-swordv2 + + org.apache.commons commons-collections4 @@ -266,7 +287,7 @@ com.nimbusds nimbus-jose-jwt - 6.2 + ${nimbus-jose-jwt.version} org.apache.solr @@ -288,13 +309,18 @@ org.json json + + + com.jayway.jsonpath + json-path + com.jayway.jsonpath json-path - test ${json-path.version} + test com.jayway.jsonpath diff --git a/dspace-spring-rest/src/main/java/org/dspace/app/rest/Application.java b/dspace-spring-rest/src/main/java/org/dspace/app/rest/Application.java index 3e8328d478..0315860178 100644 --- a/dspace-spring-rest/src/main/java/org/dspace/app/rest/Application.java +++ b/dspace-spring-rest/src/main/java/org/dspace/app/rest/Application.java @@ -14,6 +14,7 @@ import org.dspace.app.rest.filter.DSpaceRequestContextFilter; import org.dspace.app.rest.model.hateoas.DSpaceRelProvider; import org.dspace.app.rest.parameter.resolver.SearchFilterResolver; import org.dspace.app.rest.utils.ApplicationConfig; +import org.dspace.app.rest.utils.DSpaceConfigurationInitializer; import org.dspace.app.rest.utils.DSpaceKernelInitializer; import org.dspace.app.util.DSpaceContextListener; import org.dspace.utils.servlet.DSpaceWebappServletFilter; @@ -22,7 +23,6 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.web.servlet.ServletContextInitializer; import org.springframework.boot.web.support.SpringBootServletInitializer; import org.springframework.context.annotation.Bean; import org.springframework.core.annotation.Order; @@ -62,7 +62,6 @@ public class Application extends SpringBootServletInitializer { * This is necessary to allow us to build a deployable WAR, rather than * always relying on embedded Tomcat. *

- *

* See: http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-create-a-deployable-war-file * * @param application @@ -70,13 +69,10 @@ public class Application extends SpringBootServletInitializer { */ @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { + // Pass this Application class, and our initializers for DSpace Kernel and Configuration + // NOTE: Kernel must be initialized before Configuration return application.sources(Application.class) - .initializers(new DSpaceKernelInitializer()); - } - - @Bean - public ServletContextInitializer contextInitializer() { - return servletContext -> servletContext.setInitParameter("dspace.dir", configuration.getDspaceHome()); + .initializers(new DSpaceKernelInitializer(), new DSpaceConfigurationInitializer()); } /** @@ -89,7 +85,6 @@ public class Application extends SpringBootServletInitializer { @Order(2) protected DSpaceContextListener dspaceContextListener() { // This listener initializes the DSpace Context object - // (and loads all DSpace configs) return new DSpaceContextListener(); } diff --git a/dspace-spring-rest/src/main/java/org/dspace/app/rest/RelationshipRestController.java b/dspace-spring-rest/src/main/java/org/dspace/app/rest/RelationshipRestController.java index 7f6a1f22cf..a849445bd2 100644 --- a/dspace-spring-rest/src/main/java/org/dspace/app/rest/RelationshipRestController.java +++ b/dspace-spring-rest/src/main/java/org/dspace/app/rest/RelationshipRestController.java @@ -7,6 +7,7 @@ */ package org.dspace.app.rest; +import java.sql.SQLException; import java.util.LinkedList; import java.util.List; import java.util.UUID; @@ -19,6 +20,7 @@ import org.dspace.app.rest.link.HalLinkService; import org.dspace.app.rest.model.RelationshipRest; import org.dspace.app.rest.model.RelationshipRestWrapper; import org.dspace.app.rest.model.hateoas.RelationshipResourceWrapper; +import org.dspace.app.rest.repository.RelationshipRestRepository; import org.dspace.app.rest.utils.ContextUtil; import org.dspace.app.rest.utils.Utils; import org.dspace.content.Item; @@ -52,9 +54,17 @@ public class RelationshipRestController { private static final String REGEX_REQUESTMAPPING_LABEL = "/{label:^(?!^\\d+$)" + "(?!^[0-9a-fxA-FX]{8}-[0-9a-fxA-FX]{4}-[0-9a-fxA-FX]{4}-[0-9a-fxA-FX]{4}-[0-9a-fxA-FX]{12}$)[\\w+\\-]+$+}"; + /** + * Regular expression in the request mapping to accept number as identifier + */ + private static final String REGEX_REQUESTMAPPING_IDENTIFIER_AS_DIGIT = "/{id:\\d+}"; + @Autowired private RelationshipTypeService relationshipTypeService; + @Autowired + private RelationshipRestRepository relationshipRestRepository; + @Autowired private RelationshipService relationshipService; @@ -130,4 +140,29 @@ public class RelationshipRestController { return relationshipResourceWrapper; } -} + /** + * Method to change the left item of a relationship with a given item in the body + * @return The modified relationship + */ + @RequestMapping(method = RequestMethod.PUT, value = REGEX_REQUESTMAPPING_IDENTIFIER_AS_DIGIT + "/leftItem", + consumes = {"text/uri-list"}) + public RelationshipRest updateRelationshipLeft(@PathVariable Integer id, HttpServletResponse response, + HttpServletRequest request) throws SQLException { + Context context = ContextUtil.obtainContext(request); + return relationshipRestRepository.put(context,"/api/core/relationships/", id, + utils.getStringListFromRequest(request), false); + } + + /** + * Method to change the right item of a relationship with a given item in the body + * @return The modified relationship + */ + @RequestMapping(method = RequestMethod.PUT, value = REGEX_REQUESTMAPPING_IDENTIFIER_AS_DIGIT + "/rightItem", + consumes = {"text/uri-list"}) + public RelationshipRest updateRelationshipRight(@PathVariable Integer id, HttpServletResponse response, + HttpServletRequest request) throws SQLException { + Context context = ContextUtil.obtainContext(request); + return relationshipRestRepository.put(context,"/api/core/relationships/", id, + utils.getStringListFromRequest(request), true); + } +} \ No newline at end of file diff --git a/dspace-spring-rest/src/main/java/org/dspace/app/rest/RestResourceController.java b/dspace-spring-rest/src/main/java/org/dspace/app/rest/RestResourceController.java index 1a359947aa..e17e5d55cc 100644 --- a/dspace-spring-rest/src/main/java/org/dspace/app/rest/RestResourceController.java +++ b/dspace-spring-rest/src/main/java/org/dspace/app/rest/RestResourceController.java @@ -832,7 +832,7 @@ public class RestResourceController implements InitializingBean { link = linkTo(this.getClass(), apiCategory, model).slash(uuid) .slash(subpath + '?' + querystring).withSelfRel(); } else { - link = linkTo(this.getClass(), apiCategory, model).slash(uuid).withSelfRel(); + link = linkTo(this.getClass(), apiCategory, model).slash(uuid).slash(subpath).withSelfRel(); } Page halResources = pageResult.map(linkRepository::wrapResource); diff --git a/dspace-spring-rest/src/main/java/org/dspace/app/rest/exception/InvalidDSpaceObjectTypeException.java b/dspace-spring-rest/src/main/java/org/dspace/app/rest/exception/InvalidDSpaceObjectTypeException.java deleted file mode 100644 index 0211eb228d..0000000000 --- a/dspace-spring-rest/src/main/java/org/dspace/app/rest/exception/InvalidDSpaceObjectTypeException.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * 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.rest.exception; - -/** - * This class creates an Exception to be used when the given DSpaceObjectType is invalid - */ -public class InvalidDSpaceObjectTypeException extends InvalidRequestException { - public InvalidDSpaceObjectTypeException(String message) { - super(message); - } -} diff --git a/dspace-spring-rest/src/main/java/org/dspace/app/rest/exception/InvalidRequestException.java b/dspace-spring-rest/src/main/java/org/dspace/app/rest/exception/InvalidRequestException.java deleted file mode 100644 index e6d4558a29..0000000000 --- a/dspace-spring-rest/src/main/java/org/dspace/app/rest/exception/InvalidRequestException.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * 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.rest.exception; - -/** - * This class provides an exception for when the given request is invalid - */ -public class InvalidRequestException extends Exception { - public InvalidRequestException(String message) { - super(message); - } - - public InvalidRequestException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/dspace-spring-rest/src/main/java/org/dspace/app/rest/exception/InvalidSearchFacetException.java b/dspace-spring-rest/src/main/java/org/dspace/app/rest/exception/InvalidSearchFacetException.java deleted file mode 100644 index d3a7cc81ba..0000000000 --- a/dspace-spring-rest/src/main/java/org/dspace/app/rest/exception/InvalidSearchFacetException.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * 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.rest.exception; - -/** - * Exception thrown when the search endpoint receives an invalid facet name - */ -public class InvalidSearchFacetException extends InvalidRequestException { - public InvalidSearchFacetException(final String message) { - super(message); - } -} diff --git a/dspace-spring-rest/src/main/java/org/dspace/app/rest/exception/InvalidSearchFilterException.java b/dspace-spring-rest/src/main/java/org/dspace/app/rest/exception/InvalidSearchFilterException.java deleted file mode 100644 index ff8e522a14..0000000000 --- a/dspace-spring-rest/src/main/java/org/dspace/app/rest/exception/InvalidSearchFilterException.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * 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.rest.exception; - -/** - * This class provides an exception to be used when the SearchFilter given is invalid - */ -public class InvalidSearchFilterException extends InvalidRequestException { - public InvalidSearchFilterException(String message, Throwable cause) { - super(message, cause); - } - - public InvalidSearchFilterException(final String message) { - super(message); - } -} diff --git a/dspace-spring-rest/src/main/java/org/dspace/app/rest/exception/InvalidSortingException.java b/dspace-spring-rest/src/main/java/org/dspace/app/rest/exception/InvalidSortingException.java deleted file mode 100644 index 182dd64736..0000000000 --- a/dspace-spring-rest/src/main/java/org/dspace/app/rest/exception/InvalidSortingException.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * 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.rest.exception; - -/** - * This class makes an Exception to be used when a certain sorting is invalid - */ -public class InvalidSortingException extends InvalidRequestException { - public InvalidSortingException(String message) { - super(message); - } -} diff --git a/dspace-spring-rest/src/main/java/org/dspace/app/rest/link/BrowseEntryHalLinkFactory.java b/dspace-spring-rest/src/main/java/org/dspace/app/rest/link/BrowseEntryHalLinkFactory.java index 6ccfd052e3..a9074b6020 100644 --- a/dspace-spring-rest/src/main/java/org/dspace/app/rest/link/BrowseEntryHalLinkFactory.java +++ b/dspace-spring-rest/src/main/java/org/dspace/app/rest/link/BrowseEntryHalLinkFactory.java @@ -54,13 +54,13 @@ public class BrowseEntryHalLinkFactory extends HalLinkFactory searchFilters, final Pageable page) - throws InvalidRequestException { + final List searchFilters, final Pageable page) { Context context = obtainContext(); IndexableObject scopeObject = scopeResolver.resolveScope(context, dsoScope); DiscoveryConfiguration discoveryConfiguration = searchConfigurationService @@ -131,8 +129,7 @@ public class DiscoveryRestRepository extends AbstractDSpaceRestRepository { } public FacetResultsRest getFacetObjects(String facetName, String prefix, String query, String dsoType, - String dsoScope, final String configuration, List searchFilters, Pageable page) - throws InvalidRequestException { + String dsoScope, final String configuration, List searchFilters, Pageable page) { Context context = obtainContext(); @@ -158,7 +155,7 @@ public class DiscoveryRestRepository extends AbstractDSpaceRestRepository { } public SearchResultsRest getAllFacets(String query, String dsoType, String dsoScope, String configuration, - List searchFilters) throws InvalidRequestException { + List searchFilters) { Context context = obtainContext(); Pageable page = new PageRequest(1, 1); diff --git a/dspace-spring-rest/src/main/java/org/dspace/app/rest/repository/RelationshipRestRepository.java b/dspace-spring-rest/src/main/java/org/dspace/app/rest/repository/RelationshipRestRepository.java index 378fea6418..212b458712 100644 --- a/dspace-spring-rest/src/main/java/org/dspace/app/rest/repository/RelationshipRestRepository.java +++ b/dspace-spring-rest/src/main/java/org/dspace/app/rest/repository/RelationshipRestRepository.java @@ -34,6 +34,7 @@ import org.dspace.eperson.EPerson; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; +import org.springframework.data.rest.webmvc.ResourceNotFoundException; import org.springframework.security.access.AccessDeniedException; import org.springframework.stereotype.Component; @@ -128,29 +129,59 @@ public class RelationshipRestRepository extends DSpaceRestRepository stringList) - throws RepositoryMethodNotImplementedException, SQLException, AuthorizeException { + /** + * Method to replace either the right or left item of a relationship with a given new item + * Called by request mappings in RelationshipRestController + * - For replace right item (itemToReplaceIsRight = true) + * => Newly proposed changed relationship: left = old-left; right = new-item + * - For replace left item (itemToReplaceIsRight = false) + * => Newly proposed changed relationship: left = new-item; right = old-right + * @param context + * @param contextPath What API call was made to get here + * @param id ID of the relationship we wish to modify + * @param stringList Item to replace either right or left item of relationship with + * @param itemToReplaceIsRight Boolean to decide whether to replace right item (true) or left item (false) + * @return The (modified) relationship + * @throws SQLException + */ + public RelationshipRest put(Context context, String contextPath, Integer id, List stringList, + Boolean itemToReplaceIsRight) throws SQLException { - Relationship relationship = relationshipService.find(context, id); + Relationship relationship; + try { + relationship = relationshipService.find(context, id); + } catch (SQLException e) { + throw new ResourceNotFoundException(contextPath + " with id: " + id + " not found"); + } if (relationship == null) { - throw new ResourceNotFoundException(apiCategory + "." + model + " with id: " + id + " not found"); + throw new ResourceNotFoundException(contextPath + " with id: " + id + " not found"); } List dSpaceObjects = utils.constructDSpaceObjectList(context, stringList); - if (dSpaceObjects.size() == 2 && dSpaceObjects.get(0).getType() == Constants.ITEM - && dSpaceObjects.get(1).getType() == Constants.ITEM) { - Item leftItem = (Item) dSpaceObjects.get(0); - Item rightItem = (Item) dSpaceObjects.get(1); + if (dSpaceObjects.size() == 1 && dSpaceObjects.get(0).getType() == Constants.ITEM) { + + Item replacementItemInRelationship = (Item) dSpaceObjects.get(0); + Item leftItem; + Item rightItem; + if (itemToReplaceIsRight) { + leftItem = relationship.getLeftItem(); + rightItem = replacementItemInRelationship; + } else { + leftItem = replacementItemInRelationship; + rightItem = relationship.getRightItem(); + } if (isAllowedToModifyRelationship(context, relationship, leftItem, rightItem)) { relationship.setLeftItem(leftItem); relationship.setRightItem(rightItem); - relationshipService.updatePlaceInRelationship(context, relationship, false); - relationshipService.update(context, relationship); + try { + relationshipService.updatePlaceInRelationship(context, relationship, false); + relationshipService.update(context, relationship); + context.commit(); + context.reloadEntity(relationship); + } catch (AuthorizeException e) { + throw new AccessDeniedException("You do not have write rights on this relationship's items"); + } return relationshipConverter.fromModel(relationship); } else { @@ -161,7 +192,6 @@ public class RelationshipRestRepository extends DSpaceRestRepository + * NOTE: @ComponentScan on "org.dspace.app.configuration" provides a way for other DSpace modules or plugins + * to "inject" their own Spring configurations / subpaths into our Spring Boot webapp. * * @author Andrea Bollini (andrea.bollini at 4science.it) + * @author Tim Donohue */ @Configuration @EnableSpringDataWebSupport -@ComponentScan( {"org.dspace.app.rest.converter", "org.dspace.app.rest.repository", "org.dspace.app.rest.utils"}) +@ComponentScan( {"org.dspace.app.rest.converter", "org.dspace.app.rest.repository", "org.dspace.app.rest.utils", + "org.dspace.app.configuration"}) public class ApplicationConfig { - @Value("${dspace.dir}") - private String dspaceHome; - - @Value("${cors.allowed-origins}") + // Allowed CORS origins. Defaults to * (everywhere) + // Can be overridden in DSpace configuration + @Value("${rest.cors.allowed-origins:*}") private String corsAllowedOrigins; - public String getDspaceHome() { - return dspaceHome; - } - public String[] getCorsAllowedOrigins() { if (corsAllowedOrigins != null) { return corsAllowedOrigins.split("\\s*,\\s*"); diff --git a/dspace-spring-rest/src/main/java/org/dspace/app/rest/utils/DSpaceConfigurationInitializer.java b/dspace-spring-rest/src/main/java/org/dspace/app/rest/utils/DSpaceConfigurationInitializer.java new file mode 100644 index 0000000000..2e05ea3fb7 --- /dev/null +++ b/dspace-spring-rest/src/main/java/org/dspace/app/rest/utils/DSpaceConfigurationInitializer.java @@ -0,0 +1,48 @@ +/** + * 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.rest.utils; + +import org.apache.commons.configuration2.Configuration; +import org.apache.commons.configuration2.spring.ConfigurationPropertySource; +import org.dspace.services.ConfigurationService; +import org.dspace.services.factory.DSpaceServicesFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.ApplicationContextInitializer; +import org.springframework.context.ConfigurableApplicationContext; + +/** + * Utility class that will initialize the DSpace Configuration on Spring Boot startup. + *

+ * NOTE: MUST be loaded after DSpaceKernelInitializer, as it requires the kernel is already initialized. + *

+ * This initializer ensures that our DSpace Configuration is loaded into Spring's list of PropertySources + * very early in the Spring Boot startup process. That is important as it allows us to use DSpace configurations + * within @ConditionalOnProperty annotations on beans, as well as @Value annotations and XML bean definitions. + *

+ * Used by org.dspace.app.rest.Application + */ +public class DSpaceConfigurationInitializer implements ApplicationContextInitializer { + + private static final Logger log = LoggerFactory.getLogger(DSpaceConfigurationInitializer.class); + + @Override + public void initialize(final ConfigurableApplicationContext applicationContext) { + // Load DSpace Configuration service (requires kernel already initialized) + ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService(); + Configuration configuration = configurationService.getConfiguration(); + + // Create an Apache Commons Configuration Property Source from our configuration + ConfigurationPropertySource apacheCommonsConfigPropertySource = + new ConfigurationPropertySource(configuration.getClass().getName(), configuration); + + // Append it to the Environment's list of PropertySources + applicationContext.getEnvironment().getPropertySources().addLast(apacheCommonsConfigPropertySource); + } +} + diff --git a/dspace-spring-rest/src/main/java/org/dspace/app/rest/utils/DSpaceKernelInitializer.java b/dspace-spring-rest/src/main/java/org/dspace/app/rest/utils/DSpaceKernelInitializer.java index 039cfa5af9..73a96259bf 100644 --- a/dspace-spring-rest/src/main/java/org/dspace/app/rest/utils/DSpaceKernelInitializer.java +++ b/dspace-spring-rest/src/main/java/org/dspace/app/rest/utils/DSpaceKernelInitializer.java @@ -11,6 +11,7 @@ import java.io.File; import javax.naming.Context; import javax.naming.InitialContext; +import org.apache.commons.lang3.StringUtils; import org.dspace.kernel.DSpaceKernel; import org.dspace.kernel.DSpaceKernelManager; import org.dspace.servicemanager.DSpaceKernelImpl; @@ -22,6 +23,7 @@ import org.springframework.context.ApplicationContextInitializer; import org.springframework.context.ApplicationListener; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.event.ContextClosedEvent; +import org.springframework.core.env.ConfigurableEnvironment; /** * Utility class that will initialize the DSpace Kernel on Spring Boot startup. @@ -35,16 +37,16 @@ public class DSpaceKernelInitializer implements ApplicationContextInitializer searchFilters, String dsoType, Pageable page) - throws InvalidRequestException { + throws DSpaceBadRequestException { DiscoverQuery queryArgs = buildCommonDiscoverQuery(context, discoveryConfiguration, query, searchFilters, dsoType); @@ -104,7 +100,7 @@ public class DiscoverQueryBuilder implements InitializingBean { DiscoveryConfiguration discoveryConfiguration, String prefix, String query, List searchFilters, String dsoType, Pageable page, String facetName) - throws InvalidRequestException { + throws DSpaceBadRequestException { DiscoverQuery queryArgs = buildCommonDiscoverQuery(context, discoveryConfiguration, query, searchFilters, dsoType); @@ -129,7 +125,7 @@ public class DiscoverQueryBuilder implements InitializingBean { private DiscoverQuery addFacetingForFacets(Context context, IndexableObject scope, String prefix, DiscoverQuery queryArgs, DiscoveryConfiguration discoveryConfiguration, String facetName, Pageable page) - throws InvalidSearchFacetException { + throws DSpaceBadRequestException { DiscoverySearchFilterFacet facet = discoveryConfiguration.getSidebarFacet(facetName); if (facet != null) { @@ -139,7 +135,7 @@ public class DiscoverQueryBuilder implements InitializingBean { fillFacetIntoQueryArgs(context, scope, prefix, queryArgs, facet, pageSize); } else { - throw new InvalidSearchFacetException(facetName + " is not a valid search facet"); + throw new DSpaceBadRequestException(facetName + " is not a valid search facet"); } return queryArgs; @@ -173,7 +169,7 @@ public class DiscoverQueryBuilder implements InitializingBean { private DiscoverQuery buildCommonDiscoverQuery(Context context, DiscoveryConfiguration discoveryConfiguration, String query, List searchFilters, String dsoType) - throws InvalidSearchFilterException, InvalidDSpaceObjectTypeException { + throws DSpaceBadRequestException { DiscoverQuery queryArgs = buildBaseQueryForConfiguration(discoveryConfiguration); //Add search filters @@ -202,7 +198,7 @@ public class DiscoverQueryBuilder implements InitializingBean { } private void configureSorting(Pageable page, DiscoverQuery queryArgs, - DiscoverySortConfiguration searchSortConfiguration) throws InvalidSortingException { + DiscoverySortConfiguration searchSortConfiguration) throws DSpaceBadRequestException { String sortBy = null; String sortOrder = null; @@ -237,11 +233,11 @@ public class DiscoverQueryBuilder implements InitializingBean { } else if ("desc".equalsIgnoreCase(sortOrder)) { queryArgs.setSortField(sortField, DiscoverQuery.SORT_ORDER.desc); } else { - throw new InvalidSortingException(sortOrder + " is not a valid sort order"); + throw new DSpaceBadRequestException(sortOrder + " is not a valid sort order"); } } else { - throw new InvalidSortingException(sortBy + " is not a valid sort field"); + throw new DSpaceBadRequestException(sortBy + " is not a valid sort field"); } } @@ -273,16 +269,16 @@ public class DiscoverQueryBuilder implements InitializingBean { } } - private int getDsoTypeId(String dsoType) throws InvalidDSpaceObjectTypeException { + private int getDsoTypeId(String dsoType) throws DSpaceBadRequestException { int index = ArrayUtils.indexOf(Constants.typeText, dsoType.toUpperCase()); if (index < 0) { - throw new InvalidDSpaceObjectTypeException(dsoType + " is not a valid DSpace Object type"); + throw new DSpaceBadRequestException(dsoType + " is not a valid DSpace Object type"); } return index; } private String[] convertFilters(Context context, DiscoveryConfiguration discoveryConfiguration, - List searchFilters) throws InvalidSearchFilterException { + List searchFilters) throws DSpaceBadRequestException { ArrayList filterQueries = new ArrayList<>(CollectionUtils.size(searchFilters)); SearchQueryConverter searchQueryConverter = new SearchQueryConverter(); @@ -291,7 +287,7 @@ public class DiscoverQueryBuilder implements InitializingBean { for (SearchFilter searchFilter : CollectionUtils.emptyIfNull(transformedFilters)) { DiscoverySearchFilter filter = discoveryConfiguration.getSearchFilter(searchFilter.getName()); if (filter == null) { - throw new InvalidSearchFilterException(searchFilter.getName() + " is not a valid search filter"); + throw new DSpaceBadRequestException(searchFilter.getName() + " is not a valid search filter"); } DiscoverFilterQuery filterQuery = searchService.toFilterQuery(context, @@ -304,7 +300,7 @@ public class DiscoverQueryBuilder implements InitializingBean { } } } catch (SQLException e) { - throw new InvalidSearchFilterException("There was a problem parsing the search filters.", e); + throw new DSpaceBadRequestException("There was a problem parsing the search filters.", e); } return filterQueries.toArray(new String[filterQueries.size()]); diff --git a/dspace-spring-rest/src/main/resources/application.properties b/dspace-spring-rest/src/main/resources/application.properties index c6fbf3b6b1..7a5e5a0193 100644 --- a/dspace-spring-rest/src/main/resources/application.properties +++ b/dspace-spring-rest/src/main/resources/application.properties @@ -7,34 +7,31 @@ # # -# Spring Boot application.properties -# Docs (including info on how to override these default settings) +# Spring Boot's application.properties +# +# This properties file is used by Spring Boot to initialize its ApplicationContext and configure +# default Spring beans. It also uses the "dspace.dir" custom setting to locate your DSpace installation, +# and load all DSpace services and configurations. +# +# WARNING: Because this properties file initializes Spring Boot, it loads *before* any DSpace specific +# configurations/settings. Therefore settings in this file CANNOT depend on any DSpace configurations. +# The *only* DSpace configuration allowed in this file is "dspace.dir", which is documented below. +# +# Docs (including info on how to override these default settings) # http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html -# For common settings see: +# For common settings see: # http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html # -# -# TODO: Eventually would could think of "wiring" this up to use Commons Configuration as well -# See, for example: http://stackoverflow.com/questions/25271537/remote-propertysource -# and https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html ######################## # DSpace Settings # -# DSpace installation directory +# DSpace home/installation directory +# REQUIRED to be specified in this application.properties file, as it is used to locate and initialize +# the DSpace Kernel and all Services (including configuration). See org.dspace.app.rest.Application.getDSpaceHome() +# NOTE: this configuration is filled out by Apache Ant during the DSpace install/update process. It does NOT +# interact with or read its configuration from dspace.cfg. dspace.dir=${dspace.dir} -#dspace.dir=d:/install/dspace7 - -######################## -# DSpace API CORS Settings -# -cors.allowed-origins = * - -######################## -# Spring Boot Settings -# -# Testing an "application Name" -spring.application.name = DSpace Spring Rest ######################## # Spring DATA Rest settings @@ -75,15 +72,6 @@ server.port=8080 # (Optional, defaults to root context) #server.context-path=/spring-data-rest -# This creates a Tomcat context-param named "dspace.dir" -# and sets it to the value of the "dspace.dir" property (listed above) -server.context-parameters.dspace.dir=${dspace.dir} - -# This creates a Tomcat context-param named "dspace-config" -# (Used by DSpaceContextListener to load the configurations) -# This is only needed in DSpace 5 or below to initialize ConfigurationManager -#server.context-parameters.dspace-config=${dspace.dir}/config/dspace.cfg - # Error handling settings # Always include the fullstacktrace in error pages # Can be set to "never" if you don't want it. @@ -94,8 +82,8 @@ server.error.include-stacktrace = always # # DISABLE a few autoconfiguration scripts, as DSpace initializes/configures these already # * DataSourceAutoConfiguration (DB connection / datasource) +# * HibernateJpaAutoConfiguration (Hibernate ORM) # * FlywayAutoConfiguration (Flyway migrations) -# * HibernateJpaAutoConfiguration (Hibernate) # * SolrAutoConfiguration (Solr) # # TODO: At some point we may want to investigate whether we can re-enable these and remove the custom DSpace init code diff --git a/dspace-spring-rest/src/main/webapp/login.html b/dspace-spring-rest/src/main/webapp/login.html index 8895e7bba2..448dcf86bf 100644 --- a/dspace-spring-rest/src/main/webapp/login.html +++ b/dspace-spring-rest/src/main/webapp/login.html @@ -55,11 +55,11 @@

-