#833 - Migrate packages.

Changed the package structure to better reflect the different modules of the library. All client related code now lives in the client package, server related APIs in server with their respective WebMVC and WebFlux implementations in sub-packages.

Added migration script to allow users to easily migrate to the new structure and added reference documentation section on the migration.

Traversons built in defaulting to HAL HttpMessageConverters and LinkDiscoverer implementation now caused a cyclic relationship between the client and mediatype.hal packages. This has be fixed by looking up the defaults via a SpringFactories interface.
This commit is contained in:
Oliver Drotbohm
2019-02-26 13:21:47 +01:00
parent cc57e2eb44
commit 57f36a58db
280 changed files with 899 additions and 571 deletions

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.core;
package org.springframework.hateoas.client;
import net.minidev.json.JSONArray;
@@ -28,7 +28,6 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.LinkDiscoverer;
import org.springframework.hateoas.LinkRelation;
import org.springframework.hateoas.Links;
import org.springframework.http.MediaType;

View File

@@ -13,11 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas;
package org.springframework.hateoas.client;
import java.io.InputStream;
import java.util.Optional;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.LinkRelation;
import org.springframework.hateoas.Links;
import org.springframework.http.MediaType;
import org.springframework.plugin.core.Plugin;

View File

@@ -13,10 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas;
package org.springframework.hateoas.client;
import java.util.Optional;
import org.springframework.hateoas.MediaTypes;
import org.springframework.http.MediaType;
import org.springframework.plugin.core.PluginRegistry;
import org.springframework.util.Assert;

View File

@@ -18,8 +18,6 @@ package org.springframework.hateoas.client;
import java.util.Optional;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.LinkDiscoverer;
import org.springframework.hateoas.LinkDiscoverers;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;

View File

