diff options
Diffstat (limited to 'OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs')
-rw-r--r-- | OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs | 47 |
1 files changed, 7 insertions, 40 deletions
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs index 986394b..0cfe5b1 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs | |||
@@ -42,32 +42,18 @@ using OpenSim.Framework.Servers.HttpServer; | |||
42 | 42 | ||
43 | namespace OpenSim.Server.Handlers.Asset | 43 | namespace OpenSim.Server.Handlers.Asset |
44 | { | 44 | { |
45 | /// <summary> | ||
46 | /// Remote deletes allowed. | ||
47 | /// </summary> | ||
48 | public enum AllowedRemoteDeleteTypes | ||
49 | { | ||
50 | None, | ||
51 | MapTile, | ||
52 | All | ||
53 | } | ||
54 | |||
55 | public class AssetServerDeleteHandler : BaseStreamHandler | 45 | public class AssetServerDeleteHandler : BaseStreamHandler |
56 | { | 46 | { |
57 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
58 | 48 | ||
59 | private IAssetService m_AssetService; | 49 | private IAssetService m_AssetService; |
50 | protected bool m_allowDelete; | ||
60 | 51 | ||
61 | /// <summary> | 52 | public AssetServerDeleteHandler(IAssetService service, bool allowDelete) : |
62 | /// Asset types that can be deleted remotely. | ||
63 | /// </summary> | ||
64 | private AllowedRemoteDeleteTypes m_allowedTypes; | ||
65 | |||
66 | public AssetServerDeleteHandler(IAssetService service, AllowedRemoteDeleteTypes allowedTypes) : | ||
67 | base("DELETE", "/assets") | 53 | base("DELETE", "/assets") |
68 | { | 54 | { |
69 | m_AssetService = service; | 55 | m_AssetService = service; |
70 | m_allowedTypes = allowedTypes; | 56 | m_allowDelete = allowDelete; |
71 | } | 57 | } |
72 | 58 | ||
73 | public override byte[] Handle(string path, Stream request, | 59 | public override byte[] Handle(string path, Stream request, |
@@ -77,32 +63,13 @@ namespace OpenSim.Server.Handlers.Asset | |||
77 | 63 | ||
78 | string[] p = SplitParams(path); | 64 | string[] p = SplitParams(path); |
79 | 65 | ||
80 | if (p.Length > 0) | 66 | if (p.Length > 0 && m_allowDelete) |
81 | { | 67 | { |
82 | if (m_allowedTypes != AllowedRemoteDeleteTypes.None) | 68 | result = m_AssetService.Delete(p[0]); |
83 | { | ||
84 | string assetID = p[0]; | ||
85 | |||
86 | AssetBase asset = m_AssetService.Get(assetID); | ||
87 | if (asset != null) | ||
88 | { | ||
89 | if (m_allowedTypes == AllowedRemoteDeleteTypes.All | ||
90 | || (int)(asset.Flags & AssetFlags.Maptile) != 0) | ||
91 | { | ||
92 | result = m_AssetService.Delete(assetID); | ||
93 | } | ||
94 | else | ||
95 | { | ||
96 | m_log.DebugFormat( | ||
97 | "[ASSET SERVER DELETE HANDLER]: Request to delete asset {0}, but type is {1} and allowed remote delete types are {2}", | ||
98 | assetID, (AssetFlags)asset.Flags, m_allowedTypes); | ||
99 | } | ||
100 | } | ||
101 | } | ||
102 | } | 69 | } |
103 | 70 | ||
104 | XmlSerializer xs = new XmlSerializer(typeof(bool)); | 71 | XmlSerializer xs = new XmlSerializer(typeof(bool)); |
105 | return ServerUtils.SerializeResult(xs, result); | 72 | return ServerUtils.SerializeResult(xs, result); |
106 | } | 73 | } |
107 | } | 74 | } |
108 | } \ No newline at end of file | 75 | } |