#597 - Add ALPS media type and LinkDiscoverer.
Migrate general ALPS material from Spring Data REST into Spring HATEOAS.
This commit is contained in:
committed by
Oliver Gierke
parent
312134ee82
commit
b0820011e8
@@ -23,6 +23,7 @@ import org.springframework.http.MediaType;
|
||||
* @author Oliver Gierke
|
||||
* @author Przemek Nowak
|
||||
* @author Drummond Dawson
|
||||
* @author Greg Turnquist
|
||||
*/
|
||||
public class MediaTypes {
|
||||
|
||||
@@ -45,4 +46,14 @@ public class MediaTypes {
|
||||
* Public constant media type for {@code application/hal+json;charset=UTF-8}.
|
||||
*/
|
||||
public static final MediaType HAL_JSON_UTF8 = MediaType.valueOf(HAL_JSON_UTF8_VALUE);
|
||||
|
||||
/**
|
||||
* A string equivalient of {@link MediaTypes#ALPS_JSON}.
|
||||
*/
|
||||
public static final String ALPS_JSON_VALUE = "application/alps+json";
|
||||
|
||||
/**
|
||||
* Public constant media type for {@code application/alps+json}.
|
||||
*/
|
||||
public static final MediaType ALPS_JSON = MediaType.parseMediaType(ALPS_JSON_VALUE);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2017 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.alps;
|
||||
|
||||
import org.springframework.hateoas.LinkDiscoverer;
|
||||
import org.springframework.hateoas.MediaTypes;
|
||||
import org.springframework.hateoas.core.JsonPathLinkDiscoverer;
|
||||
|
||||
/**
|
||||
* {@link LinkDiscoverer} implementation to find ALPS-based links.
|
||||
*
|
||||
* @author Greg Turnquist
|
||||
*/
|
||||
public class AlpsLinkDiscoverer extends JsonPathLinkDiscoverer {
|
||||
|
||||
public AlpsLinkDiscoverer() {
|
||||
super("$.descriptors[?(@.name == '%s')].href", MediaTypes.ALPS_JSON);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user