diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/RESTController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/RESTController.java index a61b7fb7..7b0dbec4 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/RESTController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/RESTController.java @@ -19,124 +19,46 @@ */ package org.libresonic.player.controller; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.SortedMap; -import java.util.SortedSet; -import java.util.TreeSet; -import java.util.concurrent.ConcurrentHashMap; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletRequestWrapper; -import javax.servlet.http.HttpServletResponse; - import org.apache.commons.lang.StringUtils; -import org.springframework.web.bind.ServletRequestUtils; -import org.springframework.web.servlet.ModelAndView; -import org.springframework.web.servlet.mvc.multiaction.MultiActionController; -import org.libresonic.restapi.AlbumID3; -import org.libresonic.restapi.AlbumList; -import org.libresonic.restapi.AlbumList2; -import org.libresonic.restapi.AlbumWithSongsID3; -import org.libresonic.restapi.ArtistID3; -import org.libresonic.restapi.ArtistInfo; -import org.libresonic.restapi.ArtistInfo2; -import org.libresonic.restapi.ArtistWithAlbumsID3; -import org.libresonic.restapi.ArtistsID3; -import org.libresonic.restapi.Bookmarks; -import org.libresonic.restapi.ChatMessage; -import org.libresonic.restapi.ChatMessages; -import org.libresonic.restapi.Child; -import org.libresonic.restapi.Directory; -import org.libresonic.restapi.Genres; -import org.libresonic.restapi.Index; -import org.libresonic.restapi.IndexID3; -import org.libresonic.restapi.Indexes; -import org.libresonic.restapi.InternetRadioStation; -import org.libresonic.restapi.InternetRadioStations; -import org.libresonic.restapi.JukeboxPlaylist; -import org.libresonic.restapi.JukeboxStatus; -import org.libresonic.restapi.Lyrics; -import org.libresonic.restapi.MediaType; -import org.libresonic.restapi.MusicFolders; -import org.libresonic.restapi.NewestPodcasts; -import org.libresonic.restapi.NowPlaying; -import org.libresonic.restapi.NowPlayingEntry; -import org.libresonic.restapi.PlaylistWithSongs; -import org.libresonic.restapi.Playlists; -import org.libresonic.restapi.PodcastStatus; -import org.libresonic.restapi.Podcasts; -import org.libresonic.restapi.Response; -import org.libresonic.restapi.SearchResult2; -import org.libresonic.restapi.SearchResult3; -import org.libresonic.restapi.Shares; -import org.libresonic.restapi.SimilarSongs; -import org.libresonic.restapi.SimilarSongs2; -import org.libresonic.restapi.Songs; -import org.libresonic.restapi.Starred; -import org.libresonic.restapi.Starred2; -import org.libresonic.restapi.TopSongs; -import org.libresonic.restapi.Users; -import org.libresonic.restapi.Videos; - import org.libresonic.player.Logger; import org.libresonic.player.ajax.ChatService; import org.libresonic.player.ajax.LyricsInfo; import org.libresonic.player.ajax.LyricsService; import org.libresonic.player.ajax.PlayQueueService; import org.libresonic.player.command.UserSettingsCommand; -import org.libresonic.player.dao.AlbumDao; -import org.libresonic.player.dao.ArtistDao; -import org.libresonic.player.dao.BookmarkDao; -import org.libresonic.player.dao.MediaFileDao; -import org.libresonic.player.dao.PlayQueueDao; -import org.libresonic.player.domain.Album; +import org.libresonic.player.dao.*; +import org.libresonic.player.domain.*; import org.libresonic.player.domain.Artist; -import org.libresonic.player.domain.ArtistBio; import org.libresonic.player.domain.Bookmark; import org.libresonic.player.domain.Genre; -import org.libresonic.player.domain.InternetRadio; -import org.libresonic.player.domain.MediaFile; import org.libresonic.player.domain.MusicFolder; -import org.libresonic.player.domain.MusicFolderContent; -import org.libresonic.player.domain.MusicIndex; import org.libresonic.player.domain.PlayQueue; -import org.libresonic.player.domain.PlayStatus; -import org.libresonic.player.domain.Player; -import org.libresonic.player.domain.PlayerTechnology; import org.libresonic.player.domain.Playlist; import org.libresonic.player.domain.PodcastChannel; import org.libresonic.player.domain.PodcastEpisode; -import org.libresonic.player.domain.RandomSearchCriteria; -import org.libresonic.player.domain.SavedPlayQueue; -import org.libresonic.player.domain.SearchCriteria; import org.libresonic.player.domain.SearchResult; import org.libresonic.player.domain.Share; -import org.libresonic.player.domain.TranscodeScheme; import org.libresonic.player.domain.User; -import org.libresonic.player.domain.UserSettings; -import org.libresonic.player.service.AudioScrobblerService; -import org.libresonic.player.service.JukeboxService; -import org.libresonic.player.service.LastFmService; -import org.libresonic.player.service.MediaFileService; -import org.libresonic.player.service.MusicIndexService; -import org.libresonic.player.service.PlayerService; -import org.libresonic.player.service.PlaylistService; -import org.libresonic.player.service.PodcastService; -import org.libresonic.player.service.RatingService; -import org.libresonic.player.service.SearchService; -import org.libresonic.player.service.SecurityService; -import org.libresonic.player.service.SettingsService; -import org.libresonic.player.service.ShareService; -import org.libresonic.player.service.StatusService; -import org.libresonic.player.service.TranscodingService; +import org.libresonic.player.service.*; import org.libresonic.player.util.Pair; import org.libresonic.player.util.StringUtil; import org.libresonic.player.util.Util; +import org.libresonic.restapi.*; +import org.libresonic.restapi.Genres; +import org.libresonic.restapi.PodcastStatus; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.ServletRequestUtils; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.servlet.ModelAndView; + +import javax.annotation.PostConstruct; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequestWrapper; +import javax.servlet.http.HttpServletResponse; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; import static org.libresonic.player.security.RESTRequestParameterProcessingFilter.decrypt; import static org.springframework.web.bind.ServletRequestUtils.*; @@ -150,44 +72,76 @@ import static org.springframework.web.bind.ServletRequestUtils.*; * * @author Sindre Mehus */ -public class RESTController extends MultiActionController { +@Controller +public class RESTController { private static final Logger LOG = Logger.getLogger(RESTController.class); + @Autowired private SettingsService settingsService; + @Autowired private SecurityService securityService; + @Autowired private PlayerService playerService; + @Autowired private MediaFileService mediaFileService; + @Autowired private LastFmService lastFmService; + @Autowired private MusicIndexService musicIndexService; + @Autowired private TranscodingService transcodingService; + @Autowired private DownloadController downloadController; + @Autowired private CoverArtController coverArtController; + @Autowired private AvatarController avatarController; + @Autowired private UserSettingsController userSettingsController; + @Autowired private LeftController leftController; + @Autowired private StatusService statusService; + @Autowired private StreamController streamController; + @Autowired private HLSController hlsController; + @Autowired private ShareService shareService; + @Autowired private PlaylistService playlistService; + @Autowired private ChatService chatService; + @Autowired private LyricsService lyricsService; + @Autowired private PlayQueueService playQueueService; + @Autowired private JukeboxService jukeboxService; + @Autowired private AudioScrobblerService audioScrobblerService; + @Autowired private PodcastService podcastService; + @Autowired private RatingService ratingService; + @Autowired private SearchService searchService; + @Autowired private MediaFileDao mediaFileDao; + @Autowired private ArtistDao artistDao; + @Autowired private AlbumDao albumDao; + @Autowired private BookmarkDao bookmarkDao; + @Autowired private PlayQueueDao playQueueDao; private final Map bookmarkCache = new ConcurrentHashMap(); private final JAXBWriter jaxbWriter = new JAXBWriter(); + @PostConstruct public void init() { refreshBookmarkCache(); } @@ -199,7 +153,7 @@ public class RESTController extends MultiActionController { } } - @SuppressWarnings("UnusedDeclaration") + @RequestMapping(value = "/rest/ping", method = RequestMethod.GET) public void ping(HttpServletRequest request, HttpServletResponse response) throws Exception { Response res = createResponse(); jaxbWriter.writeResponse(request, response, res); @@ -1066,7 +1020,7 @@ public class RESTController extends MultiActionController { writeEmptyResponse(request, response); } - @SuppressWarnings("UnusedDeclaration") + @RequestMapping(value = "/rest/getAlbumList", method = RequestMethod.GET) public void getAlbumList(HttpServletRequest request, HttpServletResponse response) throws Exception { request = wrapRequest(request); Player player = playerService.getPlayer(request, response); @@ -2342,125 +2296,6 @@ public class RESTController extends MultiActionController { return !players.isEmpty() ? players.get(0).getId() : null; } - public void setSettingsService(SettingsService settingsService) { - this.settingsService = settingsService; - } - - public void setSecurityService(SecurityService securityService) { - this.securityService = securityService; - } - - public void setPlayerService(PlayerService playerService) { - this.playerService = playerService; - } - - public void setTranscodingService(TranscodingService transcodingService) { - this.transcodingService = transcodingService; - } - - public void setDownloadController(DownloadController downloadController) { - this.downloadController = downloadController; - } - - public void setCoverArtController(CoverArtController coverArtController) { - this.coverArtController = coverArtController; - } - - public void setUserSettingsController(UserSettingsController userSettingsController) { - this.userSettingsController = userSettingsController; - } - - public void setLeftController(LeftController leftController) { - this.leftController = leftController; - } - - public void setStatusService(StatusService statusService) { - this.statusService = statusService; - } - - public void setPlaylistService(PlaylistService playlistService) { - this.playlistService = playlistService; - } - - public void setStreamController(StreamController streamController) { - this.streamController = streamController; - } - - public void setHlsController(HLSController hlsController) { - this.hlsController = hlsController; - } - - public void setChatService(ChatService chatService) { - this.chatService = chatService; - } - - public void setLyricsService(LyricsService lyricsService) { - this.lyricsService = lyricsService; - } - - public void setPlayQueueService(PlayQueueService playQueueService) { - this.playQueueService = playQueueService; - } - - public void setJukeboxService(JukeboxService jukeboxService) { - this.jukeboxService = jukeboxService; - } - - public void setAudioScrobblerService(AudioScrobblerService audioScrobblerService) { - this.audioScrobblerService = audioScrobblerService; - } - - public void setPodcastService(PodcastService podcastService) { - this.podcastService = podcastService; - } - - public void setRatingService(RatingService ratingService) { - this.ratingService = ratingService; - } - - public void setSearchService(SearchService searchService) { - this.searchService = searchService; - } - - public void setShareService(ShareService shareService) { - this.shareService = shareService; - } - - public void setMediaFileService(MediaFileService mediaFileService) { - this.mediaFileService = mediaFileService; - } - - public void setAvatarController(AvatarController avatarController) { - this.avatarController = avatarController; - } - - public void setArtistDao(ArtistDao artistDao) { - this.artistDao = artistDao; - } - - public void setAlbumDao(AlbumDao albumDao) { - this.albumDao = albumDao; - } - - public void setMediaFileDao(MediaFileDao mediaFileDao) { - this.mediaFileDao = mediaFileDao; - } - - public void setMusicIndexService(MusicIndexService musicIndexService) { - this.musicIndexService = musicIndexService; - } - - public void setBookmarkDao(BookmarkDao bookmarkDao) { - this.bookmarkDao = bookmarkDao; - } - - public void setLastFmService(LastFmService lastFmService) { - this.lastFmService = lastFmService; - } - - public void setPlayQueueDao(PlayQueueDao playQueueDao) { - this.playQueueDao = playQueueDao; - } public enum ErrorCode { diff --git a/libresonic-main/src/main/resources/applicationContext-security.xml b/libresonic-main/src/main/resources/applicationContext-security.xml index d7850d46..7831aa7b 100644 --- a/libresonic-main/src/main/resources/applicationContext-security.xml +++ b/libresonic-main/src/main/resources/applicationContext-security.xml @@ -24,6 +24,7 @@ + diff --git a/libresonic-main/src/main/resources/libresonic-servlet.xml b/libresonic-main/src/main/resources/libresonic-servlet.xml index 1de4c524..8576ae81 100644 --- a/libresonic-main/src/main/resources/libresonic-servlet.xml +++ b/libresonic-main/src/main/resources/libresonic-servlet.xml @@ -26,38 +26,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -66,7 +34,6 @@ podcastController downloadController wapController - restController diff --git a/libresonic-main/src/test/resources/libresonic-rest-api-soapui-project.xml b/libresonic-main/src/test/resources/libresonic-rest-api-soapui-project.xml new file mode 100755 index 00000000..8bb18c1a --- /dev/null +++ b/libresonic-main/src/test/resources/libresonic-rest-api-soapui-project.xml @@ -0,0 +1,19 @@ + +http://localhost:8080/uadminQUERYadminpadminQUERYadminv1.12.0QUERY1.12.0csoapuiQUERYsoapuiuadminQUERYadminpadminQUERYadminv1.13.0QUERY1.13.0csoapuiQUERYsoapuitext/xml; charset=utf-8200res:subsonic-responsetext/html; charset=iso-8859-1404html0data0data0data0datatext/html;charset=utf-8200htmltext/xml;charset=UTF-8200res:subsonic-response<xml-fragment/>http://localhost:8080/http://localhost/rest/ping.viewNo AuthorizationujoeQUERYjoepsesameQUERYsesamev1.12.0QUERY1.12.0cmyappQUERYmyapptext/xml; charset=utf-8200res:subsonic-responsetext/html; charset=iso-8859-1404html0data0data0data0data<xml-fragment/>http://192.168.0.11:4040http://192.168.0.11/rest/ping.viewNo Authorization + + +upvcujoeQUERYjoepsesameQUERYsesamev1.12.0QUERY1.12.0cmyappQUERYmyappincludeEpisodesQUERYuremiQUERYremipMozart*1QUERYMozart*1v1.2.0QUERY1.2.0cmyappQUERYmyappincludeEpisodesfalseQUERYfalsetext/xml; charset=utf-8200res:subsonic-responsetext/html; charset=iso-8859-1404html0data<xml-fragment/>http://192.168.0.11:4040http://192.168.0.11/rest/ping.viewNo Authorization + + + +upvcincludeEpisodesuremiQUERYremipMozart*1QUERYMozart*1v1.2.0QUERY1.2.0cmyappQUERYmyappincludeEpisodestrueQUERYtrueidQUERYtext/xml; charset=utf-8200res:subsonic-response<xml-fragment/>http://192.168.0.11:4040http://192.168.0.11/rest/getPodcasts.viewNo Authorization<xml-fragment/>http://192.168.0.11:4040http://192.168.0.11/rest/getPodcasts.viewNo AuthorizationuadminQUERYadminpadminQUERYadminv1.13.0QUERY1.13.0csoapuiQUERYsoapuitypeQUERYsizeQUERYoffsetQUERYfromYearQUERYtoYearQUERYgenreQUERYmusicFolderIdQUERYapplication/json;charset=UTF-8500get:Fault<xml-fragment/>http://localhost:8080/http://localhost/rest/getAlbumList.viewNo Authorization + + +uremiQUERYremipMozart*1QUERYMozart*1v1.2.0QUERY1.2.0csoapuiQUERYsoapuisizeQUERYgenreQUERYfromYearQUERYtoYearQUERYmusicFolderIdQUERYuremiQUERYremipMozart*1QUERYMozart*1v1.2.0QUERY1.2.0cmyappQUERYmyapptypeQUERYsizeQUERYoffsetQUERYfromYearQUERYtoYearQUERYgenreQUERYmusicFolderIdQUERYtext/xml; charset=utf-8200res:subsonic-response0data<xml-fragment/>http://192.168.0.11:4040http://192.168.0.11/rest/getAlbumList.viewNo Authorization + + +upvctypesizeoffsetfromYeartoYeargenremusicFolderIduremiQUERYremipMozart*1QUERYMozart*1v1.2.0QUERY1.2.0csoapuiQUERYsoapuiidQUERYtext/xml; charset=utf-8200res:subsonic-response<xml-fragment/>http://192.168.0.11:4040http://192.168.0.11/rest/getAlbum.viewNo AuthorizationujoeQUERYjoepsesameQUERYsesamev1.12.0QUERY1.12.0cmyappQUERYmyappgenreQUERYcountQUERYoffsetQUERYmusicFolderIdQUERYtext/xml; charset=utf-8200res:subsonic-response0data0data0data0data0datatext/html; charset=iso-8859-1503html0data0data0data0data<xml-fragment/>http://localhost:8080/testResthttp://192.168.0.11/rest/getSongsByGenre.viewNo Authorization + + + +http://localhost:8080/ \ No newline at end of file