use of org.onosproject.ui.UiPreferencesService in project onos by opennetworkinglab.
the class MainIndexResource method userPreferences.
// Produces an input stream including user preferences.
private InputStream userPreferences(String userName) {
UiPreferencesService service = get(UiPreferencesService.class);
ObjectNode prefs = mapper().createObjectNode();
service.getPreferences(userName).forEach(prefs::set);
String string = "var userPrefs = " + prefs.toString() + ";\n";
return new ByteArrayInputStream(string.getBytes());
}
use of org.onosproject.ui.UiPreferencesService in project onos by opennetworkinglab.
the class UiPreferencesWebResource method download.
/**
* Gets user preferences for the given user.
*
* @param user user name
* @return 200 OK with user preferences JSON
*/
@GET
@Path("{user}")
@Produces(MediaType.APPLICATION_JSON)
public Response download(@PathParam("user") String user) {
UiPreferencesService service = get(UiPreferencesService.class);
ObjectMapper mapper = new ObjectMapper();
ObjectNode prefs = mapper.createObjectNode();
service.getPreferences(user).forEach(prefs::set);
return ok(prefs).build();
}
use of org.onosproject.ui.UiPreferencesService in project onos by opennetworkinglab.
the class UiPreferencesWebResource method upload.
/**
* Gets the specified user preferences for the given user.
*
* @param user user name
* @param pref preferences name
* @param request preferences JSON
* @return 200 OK
* @throws IOException if given JSON is invalid
*/
@PUT
@Path("{user}/{pref}")
@Produces(MediaType.APPLICATION_JSON)
public Response upload(@PathParam("user") String user, @PathParam("pref") String pref, String request) throws IOException {
UiPreferencesService service = get(UiPreferencesService.class);
ObjectNode json = (ObjectNode) mapper().readTree(request);
service.setPreference(user, pref, json);
return Response.ok().build();
}
use of org.onosproject.ui.UiPreferencesService in project onos by opennetworkinglab.
the class UiPreferencesListCommand method doExecute.
@Override
protected void doExecute() {
UiPreferencesService service = get(UiPreferencesService.class);
ObjectMapper mapper = new ObjectMapper();
ObjectNode root = mapper.createObjectNode();
service.getUserNames().forEach(user -> {
ObjectNode prefs = mapper.createObjectNode();
root.set(user, prefs);
service.getPreferences(user).forEach(prefs::set);
});
print("%s", root);
}
use of org.onosproject.ui.UiPreferencesService in project onos by opennetworkinglab.
the class UiPreferencesWebResource method remove.
/**
* Removes the specified user preferences for the given user.
*
* @param user user name
* @param pref preferences name
* @return 204 no content
*/
@DELETE
@Path("{user}/{pref}")
@Produces(MediaType.APPLICATION_JSON)
public Response remove(@PathParam("user") String user, @PathParam("pref") String pref) {
UiPreferencesService service = get(UiPreferencesService.class);
service.setPreference(user, pref, null);
return Response.noContent().build();
}
Aggregations