Merge pull request #131 from lukeIam/develop
Fixed: Bad request on some playlist operations
This commit is contained in:
commit
f24acd7372
4 files changed
+149
-11
No files matched your search
+114
-9
@@ -376,48 +376,153 @@ namespace ServerLib
|
|||||||
|
|
||||||
public SPlaylistData GetPlaylist(int playlistId)
|
public SPlaylistData GetPlaylist(int playlistId)
|
||||||
{
|
{
|
||||||
return CServer.GetPlaylist(playlistId);
|
try
|
||||||
|
{
|
||||||
|
return CServer.GetPlaylist(playlistId);
|
||||||
|
}
|
||||||
|
catch (ArgumentException e)
|
||||||
|
{
|
||||||
|
if (WebOperationContext.Current != null)
|
||||||
|
{
|
||||||
|
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden;
|
||||||
|
WebOperationContext.Current.OutgoingResponse.StatusDescription = e.Message;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new SPlaylistData();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddSongToPlaylist(int songId, int playlistId, bool allowDuplicates)
|
public void AddSongToPlaylist(int songId, int playlistId, bool allowDuplicates)
|
||||||
{
|
{
|
||||||
if (_CheckRight(EUserRights.AddSongToPlaylist))
|
if (!_CheckRight(EUserRights.AddSongToPlaylist))
|
||||||
|
return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
CServer.AddSongToPlaylist(songId, playlistId, allowDuplicates);
|
CServer.AddSongToPlaylist(songId, playlistId, allowDuplicates);
|
||||||
|
}
|
||||||
|
catch (ArgumentException e)
|
||||||
|
{
|
||||||
|
if (WebOperationContext.Current != null)
|
||||||
|
{
|
||||||
|
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden;
|
||||||
|
WebOperationContext.Current.OutgoingResponse.StatusDescription = e.Message;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveSongFromPlaylist(int position, int playlistId, int songId)
|
public void RemoveSongFromPlaylist(int position, int playlistId, int songId)
|
||||||
{
|
{
|
||||||
if (_CheckRight(EUserRights.RemoveSongsFromPlaylists))
|
if (!_CheckRight(EUserRights.RemoveSongsFromPlaylists))
|
||||||
|
return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
CServer.RemoveSongFromPlaylist(position, playlistId, songId);
|
CServer.RemoveSongFromPlaylist(position, playlistId, songId);
|
||||||
|
}
|
||||||
|
catch (ArgumentException e)
|
||||||
|
{
|
||||||
|
if (WebOperationContext.Current != null)
|
||||||
|
{
|
||||||
|
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden;
|
||||||
|
WebOperationContext.Current.OutgoingResponse.StatusDescription = e.Message;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveSongInPlaylist(int newPosition, int playlistId, int songId)
|
public void MoveSongInPlaylist(int newPosition, int playlistId, int songId)
|
||||||
{
|
{
|
||||||
if (_CheckRight(EUserRights.ReorderPlaylists))
|
if (!_CheckRight(EUserRights.ReorderPlaylists))
|
||||||
|
return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
CServer.MoveSongInPlaylist(newPosition, playlistId, songId);
|
CServer.MoveSongInPlaylist(newPosition, playlistId, songId);
|
||||||
|
}
|
||||||
|
catch (ArgumentException e)
|
||||||
|
{
|
||||||
|
if (WebOperationContext.Current != null)
|
||||||
|
{
|
||||||
|
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden;
|
||||||
|
WebOperationContext.Current.OutgoingResponse.StatusDescription = e.Message;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool PlaylistContainsSong(int songId, int playlistId)
|
public bool PlaylistContainsSong(int songId, int playlistId)
|
||||||
{
|
{
|
||||||
return CServer.PlaylistContainsSong(songId, playlistId);
|
try
|
||||||
|
{
|
||||||
|
return CServer.PlaylistContainsSong(songId, playlistId);
|
||||||
|
}
|
||||||
|
catch (ArgumentException e)
|
||||||
|
{
|
||||||
|
if (WebOperationContext.Current != null)
|
||||||
|
{
|
||||||
|
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden;
|
||||||
|
WebOperationContext.Current.OutgoingResponse.StatusDescription = e.Message;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SPlaylistSongInfo[] GetPlaylistSongs(int playlistId)
|
public SPlaylistSongInfo[] GetPlaylistSongs(int playlistId)
|
||||||
{
|
{
|
||||||
return CServer.GetPlaylistSongs(playlistId);
|
try
|
||||||
|
{
|
||||||
|
return CServer.GetPlaylistSongs(playlistId);
|
||||||
|
}
|
||||||
|
catch (ArgumentException e)
|
||||||
|
{
|
||||||
|
if (WebOperationContext.Current != null)
|
||||||
|
{
|
||||||
|
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden;
|
||||||
|
WebOperationContext.Current.OutgoingResponse.StatusDescription = e.Message;
|
||||||
|
}
|
||||||
|
return new SPlaylistSongInfo[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemovePlaylist(int playlistId)
|
public void RemovePlaylist(int playlistId)
|
||||||
{
|
{
|
||||||
if (_CheckRight(EUserRights.DeletePlaylists))
|
if (!_CheckRight(EUserRights.DeletePlaylists))
|
||||||
|
return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
CServer.RemovePlaylist(playlistId);
|
CServer.RemovePlaylist(playlistId);
|
||||||
|
}
|
||||||
|
catch (ArgumentException e)
|
||||||
|
{
|
||||||
|
if (WebOperationContext.Current != null)
|
||||||
|
{
|
||||||
|
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden;
|
||||||
|
WebOperationContext.Current.OutgoingResponse.StatusDescription = e.Message;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int AddPlaylist(string playlistName)
|
public int AddPlaylist(string playlistName)
|
||||||
{
|
{
|
||||||
if (_CheckRight(EUserRights.CreatePlaylists))
|
if (!_CheckRight(EUserRights.CreatePlaylists))
|
||||||
return CServer.AddPlaylist(playlistName);
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return CServer.AddPlaylist(playlistName);
|
||||||
|
}
|
||||||
|
catch (ArgumentException e)
|
||||||
|
{
|
||||||
|
if (WebOperationContext.Current != null)
|
||||||
|
{
|
||||||
|
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Forbidden;
|
||||||
|
WebOperationContext.Current.OutgoingResponse.StatusDescription = e.Message;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace Vocaluxe.Lib.Playlist
|
|||||||
|
|
||||||
public void Save()
|
public void Save()
|
||||||
{
|
{
|
||||||
if (File == "")
|
if (string.IsNullOrEmpty(File))
|
||||||
{
|
{
|
||||||
string filename = string.Empty;
|
string filename = string.Empty;
|
||||||
// ReSharper disable LoopCanBeConvertedToQuery
|
// ReSharper disable LoopCanBeConvertedToQuery
|
||||||
|
|||||||
@@ -46,6 +46,10 @@
|
|||||||
data.timeout = 10000; //10 sec. timeout
|
data.timeout = 10000; //10 sec. timeout
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((typeof data.type) == "undefined") {
|
||||||
|
data.type = "GET";
|
||||||
|
}
|
||||||
|
|
||||||
if (message != "noOverlay") {
|
if (message != "noOverlay") {
|
||||||
var message2 = message;
|
var message2 = message;
|
||||||
if (i18n.t) {
|
if (i18n.t) {
|
||||||
@@ -585,6 +589,7 @@
|
|||||||
url: "sendPhoto",
|
url: "sendPhoto",
|
||||||
contentType: "application/json;charset=utf-8",
|
contentType: "application/json;charset=utf-8",
|
||||||
type: "POST",
|
type: "POST",
|
||||||
|
timeout: 40000,
|
||||||
data: JSON.stringify({ Photo: { base64Data: imgData } })
|
data: JSON.stringify({ Photo: { base64Data: imgData } })
|
||||||
}, 'Uploading photo...');
|
}, 'Uploading photo...');
|
||||||
}
|
}
|
||||||
@@ -1226,7 +1231,7 @@
|
|||||||
if (name != null
|
if (name != null
|
||||||
&& name.replace(" ", "") != ""
|
&& name.replace(" ", "") != ""
|
||||||
&& $('h2').filter(function () { return this.textContent == name; }).length == 0) {
|
&& $('h2').filter(function () { return this.textContent == name; }).length == 0) {
|
||||||
request({ url: "addPlaylist?playlistName=" + name }, "Creating...").done(function () {
|
request({ url: "addPlaylist?playlistName=" + name, dataType: "json" }, "Creating...").done(function () {
|
||||||
request({
|
request({
|
||||||
url: "getPlaylists"
|
url: "getPlaylists"
|
||||||
}).done(function (data2) {
|
}).done(function (data2) {
|
||||||
|
|||||||
@@ -3,4 +3,32 @@
|
|||||||
<startup>
|
<startup>
|
||||||
|
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
|
||||||
|
<!-- Enable for WCF tracing
|
||||||
|
<system.serviceModel>
|
||||||
|
<diagnostics>
|
||||||
|
<messageLogging logEntireMessage="true" logMalformedMessages="true"
|
||||||
|
logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxMessagesToLog="3000" />
|
||||||
|
</diagnostics>
|
||||||
|
</system.serviceModel>
|
||||||
|
<system.diagnostics>
|
||||||
|
<sources>
|
||||||
|
<source name="System.ServiceModel" switchValue="Information,ActivityTracing"
|
||||||
|
propagateActivity="true">
|
||||||
|
<listeners>
|
||||||
|
<add name="xml" />
|
||||||
|
</listeners>
|
||||||
|
</source>
|
||||||
|
<source name="System.ServiceModel.MessageLogging">
|
||||||
|
<listeners>
|
||||||
|
<add name="xml" />
|
||||||
|
</listeners>
|
||||||
|
</source>
|
||||||
|
</sources>
|
||||||
|
<sharedListeners>
|
||||||
|
<add initializeData="C:\temp\TracingAndLogging-service.svclog" type="System.Diagnostics.XmlWriterTraceListener"
|
||||||
|
name="xml" />
|
||||||
|
</sharedListeners>
|
||||||
|
<trace autoflush="true" />
|
||||||
|
</system.diagnostics>
|
||||||
|
-->
|
||||||
</configuration>
|
</configuration>
|
||||||
Reference in new issue
Block a user