diff options
Diffstat (limited to 'OpenSim/Server/Handlers')
3 files changed, 77 insertions, 8 deletions
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs index 46b0c67..ff45d94 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs | |||
@@ -67,10 +67,25 @@ namespace OpenSim.Server.Handlers.Asset | |||
67 | throw new Exception(String.Format("Failed to load AssetService from {0}; config is {1}", assetService, m_ConfigName)); | 67 | throw new Exception(String.Format("Failed to load AssetService from {0}; config is {1}", assetService, m_ConfigName)); |
68 | 68 | ||
69 | bool allowDelete = serverConfig.GetBoolean("AllowRemoteDelete", false); | 69 | bool allowDelete = serverConfig.GetBoolean("AllowRemoteDelete", false); |
70 | bool allowDeleteAllTypes = serverConfig.GetBoolean("AllowRemoteDeleteAllTypes", false); | ||
71 | |||
72 | AllowedRemoteDeleteTypes allowedRemoteDeleteTypes; | ||
73 | |||
74 | if (!allowDelete) | ||
75 | { | ||
76 | allowedRemoteDeleteTypes = AllowedRemoteDeleteTypes.None; | ||
77 | } | ||
78 | else | ||
79 | { | ||
80 | if (allowDeleteAllTypes) | ||
81 | allowedRemoteDeleteTypes = AllowedRemoteDeleteTypes.All; | ||
82 | else | ||
83 | allowedRemoteDeleteTypes = AllowedRemoteDeleteTypes.MapTile; | ||
84 | } | ||
70 | 85 | ||
71 | server.AddStreamHandler(new AssetServerGetHandler(m_AssetService)); | 86 | server.AddStreamHandler(new AssetServerGetHandler(m_AssetService)); |
72 | server.AddStreamHandler(new AssetServerPostHandler(m_AssetService)); | 87 | server.AddStreamHandler(new AssetServerPostHandler(m_AssetService)); |
73 | server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowDelete)); | 88 | server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowedRemoteDeleteTypes)); |
74 | 89 | ||
75 | MainConsole.Instance.Commands.AddCommand("Assets", false, | 90 | MainConsole.Instance.Commands.AddCommand("Assets", false, |
76 | "show asset", | 91 | "show asset", |
@@ -141,6 +156,9 @@ namespace OpenSim.Server.Handlers.Asset | |||
141 | } | 156 | } |
142 | 157 | ||
143 | string fileName = rawAssetId; | 158 | string fileName = rawAssetId; |
159 | |||
160 | if (!ConsoleUtil.CheckFileDoesNotExist(MainConsole.Instance, fileName)) | ||
161 | return; | ||
144 | 162 | ||
145 | using (FileStream fs = new FileStream(fileName, FileMode.CreateNew)) | 163 | using (FileStream fs = new FileStream(fileName, FileMode.CreateNew)) |
146 | { | 164 | { |
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs index 0cfe5b1..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,13 +77,32 @@ 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 | result = m_AssetService.Delete(p[0]); | 82 | if (m_allowedTypes != AllowedRemoteDeleteTypes.None) |
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 | } | ||
69 | } | 102 | } |
70 | 103 | ||
71 | XmlSerializer xs = new XmlSerializer(typeof(bool)); | 104 | XmlSerializer xs = new XmlSerializer(typeof(bool)); |
72 | return ServerUtils.SerializeResult(xs, result); | 105 | return ServerUtils.SerializeResult(xs, result); |
73 | } | 106 | } |
74 | } | 107 | } |
75 | } | 108 | } \ No newline at end of file |
diff --git a/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs b/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs index 393584e..8cd747e 100644 --- a/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs | |||
@@ -137,6 +137,8 @@ namespace OpenSim.Server.Handlers.Avatar | |||
137 | if (!UUID.TryParse(request["UserID"].ToString(), out user)) | 137 | if (!UUID.TryParse(request["UserID"].ToString(), out user)) |
138 | return FailureResult(); | 138 | return FailureResult(); |
139 | 139 | ||
140 | RemoveRequestParamsNotForStorage(request); | ||
141 | |||
140 | AvatarData avatar = new AvatarData(request); | 142 | AvatarData avatar = new AvatarData(request); |
141 | if (m_AvatarService.SetAvatar(user, avatar)) | 143 | if (m_AvatarService.SetAvatar(user, avatar)) |
142 | return SuccessResult(); | 144 | return SuccessResult(); |
@@ -153,11 +155,25 @@ namespace OpenSim.Server.Handlers.Avatar | |||
153 | if (!UUID.TryParse(request["UserID"].ToString(), out user)) | 155 | if (!UUID.TryParse(request["UserID"].ToString(), out user)) |
154 | return FailureResult(); | 156 | return FailureResult(); |
155 | 157 | ||
158 | RemoveRequestParamsNotForStorage(request); | ||
159 | |||
156 | if (m_AvatarService.ResetAvatar(user)) | 160 | if (m_AvatarService.ResetAvatar(user)) |
157 | return SuccessResult(); | 161 | return SuccessResult(); |
158 | 162 | ||
159 | return FailureResult(); | 163 | return FailureResult(); |
160 | } | 164 | } |
165 | |||
166 | /// <summary> | ||
167 | /// Remove parameters that were used to invoke the method and should not in themselves be persisted. | ||
168 | /// </summary> | ||
169 | /// <param name='request'></param> | ||
170 | private void RemoveRequestParamsNotForStorage(Dictionary<string, object> request) | ||
171 | { | ||
172 | request.Remove("VERSIONMAX"); | ||
173 | request.Remove("VERSIONMIN"); | ||
174 | request.Remove("METHOD"); | ||
175 | request.Remove("UserID"); | ||
176 | } | ||
161 | 177 | ||
162 | byte[] SetItems(Dictionary<string, object> request) | 178 | byte[] SetItems(Dictionary<string, object> request) |
163 | { | 179 | { |
@@ -173,6 +189,8 @@ namespace OpenSim.Server.Handlers.Avatar | |||
173 | if (!(request["Names"] is List<string> || request["Values"] is List<string>)) | 189 | if (!(request["Names"] is List<string> || request["Values"] is List<string>)) |
174 | return FailureResult(); | 190 | return FailureResult(); |
175 | 191 | ||
192 | RemoveRequestParamsNotForStorage(request); | ||
193 | |||
176 | List<string> _names = (List<string>)request["Names"]; | 194 | List<string> _names = (List<string>)request["Names"]; |
177 | names = _names.ToArray(); | 195 | names = _names.ToArray(); |
178 | List<string> _values = (List<string>)request["Values"]; | 196 | List<string> _values = (List<string>)request["Values"]; |