*/
@Override
protected void doPutWithSubjectAndActor(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
PreferencesProvider preferencesProvider = getPreferencesProvider(request);
if (preferencesProvider == null)
{
response.sendError(HttpServletResponse.SC_NOT_FOUND, "Preferences provider is not configured");
return;
}
String userName = getAuthenticatedUserName(request);
ObjectMapper mapper = new ObjectMapper();
@SuppressWarnings("unchecked")
Map<String, Object> newPreferences = mapper.readValue(request.getInputStream(), LinkedHashMap.class);
preferencesProvider.deletePreferences(userName);
Map<String, Object> preferences = preferencesProvider.setPreferences(userName, newPreferences);
if (preferences == null)
{
preferences = Collections.<String, Object>emptyMap();
}
sendJsonResponse(preferences, response);