use of org.onosproject.ui.UiPreferencesService in project onos by opennetworkinglab.
the class UiPreferencesWebResource method download.
/**
* Gets all user preferences.
*
* @return 200 OK with user preferences JSON
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response download() {
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);
});
return ok(root).build();
}
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());
}
Aggregations