Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

Adds support for templated Urls of HAL specification #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ ext {
logbackVersion = "1.0.9"

springVersion = "3.2.2.RELEASE"
springShellVersion = "1.0.1.BUILD-SNAPSHOT"
hateoasVersion = "0.4.0.RELEASE"
springShellVersion = "1.0.0.RELEASE"
hateoasVersion = "0.9.0.RELEASE"
jacksonVersion = "1.9.12"

junitVersion = "4.11"
Expand All @@ -38,7 +38,7 @@ project.targetCompatibility = 1.6

// Repositories
repositories {
//maven { url "http://repo.springsource.org/libs-snapshot" }
maven { url "http://repo.springsource.org/libs-snapshot" }
//maven { url "http://repo.springsource.org/libs-milestone" }
maven { url "http://repo.springsource.org/libs-release" }
maven { url "http://spring-roo-repository.springsource.org/release" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSession;
Expand All @@ -21,6 +22,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.data.rest.shell.util.LinkUtil;
import org.springframework.hateoas.Link;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
Expand Down Expand Up @@ -60,7 +62,7 @@ public class DiscoveryCommands implements CommandMarker, ApplicationEventPublish
private RestTemplate client = new RestTemplate(requestFactory);
@Autowired(required = false)
private ObjectMapper mapper = new ObjectMapper();
private Map<String, String> resources = new HashMap<String, String>();
private Map<String, Link> resources = new HashMap<String, Link>();
private ApplicationEventPublisher ctx;

private static String pad(String s, int len) {
Expand All @@ -78,7 +80,7 @@ private static String pad(String s, int len) {
*
* @return
*/
public Map<String, String> getResources() {
public Map<String, Link> getResources() {
return resources;
}

Expand Down Expand Up @@ -134,7 +136,7 @@ public String list(
} else if(path.getPath().startsWith("http")) {
requestUri = URI.create(path.getPath());
} else if(resources.containsKey(path)) {
requestUri = UriComponentsBuilder.fromUriString(resources.get(path))
requestUri = UriComponentsBuilder.fromUriString(LinkUtil.normalize(resources.get(path)))
.build()
.toUri();
} else if("/".equals(configCmds.getBaseUri().getPath())) {
Expand Down Expand Up @@ -191,7 +193,7 @@ public String list(

// Now build a table
for(Link l : links) {
resources.put(l.getRel(), l.getHref());
resources.put(l.getRel(), l);
sb.append(pad(l.getRel(), maxRelLen))
.append(pad(l.getHref(), maxHrefLen))
.append(OsUtils.LINE_SEPARATOR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.net.URISyntaxException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.rest.shell.util.LinkUtil;
import org.springframework.shell.core.CommandMarker;
import org.springframework.shell.core.annotation.CliAvailabilityIndicator;
import org.springframework.shell.core.annotation.CliCommand;
Expand Down Expand Up @@ -35,7 +36,7 @@ public boolean isHierarchyAvailable() {
@CliCommand(value = "up", help = "Traverse one level up in the URL hierarchy.")
public void up() throws URISyntaxException {
if(discoveryCmds.getResources().containsKey("parent")) {
configCmds.setBaseUri(discoveryCmds.getResources().get("parent"));
configCmds.setBaseUri(LinkUtil.normalize(discoveryCmds.getResources().get("parent")));
return;
}

Expand Down
Loading