com.atlassian.gadgets.dashboard.internal.rest
Class GadgetResource

java.lang.Object
  extended by com.atlassian.gadgets.dashboard.internal.rest.GadgetResource

public class GadgetResource
extends Object

Provides REST endpoints for manipulating a Gadget.


Constructor Summary
GadgetResource(PermissionService permissionService, DashboardRepository repository, GadgetRequestContextFactory gadgetRequestContextFactory, AddGadgetHandler addGadgetHandler, DeleteGadgetHandler deleteGadgetHandler, ChangeGadgetColorHandler changeGadgetColorHandler, UpdateGadgetUserPrefsHandler updateGadgetUserPrefsHandler, com.atlassian.sal.api.message.I18nResolver i18n, RepresentationFactory representationFactory)
          Constructor.
 
Method Summary
 javax.ws.rs.core.Response changeGadgetColor(DashboardId dashboardId, GadgetId gadgetId, String colorParam, javax.servlet.http.HttpServletRequest request)
          Changes the specified gadget's color in response to a PUT request.
 javax.ws.rs.core.Response changeGadgetColorViaPOST(String method, DashboardId dashboardId, GadgetId gadgetId, String colorParam, javax.servlet.http.HttpServletRequest request)
          Forwards POST requests (coming from Ajax or web browsers) to the PUT handler for color changing.
 javax.ws.rs.core.Response deleteGadget(DashboardId dashboardId, GadgetId gadgetId, javax.servlet.http.HttpServletRequest request)
          Deletes the specified gadget from the specified dashboard when invoked as a DELETE request.
 javax.ws.rs.core.Response deleteOrMoveGadgetViaPost(String method, DashboardId dashboardId, GadgetId gadgetId, javax.servlet.http.HttpServletRequest request)
          Deletes or moves the specified gadget from the specified dashboard when invoked as a POST request.
 javax.ws.rs.core.Response getRenderedGadget(DashboardId dashboardId, GadgetId gadgetId, javax.servlet.http.HttpServletRequest request)
          Returns a Gadget's JSON or XMl representation.
 javax.ws.rs.core.Response moveGadget(DashboardId targetDashboardId, GadgetId gadgetId, javax.servlet.http.HttpServletRequest request)
          Moves the specified gadget to the specified dashboard.
 javax.ws.rs.core.Response updateUserPrefsViaPOST(String method, DashboardId dashboardId, GadgetId gadgetId, javax.servlet.http.HttpServletRequest request, javax.ws.rs.core.MultivaluedMap<String,String> formParams)
          Forwards POST requests (coming from Ajax or web browsers) to the PUT handler for user pref changes.
 javax.ws.rs.core.Response updateUserPrefsViaPUT(DashboardId dashboardId, GadgetId gadgetId, javax.servlet.http.HttpServletRequest request, javax.ws.rs.core.UriInfo uriInfo)
          Updates the user prefs of the specified gadget.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GadgetResource

public GadgetResource(PermissionService permissionService,
                      DashboardRepository repository,
                      GadgetRequestContextFactory gadgetRequestContextFactory,
                      AddGadgetHandler addGadgetHandler,
                      DeleteGadgetHandler deleteGadgetHandler,
                      ChangeGadgetColorHandler changeGadgetColorHandler,
                      UpdateGadgetUserPrefsHandler updateGadgetUserPrefsHandler,
                      com.atlassian.sal.api.message.I18nResolver i18n,
                      RepresentationFactory representationFactory)
Constructor.

Parameters:
permissionService - the PermissionService to use
repository - the DashboardRepository to use
gadgetRequestContextFactory - the GadgetRequestContextFactory to use
addGadgetHandler - the AddGadgetHandler to use
deleteGadgetHandler - the DeleteGadgetHandler to use
changeGadgetColorHandler - the ChangeGadgetColorHandler to use
updateGadgetUserPrefsHandler - the UpdateGadgetUserPrefsHandler to use
i18n - the SAL I18nResolver to use
representationFactory - Used to created JAXB Gadget representations
Method Detail

getRenderedGadget

public javax.ws.rs.core.Response getRenderedGadget(DashboardId dashboardId,
                                                   GadgetId gadgetId,
                                                   @Context
                                                   javax.servlet.http.HttpServletRequest request)
Returns a Gadget's JSON or XMl representation.

Parameters:
dashboardId - the id of the dashboard which it belongs to
gadgetId - the ID of the gadget to return
request - the HttpServletRequest that was routed here
Returns:
The gadget representation

