mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-15 14:03:17 +00:00
Replace Spring Data REST HAL Browser with HAL Browser from WebJars
This commit is contained in:
@@ -22,7 +22,10 @@ The only tested way right now is to run this webapp inside your IDE (Eclipse). J
|
|||||||
> dspace.dir = d:/install/dspace7
|
> dspace.dir = d:/install/dspace7
|
||||||
|
|
||||||
## HAL Browser
|
## HAL Browser
|
||||||
The modified version of the HAL Browser from the Spring Data REST project is included, the index.html file is overriden locally to support the /api baseURL (see [DATAREST-971](https://jira.spring.io/browse/DATAREST-971))
|
|
||||||
|
The modified version of the HAL Browser from https://github.com/mikekelly/hal-browser
|
||||||
|
|
||||||
|
We've updated/customized the HAL Browser to integrate better with our authentication system, provide CSRF support, and use a more recent version of its dependencies.
|
||||||
|
|
||||||
## Packages and main classes
|
## Packages and main classes
|
||||||
*[org.dspace.app.rest.Application](src/main/java/org/dspace/app/rest/Application.java)* is the spring boot main class it initializes
|
*[org.dspace.app.rest.Application](src/main/java/org/dspace/app/rest/Application.java)* is the spring boot main class it initializes
|
||||||
|
@@ -238,24 +238,7 @@
|
|||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!-- These next two dependencies build a WAR that is BOTH executable
|
<!-- Spring Boot dependencies -->
|
||||||
AND deployable into an external container (Tomcat).
|
|
||||||
See: http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#build-tool-plugins-maven-packaging -->
|
|
||||||
<!-- NOTE: For rapid development (if you don't need Solr or other webapps),
|
|
||||||
you can temporarily comment these out, and switch <packaging> to "jar".
|
|
||||||
This lets you develop in a standalone, runnable JAR application. -->
|
|
||||||
<!--<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>-->
|
|
||||||
<!-- Ensure embedded servlet container doesn't interfere when this
|
|
||||||
WAR is deployed to an external Tomcat (i.e. provided). -->
|
|
||||||
<!--<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>-->
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
@@ -293,17 +276,15 @@
|
|||||||
<version>0.4.6</version>
|
<version>0.4.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- The HAL Browser -->
|
<!-- HAL Browser (via WebJars) : https://github.com/mikekelly/hal-browser -->
|
||||||
|
<!-- This is primarily used to pull in the HAL Browser core Javascript code ('js' folder), as we've overridden
|
||||||
|
many dependencies below and the HTML pages in src/main/webapp/ -->
|
||||||
|
<!-- NOTE: Eventually this should be replaced by the HAL Explorer included in Spring Data REST,
|
||||||
|
see https://github.com/DSpace/DSpace/issues/3017 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.data</groupId>
|
<groupId>org.webjars</groupId>
|
||||||
<artifactId>spring-data-rest-hal-browser</artifactId>
|
<artifactId>hal-browser</artifactId>
|
||||||
<version>${spring-hal-browser.version}</version>
|
<version>ad9b865</version>
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.springframework.data</groupId>
|
|
||||||
<artifactId>spring-data-rest-webmvc</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- WebJars dependencies used to update/enhance the default HAL Browser -->
|
<!-- WebJars dependencies used to update/enhance the default HAL Browser -->
|
||||||
|
@@ -40,6 +40,7 @@ import org.springframework.web.cors.CorsConfiguration;
|
|||||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -192,13 +193,31 @@ public class Application extends SpringBootServletInitializer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a ViewController for the root path, to load HAL Browser
|
||||||
|
* @param registry ViewControllerRegistry
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void addViewControllers(ViewControllerRegistry registry) {
|
||||||
|
// Ensure accessing the root path will load the index.html of the HAL Browser
|
||||||
|
registry.addViewController("/").setViewName("forward:/index.html");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new ResourceHandler to allow us to use WebJars.org to pull in web dependencies
|
* Add a new ResourceHandler to allow us to use WebJars.org to pull in web dependencies
|
||||||
* dynamically for HAL Browser, and access them off the /webjars path.
|
* dynamically for HAL Browser, etc.
|
||||||
* @param registry ResourceHandlerRegistry
|
* @param registry ResourceHandlerRegistry
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||||
|
// First, "mount" the Hal Browser resources at the /browser path
|
||||||
|
// NOTE: the hal-browser directory uses the version of the Hal browser, so this needs to be synced
|
||||||
|
// with the org.webjars.hal-browser version in the POM
|
||||||
|
registry
|
||||||
|
.addResourceHandler("/browser/**")
|
||||||
|
.addResourceLocations("/webjars/hal-browser/ad9b865/");
|
||||||
|
|
||||||
|
// Make all other Webjars available off the /webjars path
|
||||||
registry
|
registry
|
||||||
.addResourceHandler("/webjars/**")
|
.addResourceHandler("/webjars/**")
|
||||||
.addResourceLocations("/webjars/");
|
.addResourceLocations("/webjars/");
|
||||||
|
5
pom.xml
5
pom.xml
@@ -46,8 +46,6 @@
|
|||||||
<bouncycastle.version>1.70</bouncycastle.version>
|
<bouncycastle.version>1.70</bouncycastle.version>
|
||||||
|
|
||||||
<!--=== SERVER WEBAPP DEPENDENCIES ===-->
|
<!--=== SERVER WEBAPP DEPENDENCIES ===-->
|
||||||
<!-- Spring Data REST HAL Browser (used by Server webapp) -->
|
|
||||||
<spring-hal-browser.version>3.3.9.RELEASE</spring-hal-browser.version>
|
|
||||||
<!-- Library for reading JSON documents: https://github.com/json-path/JsonPath (used by Server webapp) -->
|
<!-- Library for reading JSON documents: https://github.com/json-path/JsonPath (used by Server webapp) -->
|
||||||
<json-path.version>2.6.0</json-path.version>
|
<json-path.version>2.6.0</json-path.version>
|
||||||
<!-- Library for managing JSON Web Tokens (JWT): https://bitbucket.org/connect2id/nimbus-jose-jwt/wiki/Home
|
<!-- Library for managing JSON Web Tokens (JWT): https://bitbucket.org/connect2id/nimbus-jose-jwt/wiki/Home
|
||||||
@@ -1753,12 +1751,13 @@
|
|||||||
<version>1.2.5</version>
|
<version>1.2.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- json-path is needed by Spring HATEOAS -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.jayway.jsonpath</groupId>
|
<groupId>com.jayway.jsonpath</groupId>
|
||||||
<artifactId>json-path</artifactId>
|
<artifactId>json-path</artifactId>
|
||||||
<version>${json-path.version}</version>
|
<version>${json-path.version}</version>
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- json-path-assert is just needed by tests -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.jayway.jsonpath</groupId>
|
<groupId>com.jayway.jsonpath</groupId>
|
||||||
<artifactId>json-path-assert</artifactId>
|
<artifactId>json-path-assert</artifactId>
|
||||||
|
Reference in New Issue
Block a user