From 719f850add5a926d49b167e12ef574f7303b08b7 Mon Sep 17 00:00:00 2001 From: Osvaldo Ferrero Date: Mon, 25 Feb 2013 18:27:30 -0400 Subject: [PATCH] Fix for #66. Added verification for repository metadata information. Added verification for repository metadata information. --- .../rest/webmvc/RepositoryRestController.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryRestController.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryRestController.java index 48ebf6f56..545bac2f9 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryRestController.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryRestController.java @@ -1790,18 +1790,17 @@ private Map throwableToMap(Throwable t) { private String objectToMapKey(Object obj) { Assert.notNull(obj, "Map key cannot be null!"); - RepositoryMetadata repoMeta; String key; - if(ClassUtils.isAssignable(obj.getClass(), String.class)) { - key = (String)obj; - } else if(null != (repoMeta = repositoryMetadataFor(obj.getClass()))) { - AttributeMetadata attrMeta = repoMeta.entityMetadata().idAttribute(); - String id = attrMeta.get(obj).toString(); - key = "@" + buildUri(config.getBaseUri(), repoMeta.name(), id); + if (ClassUtils.isAssignable(obj.getClass(), String.class)) { + key = (String) obj; + } else if(hasRepositoryMetadataFor(obj.getClass())) { + RepositoryMetadata repoMeta = repositoryMetadataFor(obj.getClass()); + AttributeMetadata attrMeta = repoMeta.entityMetadata().idAttribute(); + String id = attrMeta.get(obj).toString(); + key = "@" + buildUri(config.getBaseUri(), repoMeta.name(), id); } else { - key = conversionService.convert(obj, String.class); + key = conversionService.convert(obj, String.class); } - return key; }