DATAREST-93 - Code cleanups.

Added missing license header. Polished code in RepositoryEntityController.
This commit is contained in:
Oliver Gierke
2013-10-01 17:41:03 +02:00
parent 282132994b
commit 6260d3fba9
2 changed files with 18 additions and 5 deletions

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2012-2013 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.data.rest.core.support;
import org.springframework.beans.factory.annotation.Autowired;

View File

@@ -164,6 +164,7 @@ class RepositoryEntityController extends AbstractRepositoryRestController implem
PersistentEntityResource<?> incoming) {
RepositoryInvoker invoker = repoRequest.getRepositoryInvoker();
if (!invoker.exposesSave()) {
throw new NoSuchMethodError();
}
@@ -176,11 +177,8 @@ class RepositoryEntityController extends AbstractRepositoryRestController implem
HttpHeaders headers = new HttpHeaders();
headers.setLocation(URI.create(selfLink.getHref()));
if (config.isReturnBodyOnCreate()) {
return ControllerUtils.toResponseEntity(headers, perAssembler.toResource(obj), HttpStatus.CREATED);
} else {
return ControllerUtils.toResponseEntity(headers, null, HttpStatus.CREATED);
}
PersistentEntityResource<Object> resource = config.isReturnBodyOnCreate() ? perAssembler.toResource(obj) : null;
return ControllerUtils.toResponseEntity(headers, resource, HttpStatus.CREATED);
}
/**