use of org.libresonic.player.domain.Share 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.Share 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