@@ -21,10 +21,8 @@ import lombok.RequiredArgsConstructor;
import lombok.Value;
import java.net.URI;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -32,28 +30,21 @@ import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.io.support.SpringFactoriesLoader;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.LinkDiscoverer;
import org.springframework.hateoas.LinkDiscoverers;
import org.springframework.hateoas.MediaTypes;
import org.springframework.hateoas.UriTemplate;
import org.springframework.hateoas.client.Rels.Rel;
import org.springframework.hateoas.hal.HalLinkDiscoverer;
import org.springframework.hateoas.hal.Jackson2HalModule;
import org.springframework.hateoas.mediatype.hal.HalLinkDiscoverer;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.plugin.core.OrderAwarePluginRegistry;
import org.springframework.util.Assert;
import org.springframework.web.client.RestOperations;
import org.springframework.web.client.RestTemplate;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jayway.jsonpath.JsonPath;
/**
@@ -70,11 +61,21 @@ import com.jayway.jsonpath.JsonPath;
*/
public class Traverson {
private static final LinkDiscoverers DEFAULT_LINK_DISCOVERERS;
private static final TraversonDefaults DEFAULTS;
static {
LinkDiscoverer discoverer = new HalLinkDiscoverer();
DEFAULT_LINK_DISCOVERERS = new LinkDiscoverers(OrderAwarePluginRegistry.of(discoverer));
List<TraversonDefaults> ALL_DEFAULTS = SpringFactoriesLoader.loadFactories(TraversonDefaults.class,
Traverson.class.getClassLoader());
Assert.isTrue(ALL_DEFAULTS.size() == 1,
() -> String.format("Expected to find only one TraversonDefaults instance, but found: ", //
ALL_DEFAULTS.stream() //
.map(Object::getClass) //
.map(Class::getName) //
.collect(Collectors.joining(", "))));
DEFAULTS = ALL_DEFAULTS.get(0);
}
private final URI baseUri;
@@ -108,8 +109,8 @@ public class Traverson {
this.mediaTypes = mediaTypes;
this.baseUri = baseUri;
this.discoverers = DEFAULT_LINK_DISCOVERERS;
setLinkDiscoverers(DEFAULTS.getLinkDiscoverers(mediaTypes));
setRestOperations(createDefaultTemplate(this.mediaTypes));
}
@@ -120,71 +121,17 @@ public class Traverson {
* @return
*/
public static List<HttpMessageConverter<?>> getDefaultMessageConverters(MediaType... mediaTypes) {
return getDefaultMessageConverters(Arrays.asList(mediaTypes));
}
/**
* Returns all {@link HttpMessageConverter}s that will be registered for the given {@link MediaType}s by default.
*
* @param mediaTypes must not be {@literal null}.
* @return
*/
public static List<HttpMessageConverter<?>> getDefaultMessageConverters(List<MediaType> mediaTypes) {
Assert.notNull(mediaTypes, "Media types must not be null!");
List<HttpMessageConverter<?>> converters = new ArrayList<>();
converters.add(new StringHttpMessageConverter(Charset.forName("UTF-8")));
List<MediaType> halFlavors = getHalJsonFlavors(mediaTypes);
if (!halFlavors.isEmpty()) {
converters.add(getHalConverter(halFlavors));
}
return converters;
}
/**
* Returns all HAL JSON compatible media types from the given list.
*
* @param mediaTypes must not be {@literal null}.
* @return
*/
private static List<MediaType> getHalJsonFlavors(Collection<MediaType> mediaTypes) {
return mediaTypes.stream() //
.filter(MediaTypes.HAL_JSON::isCompatibleWith) //
.collect(Collectors.toList());
return DEFAULTS.getHttpMessageConverters(Arrays.asList(mediaTypes));
}
private static final RestOperations createDefaultTemplate(List<MediaType> mediaTypes) {
RestTemplate template = new RestTemplate();
template.setMessageConverters(getDefaultMessageConverters(mediaTypes));
template.setMessageConverters(DEFAULTS.getHttpMessageConverters(mediaTypes));
return template;
}
/**
* Creates a new {@link HttpMessageConverter} to support HAL.
*
* @return
*/
private static final HttpMessageConverter<?> getHalConverter(List<MediaType> halFlavours) {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new Jackson2HalModule());
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
converter.setObjectMapper(mapper);
converter.setSupportedMediaTypes(halFlavours);
return converter;
}
/**
* Configures the {@link RestOperations} to use. If {@literal null} is provided a default {@link RestTemplate} will be
* used.
@@ -194,7 +141,10 @@ public class Traverson {
*/
public Traverson setRestOperations(RestOperations operations) {
this.operations = operations == null ? createDefaultTemplate(this.mediaTypes) : operations;
this.operations = operations == null //
? createDefaultTemplate(this.mediaTypes) //
: operations;
return this;
}
@@ -207,8 +157,11 @@ public class Traverson {
*/
public Traverson setLinkDiscoverers(List<? extends LinkDiscoverer> discoverer) {
this.discoverers = this.discoverers == null ? DEFAULT_LINK_DISCOVERERS
: new LinkDiscoverers(OrderAwarePluginRegistry.of(discoverer));
List<? extends LinkDiscoverer> defaultedDiscoverers = discoverer == null //
? DEFAULTS.getLinkDiscoverers(mediaTypes) //
: discoverer;
this.discoverers = new LinkDiscoverers(OrderAwarePluginRegistry.of(defaultedDiscoverers));
return this;
}

View File

@@ -0,0 +1,47 @@
/*
* Copyright 2019 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.hateoas.client;
import java.util.Collection;
import java.util.List;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
/**
* SPI that exposes {@link HttpMessageConverter}s and {@link LinkDiscoverer}s to be used by default by
* {@link Traverson}. Not intended for public implementation.
*
* @author Oliver Drotbohm
*/
public interface TraversonDefaults {
/**
* Returns the {@link HttpMessageConverter} instances to be registered for the given {@link MediaType}s.
*
* @param mediaTypes will never be {@literal null}.
* @return
*/
List<HttpMessageConverter<?>> getHttpMessageConverters(Collection<MediaType> mediaTypes);
/**
* Returns the {@link LinkDiscoverer}s to be registered by default for the given {@link MediaType}s.
*
* @param mediaTypes will never be {@literal null}.
* @return
*/
List<LinkDiscoverer> getLinkDiscoverers(Collection<MediaType> mediaTypes);
}

View File

@@ -23,8 +23,8 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.context.annotation.Import;
import org.springframework.hateoas.LinkBuilder;
import org.springframework.hateoas.core.DelegatingEntityLinks;
import org.springframework.hateoas.server.LinkBuilder;
import org.springframework.hateoas.server.core.DelegatingEntityLinks;
/**
* Enables the collection of {@link LinkBuilder} instances from the application context. All found ones will be exposed

View File

@@ -20,10 +20,10 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Primary;
import org.springframework.hateoas.EntityLinks;
import org.springframework.hateoas.core.ControllerEntityLinksFactoryBean;
import org.springframework.hateoas.core.DelegatingEntityLinks;
import org.springframework.hateoas.mvc.WebMvcLinkBuilderFactory;
import org.springframework.hateoas.server.EntityLinks;
import org.springframework.hateoas.server.core.ControllerEntityLinksFactoryBean;
import org.springframework.hateoas.server.core.DelegatingEntityLinks;
import org.springframework.hateoas.server.mvc.WebMvcLinkBuilderFactory;
import org.springframework.plugin.core.PluginRegistry;
import org.springframework.plugin.core.support.PluginRegistryFactoryBean;
import org.springframework.stereotype.Controller;
@@ -49,13 +49,13 @@ class EntityLinksConfiguration {
@Primary
@Bean
@DependsOn("controllerEntityLinks")
@DependsOn("webMvcEntityLinks")
DelegatingEntityLinks delegatingEntityLinks(PluginRegistry<EntityLinks, Class<?>> entityLinksPluginRegistry) {
return new DelegatingEntityLinks(entityLinksPluginRegistry);
}
@Bean
ControllerEntityLinksFactoryBean controllerEntityLinks(ObjectProvider<WebMvcLinkBuilderFactory> linkBuilderFactory) {
ControllerEntityLinksFactoryBean webMvcEntityLinks(ObjectProvider<WebMvcLinkBuilderFactory> linkBuilderFactory) {
ControllerEntityLinksFactoryBean factory = new ControllerEntityLinksFactoryBean();
factory.setAnnotation(Controller.class);

View File

@@ -21,13 +21,13 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.hateoas.LinkDiscoverer;
import org.springframework.hateoas.LinkDiscoverers;
import org.springframework.hateoas.RelProvider;
import org.springframework.hateoas.core.AnnotationRelProvider;
import org.springframework.hateoas.core.DefaultRelProvider;
import org.springframework.hateoas.core.DelegatingRelProvider;
import org.springframework.hateoas.core.EvoInflectorRelProvider;
import org.springframework.hateoas.client.LinkDiscoverer;
import org.springframework.hateoas.client.LinkDiscoverers;
import org.springframework.hateoas.server.RelProvider;
import org.springframework.hateoas.server.core.AnnotationRelProvider;
import org.springframework.hateoas.server.core.DefaultRelProvider;
import org.springframework.hateoas.server.core.DelegatingRelProvider;
import org.springframework.hateoas.server.core.EvoInflectorRelProvider;
import org.springframework.http.MediaType;
import org.springframework.plugin.core.PluginRegistry;
import org.springframework.plugin.core.config.EnablePluginRegistries;
@@ -48,7 +48,7 @@ class HateoasConfiguration {
/**
* The {@link MessageSourceAccessor} to provide messages for {@link ResourceDescription}s being rendered.
*
*
* @return
*/
@Bean

View File

@@ -62,4 +62,8 @@ class HypermediaConfigurationImportSelector implements ImportSelector {
.map(Class::getName) //
.toArray(String[]::new);
}
public String[] selectImports(Collection<MediaType> mediaType) {
return new String[] {};
}
}

View File

@@ -1,4 +1,4 @@
package org.springframework.hateoas.config.reactive;
package org.springframework.hateoas.config;
import lombok.RequiredArgsConstructor;
@@ -12,7 +12,6 @@ import org.springframework.core.codec.Decoder;
import org.springframework.core.codec.Encoder;
import org.springframework.core.codec.StringDecoder;
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
import org.springframework.hateoas.config.HypermediaMappingInformation;
import org.springframework.http.codec.json.Jackson2JsonDecoder;
import org.springframework.http.codec.json.Jackson2JsonEncoder;
import org.springframework.util.MimeType;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.config.reactive;
package org.springframework.hateoas.config;
import lombok.RequiredArgsConstructor;
@@ -24,10 +24,10 @@ import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.core.codec.CharSequenceEncoder;
import org.springframework.core.codec.StringDecoder;
import org.springframework.hateoas.config.HypermediaMappingInformation;
import org.springframework.hateoas.reactive.HypermediaWebFilter;
import org.springframework.hateoas.server.reactive.HypermediaWebFilter;
import org.springframework.http.codec.CodecConfigurer;
import org.springframework.http.codec.ServerCodecConfigurer;
import org.springframework.http.codec.json.Jackson2JsonDecoder;
@@ -42,7 +42,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
* Spring WebFlux HATEOAS configuration.
*
* @author Greg Turnquist
* @since 1.0
* @since 1.0 TODO: Inspect ApplicationContext -> WebApplicationContext -> WebMVC
*/
@Configuration
class WebFluxHateoasConfiguration {
@@ -70,6 +70,7 @@ class WebFluxHateoasConfiguration {
* completed.
*/
@Bean
@Lazy // To avoid creation on a WebMVC app using WebClient only
HypermediaWebFilter hypermediaWebFilter() {
return new HypermediaWebFilter();
}
@@ -131,7 +132,6 @@ class WebFluxHateoasConfiguration {
MimeType[] mimeTypes = hypermedia.getMediaTypes().toArray(new MimeType[0]);
ObjectMapper objectMapper = hypermedia.configureObjectMapper(this.mapper.copy());
customCodecs.encoder(new Jackson2JsonEncoder(objectMapper, mimeTypes));
customCodecs.decoder(new Jackson2JsonDecoder(objectMapper, mimeTypes));
});

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.config.mvc;
package org.springframework.hateoas.config;
import lombok.RequiredArgsConstructor;
@@ -27,10 +27,9 @@ import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.hateoas.config.HypermediaMappingInformation;
import org.springframework.hateoas.mvc.TypeConstrainedMappingJackson2HttpMessageConverter;
import org.springframework.hateoas.mvc.UriComponentsContributor;
import org.springframework.hateoas.mvc.WebMvcLinkBuilderFactory;
import org.springframework.hateoas.server.mvc.TypeConstrainedMappingJackson2HttpMessageConverter;
import org.springframework.hateoas.server.mvc.UriComponentsContributor;
import org.springframework.hateoas.server.mvc.WebMvcLinkBuilderFactory;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

View File

@@ -39,11 +39,11 @@ class WebStackImportSelector implements ImportSelector {
List<String> imports = new ArrayList<>();
if (WebStack.WEBMVC.isAvailable()) {
imports.add("org.springframework.hateoas.config.mvc.WebMvcHateoasConfiguration");
imports.add("org.springframework.hateoas.config.WebMvcHateoasConfiguration");
}
if (WebStack.WEBFLUX.isAvailable()) {
imports.add("org.springframework.hateoas.config.reactive.WebFluxHateoasConfiguration");
imports.add("org.springframework.hateoas.config.WebFluxHateoasConfiguration");
}
return imports.toArray(new String[imports.size()]);

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.support;
package org.springframework.hateoas.mediatype;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.Resources;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.support;
package org.springframework.hateoas.mediatype;
import java.beans.FeatureDescriptor;
import java.beans.PropertyDescriptor;
@@ -36,6 +36,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.core.ResolvableType;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.support.WebStack;
import org.springframework.util.ReflectionUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;

View File

@@ -13,16 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.alps;
package org.springframework.hateoas.mediatype.alps;
import lombok.Builder;
import lombok.Value;
import java.util.List;
import org.springframework.hateoas.alps.Descriptor.DescriptorBuilder;
import org.springframework.hateoas.alps.Doc.DocBuilder;
import org.springframework.hateoas.alps.Ext.ExtBuilder;
import org.springframework.hateoas.mediatype.alps.Descriptor.DescriptorBuilder;
import org.springframework.hateoas.mediatype.alps.Doc.DocBuilder;
import org.springframework.hateoas.mediatype.alps.Ext.ExtBuilder;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

View File

@@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.alps;
package org.springframework.hateoas.mediatype.alps;
import org.springframework.hateoas.LinkDiscoverer;
import org.springframework.hateoas.MediaTypes;
import org.springframework.hateoas.core.JsonPathLinkDiscoverer;
import org.springframework.hateoas.client.JsonPathLinkDiscoverer;
import org.springframework.hateoas.client.LinkDiscoverer;
/**
* {@link LinkDiscoverer} implementation to find ALPS-based links.

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.alps;
package org.springframework.hateoas.mediatype.alps;
import lombok.Builder;
import lombok.Value;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.alps;
package org.springframework.hateoas.mediatype.alps;
import lombok.AllArgsConstructor;
import lombok.Builder;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.alps;
package org.springframework.hateoas.mediatype.alps;
import lombok.Builder;
import lombok.Value;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.alps;
package org.springframework.hateoas.mediatype.alps;
import java.util.Locale;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.alps;
package org.springframework.hateoas.mediatype.alps;
import java.util.Locale;

View File

@@ -3,5 +3,5 @@
*
* @see https://alps.io
*/
package org.springframework.hateoas.alps;
package org.springframework.hateoas.mediatype.alps;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.collectionjson;
package org.springframework.hateoas.mediatype.collectionjson;
import lombok.AccessLevel;
import lombok.Value;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.collectionjson;
package org.springframework.hateoas.mediatype.collectionjson;
import lombok.EqualsAndHashCode;
import lombok.Getter;
@@ -29,7 +29,7 @@ import org.springframework.hateoas.Affordance;
import org.springframework.hateoas.AffordanceModel;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.QueryParameter;
import org.springframework.hateoas.support.PropertyUtils;
import org.springframework.hateoas.mediatype.PropertyUtils;
import org.springframework.http.HttpMethod;
/**

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.collectionjson;
package org.springframework.hateoas.mediatype.collectionjson;
import lombok.Getter;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.collectionjson;
package org.springframework.hateoas.mediatype.collectionjson;
import lombok.Value;
import lombok.experimental.Wither;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.collectionjson;
package org.springframework.hateoas.mediatype.collectionjson;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.collectionjson;
package org.springframework.hateoas.mediatype.collectionjson;
import lombok.AccessLevel;
import lombok.Value;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.collectionjson;
package org.springframework.hateoas.mediatype.collectionjson;
import lombok.AccessLevel;
import lombok.Getter;
@@ -29,7 +29,7 @@ import java.util.stream.Collectors;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.Links;
import org.springframework.hateoas.Links.MergeMode;
import org.springframework.hateoas.support.PropertyUtils;
import org.springframework.hateoas.mediatype.PropertyUtils;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;

View File

@@ -13,18 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.collectionjson;
package org.springframework.hateoas.mediatype.collectionjson;
import java.io.InputStream;
import java.util.Optional;
import org.springframework.hateoas.IanaLinkRelations;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.LinkDiscoverer;
import org.springframework.hateoas.LinkRelation;
import org.springframework.hateoas.Links;
import org.springframework.hateoas.MediaTypes;
import org.springframework.hateoas.core.JsonPathLinkDiscoverer;
import org.springframework.hateoas.client.JsonPathLinkDiscoverer;
import org.springframework.hateoas.client.LinkDiscoverer;
import org.springframework.util.Assert;
/**

View File

@@ -13,14 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.collectionjson;
package org.springframework.hateoas.mediatype.collectionjson;
import java.util.List;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.hateoas.LinkDiscoverer;
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
import org.springframework.hateoas.client.LinkDiscoverer;
import org.springframework.hateoas.config.HypermediaMappingInformation;
import org.springframework.http.MediaType;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.collectionjson;
package org.springframework.hateoas.mediatype.collectionjson;
import java.util.Collection;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.collectionjson;
package org.springframework.hateoas.mediatype.collectionjson;
import static com.fasterxml.jackson.annotation.JsonInclude.*;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.collectionjson;
package org.springframework.hateoas.mediatype.collectionjson;
import lombok.Value;
import lombok.experimental.Wither;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.collectionjson;
package org.springframework.hateoas.mediatype.collectionjson;
import java.io.IOException;
import java.util.ArrayList;
@@ -30,13 +30,13 @@ import org.springframework.hateoas.IanaLinkRelations;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.Links;
import org.springframework.hateoas.Links.MergeMode;
import org.springframework.hateoas.mediatype.JacksonHelper;
import org.springframework.hateoas.mediatype.PropertyUtils;
import org.springframework.hateoas.MediaTypes;
import org.springframework.hateoas.PagedResources;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.hateoas.Resources;
import org.springframework.hateoas.support.JacksonHelper;
import org.springframework.hateoas.support.PropertyUtils;
import org.springframework.http.HttpMethod;
import com.fasterxml.jackson.core.JsonGenerator;

View File

@@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.collectionjson;
package org.springframework.hateoas.mediatype.collectionjson;
import static org.springframework.hateoas.collectionjson.Jackson2CollectionJsonModule.*;
import static org.springframework.hateoas.mediatype.collectionjson.Jackson2CollectionJsonModule.*;
import org.springframework.hateoas.PagedResources;

View File

@@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.collectionjson;
package org.springframework.hateoas.mediatype.collectionjson;
import static org.springframework.hateoas.collectionjson.Jackson2CollectionJsonModule.*;
import static org.springframework.hateoas.mediatype.collectionjson.Jackson2CollectionJsonModule.*;
import org.springframework.hateoas.Resource;

View File

@@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.collectionjson;
package org.springframework.hateoas.mediatype.collectionjson;
import org.springframework.hateoas.Links;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.hateoas.collectionjson.Jackson2CollectionJsonModule.CollectionJsonLinksDeserializer;
import org.springframework.hateoas.collectionjson.Jackson2CollectionJsonModule.CollectionJsonLinksSerializer;
import org.springframework.hateoas.collectionjson.Jackson2CollectionJsonModule.CollectionJsonResourceSupportDeserializer;
import org.springframework.hateoas.mediatype.collectionjson.Jackson2CollectionJsonModule.CollectionJsonLinksDeserializer;
import org.springframework.hateoas.mediatype.collectionjson.Jackson2CollectionJsonModule.CollectionJsonLinksSerializer;
import org.springframework.hateoas.mediatype.collectionjson.Jackson2CollectionJsonModule.CollectionJsonResourceSupportDeserializer;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

View File

@@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.collectionjson;
package org.springframework.hateoas.mediatype.collectionjson;
import static org.springframework.hateoas.collectionjson.Jackson2CollectionJsonModule.*;
import static org.springframework.hateoas.mediatype.collectionjson.Jackson2CollectionJsonModule.*;
import org.springframework.hateoas.Resources;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.hal;
package org.springframework.hateoas.mediatype.hal;
import java.util.Collection;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.hal;
package org.springframework.hateoas.mediatype.hal;
import lombok.Getter;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.hal;
package org.springframework.hateoas.mediatype.hal;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.hal;
package org.springframework.hateoas.mediatype.hal;
import java.util.ArrayList;
import java.util.Collection;
@@ -23,10 +23,10 @@ import java.util.List;
import java.util.Map;
import org.springframework.hateoas.LinkRelation;
import org.springframework.hateoas.RelProvider;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.core.EmbeddedWrapper;
import org.springframework.hateoas.core.EmbeddedWrappers;
import org.springframework.hateoas.server.RelProvider;
import org.springframework.hateoas.server.core.EmbeddedWrapper;
import org.springframework.hateoas.server.core.EmbeddedWrappers;
import org.springframework.util.Assert;
/**

View File

@@ -13,15 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.hal;
package org.springframework.hateoas.mediatype.hal;
import java.util.Map;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.LinkDiscoverer;
import org.springframework.hateoas.LinkRelation;
import org.springframework.hateoas.MediaTypes;
import org.springframework.hateoas.core.JsonPathLinkDiscoverer;
import org.springframework.hateoas.client.JsonPathLinkDiscoverer;
import org.springframework.hateoas.client.LinkDiscoverer;
import org.springframework.http.MediaType;
/**

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.hal;
package org.springframework.hateoas.mediatype.hal;
import lombok.AccessLevel;
import lombok.EqualsAndHashCode;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.hal;
package org.springframework.hateoas.mediatype.hal;
import lombok.RequiredArgsConstructor;
@@ -23,9 +23,9 @@ import org.springframework.beans.factory.ObjectProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.hateoas.LinkDiscoverer;
import org.springframework.hateoas.RelProvider;
import org.springframework.hateoas.client.LinkDiscoverer;
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
import org.springframework.hateoas.server.RelProvider;
import org.springframework.hateoas.config.HypermediaMappingInformation;
import org.springframework.http.MediaType;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.hal;
package org.springframework.hateoas.mediatype.hal;
import java.util.Collection;

View File

@@ -0,0 +1,98 @@
/*
* Copyright 2019 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.hateoas.mediatype.hal;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.hateoas.MediaTypes;
import org.springframework.hateoas.client.LinkDiscoverer;
import org.springframework.hateoas.client.TraversonDefaults;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
/**
* Traverson defaults to support HAL.
*
* @author Oliver Drotbohm
*/
class HalTraversonDefaults implements TraversonDefaults {
private static final List<MediaType> HAL_FLAVORS = Arrays.asList(MediaTypes.HAL_JSON, MediaTypes.HAL_JSON_UTF8);
/*
* (non-Javadoc)
* @see org.springframework.hateoas.config.TraversonDefaults#getHttpMessageConverters(java.util.Collection)
*/
@Override
public List<HttpMessageConverter<?>> getHttpMessageConverters(Collection<MediaType> mediaTypes) {
List<HttpMessageConverter<?>> converters = new ArrayList<>();
converters.add(new StringHttpMessageConverter(StandardCharsets.UTF_8));
List<MediaType> halFlavors = mediaTypes.stream() //
.filter(it -> HAL_FLAVORS.contains(it)) //
.collect(Collectors.toList());
if (!halFlavors.isEmpty()) {
converters.add(getHalConverter(halFlavors));
}
return converters;
}
/*
* (non-Javadoc)
* @see org.springframework.hateoas.config.TraversonDefaults#getLinkDiscoverers(java.util.Collection)
*/
@Override
public List<LinkDiscoverer> getLinkDiscoverers(Collection<MediaType> mediaTypes) {
return mediaTypes.stream().anyMatch(it -> it.isCompatibleWith(MediaTypes.HAL_JSON)) //
? Collections.singletonList(new HalLinkDiscoverer()) //
: Collections.emptyList();
}
/**
* Creates a new {@link HttpMessageConverter} to support HAL.
*
* @return
*/
private static final HttpMessageConverter<?> getHalConverter(List<MediaType> halFlavours) {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new Jackson2HalModule());
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
converter.setObjectMapper(mapper);
converter.setSupportedMediaTypes(halFlavours);
return converter;
}
}

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.hal;
package org.springframework.hateoas.mediatype.hal;
import java.io.IOException;
import java.lang.reflect.Type;
@@ -32,11 +32,11 @@ import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.LinkRelation;
import org.springframework.hateoas.Links;
import org.springframework.hateoas.RelProvider;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.hateoas.Resources;
import org.springframework.hateoas.hal.HalConfiguration.RenderSingleLinks;
import org.springframework.hateoas.mediatype.hal.HalConfiguration.RenderSingleLinks;
import org.springframework.hateoas.server.RelProvider;
import org.springframework.util.Assert;
import com.fasterxml.jackson.annotation.JsonInclude;

View File

@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.hal;
package org.springframework.hateoas.mediatype.hal;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.hal.Jackson2HalModule.TrueOnlyBooleanSerializer;
import org.springframework.hateoas.mediatype.hal.Jackson2HalModule.TrueOnlyBooleanSerializer;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.hal;
package org.springframework.hateoas.mediatype.hal;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.Links;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.hal;
package org.springframework.hateoas.mediatype.hal;
import java.util.Collection;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.hal.forms;
package org.springframework.hateoas.mediatype.hal.forms;
import static org.springframework.http.HttpMethod.*;
@@ -31,7 +31,7 @@ import org.springframework.hateoas.Affordance;
import org.springframework.hateoas.AffordanceModel;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.QueryParameter;
import org.springframework.hateoas.support.PropertyUtils;
import org.springframework.hateoas.mediatype.PropertyUtils;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.hal.forms;
package org.springframework.hateoas.mediatype.hal.forms;
import lombok.Getter;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.hal.forms;
package org.springframework.hateoas.mediatype.hal.forms;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
@@ -22,7 +22,7 @@ import lombok.NoArgsConstructor;
import lombok.experimental.Wither;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.hal.HalConfiguration;
import org.springframework.hateoas.mediatype.hal.HalConfiguration;
/**
* @author Greg Turnquist

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.hal.forms;
package org.springframework.hateoas.mediatype.hal.forms;
import java.io.IOException;
import java.util.ArrayList;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.hal.forms;
package org.springframework.hateoas.mediatype.hal.forms;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
@@ -29,9 +29,9 @@ import java.util.Map;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.Links;
import org.springframework.hateoas.PagedResources;
import org.springframework.hateoas.hal.HalLinkRelation;
import org.springframework.hateoas.hal.Jackson2HalModule.HalLinkListSerializer;
import org.springframework.hateoas.hal.forms.Jackson2HalFormsModule.HalFormsLinksDeserializer;
import org.springframework.hateoas.mediatype.hal.HalLinkRelation;
import org.springframework.hateoas.mediatype.hal.Jackson2HalModule.HalLinkListSerializer;
import org.springframework.hateoas.mediatype.hal.forms.Jackson2HalFormsModule.HalFormsLinksDeserializer;
import org.springframework.util.Assert;
import com.fasterxml.jackson.annotation.JsonIgnore;

View File

@@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.hal.forms;
package org.springframework.hateoas.mediatype.hal.forms;
import org.springframework.hateoas.MediaTypes;
import org.springframework.hateoas.core.JsonPathLinkDiscoverer;
import org.springframework.hateoas.hal.HalLinkDiscoverer;
import org.springframework.hateoas.client.JsonPathLinkDiscoverer;
import org.springframework.hateoas.mediatype.hal.HalLinkDiscoverer;
/**
* HAL-FORMS based {@link JsonPathLinkDiscoverer}.

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.hal.forms;
package org.springframework.hateoas.mediatype.hal.forms;
import lombok.RequiredArgsConstructor;
@@ -23,11 +23,11 @@ import org.springframework.beans.factory.ObjectProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.hateoas.LinkDiscoverer;
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
import org.springframework.hateoas.mediatype.hal.CurieProvider;
import org.springframework.hateoas.client.LinkDiscoverer;
import org.springframework.hateoas.config.HypermediaMappingInformation;
import org.springframework.hateoas.core.DelegatingRelProvider;
import org.springframework.hateoas.hal.CurieProvider;
import org.springframework.hateoas.server.core.DelegatingRelProvider;
import org.springframework.http.MediaType;
import com.fasterxml.jackson.databind.DeserializationFeature;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.hal.forms;
package org.springframework.hateoas.mediatype.hal.forms;
import java.util.Collection;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.hal.forms;
package org.springframework.hateoas.mediatype.hal.forms;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.hal.forms;
package org.springframework.hateoas.mediatype.hal.forms;
import java.io.IOException;
import java.util.Collections;
@@ -29,8 +29,8 @@ import org.springframework.hateoas.PagedResources;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.hateoas.Resources;
import org.springframework.hateoas.hal.HalLinkRelation;
import org.springframework.hateoas.hal.Jackson2HalModule;
import org.springframework.hateoas.mediatype.hal.HalLinkRelation;
import org.springframework.hateoas.mediatype.hal.Jackson2HalModule;
import org.springframework.http.HttpMethod;
import com.fasterxml.jackson.core.JsonGenerator;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.hal.forms;
package org.springframework.hateoas.mediatype.hal.forms;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
@@ -27,7 +27,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.springframework.hateoas.hal.forms.HalFormsDeserializers.MediaTypesDeserializer;
import org.springframework.hateoas.mediatype.hal.forms.HalFormsDeserializers.MediaTypesDeserializer;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.hal.forms;
package org.springframework.hateoas.mediatype.hal.forms;
import java.io.IOException;
import java.util.Collection;
@@ -25,20 +25,20 @@ import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.Links;
import org.springframework.hateoas.PagedResources;
import org.springframework.hateoas.RelProvider;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.hateoas.Resources;
import org.springframework.hateoas.hal.CurieProvider;
import org.springframework.hateoas.hal.Jackson2HalModule.EmbeddedMapper;
import org.springframework.hateoas.hal.Jackson2HalModule.HalHandlerInstantiator;
import org.springframework.hateoas.hal.Jackson2HalModule.HalLinkListDeserializer;
import org.springframework.hateoas.hal.Jackson2HalModule.HalLinkListSerializer;
import org.springframework.hateoas.hal.LinkMixin;
import org.springframework.hateoas.hal.ResourceSupportMixin;
import org.springframework.hateoas.hal.forms.HalFormsDeserializers.HalFormsResourcesDeserializer;
import org.springframework.hateoas.hal.forms.HalFormsSerializers.HalFormsResourceSerializer;
import org.springframework.hateoas.hal.forms.HalFormsSerializers.HalFormsResourcesSerializer;
import org.springframework.hateoas.mvc.JacksonSerializers.MediaTypeDeserializer;
import org.springframework.hateoas.mediatype.hal.CurieProvider;
import org.springframework.hateoas.mediatype.hal.LinkMixin;
import org.springframework.hateoas.mediatype.hal.ResourceSupportMixin;
import org.springframework.hateoas.mediatype.hal.Jackson2HalModule.EmbeddedMapper;
import org.springframework.hateoas.mediatype.hal.Jackson2HalModule.HalHandlerInstantiator;
import org.springframework.hateoas.mediatype.hal.Jackson2HalModule.HalLinkListDeserializer;
import org.springframework.hateoas.mediatype.hal.Jackson2HalModule.HalLinkListSerializer;
import org.springframework.hateoas.mediatype.hal.forms.HalFormsDeserializers.HalFormsResourcesDeserializer;
import org.springframework.hateoas.mediatype.hal.forms.HalFormsSerializers.HalFormsResourceSerializer;
import org.springframework.hateoas.mediatype.hal.forms.HalFormsSerializers.HalFormsResourcesSerializer;
import org.springframework.hateoas.server.RelProvider;
import org.springframework.hateoas.server.mvc.JacksonSerializers.MediaTypeDeserializer;
import org.springframework.http.MediaType;
import com.fasterxml.jackson.annotation.JsonInclude;

View File

@@ -3,5 +3,5 @@
*
* @see http://stateless.co/hal_specification.html
*/
package org.springframework.hateoas.hal;
package org.springframework.hateoas.mediatype.hal;

View File

@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.uber;
package org.springframework.hateoas.mediatype.uber;
import static org.springframework.hateoas.support.JacksonHelper.*;
import static org.springframework.hateoas.uber.UberData.*;
import static org.springframework.hateoas.mediatype.JacksonHelper.*;
import static org.springframework.hateoas.mediatype.uber.UberData.*;
import java.io.IOException;
import java.util.ArrayList;
@@ -30,11 +30,11 @@ import org.springframework.hateoas.Link;
import org.springframework.hateoas.Links;
import org.springframework.hateoas.PagedResources;
import org.springframework.hateoas.PagedResources.PageMetadata;
import org.springframework.hateoas.mediatype.JacksonHelper;
import org.springframework.hateoas.mediatype.PropertyUtils;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.hateoas.Resources;
import org.springframework.hateoas.support.JacksonHelper;
import org.springframework.hateoas.support.PropertyUtils;
import org.springframework.util.StringUtils;
import com.fasterxml.jackson.core.JsonGenerator;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.uber;
package org.springframework.hateoas.mediatype.uber;
import lombok.AccessLevel;
import lombok.Value;

View File

@@ -14,11 +14,11 @@
* limitations under the License.
*/
package org.springframework.hateoas.uber;
package org.springframework.hateoas.mediatype.uber;
import java.util.Arrays;
import org.springframework.hateoas.uber.Jackson2UberModule.UberActionDeserializer;
import org.springframework.hateoas.mediatype.uber.Jackson2UberModule.UberActionDeserializer;
import org.springframework.http.HttpMethod;
import com.fasterxml.jackson.annotation.JsonValue;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.uber;
package org.springframework.hateoas.mediatype.uber;
import lombok.Getter;
@@ -29,7 +29,7 @@ import org.springframework.hateoas.AffordanceModel;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.MediaTypes;
import org.springframework.hateoas.QueryParameter;
import org.springframework.hateoas.support.PropertyUtils;
import org.springframework.hateoas.mediatype.PropertyUtils;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.uber;
package org.springframework.hateoas.mediatype.uber;
import lombok.Getter;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.uber;
package org.springframework.hateoas.mediatype.uber;
import lombok.AccessLevel;
import lombok.Data;
@@ -39,7 +39,7 @@ import org.springframework.hateoas.PagedResources;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.hateoas.Resources;
import org.springframework.hateoas.support.PropertyUtils;
import org.springframework.hateoas.mediatype.PropertyUtils;
import org.springframework.http.HttpMethod;
import org.springframework.util.StringUtils;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.uber;
package org.springframework.hateoas.mediatype.uber;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.uber;
package org.springframework.hateoas.mediatype.uber;
import lombok.AccessLevel;
import lombok.Value;

View File

@@ -13,17 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.uber;
package org.springframework.hateoas.mediatype.uber;
import java.io.IOException;
import java.io.InputStream;
import java.util.Optional;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.LinkDiscoverer;
import org.springframework.hateoas.LinkRelation;
import org.springframework.hateoas.Links;
import org.springframework.hateoas.MediaTypes;
import org.springframework.hateoas.client.LinkDiscoverer;
import org.springframework.http.MediaType;
import com.fasterxml.jackson.databind.ObjectMapper;

View File

@@ -13,14 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.uber;
package org.springframework.hateoas.mediatype.uber;
import java.util.List;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.hateoas.LinkDiscoverer;
import org.springframework.hateoas.config.EnableHypermediaSupport.HypermediaType;
import org.springframework.hateoas.client.LinkDiscoverer;
import org.springframework.hateoas.config.HypermediaMappingInformation;
import org.springframework.http.MediaType;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.uber;
package org.springframework.hateoas.mediatype.uber;
import java.util.Collection;

View File

@@ -13,13 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas;
package org.springframework.hateoas.mediatype.vnderrors;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

View File

@@ -13,8 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas;
package org.springframework.hateoas.server;
import org.springframework.hateoas.IanaLinkRelations;
import org.springframework.hateoas.Identifiable;
import org.springframework.hateoas.Link;
import org.springframework.plugin.core.Plugin;
/**

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas;
package org.springframework.hateoas.server;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
@@ -22,7 +22,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.hateoas.core.ControllerEntityLinks;
import org.springframework.hateoas.server.core.ControllerEntityLinks;
/**
* Annotation to demarcate controllers that expose URI templates of a structure according to

View File

@@ -13,10 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas;
package org.springframework.hateoas.server;
import java.net.URI;
import org.springframework.hateoas.IanaLinkRelations;
import org.springframework.hateoas.Identifiable;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.LinkRelation;
/**
* Builder to ease building {@link Link} instances.
*

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas;
package org.springframework.hateoas.server;
import java.util.Map;

View File

@@ -13,12 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas;
package org.springframework.hateoas.server;
import java.lang.reflect.Method;
import org.springframework.hateoas.core.DummyInvocationUtils;
import org.springframework.hateoas.mvc.WebMvcLinkBuilder;
import org.springframework.hateoas.server.core.DummyInvocationUtils;
import org.springframework.hateoas.server.mvc.WebMvcLinkBuilder;
/**
* Extension of {@link LinkBuilderFactory} for implementations that also support creating {@link LinkBuilder}s by

View File

@@ -13,8 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas;
package org.springframework.hateoas.server;
import org.springframework.hateoas.LinkRelation;
import org.springframework.plugin.core.Plugin;
/**

View File

@@ -13,11 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas;
package org.springframework.hateoas.server;
import java.util.ArrayList;
import java.util.List;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.hateoas.Resources;
/**
* Interface for components that convert a domain type into a {@link ResourceSupport}.
*

View File

@@ -13,7 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas;
package org.springframework.hateoas.server;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.hateoas.Resources;
/**
* SPI interface to allow components to process the {@link ResourceSupport} instances returned from Spring MVC

View File

@@ -13,11 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas;
package org.springframework.hateoas.server;
import java.util.ArrayList;
import java.util.List;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.Resources;
import org.springframework.util.Assert;
/**

View File

@@ -13,12 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.core;
package org.springframework.hateoas.server.core;
import org.springframework.hateoas.EntityLinks;
import org.springframework.hateoas.Identifiable;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.LinkBuilder;
import org.springframework.hateoas.server.EntityLinks;
import org.springframework.hateoas.server.LinkBuilder;
import org.springframework.util.Assert;
/**

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.core;
package org.springframework.hateoas.server.core;
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.core;
package org.springframework.hateoas.server.core;
import static org.springframework.core.annotation.AnnotatedElementUtils.*;
import static org.springframework.core.annotation.AnnotationUtils.*;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.core;
package org.springframework.hateoas.server.core;
import java.util.HashMap;
import java.util.Map;
@@ -21,7 +21,7 @@ import java.util.Map;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.hateoas.LinkRelation;
import org.springframework.hateoas.RelProvider;
import org.springframework.hateoas.server.RelProvider;
/**
* @author Oliver Gierke
@@ -32,11 +32,6 @@ public class AnnotationRelProvider implements RelProvider, Ordered {
private final Map<Class<?>, Relation> annotationCache = new HashMap<>();
@Override
public int getOrder() {
return 100;
}
/*
* (non-Javadoc)
* @see org.springframework.hateoas.RelProvider#getRelForCollectionResource(java.lang.Class)
@@ -69,6 +64,15 @@ public class AnnotationRelProvider implements RelProvider, Ordered {
return LinkRelation.of(annotation.value());
}
/*
* (non-Javadoc)
* @see org.springframework.core.Ordered#getOrder()
*/
@Override
public int getOrder() {
return 100;
}
/*
* (non-Javadoc)
* @see org.springframework.plugin.core.Plugin#supports(java.lang.Object)

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.core;
package org.springframework.hateoas.server.core;
import lombok.RequiredArgsConstructor;

View File

@@ -13,17 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.core;
package org.springframework.hateoas.server.core;
import java.util.HashMap;
import java.util.Map;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.hateoas.EntityLinks;
import org.springframework.hateoas.ExposesResourceFor;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.LinkBuilder;
import org.springframework.hateoas.LinkBuilderFactory;
import org.springframework.hateoas.server.EntityLinks;
import org.springframework.hateoas.server.ExposesResourceFor;
import org.springframework.hateoas.server.LinkBuilder;
import org.springframework.hateoas.server.LinkBuilderFactory;
import org.springframework.util.Assert;
/**

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.core;
package org.springframework.hateoas.server.core;
import java.lang.annotation.Annotation;
import java.util.Collection;
@@ -25,9 +25,9 @@ import org.springframework.beans.factory.config.AbstractFactoryBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.hateoas.ExposesResourceFor;
import org.springframework.hateoas.LinkBuilder;
import org.springframework.hateoas.LinkBuilderFactory;
import org.springframework.hateoas.server.ExposesResourceFor;
import org.springframework.hateoas.server.LinkBuilder;
import org.springframework.hateoas.server.LinkBuilderFactory;
import org.springframework.util.Assert;
/**

View File

@@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.core;
package org.springframework.hateoas.server.core;
import org.springframework.core.Ordered;
import org.springframework.hateoas.LinkRelation;
import org.springframework.hateoas.RelProvider;
import org.springframework.hateoas.server.RelProvider;
import org.springframework.util.StringUtils;
/**

View File

@@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.core;
package org.springframework.hateoas.server.core;
import org.springframework.hateoas.EntityLinks;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.LinkBuilder;
import org.springframework.hateoas.server.EntityLinks;
import org.springframework.hateoas.server.LinkBuilder;
import org.springframework.plugin.core.PluginRegistry;
import org.springframework.util.Assert;

View File

@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.core;
package org.springframework.hateoas.server.core;
import org.springframework.hateoas.LinkRelation;
import org.springframework.hateoas.RelProvider;
import org.springframework.hateoas.server.RelProvider;
import org.springframework.plugin.core.PluginRegistry;
import org.springframework.util.Assert;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.core;
package org.springframework.hateoas.server.core;
import lombok.NonNull;
import lombok.Value;

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.hateoas.core;
package org.springframework.hateoas.server.core;
import java.util.Optional;

Some files were not shown because too many files have changed in this diff Show More