use of org.libresonic.player.domain.User in project libresonic by Libresonic.
the class PlayQueueController method handleRequestInternal.
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
User user = securityService.getCurrentUser(request);
UserSettings userSettings = settingsService.getUserSettings(user.getUsername());
Player player = playerService.getPlayer(request, response);
Map<String, Object> map = new HashMap<>();
map.put("user", user);
map.put("player", player);
map.put("players", playerService.getPlayersForUserAndClientId(user.getUsername(), null));
map.put("visibility", userSettings.getPlaylistVisibility());
map.put("partyMode", userSettings.isPartyModeEnabled());
map.put("notify", userSettings.isSongNotificationEnabled());
map.put("autoHide", userSettings.isAutoHidePlayQueue());
return new ModelAndView("playQueue", "model", map);
}
use of org.libresonic.player.domain.User in project libresonic by Libresonic.
the class PlaylistsController method doGet.
@RequestMapping(method = RequestMethod.GET)
public String doGet(HttpServletRequest request, Model model) throws Exception {
Map<String, Object> map = new HashMap<>();
User user = securityService.getCurrentUser(request);
List<Playlist> playlists = playlistService.getReadablePlaylistsForUser(user.getUsername());
map.put("playlists", playlists);
model.addAttribute("model", map);
return "playlists";
}
use of org.libresonic.player.domain.User in project libresonic by Libresonic.
the class RESTController method getPlaylists.
@RequestMapping(value = "/rest/getPlaylists", method = { RequestMethod.GET, RequestMethod.POST })
public void getPlaylists(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
User user = securityService.getCurrentUser(request);
String authenticatedUsername = user.getUsername();
String requestedUsername = request.getParameter("username");
if (requestedUsername == null) {
requestedUsername = authenticatedUsername;
} else if (!user.isAdminRole()) {
error(request, response, ErrorCode.NOT_AUTHORIZED, authenticatedUsername + " is not authorized to get playlists for " + requestedUsername);
return;
}
Playlists result = new Playlists();
for (Playlist playlist : playlistService.getReadablePlaylistsForUser(requestedUsername)) {
result.getPlaylist().add(createJaxbPlaylist(new org.libresonic.restapi.Playlist(), playlist));
}
Response res = createResponse();
res.setPlaylists(result);
jaxbWriter.writeResponse(request, response, res);
}
use of org.libresonic.player.domain.User in project libresonic by Libresonic.
the class RESTController method createPodcastChannel.
@RequestMapping(value = "/rest/createPodcastChannel", method = { RequestMethod.GET, RequestMethod.POST })
public void createPodcastChannel(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
User user = securityService.getCurrentUser(request);
if (!user.isPodcastRole()) {
error(request, response, ErrorCode.NOT_AUTHORIZED, user.getUsername() + " is not authorized to administrate podcasts.");
return;
}
String url = getRequiredStringParameter(request, "url");
podcastService.createChannel(url);
writeEmptyResponse(request, response);
}
use of org.libresonic.player.domain.User in project libresonic by Libresonic.
the class RESTController method createUser.
@RequestMapping(value = "/rest/createUser", method = { RequestMethod.GET, RequestMethod.POST })
public void createUser(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
User user = securityService.getCurrentUser(request);
if (!user.isAdminRole()) {
error(request, response, ErrorCode.NOT_AUTHORIZED, user.getUsername() + " is not authorized to create new users.");
return;
}
UserSettingsCommand command = new UserSettingsCommand();
command.setUsername(getRequiredStringParameter(request, "username"));
command.setPassword(decrypt(getRequiredStringParameter(request, "password")));
command.setEmail(getRequiredStringParameter(request, "email"));
command.setLdapAuthenticated(getBooleanParameter(request, "ldapAuthenticated", false));
command.setAdminRole(getBooleanParameter(request, "adminRole", false));
command.setCommentRole(getBooleanParameter(request, "commentRole", false));
command.setCoverArtRole(getBooleanParameter(request, "coverArtRole", false));
command.setDownloadRole(getBooleanParameter(request, "downloadRole", false));
command.setStreamRole(getBooleanParameter(request, "streamRole", true));
command.setUploadRole(getBooleanParameter(request, "uploadRole", false));
command.setJukeboxRole(getBooleanParameter(request, "jukeboxRole", false));
command.setPodcastRole(getBooleanParameter(request, "podcastRole", false));
command.setSettingsRole(getBooleanParameter(request, "settingsRole", true));
command.setShareRole(getBooleanParameter(request, "shareRole", false));
command.setTranscodeSchemeName(TranscodeScheme.OFF.name());
int[] folderIds = ServletRequestUtils.getIntParameters(request, "musicFolderId");
if (folderIds.length == 0) {
folderIds = Util.toIntArray(MusicFolder.toIdList(settingsService.getAllMusicFolders()));
}
command.setAllowedMusicFolderIds(folderIds);
userSettingsController.createUser(command);
writeEmptyResponse(request, response);
}
Aggregations