aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Server/Base/ServicesServerBase.cs28
-rw-r--r--OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs50
-rw-r--r--OpenSim/Server/Handlers/Inventory/InventoryServerMoveItemsHandler.cs (renamed from OpenSim/Grid/AssetInventoryServer/Plugins/NullAuthenticationPlugin.cs)86
3 files changed, 108 insertions, 56 deletions
diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs
index 619c2d1..1d9eb0d 100644
--- a/OpenSim/Server/Base/ServicesServerBase.cs
+++ b/OpenSim/Server/Base/ServicesServerBase.cs
@@ -65,6 +65,10 @@ namespace OpenSim.Server.Base
65 // 65 //
66 private bool m_Running = true; 66 private bool m_Running = true;
67 67
68 // PID file
69 //
70 private string m_pidFile = String.Empty;
71
68 // Handle all the automagical stuff 72 // Handle all the automagical stuff
69 // 73 //
70 public ServicesServerBase(string prompt, string[] args) 74 public ServicesServerBase(string prompt, string[] args)
@@ -211,6 +215,11 @@ namespace OpenSim.Server.Base
211 } 215 }
212 } 216 }
213 217
218 if (startupConfig.GetString("PIDFile", String.Empty) != String.Empty)
219 {
220 CreatePIDFile(startupConfig.GetString("PIDFile"));
221 }
222
214 // Register the quit command 223 // Register the quit command
215 // 224 //
216 MainConsole.Instance.Commands.AddCommand("base", false, "quit", 225 MainConsole.Instance.Commands.AddCommand("base", false, "quit",
@@ -230,6 +239,8 @@ namespace OpenSim.Server.Base
230 MainConsole.Instance.Prompt(); 239 MainConsole.Instance.Prompt();
231 } 240 }
232 241
242 if (m_pidFile != String.Empty)
243 File.Delete(m_pidFile);
233 return 0; 244 return 0;
234 } 245 }
235 246
@@ -246,5 +257,22 @@ namespace OpenSim.Server.Base
246 protected virtual void Initialise() 257 protected virtual void Initialise()
247 { 258 {
248 } 259 }
260
261 protected void CreatePIDFile(string path)
262 {
263 try
264 {
265 string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
266 FileStream fs = File.Create(path);
267 System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
268 Byte[] buf = enc.GetBytes(pidstring);
269 fs.Write(buf, 0, buf.Length);
270 fs.Close();
271 m_pidFile = path;
272 }
273 catch (Exception)
274 {
275 }
276 }
249 } 277 }
250} 278}
diff --git a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs
index 30b3cae..998b322 100644
--- a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs
+++ b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs
@@ -105,8 +105,12 @@ namespace OpenSim.Server.Handlers.Inventory
105 "POST", "/PurgeFolder/", m_InventoryService.PurgeFolder, CheckAuthSession)); 105 "POST", "/PurgeFolder/", m_InventoryService.PurgeFolder, CheckAuthSession));
106 106
107 m_httpServer.AddStreamHandler( 107 m_httpServer.AddStreamHandler(
108 new RestDeserialiseSecureHandler<InventoryItemBase, bool>( 108 new RestDeserialiseSecureHandler<List<Guid>, bool>(
109 "POST", "/DeleteItem/", m_InventoryService.DeleteItem, CheckAuthSession)); 109 "POST", "/DeleteFolders/", DeleteFolders, CheckAuthSession));
110
111 m_httpServer.AddStreamHandler(
112 new RestDeserialiseSecureHandler<List<Guid>, bool>(
113 "POST", "/DeleteItem/", DeleteItems, CheckAuthSession));
110 114
111 m_httpServer.AddStreamHandler( 115 m_httpServer.AddStreamHandler(
112 new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>( 116 new RestDeserialiseSecureHandler<InventoryItemBase, InventoryItemBase>(
@@ -125,8 +129,8 @@ namespace OpenSim.Server.Handlers.Inventory
125 "POST", "/NewFolder/", m_InventoryService.AddFolder, CheckAuthSession)); 129 "POST", "/NewFolder/", m_InventoryService.AddFolder, CheckAuthSession));
126 130
127 m_httpServer.AddStreamHandler( 131 m_httpServer.AddStreamHandler(
128 new RestDeserialiseTrustedHandler<InventoryFolderBase, bool>( 132 new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
129 "POST", "/CreateFolder/", m_InventoryService.AddFolder, CheckTrustSource)); 133 "POST", "/CreateFolder/", m_InventoryService.AddFolder, CheckAuthSession));
130 134
131 m_httpServer.AddStreamHandler( 135 m_httpServer.AddStreamHandler(
132 new RestDeserialiseSecureHandler<InventoryItemBase, bool>( 136 new RestDeserialiseSecureHandler<InventoryItemBase, bool>(
@@ -137,9 +141,16 @@ namespace OpenSim.Server.Handlers.Inventory
137 "POST", "/AddNewItem/", m_InventoryService.AddItem, CheckTrustSource)); 141 "POST", "/AddNewItem/", m_InventoryService.AddItem, CheckTrustSource));
138 142
139 m_httpServer.AddStreamHandler( 143 m_httpServer.AddStreamHandler(
140 new RestDeserialiseTrustedHandler<Guid, List<InventoryItemBase>>( 144 new RestDeserialiseSecureHandler<Guid, List<InventoryItemBase>>(
141 "POST", "/GetItems/", GetFolderItems, CheckTrustSource)); 145 "POST", "/GetItems/", GetFolderItems, CheckAuthSession));
142 146
147 m_httpServer.AddStreamHandler(
148 new RestDeserialiseSecureHandler<List<InventoryItemBase>, bool>(
149 "POST", "/MoveItems/", MoveItems, CheckAuthSession));
150
151 m_httpServer.AddStreamHandler(new InventoryServerMoveItemsHandler(m_InventoryService));
152
153
143 // for persistent active gestures 154 // for persistent active gestures
144 m_httpServer.AddStreamHandler( 155 m_httpServer.AddStreamHandler(
145 new RestDeserialiseTrustedHandler<Guid, List<InventoryItemBase>> 156 new RestDeserialiseTrustedHandler<Guid, List<InventoryItemBase>>
@@ -247,6 +258,33 @@ namespace OpenSim.Server.Handlers.Inventory
247 return m_InventoryService.GetAssetPermissions(item.Owner, item.AssetID); 258 return m_InventoryService.GetAssetPermissions(item.Owner, item.AssetID);
248 } 259 }
249 260
261 public bool DeleteFolders(List<Guid> items)
262 {
263 List<UUID> uuids = new List<UUID>();
264 foreach (Guid g in items)
265 uuids.Add(new UUID(g));
266 // oops we lost the user info here. Bad bad handlers
267 return m_InventoryService.DeleteFolders(UUID.Zero, uuids);
268 }
269
270 public bool DeleteItems(List<Guid> items)
271 {
272 List<UUID> uuids = new List<UUID>();
273 foreach (Guid g in items)
274 uuids.Add(new UUID(g));
275 // oops we lost the user info here. Bad bad handlers
276 return m_InventoryService.DeleteItems(UUID.Zero, uuids);
277 }
278
279 public bool MoveItems(List<InventoryItemBase> items)
280 {
281 // oops we lost the user info here. Bad bad handlers
282 // let's peek at one item
283 UUID ownerID = UUID.Zero;
284 if (items.Count > 0)
285 ownerID = items[0].Owner;
286 return m_InventoryService.MoveItems(ownerID, items);
287 }
250 #endregion 288 #endregion
251 289
252 /// <summary> 290 /// <summary>
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/NullAuthenticationPlugin.cs b/OpenSim/Server/Handlers/Inventory/InventoryServerMoveItemsHandler.cs
index 026b3c8..850bf14 100644
--- a/OpenSim/Grid/AssetInventoryServer/Plugins/NullAuthenticationPlugin.cs
+++ b/OpenSim/Server/Handlers/Inventory/InventoryServerMoveItemsHandler.cs
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
@@ -25,71 +25,57 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using Nini.Config;
29using log4net;
28using System; 30using System;
31using System.Collections.Generic;
29using System.Reflection; 32using System.Reflection;
30using OpenMetaverse; 33using System.IO;
34using System.Net;
35using System.Text;
36using System.Text.RegularExpressions;
37using System.Xml;
38using System.Xml.Serialization;
39using OpenSim.Server.Base;
40using OpenSim.Services.Interfaces;
31using OpenSim.Framework; 41using OpenSim.Framework;
32using log4net; 42using OpenSim.Framework.Servers.HttpServer;
43using OpenMetaverse;
33 44
34namespace OpenSim.Grid.AssetInventoryServer.Plugins 45namespace OpenSim.Server.Handlers.Inventory
35{ 46{
36 public class NullAuthenticationPlugin : IAuthenticationProvider 47 public class InventoryServerMoveItemsHandler : BaseStreamHandler
37 { 48 {
38 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
39 //private AssetInventoryServer m_server;
40
41 public NullAuthenticationPlugin()
42 {
43 }
44
45 #region IPlugin implementation
46
47 public void Initialise(AssetInventoryServer server)
48 {
49 //m_server = server;
50
51 m_log.Info("[NULLAUTHENTICATION]: Null Authentication loaded.");
52 }
53 50
54 /// <summary> 51 private IInventoryService m_InventoryService;
55 /// <para>Initialises asset interface</para>
56 /// </summary>
57 public void Initialise()
58 {
59 m_log.InfoFormat("[NULLAUTHENTICATION]: {0} cannot be default-initialized!", Name);
60 throw new PluginNotInitialisedException(Name);
61 }
62
63 public void Dispose()
64 {
65 }
66 52
67 public string Version 53 public InventoryServerMoveItemsHandler(IInventoryService service) :
54 base("PUT", "/inventory")
68 { 55 {
69 // TODO: this should be something meaningful and not hardcoded? 56 m_InventoryService = service;
70 get { return "0.1"; }
71 } 57 }
72 58
73 public string Name 59 public override byte[] Handle(string path, Stream request,
60 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
74 { 61 {
75 get { return "NullAuthentication"; } 62 XmlSerializer xs = new XmlSerializer(typeof (List<InventoryItemBase>));
76 } 63 List<InventoryItemBase> items = (List<InventoryItemBase>)xs.Deserialize(request);
77 64
78 #endregion IPlugin implementation 65 bool result = false;
66 string[] p = SplitParams(path);
79 67
80 public void AddIdentifier(UUID authToken, Uri identifier) 68 if (p.Length > 0)
81 { 69 {
82 } 70 UUID ownerID = UUID.Zero;
83 71 UUID.TryParse(p[0], out ownerID);
84 public bool RemoveIdentifier(UUID authToken) 72 result = m_InventoryService.MoveItems(ownerID, items);
85 { 73 }
86 return true; 74 else
87 } 75 m_log.WarnFormat("[MOVEITEMS HANDLER]: ownerID not provided in request. Unable to serve.");
88 76
89 public bool TryGetIdentifier(UUID authToken, out Uri identifier) 77 xs = new XmlSerializer(typeof(bool));
90 { 78 return ServerUtils.SerializeResult(xs, result);
91 identifier = null;
92 return true;
93 } 79 }
94 } 80 }
95} 81}