From f8ef6d59c09cd52fd8e5e748a2fad02c7cba0e4e Mon Sep 17 00:00:00 2001 From: Gustavo Martin Morcuende Date: Mon, 22 Aug 2016 19:52:23 +0200 Subject: [PATCH] JPA project: maven site and Javadoc working --- SpringJava/JPA/README | 1 + SpringJava/JPA/spring-jpa-bom/pom.xml | 61 ++++++++++++++++++++-- .../repository/AdDescriptionRepository.java | 2 +- .../persistence/repository/AdRepository.java | 2 +- .../rest/controllers/RevisionRestController.java | 3 +- .../controller/RepositoryBasedRestController.java | 3 +- .../org/resthub/web/controller/RestController.java | 45 ++++++++-------- .../web/controller/ServiceBasedRestController.java | 14 ++--- .../example/services/AdDescriptionService.java | 4 +- .../spring/example/services/RevisionService.java | 4 +- .../org/resthub/common/service/CrudService.java | 6 +-- 11 files changed, 100 insertions(+), 45 deletions(-) diff --git a/SpringJava/JPA/README b/SpringJava/JPA/README index 2ebf155..5b41f97 100644 --- a/SpringJava/JPA/README +++ b/SpringJava/JPA/README @@ -4,6 +4,7 @@ mvn clean install -Pintegration mvn clean install site -Pintegration mvn dependency:sources mvn dependency:resolve -Dclassifier=javadoc +mvn site mvn sonar:sonar -Dsonar.host.url=http://172.17.0.3:9091/sonarqube diff --git a/SpringJava/JPA/spring-jpa-bom/pom.xml b/SpringJava/JPA/spring-jpa-bom/pom.xml index 42bc366..780b4d2 100644 --- a/SpringJava/JPA/spring-jpa-bom/pom.xml +++ b/SpringJava/JPA/spring-jpa-bom/pom.xml @@ -18,11 +18,11 @@ Gustavo Martin Morcuende - http://www.gumartinm.name + https://www.gumartinm.name - scm:git:http://git.gumartinm.name/JavaForFun - http://git.gumartinm.name/JavaForFun + scm:git:https://git.gumartinm.name/JavaForFun + https://git.gumartinm.name/JavaForFun @@ -30,6 +30,8 @@ UTF-8 4.3.0.RELEASE 4.1.3 + 2.10.4 + 3.0.1 ${project.basedir}/target/jacoco-it.exec @@ -364,6 +366,18 @@ build-helper-maven-plugin 1.11 + + org.apache.maven.plugins + maven-site-plugin + 3.5.1 + + + org.apache.maven.wagon + wagon-ssh + 2.10 + + + @@ -386,6 +400,17 @@ ${project.build.sourceEncoding} + + maven-site-plugin + + + attach-descriptor + + attach-descriptor + + + + org.apache.maven.plugins maven-jar-plugin @@ -404,6 +429,32 @@ + org.apache.maven.plugins + maven-javadoc-plugin + ${maven.javadoc.version} + + true + ${project.build.sourceEncoding} + ${project.build.sourceEncoding} + ${project.build.sourceEncoding} + -Xdoclint:none + + + + org.apache.maven.plugins + maven-source-plugin + ${maven.source.version} + + + attach-sources + package + + jar-no-fork + + + + + org.jacoco jacoco-maven-plugin 0.7.7.201606060606 @@ -564,12 +615,12 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.10.4 + ${maven.javadoc.version} html - + API for ${project.name} ${project.version} API for ${project.name} ${project.version} diff --git a/SpringJava/JPA/spring-jpa-persistence/src/main/java/de/spring/example/persistence/repository/AdDescriptionRepository.java b/SpringJava/JPA/spring-jpa-persistence/src/main/java/de/spring/example/persistence/repository/AdDescriptionRepository.java index 817884c..e865253 100644 --- a/SpringJava/JPA/spring-jpa-persistence/src/main/java/de/spring/example/persistence/repository/AdDescriptionRepository.java +++ b/SpringJava/JPA/spring-jpa-persistence/src/main/java/de/spring/example/persistence/repository/AdDescriptionRepository.java @@ -9,7 +9,7 @@ import de.spring.example.persistence.domain.Ad; import de.spring.example.persistence.domain.AdDescription; /** - * 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-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 *

* 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 : - * + *

*
  * 
    {@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 {
 
     /**
-     * Create a new resource
- * 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 { T create(@RequestBody T resource); /** - * Update an existing resource
- * 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 { Iterable findAll(); /** - * 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 + * 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 { @RequestParam(value = "properties", required = false) String properties); /** - * Find a resource by its identifier
- * 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[]= + *

+ * example : /?ids[]=1&ids[]=2&ids[]=3 + *

* * @param ids List of ids to retrieve * @return OK http status code with list of retrieved resources. Not found resources are ignored: @@ -96,21 +97,21 @@ public interface RestController { Iterable findByIds(@RequestParam(value = "ids[]") Set ids); /** - * Delete all resources
- * 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 - *

- *

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 : - *

+ *

*
  * 
  * {@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);
 
-- 
2.1.4