diff options
author | Justin Clark-Casey (justincc) | 2012-11-02 01:41:38 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-11-02 01:41:38 +0000 |
commit | ce7beb6f20cb09e19e0f695f445cfa860b9e9c78 (patch) | |
tree | 1904f199f3abebbe756381f1627cb343368e3e31 /OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs | |
parent | Move check to allow only deletion of maptiles up to AssetServerDeleteHandler ... (diff) | |
download | opensim-SC-ce7beb6f20cb09e19e0f695f445cfa860b9e9c78.zip opensim-SC-ce7beb6f20cb09e19e0f695f445cfa860b9e9c78.tar.gz opensim-SC-ce7beb6f20cb09e19e0f695f445cfa860b9e9c78.tar.bz2 opensim-SC-ce7beb6f20cb09e19e0f695f445cfa860b9e9c78.tar.xz |
Add [AssetService] AllowRemoteDeleteAllTypes (default false).
This allows a closed grid to delete asset types other than maptile remotely.
Only operational if AllowRemoteDelete = true also.
Defaults to false - do not enable if anybody other than you can make asset service requests.
Diffstat (limited to 'OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs')
-rw-r--r-- | OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs index 9a8aee6..986394b 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs | |||
@@ -42,18 +42,32 @@ 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 | |||
45 | public class AssetServerDeleteHandler : BaseStreamHandler | 55 | public class AssetServerDeleteHandler : BaseStreamHandler |
46 | { | 56 | { |
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 57 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
48 | 58 | ||
49 | private IAssetService m_AssetService; | 59 | private IAssetService m_AssetService; |
50 | protected bool m_allowDelete; | ||
51 | 60 | ||
52 | public AssetServerDeleteHandler(IAssetService service, bool allowDelete) : | 61 | /// <summary> |
62 | /// Asset types that can be deleted remotely. | ||
63 | /// </summary> | ||
64 | private AllowedRemoteDeleteTypes m_allowedTypes; | ||
65 | |||
66 | public AssetServerDeleteHandler(IAssetService service, AllowedRemoteDeleteTypes allowedTypes) : | ||
53 | base("DELETE", "/assets") | 67 | base("DELETE", "/assets") |
54 | { | 68 | { |
55 | m_AssetService = service; | 69 | m_AssetService = service; |
56 | m_allowDelete = allowDelete; | 70 | m_allowedTypes = allowedTypes; |
57 | } | 71 | } |
58 | 72 | ||
59 | public override byte[] Handle(string path, Stream request, | 73 | public override byte[] Handle(string path, Stream request, |
@@ -63,19 +77,27 @@ namespace OpenSim.Server.Handlers.Asset | |||
63 | 77 | ||
64 | string[] p = SplitParams(path); | 78 | string[] p = SplitParams(path); |
65 | 79 | ||
66 | if (p.Length > 0 && m_allowDelete) | 80 | if (p.Length > 0) |
67 | { | 81 | { |
68 | string assetID = p[0]; | 82 | if (m_allowedTypes != AllowedRemoteDeleteTypes.None) |
69 | |||
70 | AssetBase asset = m_AssetService.Get(assetID); | ||
71 | if (asset != null && (int)(asset.Flags & AssetFlags.Maptile) != 0) | ||
72 | { | ||
73 | result = m_AssetService.Delete(assetID); | ||
74 | } | ||
75 | else | ||
76 | { | 83 | { |
77 | m_log.DebugFormat( | 84 | string assetID = p[0]; |
78 | "[ASSET SERVER DELETE HANDLER]: Request to delete asset {0}, but flags are not Maptile", assetID); | 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 | } | ||
79 | } | 101 | } |
80 | } | 102 | } |
81 | 103 | ||