diff --git a/dspace-sword/src/main/java/org/dspace/app/configuration/SWORDWebConfig.java b/dspace-sword/src/main/java/org/dspace/app/configuration/SWORDWebConfig.java index 516cbec125..4d1578385b 100644 --- a/dspace-sword/src/main/java/org/dspace/app/configuration/SWORDWebConfig.java +++ b/dspace-sword/src/main/java/org/dspace/app/configuration/SWORDWebConfig.java @@ -7,42 +7,71 @@ */ 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.ServletContextInitializer; import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +/** + * SWORD webapp configuration. Replaces the old web.xml + *
+ * This @Configuration class is automatically discovered by Spring via a @ComponentScan. + *
+ * All SWORD web configurations (beans) can be enabled or disabled by setting "sword-server.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 SWORDWebConfig {
+ // Path where SWORD should be deployed (when enabled). Defaults to "sword"
+ @Value("${sword-server.path:sword}")
+ private String swordPath;
+
+ // SWORD Server class. Defaults to "org.dspace.sword.DSpaceSWORDServer"
+ @Value("${sword-server.class:org.dspace.sword.DSpaceSWORDServer}")
+ private String serverClass;
+
+ // SWORD Authentication Method. Defaults to "Basic"
+ @Value("${sword-server.authentication-method:Basic}")
+ private String authenticationMethod;
@Bean
+ @ConditionalOnProperty("sword-server.enabled")
public ServletContextInitializer swordv1ContextInitializer() {
return servletContext -> {
- servletContext.setInitParameter("sword-server-class", "org.dspace.sword.DSpaceSWORDServer");
- servletContext.setInitParameter("authentication-method", "Basic");
+ servletContext.setInitParameter("sword-server-class", serverClass);
+ servletContext.setInitParameter("authentication-method", authenticationMethod);
};
}
@Bean
+ @ConditionalOnProperty("sword-server.enabled")
public ServletRegistrationBean swordv1ServiceDocumentBean() {
ServletRegistrationBean bean = new ServletRegistrationBean( new org.purl.sword.server.ServiceDocumentServlet(),
- "/sword/servicedocument/*");
+ "/" + swordPath + "/servicedocument/*");
bean.setLoadOnStartup(1);
return bean;
}
@Bean
+ @ConditionalOnProperty("sword-server.enabled")
public ServletRegistrationBean swordv1DepositBean() {
ServletRegistrationBean bean = new ServletRegistrationBean( new org.purl.sword.server.DepositServlet(),
- "/sword/deposit/*");
+ "/" + swordPath + "/deposit/*");
bean.setLoadOnStartup(1);
return bean;
}
@Bean
+ @ConditionalOnProperty("sword-server.enabled")
public ServletRegistrationBean swordv1MediaLinkBean() {
ServletRegistrationBean bean = new ServletRegistrationBean( new org.purl.sword.server.AtomDocumentServlet(),
- "/sword/media-link/*");
+ "/" + swordPath + "/media-link/*");
bean.setLoadOnStartup(1);
return bean;
}
diff --git a/dspace-sword/src/main/webapp/WEB-INF/web.xml b/dspace-sword/src/main/webapp/WEB-INF/web.xml
deleted file mode 100644
index 14b873ccd9..0000000000
--- a/dspace-sword/src/main/webapp/WEB-INF/web.xml
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-