org.nhindirect.config.resources
Class SettingResource

java.lang.Object
  extended by org.nhindirect.config.resources.ProtectedResource
      extended by org.nhindirect.config.resources.SettingResource

@Component
public class SettingResource
extends ProtectedResource

JAX-RS resource for managing settings resources in the configuration service.

Although not required, this class is instantiated using the Jersey SpringServlet and dependencies are defined in the Sprint context XML file.

Since:
2.0
Author:
Greg Meyer

Constructor Summary
SettingResource()
          Constructor
 
Method Summary
 javax.ws.rs.core.Response addSetting(javax.ws.rs.core.UriInfo uriInfo, String name, String value)
          Adds a setting to the system.
 javax.ws.rs.core.Response getAllSettings()
          Gets all settings in the system.
 javax.ws.rs.core.Response getSettingByName(String name)
          Gets a setting by name.
 javax.ws.rs.core.Response removeSettingByName(String name)
          Deletes a setting in the system by name.
 void setSettingDao(org.nhindirect.config.store.dao.SettingDao settingDao)
          Sets the settings Dao.
 javax.ws.rs.core.Response updateSetting(String name, String value)
          Updates the value of a setting.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SettingResource

public SettingResource()
Constructor

Method Detail

setSettingDao

@Autowired
public void setSettingDao(org.nhindirect.config.store.dao.SettingDao settingDao)
Sets the settings Dao. Auto populated by Spring

Parameters:
settingDao - Settings Dao

getAllSettings

public javax.ws.rs.core.Response getAllSettings()
Gets all settings in the system.

Returns:
A JSON representation of a collection of all settings in the system. Returns a status of 204 if no settings exist.

getSettingByName

public javax.ws.rs.core.Response getSettingByName(String name)
Gets a setting by name.

Parameters:
name - The name of the setting to retrieve.
Returns:
A JSON representation of the setting. Returns a status of 404 if a setting with the given name does not exist.

addSetting

public javax.ws.rs.core.Response addSetting(@Context
                                            javax.ws.rs.core.UriInfo uriInfo,
                                            String name,
                                            String value)
Adds a setting to the system.

Parameters:
uriInfo - Injected URI context used for building the location URI.
name - The name of the setting to add.
value - The value of the setting.
Returns:
Status of 201 if the setting was created or a status of 409 if a setting with the same name already exists.

updateSetting

public javax.ws.rs.core.Response updateSetting(String name,
                                               String value)
Updates the value of a setting.

Parameters:
name - The name of the setting to update.
value - The new value of the setting.
Returns:
Status of 204 if the value of the setting was updated or a status of 404 if a setting with the given name does not exist.

removeSettingByName

public javax.ws.rs.core.Response removeSettingByName(String name)
Deletes a setting in the system by name.

Parameters:
name - The name of the setting to delete.
Returns:
Status of 200 if the setting was deleted or a status of 204 if a setting with the given name does not exist.


Copyright © 2014. All Rights Reserved.