123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- using Nini.Config;
- using log4net;
- using System;
- using System.Reflection;
- using System.IO;
- using System.Net;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Xml;
- using System.Xml.Serialization;
- using OpenSim.Server.Base;
- using OpenSim.Services.Interfaces;
- using OpenSim.Framework;
- using OpenSim.Framework.ServiceAuth;
- using OpenSim.Framework.Servers.HttpServer;
- namespace OpenSim.Server.Handlers.Asset
- {
-
-
-
- public enum AllowedRemoteDeleteTypes
- {
- None,
- MapTile,
- All
- }
- public class AssetServerDeleteHandler : BaseStreamHandler
- {
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
- private IAssetService m_AssetService;
-
-
-
- private AllowedRemoteDeleteTypes m_allowedTypes;
- public AssetServerDeleteHandler(IAssetService service, AllowedRemoteDeleteTypes allowedTypes) :
- base("DELETE", "/assets")
- {
- m_AssetService = service;
- m_allowedTypes = allowedTypes;
- }
- public AssetServerDeleteHandler(IAssetService service, AllowedRemoteDeleteTypes allowedTypes, IServiceAuth auth) :
- base("DELETE", "/assets", auth)
- {
- m_AssetService = service;
- m_allowedTypes = allowedTypes;
- }
- protected override byte[] ProcessRequest(string path, Stream request,
- IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
- {
- bool result = false;
- string[] p = SplitParams(path);
- if (p.Length > 0)
- {
- if (m_allowedTypes != AllowedRemoteDeleteTypes.None)
- {
- string assetID = p[0];
- AssetBase asset = m_AssetService.Get(assetID);
- if (asset != null)
- {
- if (m_allowedTypes == AllowedRemoteDeleteTypes.All
- || (int)(asset.Flags & AssetFlags.Maptile) != 0)
- {
- result = m_AssetService.Delete(assetID);
- }
- else
- {
- m_log.DebugFormat(
- "[ASSET SERVER DELETE HANDLER]: Request to delete asset {0}, but type is {1} and allowed remote delete types are {2}",
- assetID, (AssetFlags)asset.Flags, m_allowedTypes);
- }
- }
- }
- }
- XmlSerializer xs = new XmlSerializer(typeof(bool));
- return ServerUtils.SerializeResult(xs, result);
- }
- }
- }
|