Skip to content

Commit

Permalink
Merged in main-cris_DSC-963 (pull request DSpace#1642)
Browse files Browse the repository at this point in the history
Merge DSC-963 into main-cirs

Approved-by: Giuseppe Digilio
  • Loading branch information
vins01-4science authored and atarix83 committed Feb 2, 2024
2 parents fe36309 + 5f6e1fe commit 24eea0a
Show file tree
Hide file tree
Showing 26 changed files with 555 additions and 445 deletions.
5 changes: 4 additions & 1 deletion dspace-api/src/test/data/dspaceFolder/config/local.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,7 @@ orcid.synchronization-enabled = true
# These settings ensure "dspace.object.owner" field are indexed by Authority Control
choices.plugin.dspace.object.owner = EPersonAuthority
choices.presentation.dspace.object.owner = suggest
authority.controlled.dspace.object.owner = true
authority.controlled.dspace.object.owner = true

# force the event system to work synchronously during test
system-event.thread.size = 0
106 changes: 78 additions & 28 deletions dspace-server-webapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.dspace</groupId>
<artifactId>dspace-server-webapp</artifactId>
<packaging>war</packaging>
<name>DSpace Server Webapp</name>
<description>
DSpace Server Webapp (Spring Boot)
Expand All @@ -25,23 +24,82 @@

<!-- Default resource delimiter for Spring Boot, so it doesn't clash with Spring ${} placeholders-->
<resource.delimiter>@</resource.delimiter>
<!-- Define our starting class for our Spring Boot Application -->
<start-class>org.dspace.app.rest.Application</start-class>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<attachClasses>true</attachClasses>
<!-- Filter the web.xml (needed for IDE compatibility/debugging) -->
<filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
</configuration>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.1.0</version>
<executions>
<execution>
<phase>prepare-package</phase>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${root.basedir}/dspace/config/dspace.cfg</file>
<file>${root.basedir}/dspace/config/local.cfg</file>
</files>
<quiet>true</quiet>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>testEnvironment</id>
<phase>process-resources</phase>
<goals>
<goal>testResources</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>${basedir}/src/test/resources</directory>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>webappFiltering</id>
<phase>process-resources</phase>
<goals>
<goal>resources</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<includes>
<include>**/*application*.properties</include>
<include>**/*dspace*.properties</include>
</includes>
<filtering>true</filtering>
</resource>
<resource>
<directory>${basedir}/src/main/resources</directory>
<excludes>
<exclude>**/*application*.properties</exclude>
<exclude>**/*dspace*.properties</exclude>
</excludes>
<includes>
<include>**/*.properties</include>
</includes>
</resource>
<resource>
<directory>${basedir}/src/main/resources</directory>
<includes>
<include>**/static/**</include>
<include>**/spring/**</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
Expand All @@ -66,11 +124,11 @@
<exclude>**/src/test/resources/**</exclude>
<exclude>**/src/test/data/**</exclude>
<!--Skip license check of third party files included/customized from HAL Browser -->
<exclude>src/main/webapp/index.html</exclude>
<exclude>src/main/webapp/login.html</exclude>
<exclude>src/main/webapp/styles.css</exclude>
<exclude>src/main/webapp/js/hal/**</exclude>
<exclude>src/main/webapp/js/vendor/**</exclude>
<exclude>src/main/resources/static/index.html</exclude>
<exclude>src/main/resources/static/login.html</exclude>
<exclude>src/main/resources/static/styles.css</exclude>
<exclude>src/main/resources/static/js/hal/**</exclude>
<exclude>src/main/resources/static/js/vendor/**</exclude>
</excludes>
</configuration>
</plugin>
Expand Down Expand Up @@ -321,12 +379,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
<version>${spring-boot.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -356,7 +408,7 @@
<dependency>
<groupId>com.flipkart.zjsonpatch</groupId>
<artifactId>zjsonpatch</artifactId>
<version>0.4.6</version>
<version>0.4.14</version>
</dependency>

<!-- HAL Browser (via WebJars) : https://github.com/mikekelly/hal-browser -->
Expand All @@ -376,7 +428,7 @@
<dependency>
<groupId>org.webjars.bowergithub.jquery</groupId>
<artifactId>jquery-dist</artifactId>
<version>3.6.0</version>
<version>3.7.0</version>
</dependency>
<!-- Pull in current version of Toastr (toastrjs.com) via WebJars
Made available at: webjars/toastr/build/toastr.min.js -->
Expand All @@ -390,7 +442,7 @@
<dependency>
<groupId>org.webjars.bowergithub.medialize</groupId>
<artifactId>uri.js</artifactId>
<version>1.19.10</version>
<version>1.19.11</version>
</dependency>
<!-- Pull in current version of Underscore.js (https://underscorejs.org/) via WebJars
Made available at: webjars/underscore/underscore-min.js -->
Expand Down Expand Up @@ -562,12 +614,10 @@
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path-assert</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down Expand Up @@ -615,7 +665,7 @@
<dependency>
<groupId>org.exparity</groupId>
<artifactId>hamcrest-date</artifactId>
<version>2.0.7</version>
<version>2.0.8</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
import org.dspace.app.rest.parameter.resolver.SearchFilterResolver;
import org.dspace.app.rest.utils.ApplicationConfig;
import org.dspace.app.rest.utils.DSpaceAPIRequestLoggingFilter;
import org.dspace.app.rest.utils.DSpaceConfigurationInitializer;
import org.dspace.app.rest.utils.DSpaceKernelInitializer;
import org.dspace.app.sitemap.GenerateSitemaps;
import org.dspace.app.solrdatabaseresync.SolrDatabaseResyncCli;
import org.dspace.app.util.DSpaceContextListener;
Expand All @@ -28,11 +26,9 @@
import org.slf4j.Logger;
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.support.SpringBootServletInitializer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.hateoas.server.LinkRelationProvider;
import org.springframework.lang.NonNull;
Expand All @@ -48,24 +44,18 @@
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
* Define the Spring Boot Application settings itself. This class takes the place
* of a web.xml file, and configures all Filters/Listeners as methods (see below).
* <p>
* NOTE: Requires a Servlet 3.0 container, e.g. Tomcat 7.0 or above.
* <p>
* NOTE: This extends SpringBootServletInitializer in order to allow us to build
* a deployable WAR file with Spring Boot. See:
* http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-create-a-deployable-war-file
* Main configuration for the dspace web module.
*
* @author Andrea Bollini (andrea.bollini at 4science.it)
* @author Tim Donohue
* @author Luca Giamminonni (luca.giamminonni at 4science.it)
*/
@SpringBootApplication
@EnableScheduling
@EnableCaching
public class Application extends SpringBootServletInitializer {
@Configuration
public class WebApplication {

private static final Logger log = LoggerFactory.getLogger(Application.class);
private static final Logger log = LoggerFactory.getLogger(WebApplication.class);

@Autowired
private ApplicationConfig configuration;
Expand All @@ -88,26 +78,6 @@ public void sendGoogleAnalyticsEvents() {
googleAsyncEventListener.sendCollectedEvents();
}

/**
* Override the default SpringBootServletInitializer.configure() method,
* passing it this Application class.
* <p>
* This is necessary to allow us to build a deployable WAR, rather than
* always relying on embedded Tomcat.
* <p>
* See: http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-create-a-deployable-war-file
*
* @param application
* @return
*/
@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(), new DSpaceConfigurationInitializer());
}

/**
* Register the "DSpaceContextListener" so that it is loaded
* for this Application.
Expand Down Expand Up @@ -279,7 +249,7 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) {
// Make all other Webjars available off the /webjars path
registry
.addResourceHandler("/webjars/**")
.addResourceLocations("/webjars/");
.addResourceLocations("/webjars/", "classpath:/META-INF/resources/webjars/");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import org.dspace.app.rest.model.hateoas.DSpaceResource;
import org.dspace.app.rest.utils.Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.data.domain.Pageable;
import org.springframework.hateoas.IanaLinkRelations;
import org.springframework.hateoas.Link;
Expand All @@ -33,6 +35,7 @@
* @author Tom Desair (tom dot desair at atmire dot com)
*/
@Component
@Order(Ordered.HIGHEST_PRECEDENCE)
public class DSpaceResourceHalLinkFactory extends HalLinkFactory<DSpaceResource, RestResourceController> {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,19 @@
@Component
public class ExternalSourceItemUriListHandler extends ExternalSourceEntryItemUriListHandler<Item> {

private Pattern pattern = Pattern.compile("\\/api\\/core\\/items\\/(.*)");

@Autowired
private ItemService itemService;

@Override
@SuppressWarnings("rawtypes")
public boolean supports(List<String> uriList, String method,Class clazz) {
if (clazz != Item.class) {
if (clazz != Item.class || uriList.size() != 1) {
return false;
}
return true;

return pattern.matcher(uriList.get(0)).find();
}

@Override
Expand All @@ -61,7 +64,6 @@ public boolean validate(Context context, HttpServletRequest request, List<String
private Item getObjectFromUriList(Context context, List<String> uriList) {
Item item = null;
String url = uriList.get(0);
Pattern pattern = Pattern.compile("\\/api\\/core\\/items\\/(.*)");
Matcher matcher = pattern.matcher(url);
if (!matcher.find()) {
throw new DSpaceBadRequestException("The uri: " + url + " doesn't resolve to an item");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;

Expand All @@ -29,6 +31,7 @@
* the authenticated EPerson is allowed to perform the requested action.
*/
@Component
@Order(value = Ordered.HIGHEST_PRECEDENCE)
public class AdminRestPermissionEvaluatorPlugin extends RestObjectPermissionEvaluatorPlugin {

private static final Logger log = LoggerFactory.getLogger(RestObjectPermissionEvaluatorPlugin.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
# 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}

########################
# Servlet context path configuration for spring boot application running with embedded tomcat
#
server.servlet.context-path=/server

########################
# Jackson serialization settings
#
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* 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;

import org.dspace.app.rest.WebApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
* Spring boot application for integration tests.
*
* @author Luca Giamminonni (luca.giamminonni at 4science.it)
*
*/
@SpringBootApplication(scanBasePackageClasses = WebApplication.class)
public class TestApplication {

}
Loading

0 comments on commit 24eea0a

Please sign in to comment.