DATAREST-638 - Polishing.

Removed unnecessary dependencies from AlpsController. Minor formatting issues. Copyright years.

Original pull request: #196.
This commit is contained in:
Oliver Gierke
2015-08-19 10:38:56 +02:00
parent 345c198a75
commit 52a8d837f0
4 changed files with 13 additions and 27 deletions

View File

@@ -21,7 +21,6 @@ import java.util.Collections;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.support.Repositories;
import org.springframework.data.rest.core.Path;
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
import org.springframework.data.rest.core.mapping.RepositoryResourceMappings;
import org.springframework.data.rest.core.mapping.ResourceMapping;
@@ -41,7 +40,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
* Profile-based controller exposing multiple forms of metadata.
*
* @author Greg Turnquist
* @see DATAREST-638
* @author Oliver Gierke
* @since 2.4
*/
@BasePathAwareController
@@ -63,7 +62,7 @@ public class ProfileController {
*/
@Autowired
public ProfileController(RepositoryRestConfiguration configuration, RepositoryResourceMappings mappings,
Repositories repositories) {
Repositories repositories) {
Assert.notNull(configuration, "RepositoryRestConfiguration must not be null!");
Assert.notNull(mappings, "RepositoryResourceMappings must not be null!");
@@ -113,7 +112,7 @@ public class ProfileController {
}
/**
* Return href for the profile root link of a given baseUri.
* Return the href for the profile root link of a given baseUri.
*
* @param configuration is the source of the app's baseUri.
* @return
@@ -125,7 +124,7 @@ public class ProfileController {
}
/**
* Return href for the profile link of a given baseUri and domain type mapping.
* Return the href for the profile link of a given baseUri and domain type mapping.
*
* @param configuration is the source of the app's baseUri.
* @param mapping provides the resource's path.
@@ -133,10 +132,7 @@ public class ProfileController {
*/
public static String getPath(RepositoryRestConfiguration configuration, ResourceMapping mapping) {
if (mapping == null) {
return getRootPath(configuration);
} else {
return getRootPath(configuration) + mapping.getPath();
}
String path = getRootPath(configuration);
return mapping == null ? path : path + mapping.getPath();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2014-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,8 +24,8 @@ import org.springframework.util.Assert;
/**
* {@link ResourceProcessor} to add a {@code profile} link to the root resource to point to multiple forms of metadata.
*
* @author Oliver Gierke
* @author Greg Turnquist
* @see DATAREST-638
* @since 2.4
*/
public class ProfileResourceProcessor implements ResourceProcessor<RepositoryLinksResource> {
@@ -43,7 +43,6 @@ public class ProfileResourceProcessor implements ResourceProcessor<RepositoryLin
public ProfileResourceProcessor(RepositoryRestConfiguration configuration) {
Assert.notNull(configuration, "RepositoryRestConfiguration must not be null!");
this.configuration = configuration;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013-2014 the original author or authors.
* Copyright 2013-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@@ -20,7 +20,6 @@ import static org.springframework.web.bind.annotation.RequestMethod.*;
import java.util.Collections;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.support.Repositories;
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
import org.springframework.data.rest.core.mapping.ResourceMappings;
import org.springframework.data.rest.webmvc.BasePathAwareController;
@@ -48,27 +47,18 @@ import org.springframework.web.bind.annotation.RequestMapping;
@BasePathAwareController
public class AlpsController {
private final Repositories repositories;
private final ResourceMappings mappings;
private final RepositoryRestConfiguration configuration;
/**
* Creates a new {@link AlpsController} for the given {@link Repositories},
* {@link RootResourceInformationToAlpsDescriptorConverter} and {@link ResourceMappings}.
* Creates a new {@link AlpsController} for the given {@link ResourceMappings}.
*
* @param repositories must not be {@literal null}.
* @param mappings must not be {@literal null}.
* @param configuration must not be {@literal null}.
*/
@Autowired
public AlpsController(Repositories repositories, ResourceMappings mappings, RepositoryRestConfiguration configuration) {
public AlpsController(RepositoryRestConfiguration configuration) {
Assert.notNull(repositories, "Repositories must not be null!");
Assert.notNull(mappings, "ResourceMappings must not be null!");
Assert.notNull(configuration, "MetadataConfiguration must not be null!");
this.repositories = repositories;
this.mappings = mappings;
this.configuration = configuration;
}
@@ -77,7 +67,8 @@ public class AlpsController {
*
* @return
*/
@RequestMapping(value = ProfileController.RESOURCE_PROFILE_MAPPING, method = OPTIONS, produces = RestMediaTypes.ALPS_JSON_VALUE)
@RequestMapping(value = ProfileController.RESOURCE_PROFILE_MAPPING, method = OPTIONS,
produces = RestMediaTypes.ALPS_JSON_VALUE)
HttpEntity<?> alpsOptions() {
verifyAlpsEnabled();