From: Gustavo Martin Morcuende
* You should extend this class when you want to use a 2 layers pattern : Repository and Controller. This is the default
* controller implementation to use if you have no service (also called business) layer. You will be able to transform
@@ -26,7 +25,7 @@ import java.util.Set;
*
* Default implementation uses "id" field (usually a Long) in order to identify resources in web request.
* If your want to identity resources by a slug (human readable identifier), your should override findById() method with for example :
- *
+ *
+ * example : You should extend this class when you want to use a 3 layers pattern : Repository, Service and Controller
- * If you don't have a real service (also called business layer), consider using RepositoryBasedRestController Default implementation uses "id" field (usually a Long) in order to identify resources in web request.
+ *
+ *
+ * You should extend this class when you want to use a 3 layers pattern : Repository, Service and Controller
+ * If you don't have a real service (also called business layer), consider using RepositoryBasedRestController
+ *
+ * Default implementation uses "id" field (usually a Long) in order to identify resources in web request.
* If your want to identity resources by a slug (human readable identifier), your should override findById() method with for example :
- * org.springframework.data.jpa.repository.support.SimpleJpaRepository
+ * By default
org.springframework.data.jpa.repository.support.SimpleJpaRepository
* will be the implementation for this interface.
*
* Be careful with @Transactional
. SimpleJpaRepository has annotated methods.
diff --git a/SpringJava/JPA/spring-jpa-persistence/src/main/java/de/spring/example/persistence/repository/AdRepository.java b/SpringJava/JPA/spring-jpa-persistence/src/main/java/de/spring/example/persistence/repository/AdRepository.java
index c0add01..9e99ee3 100644
--- a/SpringJava/JPA/spring-jpa-persistence/src/main/java/de/spring/example/persistence/repository/AdRepository.java
+++ b/SpringJava/JPA/spring-jpa-persistence/src/main/java/de/spring/example/persistence/repository/AdRepository.java
@@ -9,7 +9,7 @@ import org.springframework.data.repository.query.Param;
import de.spring.example.persistence.domain.Ad;
/**
- * By default org.springframework.data.jpa.repository.support.SimpleJpaRepository
+ * By default
org.springframework.data.jpa.repository.support.SimpleJpaRepository
* will be the implementation for this interface.
*
* Be careful with @Transactional
. SimpleJpaRepository has annotated methods.
diff --git a/SpringJava/JPA/spring-jpa-resources/src/main/java/de/spring/example/rest/controllers/RevisionRestController.java b/SpringJava/JPA/spring-jpa-resources/src/main/java/de/spring/example/rest/controllers/RevisionRestController.java
index 80d1c8e..e6fa2db 100644
--- a/SpringJava/JPA/spring-jpa-resources/src/main/java/de/spring/example/rest/controllers/RevisionRestController.java
+++ b/SpringJava/JPA/spring-jpa-resources/src/main/java/de/spring/example/rest/controllers/RevisionRestController.java
@@ -15,10 +15,11 @@ public interface RevisionRestController
*
{@literal @}Override
diff --git a/SpringJava/JPA/spring-jpa-resources/src/main/java/org/resthub/web/controller/RestController.java b/SpringJava/JPA/spring-jpa-resources/src/main/java/org/resthub/web/controller/RestController.java
index 9aa9a26..62bb43d 100644
--- a/SpringJava/JPA/spring-jpa-resources/src/main/java/org/resthub/web/controller/RestController.java
+++ b/SpringJava/JPA/spring-jpa-resources/src/main/java/org/resthub/web/controller/RestController.java
@@ -17,8 +17,8 @@ import java.util.Set;
public interface RestController
- * REST webservice published : POST /
+ * Create a new resource
+ * REST webservice published : POST /
*
* @param resource The resource to create
* @return CREATED http status code if the request has been correctly processed, with updated resource enclosed in the body, usually with and additional identifier automatically created by the database
@@ -29,21 +29,21 @@ public interface RestController
- * REST webservice published : PUT /{id}
+ * Update an existing resource
+ * REST webservice published : PUT /{id}
*
* @param id The identifier of the resource to update, usually a Long or String identifier. It is explicitely provided in order to handle cases where the identifier could be changed.
* @param resource The resource to update
* @return OK http status code if the request has been correctly processed, with the updated resource enclosed in the body
- * @throws NotFoundException
+ * @throws NotFoundException when resource id
does not exist.
*/
@RequestMapping(value = "{id}", method = RequestMethod.PUT)
@ResponseBody
T update(@PathVariable ID id, @RequestBody T resource);
/**
- * Find all resources, and return the full collection (plain list not paginated)
- * REST webservice published : GET /?page=no
+ * Find all resources, and return the full collection (plain list not paginated)
+ * REST webservice published : GET /?page=no
*
* @return OK http status code if the request has been correctly processed, with the list of all resource enclosed in the body.
* Be careful, this list should be big since it will return ALL resources. In this case, consider using paginated findAll method instead.
@@ -53,8 +53,8 @@ public interface RestController
- * REST webservice published : GET /search?page=0&size=20 or GET /search?page=0&size=20&direction=desc&properties=name
+ * Find all resources, and return a paginated and optionaly sorted collection
+ * REST webservice published : GET /search?page=0&size=20 or GET /search?page=0&size=20&direction=desc&properties=name
*
* @param page Page number starting from 0. default to 0
* @param size Number of resources by pages. default to 10
@@ -70,22 +70,23 @@ public interface RestController
- * REST webservice published : GET /{id}
+ * Find a resource by its identifier
+ * REST webservice published : GET /{id}
*
* @param id The identifier of the resouce to find
* @return OK http status code if the request has been correctly processed, with resource found enclosed in the body
- * @throws NotFoundException
+ * @throws NotFoundException when resource id
does not exist.
*/
@RequestMapping(value = "{id}", method = RequestMethod.GET)
@ResponseBody
T findById(@PathVariable ID id);
/**
- * Find multiple resources by their identifiers
- * REST webservice published : GET /?ids[]=
- *
- * example : /?ids[]=1&ids[]=2&ids[]=3
+ * Find multiple resources by their identifiers
+ * REST webservice published : GET /?ids[]=
+ * /?ids[]=1&ids[]=2&ids[]=3
+ *
- * REST webservice published : DELETE /
- * Return No Content http status code if the request has been correctly processed
+ * Delete all resources
+ * REST webservice published : DELETE /
+ * Return No Content
http status code if the request has been correctly processed
*/
@RequestMapping(method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
void delete();
/**
- * Delete a resource by its identifier
- * REST webservice published : DELETE /{id}
+ * Delete a resource by its identifier
+ * REST webservice published : DELETE /{id}
* Return No Content http status code if the request has been correctly processed
*
* @param id The identifier of the resource to delete
- * @throws NotFoundException
+ * @throws NotFoundException when resource id
does not exist.
*/
@RequestMapping(value = "{id}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
diff --git a/SpringJava/JPA/spring-jpa-resources/src/main/java/org/resthub/web/controller/ServiceBasedRestController.java b/SpringJava/JPA/spring-jpa-resources/src/main/java/org/resthub/web/controller/ServiceBasedRestController.java
index cd93416..ed13138 100644
--- a/SpringJava/JPA/spring-jpa-resources/src/main/java/org/resthub/web/controller/ServiceBasedRestController.java
+++ b/SpringJava/JPA/spring-jpa-resources/src/main/java/org/resthub/web/controller/ServiceBasedRestController.java
@@ -15,13 +15,15 @@ import org.springframework.web.bind.annotation.RequestParam;
/**
* Abstract REST controller using a service implementation
- *
- *
*
* {@literal @}Override
diff --git a/SpringJava/JPA/spring-jpa-services/src/main/java/de/spring/example/services/AdDescriptionService.java b/SpringJava/JPA/spring-jpa-services/src/main/java/de/spring/example/services/AdDescriptionService.java
index 7a571b9..0a3dc1e 100644
--- a/SpringJava/JPA/spring-jpa-services/src/main/java/de/spring/example/services/AdDescriptionService.java
+++ b/SpringJava/JPA/spring-jpa-services/src/main/java/de/spring/example/services/AdDescriptionService.java
@@ -15,8 +15,8 @@ public interface AdDescriptionService extends CrudService {
* Returns a {@link Page} of revisions for the entity with the given id.
*
* @param id must not be {@literal null}.
- * @param pageable
- * @return
+ * @param pageable page request.
+ * @return a new {@link Page} with the content of the current one mapped by the given {@link Pageable}.
*/
Page> findRevisions(Long id, Pageable pageable);
}
diff --git a/SpringJava/JPA/spring-jpa-services/src/main/java/de/spring/example/services/RevisionService.java b/SpringJava/JPA/spring-jpa-services/src/main/java/de/spring/example/services/RevisionService.java
index abc891d..4e184fc 100644
--- a/SpringJava/JPA/spring-jpa-services/src/main/java/de/spring/example/services/RevisionService.java
+++ b/SpringJava/JPA/spring-jpa-services/src/main/java/de/spring/example/services/RevisionService.java
@@ -12,8 +12,8 @@ public interface RevisionService> findRevisions(ID id, Pageable pageable);
}
diff --git a/SpringJava/JPA/spring-jpa-services/src/main/java/org/resthub/common/service/CrudService.java b/SpringJava/JPA/spring-jpa-services/src/main/java/org/resthub/common/service/CrudService.java
index a9f4332..7f482e6 100644
--- a/SpringJava/JPA/spring-jpa-services/src/main/java/org/resthub/common/service/CrudService.java
+++ b/SpringJava/JPA/spring-jpa-services/src/main/java/org/resthub/common/service/CrudService.java
@@ -45,7 +45,7 @@ public interface CrudService {
void delete(ID id);
/**
- * Delete all existing resource. Do not use cascade remove (not a choice -> JPA specs)
+ * Delete all existing resource. Do not use cascade remove (not a choice -> JPA specs)
*/
void deleteAll();
@@ -80,8 +80,8 @@ public interface CrudService {
/**
* Find all resources (pageable).
*
- * @param pageRequest page request
- * @return resources
+ * @param pageRequest page request.
+ * @return a new {@link Page} with the content of the current one mapped by the given {@link Pageable}.
*/
Page findAll(Pageable pageRequest);