Package org.silverpeas.components.suggestionbox.web

## Class SuggestionBoxResource

- java.lang.Object
- - org.silverpeas.core.web.rs.RESTWebService
  - - org.silverpeas.components.suggestionbox.web.AbstractSuggestionBoxResource
    - - org.silverpeas.components.suggestionbox.web.SuggestionBoxResource

- All Implemented Interfaces:
    `org.silverpeas.core.web.rs.ProtectedWebResource`, `org.silverpeas.core.web.rs.WebAuthenticationValidation`, `org.silverpeas.core.web.rs.WebAuthorizationValidation`, `org.silverpeas.core.web.SilverpeasWebResource`

      @WebService
      @Path("suggestionbox/{componentInstanceId}/{suggestionBoxId}")
      @Authorized
      public class SuggestionBoxResource
      extends AbstractSuggestionBoxResource

  A REST Web resource giving suggestion data.
  Author:
    Yohann Chastagnier

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.silverpeas.core.web.rs.RESTWebService

      `org.silverpeas.core.web.rs.RESTWebService.WebProcess<R extends Object>, org.silverpeas.core.web.rs.RESTWebService.WebTreatment<R extends Object>`

  - ### Field Summary

    - ### Fields inherited from class org.silverpeas.core.web.rs.RESTWebService

      `RESPONSE_HEADER_ARRAYSIZE`

    - ### Fields inherited from interface org.silverpeas.core.web.SilverpeasWebResource

      `BASE_PATH`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `SuggestionBoxResource()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `deleteSuggestion​(String suggestionId)` | Deletes the suggestion identified by the specified identifier.
    `Collection<SuggestionCommentEntity>` | `getLastComments​(int count)` | Gets the JSON representation of a list of the last comments that were posted on the suggestions of the current suggestion box.
    `Collection<SuggestionEntity>` | `getPublishedSuggestions​(String authorId, String page, String property)` | Gets the JSON representation of a list of suggestions that are published, bu default sorted by date of validation (from the newer to the older).
    `SuggestionEntity` | `getSuggestion​(String suggestionId)` | Gets the JSON representation of an suggestion.
    `Collection<SuggestionEntity>` | `getSuggestionsInDraft()` | Gets the JSON representation of a list of suggestion that are in draft for the user behind the service call.
    `Collection<SuggestionEntity>` | `getSuggestionsInPendingValidation()` | Gets the JSON representation of a list of suggestion that are pending validation.
    `Collection<SuggestionEntity>` | `getSuggestionsOutOfDraft()` | Gets the JSON representation of a list of suggestion that are out of draft for the user behind the service call.
    `SuggestionEntity` | `publishSuggestion​(String suggestionId)` | Publishes the suggestion identified by the specified identifier.

    - ### Methods inherited from class org.silverpeas.components.suggestionbox.web.AbstractSuggestionBoxResource

      `getBundleLocation, getComponentId, getResourceBasePath, getSuggestionBox`

    - ### Methods inherited from class org.silverpeas.core.web.rs.RESTWebService

      `createWebResourceUri, fromPage, getBundle, getHighestUserRole, getHttpRequest, getHttpServletRequest, getHttpServletResponse, getOrganisationController, getSilverpeasContext, getUri, getUser, getUserPreferences, getUserRoles, identifiedBy, identifiedBy, initContext, initWebResourceUri, isUserDefined, process`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.silverpeas.core.web.rs.ProtectedWebResource

      `validateUserAuthorization`

    - ### Methods inherited from interface org.silverpeas.core.web.rs.WebAuthenticationValidation

      `validateUserAuthentication`

- - ### Constructor Detail

    - #### SuggestionBoxResource

          public SuggestionBoxResource()

  - ### Method Detail

    - #### getSuggestion

          @GET
          @Path("suggestions/{suggestionId}")
          @Produces("application/json")
          public SuggestionEntity getSuggestion​(@PathParam("suggestionId")
                                                String suggestionId)

      Gets the JSON representation of an suggestion. If it doesn't exist, a 404 HTTP code is returned.
      Parameters:
        `suggestionId` - the identifier of the suggestion
      Returns:
        the response to the HTTP GET request with the JSON representation of the asked suggestion.
      See Also:
        `RESTWebService.WebProcess.execute()`

    - #### deleteSuggestion

          @DELETE
          @Path("suggestions/{suggestionId}")
          public void deleteSuggestion​(@PathParam("suggestionId")
                                       String suggestionId)

      Deletes the suggestion identified by the specified identifier. If it doesn't exist, a 404 HTTP code is returned.
      Parameters:
        `suggestionId` - the identifier of the suggestion.

    - #### publishSuggestion

          @PUT
          @Path("suggestions/{suggestionId}/publish")
          @Produces("application/json")
          public SuggestionEntity publishSuggestion​(@PathParam("suggestionId")
                                                    String suggestionId)

      Publishes the suggestion identified by the specified identifier. If it doesn't exist, a 404 HTTP code is returned.
      Parameters:
        `suggestionId` - the identifier of the suggestion.
      Returns:
        the response to the HTTP PUT request with the JSON representation of the published suggestion.

    - #### getSuggestionsInDraft

          @GET
          @Path("suggestions/inDraft")
          @Produces("application/json")
          public Collection<SuggestionEntity> getSuggestionsInDraft()

      Gets the JSON representation of a list of suggestion that are in draft for the user behind the service call.
      Returns:
        the response to the HTTP GET request with the JSON representation of the asked list of suggestions.
      See Also:
        `SuggestionBoxWebManager.getSuggestionsInDraftFor(SuggestionBox, User)`, `RESTWebService.WebProcess.execute()`

    - #### getSuggestionsOutOfDraft

          @GET
          @Path("suggestions/outOfDraft")
          @Produces("application/json")
          public Collection<SuggestionEntity> getSuggestionsOutOfDraft()

      Gets the JSON representation of a list of suggestion that are out of draft for the user behind the service call.
      Returns:
        the response to the HTTP GET request with the JSON representation of the asked list of suggestions.
      See Also:
        `SuggestionBoxWebManager.getSuggestionsInDraftFor(SuggestionBox, User)`, `RESTWebService.WebProcess.execute()`

    - #### getSuggestionsInPendingValidation

          @GET
          @Path("suggestions/pendingValidation")
          @Produces("application/json")
          public Collection<SuggestionEntity> getSuggestionsInPendingValidation()

      Gets the JSON representation of a list of suggestion that are pending validation.
      Returns:
        the response to the HTTP GET request with the JSON representation of the asked list of suggestions.
      See Also:
        `SuggestionBoxWebManager.getSuggestionsInPendingValidation(SuggestionBox)`, `RESTWebService.WebProcess.execute()`

    - #### getPublishedSuggestions

          @GET
          @Path("suggestions/published")
          @Produces("application/json")
          public Collection<SuggestionEntity> getPublishedSuggestions​(@QueryParam("author")
                                                                      String authorId,
                                                                      @QueryParam("page")
                                                                      String page,
                                                                      @QueryParam("sortby")
                                                                      String property)

      Gets the JSON representation of a list of suggestions that are published, bu default sorted by date of validation (from the newer to the older).
      Parameters:
        `authorId` - if this parameter is set, then the suggestions to get will be those proposed by the author with the specified user unique identifier.
        `page` - if this parameter is set, then the pagination is activated and only the published suggestions matching the specified pagination criterion are sent back. The parameter is semicolon-separated criterion: the first part is the page number and the second part is the count of suggestions to sent back.
        `property` - the property by which the asked published suggestions should be sorted. If no such property exists for the suggestions, then no sorting is performed.
      Returns:
        the response to the HTTP GET request with the JSON representation of the asked list of suggestions.
      See Also:
        `SuggestionBoxWebManager.getPublishedSuggestions(SuggestionBox)`, `RESTWebService.WebProcess.execute()`

    - #### getLastComments

          @GET
          @Path("suggestions/lastComments")
          @Produces("application/json")
          public Collection<SuggestionCommentEntity> getLastComments​(@QueryParam("count")
                                                                     int count)

      Gets the JSON representation of a list of the last comments that were posted on the suggestions of the current suggestion box. The comments are sorted in descent order, that is to say from the newer to the older one.
      Parameters:
        `count` - the number of comments to return. If this parameter isn't set, then only the first 5 last comments are sent back.
      Returns:
        a collection of comments on the suggestions, ready to be serialized in JSON.