use of org.libresonic.player.domain.User in project libresonic by Libresonic.
the class RESTController method deletePodcastChannel.
@RequestMapping(value = "/rest/deletePodcastChannel", method = { RequestMethod.GET, RequestMethod.POST })
public void deletePodcastChannel(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;
}
int id = getRequiredIntParameter(request, "id");
podcastService.deleteChannel(id);
writeEmptyResponse(request, response);
}
use of org.libresonic.player.domain.User in project libresonic by Libresonic.
the class RESTController method getShares.
@RequestMapping(value = "/rest/getShares", method = { RequestMethod.GET, RequestMethod.POST })
public void getShares(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
Player player = playerService.getPlayer(request, response);
String username = securityService.getCurrentUsername(request);
User user = securityService.getCurrentUser(request);
List<MusicFolder> musicFolders = settingsService.getMusicFoldersForUser(username);
Shares result = new Shares();
for (Share share : shareService.getSharesForUser(user)) {
org.libresonic.restapi.Share s = createJaxbShare(request, share);
result.getShare().add(s);
for (MediaFile mediaFile : shareService.getSharedFiles(share.getId(), musicFolders)) {
s.getEntry().add(createJaxbChild(player, mediaFile, username));
}
}
Response res = createResponse();
res.setShares(result);
jaxbWriter.writeResponse(request, response, res);
}
use of org.libresonic.player.domain.User in project libresonic by Libresonic.
the class ShareSettingsController method getShareInfos.
private List<ShareInfo> getShareInfos(HttpServletRequest request) {
List<ShareInfo> result = new ArrayList<ShareInfo>();
User user = securityService.getCurrentUser(request);
List<MusicFolder> musicFolders = settingsService.getMusicFoldersForUser(user.getUsername());
for (Share share : shareService.getSharesForUser(user)) {
List<MediaFile> files = shareService.getSharedFiles(share.getId(), musicFolders);
if (!files.isEmpty()) {
MediaFile file = files.get(0);
result.add(new ShareInfo(shareService.getShareUrl(request, share), share, file.isDirectory() ? file : mediaFileService.getParentOf(file)));
}
}
return result;
}
use of org.libresonic.player.domain.User in project libresonic by Libresonic.
the class RESTController method hls.
@RequestMapping(value = "/rest/hls", method = { RequestMethod.GET, RequestMethod.POST })
public ModelAndView hls(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
User user = securityService.getCurrentUser(request);
if (!user.isStreamRole()) {
error(request, response, ErrorCode.NOT_AUTHORIZED, user.getUsername() + " is not authorized to play files.");
return null;
}
int id = getRequiredIntParameter(request, "id");
MediaFile video = mediaFileDao.getMediaFile(id);
if (video == null || video.isDirectory()) {
error(request, response, ErrorCode.NOT_FOUND, "Video not found.");
return null;
}
if (!securityService.isFolderAccessAllowed(video, user.getUsername())) {
error(request, response, ErrorCode.NOT_AUTHORIZED, "Access denied");
return null;
}
hlsController.handleRequest(request, response);
return null;
}
use of org.libresonic.player.domain.User in project libresonic by Libresonic.
the class RESTController method deleteShare.
@RequestMapping(value = "/rest/deleteShare", method = { RequestMethod.GET, RequestMethod.POST })
public void deleteShare(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
User user = securityService.getCurrentUser(request);
int id = getRequiredIntParameter(request, "id");
Share share = shareService.getShareById(id);
if (share == null) {
error(request, response, ErrorCode.NOT_FOUND, "Shared media not found.");
return;
}
if (!user.isAdminRole() && !share.getUsername().equals(user.getUsername())) {
error(request, response, ErrorCode.NOT_AUTHORIZED, "Not authorized to delete shared media.");
return;
}
shareService.deleteShare(id);
writeEmptyResponse(request, response);
}
Aggregations