deleteOrMoveGadgetViaPost

public javax.ws.rs.core.Response deleteOrMoveGadgetViaPost(String method,
                                                           DashboardId dashboardId,
                                                           GadgetId gadgetId,
                                                           @Context
                                                           javax.servlet.http.HttpServletRequest request)
Deletes or moves the specified gadget from the specified dashboard when invoked as a POST request.

Parameters:
method - the HTTP method to forward to ("delete" does a delete, "put" does a move)
dashboardId - ID of the dashboard hosting the gadget
gadgetId - ID of the gadget
request - the request object (used for providing the locale)
Returns:
a Response with details on the request's success or failure

deleteGadget

public javax.ws.rs.core.Response deleteGadget(DashboardId dashboardId,
                                              GadgetId gadgetId,
                                              @Context
                                              javax.servlet.http.HttpServletRequest request)
Deletes the specified gadget from the specified dashboard when invoked as a DELETE request.

Parameters:
dashboardId - ID of the dashboard hosting the gadget
gadgetId - ID of the gadget to remove
request - the request object (used for providing the locale)
Returns:
a Response with details on the request's success or failure

moveGadget

public javax.ws.rs.core.Response moveGadget(DashboardId targetDashboardId,
                                            GadgetId gadgetId,
                                            @Context
                                            javax.servlet.http.HttpServletRequest request)
Moves the specified gadget to the specified dashboard. The gadget is assumed to exist on some other (unspecified) dashboard. The gadget is safely removed from that dashboard and added to the target dashboard.

Parameters:
targetDashboardId - the dashboard id for the dashboard to which this gadget should be added
gadgetId - the id of the gadget to move
request - the request object
Returns:
a Response with details on the request's success or failure

changeGadgetColorViaPOST

public javax.ws.rs.core.Response changeGadgetColorViaPOST(String method,
                                                          DashboardId dashboardId,
                                                          GadgetId gadgetId,
                                                          String colorParam,
                                                          @Context
                                                          javax.servlet.http.HttpServletRequest request)
Forwards POST requests (coming from Ajax or web browsers) to the PUT handler for color changing.

Parameters:
method - the HTTP method to forward to (must be "put")
dashboardId - ID of the dashboard hosting the gadget
gadgetId - ID of the gadget which will change color
colorParam - new color of the gadget
request - the request object (used for providing the locale)
Returns:
a Response with details on the request's success or failure

changeGadgetColor

public javax.ws.rs.core.Response changeGadgetColor(DashboardId dashboardId,
                                                   GadgetId gadgetId,
                                                   String colorParam,
                                                   @Context
                                                   javax.servlet.http.HttpServletRequest request)
Changes the specified gadget's color in response to a PUT request.

Parameters:
dashboardId - ID of the dashboard hosting the gadget
gadgetId - ID of the gadget which will change color
colorParam - new color of the gadget
request - the request object (used for providing the locale)
Returns:
a Response with details on the request's success or failure

updateUserPrefsViaPOST

public javax.ws.rs.core.Response updateUserPrefsViaPOST(String method,
                                                        DashboardId dashboardId,
                                                        GadgetId gadgetId,
                                                        @Context
                                                        javax.servlet.http.HttpServletRequest request,
                                                        javax.ws.rs.core.MultivaluedMap<String,String> formParams)

Forwards POST requests (coming from Ajax or web browsers) to the PUT handler for user pref changes.

Parameters:
method - the HTTP method to forward to (must be "put")
dashboardId - ID of the dashboard hosting the gadget
gadgetId - ID of the gadget to update the prefs for
request - the request object (used for providing the locale)
formParams - the container for the form parameters
Returns:
a Response with details on the request's success or failure

updateUserPrefsViaPUT

public javax.ws.rs.core.Response updateUserPrefsViaPUT(DashboardId dashboardId,
                                                       GadgetId gadgetId,
                                                       @Context
                                                       javax.servlet.http.HttpServletRequest request,
                                                       @Context
                                                       javax.ws.rs.core.UriInfo uriInfo)
Updates the user prefs of the specified gadget.

Parameters:
dashboardId - ID of the dashboard hosting the gadget
gadgetId - ID of the gadget to update the prefs for
request - the request object (used for providing the locale)
uriInfo - provides the query parameters for the user pref values
Returns:
a Response with details on the request's success or failure


Copyright © 2009 Atlassian. All Rights Reserved.