forked from spring-projects/spring-data-commons
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DATACMNS-418 - PagedResourcesAssembler now adds self links to PagedRe…
…sources. PagedResourcesAssembler now adds a LinkTemplate to every PagedResources instance created and pulls the template variable information from the registered resolvers for Pageable and Sort. Extended PageableResourceAssemblerArgumentResolver to create a special MethodParameterAwarePagedResourcesAssembler so that the assembler will take qualifier information into account when being injected into controller methods. Upgraded to Spring HATEOAS 0.9.0.BUILD-SNAPSHOT to be able to benefit from new methods added to MethodParameters as well as the LinkTemplate class. Updated Sonargraph architecture definition to allow the web layer to access logging.
- Loading branch information
Showing
10 changed files
with
395 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/main/java/org/springframework/data/web/MethodParameterAwarePagedResourcesAssembler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright 2014 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.springframework.data.web; | ||
|
||
import org.springframework.core.MethodParameter; | ||
import org.springframework.util.Assert; | ||
import org.springframework.web.util.UriComponents; | ||
|
||
/** | ||
* Custom {@link PagedResourcesAssembler} that is aware of the {@link MethodParameter} it shall create links for. | ||
* | ||
* @author Oliver Gierke | ||
* @since 1.7 | ||
*/ | ||
class MethodParameterAwarePagedResourcesAssembler<T> extends PagedResourcesAssembler<T> { | ||
|
||
private final MethodParameter parameter; | ||
|
||
/** | ||
* Creates a new {@link MethodParameterAwarePagedResourcesAssembler} using the given {@link MethodParameter}, | ||
* {@link HateoasPageableHandlerMethodArgumentResolver} and base URI. | ||
* | ||
* @param parameter must not be {@literal null}. | ||
* @param resolver can be {@literal null}. | ||
* @param baseUri can be {@literal null}. | ||
*/ | ||
public MethodParameterAwarePagedResourcesAssembler(MethodParameter parameter, | ||
HateoasPageableHandlerMethodArgumentResolver resolver, UriComponents baseUri) { | ||
|
||
super(resolver, baseUri); | ||
|
||
Assert.notNull(parameter, "Method parameter must not be null!"); | ||
this.parameter = parameter; | ||
} | ||
|
||
/* | ||
* (non-Javadoc) | ||
* @see org.springframework.data.web.PagedResourcesAssembler#getMethodParameter() | ||
*/ | ||
@Override | ||
protected MethodParameter getMethodParameter() { | ||
return parameter; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.