This is an automated email from the ASF dual-hosted git repository. shuber pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-unomi.git
The following commit(s) were added to refs/heads/master by this push: new 9cd7c00 UNOMI-218 add queryParam annotation to the Unomi server rest API methods new ab96c77 This closes pull request number #76 9cd7c00 is described below commit 9cd7c00bea29bab739fd5546718d515170242e20 Author: Taybou <benterki.ta...@gmail.com> AuthorDate: Tue Jan 22 17:54:35 2019 +0100 UNOMI-218 add queryParam annotation to the Unomi server rest API methods --- .../org/apache/unomi/rest/ProfileServiceEndPoint.java | 7 ++++--- .../org/apache/unomi/rest/ScoringServiceEndPoint.java | 10 ++++++++-- .../org/apache/unomi/rest/SegmentServiceEndPoint.java | 11 +++++++++-- .../org/apache/unomi/rest/UserListServiceEndPoint.java | 16 ++++++++++------ 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/rest/src/main/java/org/apache/unomi/rest/ProfileServiceEndPoint.java b/rest/src/main/java/org/apache/unomi/rest/ProfileServiceEndPoint.java index cb332df..0e47106 100644 --- a/rest/src/main/java/org/apache/unomi/rest/ProfileServiceEndPoint.java +++ b/rest/src/main/java/org/apache/unomi/rest/ProfileServiceEndPoint.java @@ -217,7 +217,7 @@ public class ProfileServiceEndPoint { @DELETE @Path("/{profileId}") public void delete(@PathParam("profileId") String profileId, @QueryParam("persona") @DefaultValue("false") boolean persona) { - profileService.delete(profileId, false); + profileService.delete(profileId, persona); } /** @@ -335,11 +335,12 @@ public class ProfileServiceEndPoint { * Removes the persona identified by the specified identifier. * * @param personaId the identifier of the persona to delete + * @param persona {@code true} if the specified identifier is supposed to refer to a persona, {@code false} if it is supposed to refer to a profile */ @DELETE @Path("/personas/{personaId}") - public void deletePersona(@PathParam("personaId") String personaId) { - profileService.delete(personaId, true); + public void deletePersona(@PathParam("personaId") String personaId, @QueryParam("persona") @DefaultValue("true") boolean persona) { + profileService.delete(personaId, persona); } /** diff --git a/rest/src/main/java/org/apache/unomi/rest/ScoringServiceEndPoint.java b/rest/src/main/java/org/apache/unomi/rest/ScoringServiceEndPoint.java index 599a42f..c7b83cc 100644 --- a/rest/src/main/java/org/apache/unomi/rest/ScoringServiceEndPoint.java +++ b/rest/src/main/java/org/apache/unomi/rest/ScoringServiceEndPoint.java @@ -61,13 +61,19 @@ public class ScoringServiceEndPoint { /** * Retrieves the set of all scoring metadata. + * @param offset zero or a positive integer specifying the position of the first element in the total ordered collection of matching elements + * @param size a positive integer specifying how many matching elements should be retrieved or {@code -1} if all of them should be retrieved + * @param sortBy an optional ({@code null} if no sorting is required) String of comma ({@code ,}) separated property names on which ordering should be performed, ordering + * elements according to the property order in the + * String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally followed by + * a column ({@code :}) and an order specifier: {@code asc} or {@code desc}. * * @return the set of all scoring metadata */ @GET @Path("/") - public List<Metadata> getScoringMetadatas() { - return segmentService.getScoringMetadatas(0, 50, null).getList(); + public List<Metadata> getScoringMetadatas(@QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("size") @DefaultValue("50") int size, @QueryParam("sort") String sortBy) { + return segmentService.getScoringMetadatas(offset,size,sortBy).getList(); } /** diff --git a/rest/src/main/java/org/apache/unomi/rest/SegmentServiceEndPoint.java b/rest/src/main/java/org/apache/unomi/rest/SegmentServiceEndPoint.java index 5d0e09c..240c9a0 100644 --- a/rest/src/main/java/org/apache/unomi/rest/SegmentServiceEndPoint.java +++ b/rest/src/main/java/org/apache/unomi/rest/SegmentServiceEndPoint.java @@ -106,12 +106,19 @@ public class SegmentServiceEndPoint { /** * Retrieves the 50 first segment metadatas. * + * @param offset zero or a positive integer specifying the position of the first element in the total ordered collection of matching elements + * @param size a positive integer specifying how many matching elements should be retrieved or {@code -1} if all of them should be retrieved + * @param sortBy an optional ({@code null} if no sorting is required) String of comma ({@code ,}) separated property names on which ordering should be performed, ordering + * elements according to the property order in the + * String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally followed by + * a column ({@code :}) and an order specifier: {@code asc} or {@code desc}. + * * @return a List of the 50 first segment metadata */ @GET @Path("/") - public List<Metadata> getSegmentMetadatas() { - return segmentService.getSegmentMetadatas(0, 50, null).getList(); + public List<Metadata> getSegmentMetadatas(@QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("size") @DefaultValue("50") int size, @QueryParam("sort") String sortBy) { + return segmentService.getSegmentMetadatas(offset, size, sortBy).getList(); } /** diff --git a/rest/src/main/java/org/apache/unomi/rest/UserListServiceEndPoint.java b/rest/src/main/java/org/apache/unomi/rest/UserListServiceEndPoint.java index ee27411..6a4c264 100644 --- a/rest/src/main/java/org/apache/unomi/rest/UserListServiceEndPoint.java +++ b/rest/src/main/java/org/apache/unomi/rest/UserListServiceEndPoint.java @@ -30,10 +30,7 @@ import org.slf4j.LoggerFactory; import javax.jws.WebMethod; import javax.jws.WebService; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import java.util.List; @@ -65,11 +62,18 @@ public class UserListServiceEndPoint { /** * Retrieves the 50 first {@link UserList} metadatas. * + * @param offset zero or a positive integer specifying the position of the first element in the total ordered collection of matching elements + * @param size a positive integer specifying how many matching elements should be retrieved or {@code -1} if all of them should be retrieved + * @param sortBy an optional ({@code null} if no sorting is required) String of comma ({@code ,}) separated property names on which ordering should be performed, ordering + * elements according to the property order in the + * String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally followed by + * a column ({@code :}) and an order specifier: {@code asc} or {@code desc}. + * * @return a List of the 50 first {@link UserList} metadata */ @GET @Path("/") - public List<Metadata> getUserListsMetadatas() { - return userListService.getUserListMetadatas(0, 50, null).getList(); + public List<Metadata> getUserListsMetadatas(@QueryParam("offset") @DefaultValue("0") int offset, @QueryParam("size") @DefaultValue("50") int size, @QueryParam("sort") String sortBy) { + return userListService.getUserListMetadatas(offset,size, sortBy).getList(); } }