Fixed a bug where complex query method parameters that aren't managed by repositories were causing the parameter processing to short-circuit to a 404 error. Replaced that method call with a different one that simple returns a boolean if a type is managed by a repository so the if/else chain can continue on to the ConversionService.

This commit is contained in:
Jon Brisbin
2012-07-31 09:22:36 -05:00
parent b681844258
commit bf9c719950
2 changed files with 32 additions and 2 deletions

View File

@@ -71,6 +71,36 @@ public abstract class RepositoryExporterSupport<S extends RepositoryExporterSupp
return (S)this;
}
/**
* Does a Repository exist for this name?
*
* @param name
*
* @return true
*/
public boolean hasRepositoryMetadataFor(String name) {
try {
return (null != repositoryMetadataFor(name));
} catch(RepositoryNotFoundException ignored) {
return false;
}
}
/**
* Is there a Repository responsible for this domain type?
*
* @param domainType
*
* @return
*/
public boolean hasRepositoryMetadataFor(Class<?> domainType) {
try {
return (null != repositoryMetadataFor(domainType));
} catch(RepositoryNotFoundException ignored) {
return false;
}
}
/**
* Find {@link RepositoryMetadata} for the {@link org.springframework.data.repository.Repository} exported under this
* name.

View File

@@ -537,11 +537,11 @@ public class RepositoryRestController
continue;
}
RepositoryMetadata paramRepoMeta;
if(String.class.isAssignableFrom(paramTypes[i])) {
// Param type is a String
paramVals[i] = queryVal;
} else if(null != (paramRepoMeta = repositoryMetadataFor(paramTypes[i]))) {
} else if(hasRepositoryMetadataFor(paramTypes[i])) {
RepositoryMetadata paramRepoMeta = repositoryMetadataFor(paramTypes[i]);
// Complex parameter is a managed type
Serializable id = stringToSerializable(queryVal,
(Class<Serializable>)paramRepoMeta.entityMetadata()