2012-07-16 16:50:44 +00:00
|
|
|
|
using System;
|
|
|
|
|
using MediaBrowser.Api.Model;
|
|
|
|
|
using MediaBrowser.Common.Net;
|
2012-07-13 03:50:50 +00:00
|
|
|
|
using MediaBrowser.Common.Net.Handlers;
|
2012-07-16 16:50:44 +00:00
|
|
|
|
using MediaBrowser.Controller;
|
2012-07-12 06:55:27 +00:00
|
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Api.HttpHandlers
|
|
|
|
|
{
|
2012-07-13 03:50:50 +00:00
|
|
|
|
public class ItemHandler : JsonHandler
|
2012-07-12 06:55:27 +00:00
|
|
|
|
{
|
|
|
|
|
public ItemHandler(RequestContext ctx)
|
|
|
|
|
: base(ctx)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-13 03:50:50 +00:00
|
|
|
|
protected sealed override object ObjectToSerialize
|
2012-07-12 06:55:27 +00:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2012-07-16 16:50:44 +00:00
|
|
|
|
Guid userId = Guid.Parse(QueryString["userid"]);
|
|
|
|
|
|
|
|
|
|
return GetSerializationObject(ItemToSerialize, true, userId);
|
2012-07-12 06:55:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-16 16:50:44 +00:00
|
|
|
|
public static object GetSerializationObject(BaseItem item, bool includeChildren, Guid userId)
|
2012-07-12 06:55:27 +00:00
|
|
|
|
{
|
2012-07-16 16:50:44 +00:00
|
|
|
|
BaseItemInfo wrapper = new BaseItemInfo()
|
2012-07-12 06:55:27 +00:00
|
|
|
|
{
|
2012-07-16 16:50:44 +00:00
|
|
|
|
Item = item,
|
|
|
|
|
UserItemData = Kernel.Instance.GetUserItemData(userId, item.Id)
|
|
|
|
|
};
|
2012-07-15 20:27:07 +00:00
|
|
|
|
|
2012-07-16 16:50:44 +00:00
|
|
|
|
if (includeChildren)
|
2012-07-12 06:55:27 +00:00
|
|
|
|
{
|
2012-07-16 16:50:44 +00:00
|
|
|
|
var folder = item as Folder;
|
|
|
|
|
|
|
|
|
|
if (folder != null)
|
|
|
|
|
{
|
|
|
|
|
wrapper.Children = Kernel.Instance.GetParentalAllowedChildren(folder, userId);
|
|
|
|
|
}
|
2012-07-12 06:55:27 +00:00
|
|
|
|
}
|
2012-07-16 16:50:44 +00:00
|
|
|
|
|
|
|
|
|
return wrapper;
|
2012-07-12 06:55:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-07-13 03:50:50 +00:00
|
|
|
|
protected virtual BaseItem ItemToSerialize
|
2012-07-12 06:55:27 +00:00
|
|
|
|
{
|
2012-07-13 03:50:50 +00:00
|
|
|
|
get
|
2012-07-12 06:55:27 +00:00
|
|
|
|
{
|
2012-07-13 03:50:50 +00:00
|
|
|
|
return ApiService.GetItemById(QueryString["id"]);
|
2012-07-12 06:55:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|