DS-3489: Added license headers for the build to pass and changed a test to be consistent with a new implementation

This commit is contained in:
Raf Ponsaerts
2017-10-04 11:56:55 +02:00
committed by Tom Desair
parent fbbead6137
commit ee34bb07e7
53 changed files with 124 additions and 604 deletions

View File

@@ -7,15 +7,6 @@
*/
package org.dspace.servicemanager;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.lang.ArrayUtils;
import org.dspace.kernel.Activator;
import org.dspace.kernel.mixins.*;
@@ -28,6 +19,9 @@ import org.springframework.beans.BeanWrapper;
import org.springframework.beans.PropertyAccessorFactory;
import org.springframework.context.ConfigurableApplicationContext;
import java.util.*;
import java.util.Map.Entry;
/**
* This is the core service manager which ties together the other
* service managers and generally handles any edge cases in the various

View File

@@ -7,6 +7,8 @@
*/
package org.dspace.servicemanager;
import org.springframework.context.ConfigurableApplicationContext;
import java.util.List;
import java.util.Map;

View File

@@ -7,17 +7,18 @@
*/
package org.dspace.utils.servicemanager;
import static org.junit.Assert.*;
import org.dspace.kernel.ServiceManager;
import org.dspace.kernel.mixins.OrderedService;
import org.junit.Test;
import org.springframework.context.ConfigurableApplicationContext;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.dspace.kernel.ServiceManager;
import org.dspace.kernel.mixins.OrderedService;
import org.junit.Test;
import org.springframework.context.ConfigurableApplicationContext;
import static org.junit.Assert.*;
/**
* Tests the usage of the provider stack

View File

@@ -28,7 +28,6 @@ import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.core.annotation.Order;
@@ -44,7 +43,6 @@ import javax.servlet.Filter;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import java.io.File;
import java.util.List;
/**
* Define the Spring Boot Application settings itself. This class takes the place
@@ -60,13 +58,17 @@ import java.util.List;
* @author Tim Donohue
*/
@SpringBootApplication
public class Application extends SpringBootServletInitializer
{
public class Application extends SpringBootServletInitializer {
private static final Logger log = LoggerFactory.getLogger(Application.class);
@Autowired
private ApplicationConfig configuration;
@Value("${dspace.dir}")
private String dspaceHome;
private transient DSpaceKernelImpl kernelImpl;
/**
* Override the default SpringBootServletInitializer.configure() method,
* passing it this Application class.
@@ -75,7 +77,6 @@ public class Application extends SpringBootServletInitializer
* always relying on embedded Tomcat.
* <p>
* <p>
*
* See: http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-create-a-deployable-war-file
*
* @param application
@@ -84,77 +85,39 @@ public class Application extends SpringBootServletInitializer
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
//Load extra configs (see org.dspace.servicemanager.DSpaceServiceManager.startup())
String[] extraConfigs = dsConfigService.getPropertyAsType("service.manager.spring.configs", String[].class);
// start the kernel when the webapp starts
try {
this.kernelImpl = DSpaceKernelInit.getKernel(null);
if (!this.kernelImpl.isRunning()) {
this.kernelImpl.start(getProvidedHome(dspaceHome)); // init the kernel
}
String[] extraSources = SpringServiceManager.getSpringPaths(false, extraConfigs, dsConfigService);
return application
.parent(kernelImpl.getServiceManager().getApplicationContext())
.listeners(new DSpaceKernelDestroyer(kernelImpl))
.sources(Application.class);
return application.sources(Application.class)
.sources(extraSources);
} catch (Exception e) {
// failed to start so destroy it and log and throw an exception
try {
this.kernelImpl.destroy();
} catch (Exception e1) {
// nothing
}
String message = "Failure during SpringApplicationBuilder configuration: " + e.getMessage();
log.error(message + ":" + e.getMessage(), e);
throw new RuntimeException(message, e);
}
}
@Bean
public ServletContextInitializer contextInitializer() {
return new ServletContextInitializer() {
private transient DSpaceKernelImpl kernelImpl;
@Override
public void onStartup(ServletContext servletContext)
throws ServletException {
servletContext.setInitParameter("dspace.dir", configuration.getDspaceHome());
// start the kernel when the webapp starts
try {
this.kernelImpl = DSpaceKernelInit.getKernel(null);
if (!this.kernelImpl.isRunning()) {
this.kernelImpl.start(getProvidedHome(configuration.getDspaceHome())); // init the kernel
}
//Set the DSpace Kernel Application context as a parent of the Spring Boot context so that
//we can auto-wire all DSpace Kernel services
springBootApplicationContext.setParent(kernelImpl.getServiceManager().getApplicationContext());
//Add a listener for Spring Boot application shutdown so that we can nicely cleanup the DSpace kernel.
springBootApplicationContext.addApplicationListener(new DSpaceKernelDestroyer(kernelImpl));
} catch (Exception e) {
// failed to start so destroy it and log and throw an exception
try {
this.kernelImpl.destroy();
} catch (Exception e1) {
// nothing
}
String message = "Failure during ServletContext initialisation: " + e.getMessage();
log.error(message + ":" + e.getMessage(), e);
throw new RuntimeException(message, e);
}
}
/**
* Find DSpace's "home" directory.
* Initially look for JNDI Resource called "java:/comp/env/dspace.dir".
* If not found, look for "dspace.dir" initial context parameter.
*/
private String getProvidedHome(String dspaceHome) {
String providedHome = null;
try {
Context ctx = new InitialContext();
providedHome = (String) ctx.lookup("java:/comp/env/" + DSpaceConfigurationService.DSPACE_HOME);
} catch (Exception e) {
// do nothing
}
if (providedHome == null) {
if (dspaceHome != null && !dspaceHome.equals("") &&
!dspaceHome.equals("${" + DSpaceConfigurationService.DSPACE_HOME + "}")) {
File test = new File(dspaceHome);
if (test.exists() && new File(test, DSpaceConfigurationService.DSPACE_CONFIG_PATH).exists()) {
providedHome = dspaceHome;
}
}
}
return providedHome;
}
};
}
@@ -225,92 +188,31 @@ public class Application extends SpringBootServletInitializer
};
}
/** Utility class that will destroy the DSpace Kernel on Spring Boot shutdown */
private class DSpaceKernelDestroyer implements ApplicationListener<ContextClosedEvent> {
private DSpaceKernel kernel;
public DSpaceKernelDestroyer(DSpaceKernel kernel) {
this.kernel = kernel;
/**
* Find DSpace's "home" directory.
* Initially look for JNDI Resource called "java:/comp/env/dspace.dir".
* If not found, look for "dspace.dir" initial context parameter.
*/
private String getProvidedHome(String dspaceHome) {
String providedHome = null;
try {
Context ctx = new InitialContext();
providedHome = (String) ctx.lookup("java:/comp/env/" + DSpaceConfigurationService.DSPACE_HOME);
} catch (Exception e) {
// do nothing
}
public void onApplicationEvent(final ContextClosedEvent event) {
if (this.kernel != null) {
this.kernel.destroy();
this.kernel = null;
}
}
}
/** Utility class that will initialize the DSpace Kernel on Spring Boot startup */
private class DSpaceKernelInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {
private transient DSpaceKernel dspaceKernel;
public void initialize(final ConfigurableApplicationContext applicationContext) {
String dspaceHome = applicationContext.getEnvironment().getProperty("dspace.dir");
this.dspaceKernel = DSpaceKernelManager.getDefaultKernel();
if (this.dspaceKernel == null) {
DSpaceKernelImpl kernelImpl = null;
try {
kernelImpl = DSpaceKernelInit.getKernel(null);
if (!kernelImpl.isRunning()) {
kernelImpl.start(getProvidedHome(dspaceHome)); // init the kernel
}
this.dspaceKernel = kernelImpl;
} catch (Exception e) {
// failed to start so destroy it and log and throw an exception
try {
if (kernelImpl != null) {
kernelImpl.destroy();
}
this.dspaceKernel = null;
} catch (Exception e1) {
// nothing
}
String message = "Failure during ServletContext initialisation: " + e.getMessage();
log.error(message + ":" + e.getMessage(), e);
throw new RuntimeException(message, e);
}
}
if (applicationContext.getParent() == null) {
//Set the DSpace Kernel Application context as a parent of the Spring Boot context so that
//we can auto-wire all DSpace Kernel services
applicationContext.setParent(dspaceKernel.getServiceManager().getApplicationContext());
//Add a listener for Spring Boot application shutdown so that we can nicely cleanup the DSpace kernel.
applicationContext.addApplicationListener(new DSpaceKernelDestroyer(dspaceKernel));
}
}
/**
* Find DSpace's "home" directory.
* Initially look for JNDI Resource called "java:/comp/env/dspace.dir".
* If not found, look for "dspace.dir" initial context parameter.
*/
private String getProvidedHome(String dspaceHome) {
String providedHome = null;
try {
Context ctx = new InitialContext();
providedHome = (String) ctx.lookup("java:/comp/env/" + DSpaceConfigurationService.DSPACE_HOME);
} catch (Exception e) {
// do nothing
}
if (providedHome == null) {
if (dspaceHome != null && !dspaceHome.equals("") &&
!dspaceHome.equals("${" + DSpaceConfigurationService.DSPACE_HOME + "}")) {
File test = new File(dspaceHome);
if (test.exists() && new File(test, DSpaceConfigurationService.DSPACE_CONFIG_PATH).exists()) {
providedHome = dspaceHome;
}
if (providedHome == null) {
if (dspaceHome != null && !dspaceHome.equals("") &&
!dspaceHome.equals("${" + DSpaceConfigurationService.DSPACE_HOME + "}")) {
File test = new File(dspaceHome);
if (test.exists() && new File(test, DSpaceConfigurationService.DSPACE_CONFIG_PATH).exists()) {
providedHome = dspaceHome;
}
}
return providedHome;
}
return providedHome;
}
private class DSpaceKernelDestroyer implements ApplicationListener<ContextClosedEvent> {

View File

@@ -1,10 +1,3 @@
/**
* 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;
import org.apache.commons.lang.StringUtils;
@@ -24,7 +17,6 @@ import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;

View File

@@ -43,16 +43,11 @@ public class RootRestResourceController {
@RequestMapping(method = RequestMethod.GET)
public RootResource listDefinedEndpoint(HttpServletRequest request) {
String restUrl = getRestURL(request);
RootRest rootRest = rootRestRepository.getRoot(restUrl);
RootRest rootRest = rootRestRepository.getRoot();
RootResource rootResource = new RootResource(rootRest);
halLinkService.addLinks(rootResource);
return rootResource;
}
private String getRestURL(HttpServletRequest request) {
String url = request.getRequestURL().toString();
return url.substring(0, url.length() - request.getRequestURI().length()) + request.getContextPath();
}
}

View File

@@ -1,10 +1,3 @@
/**
* 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.converter;
import org.apache.commons.collections4.CollectionUtils;
@@ -20,6 +13,7 @@ import java.util.List;
/**
* Created by raf on 22/09/2017.
*
* TODO RAF UNIT TEST
*/
@Component
public class DiscoverConfigurationConverter {

View File

@@ -1,10 +1,3 @@
/**
* 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.converter;
import org.apache.commons.collections4.CollectionUtils;

View File

@@ -1,10 +1,3 @@
/**
* 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.converter;
import org.dspace.app.rest.model.SearchSupportRest;

View File

@@ -1,10 +1,3 @@
/**
* 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.converter;
import org.dspace.app.rest.model.RootRest;
@@ -23,11 +16,10 @@ public class RootConverter {
@Autowired
private ConfigurationService configurationService;
public RootRest convert(String restUrl){
public RootRest convert(){
RootRest rootRest = new RootRest();
rootRest.setDspaceName(configurationService.getProperty("dspace.name"));
rootRest.setDspaceURL(configurationService.getProperty("dspace.url"));
rootRest.setDspaceRest(restUrl);
return rootRest;
}
}

View File

@@ -1,10 +1,3 @@
/**
* 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.link;
import org.dspace.app.rest.DiscoveryRestController;

View File

@@ -1,13 +1,9 @@
/**
* 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.link;
import org.apache.poi.ss.formula.functions.T;
import org.dspace.app.rest.DiscoveryRestController;
import org.dspace.app.rest.model.hateoas.HALResource;
import org.dspace.app.rest.model.hateoas.SearchResultsResource;
import org.springframework.hateoas.Link;
import org.springframework.stereotype.Component;
import org.springframework.web.util.UriComponentsBuilder;

View File

@@ -1,12 +1,6 @@
/**
* 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.link;
import org.dspace.app.rest.model.hateoas.DSpaceResource;
import org.dspace.app.rest.model.hateoas.HALResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;

View File

@@ -1,10 +1,3 @@
/**
* 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.link;
import org.dspace.app.rest.DiscoveryRestController;

View File

@@ -1,10 +1,3 @@
/**
* 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.link;
import org.dspace.app.rest.DiscoverableEndpointsService;
@@ -28,7 +21,7 @@ public class RootHalLinkFactory extends HalLinkFactory<RootResource, RootRestRes
protected void addLinks(RootResource halResource, LinkedList<Link> list) {
for(Link endpointLink : discoverableEndpointsService.getDiscoverableEndpoints()){
list.add(buildLink(endpointLink.getRel(), halResource.getData().getDspaceRest() + endpointLink.getHref()));
list.add(buildLink(endpointLink.getRel(), endpointLink.getRel()));
}
}

View File

@@ -1,21 +1,23 @@
/**
* 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.link.search;
import org.apache.commons.lang3.ObjectUtils;
import org.dspace.app.rest.DiscoveryRestController;
import org.dspace.app.rest.link.HalLinkFactory;
import org.dspace.app.rest.model.SearchConfigurationRest;
import org.dspace.app.rest.model.SearchResultsRest;
import org.dspace.app.rest.model.hateoas.HALResource;
import org.dspace.app.rest.model.hateoas.SearchConfigurationResource;
import org.dspace.app.rest.model.hateoas.SearchResultsResource;
import org.springframework.hateoas.Link;
import org.springframework.stereotype.Component;
import org.springframework.web.util.UriComponentsBuilder;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
/**
* Created by raf on 25/09/2017.

View File

@@ -1,10 +1,3 @@
/**
* 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.link.search;
import org.dspace.app.rest.DiscoveryRestController;

View File

@@ -1,10 +1,3 @@
/**
* 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.link.search;
import org.dspace.app.rest.DiscoveryRestController;

View File

@@ -10,8 +10,6 @@ package org.dspace.app.rest.model;
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.dspace.kernel.DSpaceKernel;
import org.dspace.servicemanager.DSpaceServiceManager;
import org.dspace.servicemanager.config.DSpaceConfigurationService;
@@ -42,5 +40,4 @@ public interface RestModel extends Serializable {
public Class getController();
}

View File

@@ -1,14 +1,5 @@
/**
* 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.model;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.dspace.app.rest.RootRestResourceController;
/**
@@ -19,7 +10,6 @@ public class RootRest implements RestModel {
public static final String CATEGORY = RestModel.ROOT;
private String dspaceURL;
private String dspaceName;
private String dspaceRest;
public String getCategory() {
return CATEGORY;
@@ -47,29 +37,4 @@ public class RootRest implements RestModel {
public void setDspaceName(String dspaceName) {
this.dspaceName = dspaceName;
}
public String getDspaceRest(){ return dspaceRest;}
public void setDspaceRest(String dspaceRest) {this.dspaceRest = dspaceRest;}
@Override
public boolean equals(Object object){
return (object instanceof RootRest &&
new EqualsBuilder().append(this.getCategory(), ((RootRest) object).getCategory())
.append(this.getType(), ((RootRest) object).getType())
.append(this.getController(), ((RootRest) object).getController())
.append(this.getDspaceURL(), ((RootRest) object).getDspaceURL())
.append(this.getDspaceName(), ((RootRest) object).getDspaceName())
.append(this.getDspaceRest(), ((RootRest) object).getDspaceRest())
.isEquals());
}
@Override
public int hashCode() {
return new HashCodeBuilder(17, 37)
.append(this.getCategory())
.append(this.getType())
.append(this.getController())
.append(this.getDspaceName())
.append(this.getDspaceURL())
.append(this.getDspaceRest())
.toHashCode();
}
}

View File

@@ -1,18 +1,7 @@
/**
* 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.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.apache.commons.codec.binary.StringUtils;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.dspace.app.rest.DiscoveryRestController;
import org.dspace.app.rest.model.hateoas.SearchConfigurationResource;
import java.util.ArrayList;
import java.util.LinkedList;
@@ -72,33 +61,6 @@ public class SearchConfigurationRest extends BaseObjectRest<String> {
public List<SortOption> getSortOptions(){
return sortOptions;
}
@Override
public boolean equals(Object object){
return (object instanceof SearchConfigurationRest &&
new EqualsBuilder().append(this.getCategory(), ((SearchConfigurationRest) object).getCategory())
.append(this.getType(), ((SearchConfigurationRest) object).getType())
.append(this.getController(), ((SearchConfigurationRest) object).getController())
.append(this.getScope(), ((SearchConfigurationRest) object).getScope())
.append(this.getConfigurationName(), ((SearchConfigurationRest) object).getConfigurationName())
.append(this.getFilters(), ((SearchConfigurationRest) object).getFilters())
.append(this.getSortOptions(), ((SearchConfigurationRest) object).getSortOptions())
.isEquals());
}
@Override
public int hashCode() {
return new HashCodeBuilder(17, 37)
.append(this.getCategory())
.append(this.getType())
.append(this.getController())
.append(this.getScope())
.append(this.getConfigurationName())
.append(this.getFilters())
.append(this.getSortOptions())
.toHashCode();
}
public static class Filter{
private String filter;
private List<Operator> operators = new LinkedList<>();
@@ -132,20 +94,6 @@ public class SearchConfigurationRest extends BaseObjectRest<String> {
operators.add(new Operator(OPERATOR_CONTAINS));
operators.add(new Operator(OPERATOR_NOTCONTAINS));
}
@Override
public boolean equals(Object object){
return (object instanceof SearchConfigurationRest.Filter &&
new EqualsBuilder().append(this.filter, ((Filter) object).filter)
.append(this.getOperators(), ((Filter) object).getOperators())
.isEquals());
}
@Override
public int hashCode() {
return new HashCodeBuilder(17, 37)
.append(filter)
.append(operators)
.toHashCode();
}
public static class Operator{
private String operator;
public Operator(String operator){
@@ -154,17 +102,6 @@ public class SearchConfigurationRest extends BaseObjectRest<String> {
public String getOperator(){
return operator;
}
@Override
public boolean equals(Object object){
return (object instanceof SearchConfigurationRest.Filter.Operator &&
new EqualsBuilder().append(this.getOperator(), ((Operator) object).getOperator()).isEquals());
}
@Override
public int hashCode() {
return new HashCodeBuilder(17, 37)
.append(operator)
.toHashCode();
}
}
}
@@ -187,19 +124,5 @@ public class SearchConfigurationRest extends BaseObjectRest<String> {
public String getMetadata(){
return metadata;
}
@Override
public boolean equals(Object object){
return (object instanceof SearchConfigurationRest.SortOption &&
new EqualsBuilder().append(this.getName(), ((SortOption) object).getName())
.append(this.getMetadata(), ((SortOption) object).getMetadata())
.isEquals());
}
@Override
public int hashCode() {
return new HashCodeBuilder(17, 37)
.append(name)
.append(metadata)
.toHashCode();
}
}
}

View File

@@ -1,10 +1,3 @@
/**
* 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.model;
import com.fasterxml.jackson.annotation.JsonIgnore;

View File

@@ -1,10 +1,3 @@
/**
* 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.model;
import com.fasterxml.jackson.annotation.JsonIgnore;

View File

@@ -1,14 +1,5 @@
/**
* 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.model;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.dspace.app.rest.DiscoveryRestController;
/**
@@ -28,21 +19,4 @@ public class SearchSupportRest extends BaseObjectRest<String>{
public Class getController() {
return DiscoveryRestController.class;
}
@Override
public boolean equals(Object object){
return (object instanceof SearchSupportRest &&
new EqualsBuilder().append(this.getCategory(), ((SearchSupportRest) object).getCategory())
.append(this.getType(), ((SearchSupportRest) object).getType())
.append(this.getController(), ((SearchSupportRest) object).getController())
.isEquals());
}
@Override
public int hashCode() {
return new HashCodeBuilder(17, 37)
.append(this.getCategory())
.append(this.getType())
.append(this.getController())
.toHashCode();
}
}

View File

@@ -1,10 +1,3 @@
/**
* 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.model.hateoas;
import com.fasterxml.jackson.annotation.JsonInclude;

View File

@@ -1,10 +1,3 @@
/**
* 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.model.hateoas;
import com.fasterxml.jackson.annotation.JsonUnwrapped;

View File

@@ -1,10 +1,3 @@
/**
* 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.model.hateoas;
import com.fasterxml.jackson.annotation.JsonUnwrapped;

View File

@@ -1,10 +1,3 @@
/**
* 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.model.hateoas;
import com.fasterxml.jackson.annotation.JsonUnwrapped;

View File

@@ -1,10 +1,3 @@
/**
* 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.model.hateoas;
import com.fasterxml.jackson.annotation.JsonUnwrapped;

View File

@@ -1,10 +1,3 @@
/**
* 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.model.hateoas;
import com.fasterxml.jackson.annotation.JsonUnwrapped;

View File

@@ -7,9 +7,6 @@
*/
package org.dspace.app.rest.repository;
import java.sql.SQLException;
import java.util.List;
import org.dspace.app.rest.converter.BitstreamFormatConverter;
import org.dspace.app.rest.model.BitstreamFormatRest;
import org.dspace.app.rest.model.hateoas.BitstreamFormatResource;
@@ -21,6 +18,8 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Component;
import java.sql.SQLException;
import java.util.List;
/**
* This is the repository responsible to manage BitstreamFormat Rest object

View File

@@ -7,14 +7,6 @@
*/
package org.dspace.app.rest.repository;
import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import org.dspace.app.rest.converter.BitstreamConverter;
import org.dspace.app.rest.model.BitstreamRest;
import org.dspace.app.rest.model.hateoas.BitstreamResource;
@@ -28,6 +20,14 @@ import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
/**
* This is the repository responsible to manage Bitstream Rest object
*

View File

@@ -7,20 +7,12 @@
*/
package org.dspace.app.rest.repository;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.Iterator;
import java.util.UUID;
import java.util.function.Consumer;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.dspace.app.rest.converter.BrowseEntryConverter;
import org.dspace.app.rest.converter.BrowseIndexConverter;
import org.dspace.app.rest.model.BrowseEntryRest;
import org.dspace.app.rest.model.BrowseIndexRest;
import org.dspace.app.rest.model.hateoas.BrowseEntryResource;
import org.dspace.app.rest.utils.ScopeResolver;
import org.dspace.browse.*;
import org.dspace.content.DSpaceObject;
import org.dspace.content.service.CollectionService;
@@ -35,6 +27,7 @@ import javax.servlet.http.HttpServletRequest;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.Iterator;
import java.util.UUID;
import java.util.function.Consumer;
/**
@@ -54,7 +47,10 @@ public class BrowseEntryLinkRepository extends AbstractDSpaceRestRepository
BrowseIndexConverter bixConverter;
@Autowired
ScopeResolver scopeResolver;
CollectionService collectionService;
@Autowired
CommunityService communityService;
// FIXME It will be nice to drive arguments binding by annotation as in normal spring controller methods
public Page<BrowseEntryRest> listBrowseEntries(HttpServletRequest request, String browseName,

View File

@@ -7,11 +7,6 @@
*/
package org.dspace.app.rest.repository;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.dspace.app.rest.converter.ItemConverter;
import org.dspace.app.rest.model.BrowseIndexRest;
@@ -50,7 +45,10 @@ public class BrowseItemLinkRepository extends AbstractDSpaceRestRepository
ItemRestRepository itemRestRepository;
@Autowired
ScopeResolver scopeResolver;
CollectionService collectionService;
@Autowired
CommunityService communityService;
public Page<ItemRest> listBrowseItems(HttpServletRequest request, String browseName, Pageable pageable, String projection)
throws BrowseException, SQLException {

View File

@@ -7,12 +7,6 @@
*/
package org.dspace.app.rest.repository;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.dspace.app.rest.SearchRestMethod;
import org.dspace.app.rest.converter.CollectionConverter;
import org.dspace.app.rest.model.CollectionRest;
import org.dspace.app.rest.model.hateoas.CollectionResource;
@@ -29,6 +23,11 @@ import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Component;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
* This is the repository responsible to manage Item Rest object
*

View File

@@ -7,12 +7,6 @@
*/
package org.dspace.app.rest.repository;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.dspace.app.rest.SearchRestMethod;
import org.dspace.app.rest.converter.CommunityConverter;
import org.dspace.app.rest.model.CommunityRest;
import org.dspace.app.rest.model.hateoas.CommunityResource;
@@ -27,6 +21,11 @@ import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.webmvc.ResourceNotFoundException;
import org.springframework.stereotype.Component;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
* This is the repository responsible to manage Item Rest object
*

View File

@@ -1,10 +1,3 @@
/**
* 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.repository;
import org.apache.log4j.Logger;

View File

@@ -7,12 +7,6 @@
*/
package org.dspace.app.rest.repository;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import org.dspace.app.rest.converter.ItemConverter;
import org.dspace.app.rest.model.ItemRest;
import org.dspace.app.rest.model.hateoas.ItemResource;
@@ -25,6 +19,12 @@ import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Component;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
/**
* This is the repository responsible to manage Item Rest object
*

View File

@@ -7,9 +7,6 @@
*/
package org.dspace.app.rest.repository;
import java.sql.SQLException;
import java.util.List;
import org.dspace.app.rest.converter.MetadataFieldConverter;
import org.dspace.app.rest.model.MetadataFieldRest;
import org.dspace.app.rest.model.hateoas.MetadataFieldResource;
@@ -21,6 +18,9 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Component;
import java.sql.SQLException;
import java.util.List;
/**
* This is the repository responsible to manage MetadataField Rest object
*

View File

@@ -7,9 +7,6 @@
*/
package org.dspace.app.rest.repository;
import java.sql.SQLException;
import java.util.List;
import org.dspace.app.rest.converter.MetadataSchemaConverter;
import org.dspace.app.rest.model.MetadataSchemaRest;
import org.dspace.app.rest.model.hateoas.MetadataSchemaResource;
@@ -21,6 +18,9 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Component;
import java.sql.SQLException;
import java.util.List;
/**
* This is the repository responsible to manage MetadataSchema Rest object
*

View File

@@ -1,10 +1,3 @@
/**
* 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.repository;
import org.dspace.app.rest.converter.RootConverter;
@@ -21,7 +14,7 @@ public class RootRestRepository {
@Autowired
RootConverter rootConverter;
public RootRest getRoot(String restUrl){
return rootConverter.convert(restUrl);
public RootRest getRoot(){
return rootConverter.convert();
}
}

View File

@@ -7,11 +7,6 @@
*/
package org.dspace.app.rest.repository;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.dspace.app.rest.converter.SiteConverter;
import org.dspace.app.rest.model.SiteRest;
import org.dspace.app.rest.model.hateoas.SiteResource;
@@ -24,6 +19,11 @@ import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Component;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
* This is the repository responsible to manage Item Rest object
*

View File

@@ -1,10 +1,3 @@
/**
* 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.converter;

View File

@@ -1,10 +1,3 @@
/**
* 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.converter;
import org.dspace.app.rest.model.SearchSupportRest;

View File

@@ -1,10 +1,3 @@
/**
* 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.converter;
import org.dspace.app.rest.model.RootRest;

View File

@@ -1,10 +1,3 @@
/**
* 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.link.search;
import org.dspace.app.rest.DiscoveryRestController;

View File

@@ -1,10 +1,3 @@
/**
* 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.link.search;
import org.dspace.app.rest.DiscoveryRestController;

View File

@@ -1,10 +1,3 @@
/**
* 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.link.search;
import org.dspace.app.rest.DiscoveryRestController;

View File

@@ -1,10 +1,3 @@
/**
* 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.model;
import org.dspace.app.rest.DiscoveryRestController;

View File

@@ -1,18 +1,13 @@
/**
* 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.model;
import org.dspace.app.rest.DiscoveryRestController;
import org.dspace.app.rest.RootRestResourceController;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
/**
* Created by raf on 26/09/2017.

View File

@@ -1,10 +1,3 @@
/**
* 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.model.hateoas;
import org.dspace.app.rest.model.RootRest;

View File

@@ -1,10 +1,3 @@
/**
* 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.model.hateoas;
import org.dspace.app.rest.model.SearchConfigurationRest;

View File

@@ -1,10 +1,3 @@
/**
* 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.model.hateoas;
import org.dspace.app.rest.model.SearchSupportRest;