aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGridServices
diff options
context:
space:
mode:
Diffstat (limited to 'OpenGridServices')
-rw-r--r--OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oGridData.cs77
-rw-r--r--OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oManager.cs54
-rw-r--r--OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs108
3 files changed, 237 insertions, 2 deletions
diff --git a/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oGridData.cs b/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oGridData.cs
index 546713e..723ff69 100644
--- a/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oGridData.cs
+++ b/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oGridData.cs
@@ -1,3 +1,30 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27
1using System; 28using System;
2using System.Collections.Generic; 29using System.Collections.Generic;
3using System.Text; 30using System.Text;
@@ -7,19 +34,41 @@ using libsecondlife;
7 34
8namespace OpenGrid.Framework.Data.DB4o 35namespace OpenGrid.Framework.Data.DB4o
9{ 36{
37 /// <summary>
38 /// A grid server storage mechanism employing the DB4o database system
39 /// </summary>
10 class DB4oGridData : IGridData 40 class DB4oGridData : IGridData
11 { 41 {
42 /// <summary>
43 /// The database manager object
44 /// </summary>
12 DB4oGridManager manager; 45 DB4oGridManager manager;
13 46
47 /// <summary>
48 /// Called when the plugin is first loaded (as constructors are not called)
49 /// </summary>
14 public void Initialise() { 50 public void Initialise() {
15 manager = new DB4oGridManager("gridserver.yap"); 51 manager = new DB4oGridManager("gridserver.yap");
16 } 52 }
17 53
54 /// <summary>
55 /// Returns a list of regions within the specified ranges
56 /// </summary>
57 /// <param name="a">minimum X coordinate</param>
58 /// <param name="b">minimum Y coordinate</param>
59 /// <param name="c">maximum X coordinate</param>
60 /// <param name="d">maximum Y coordinate</param>
61 /// <returns>An array of region profiles</returns>
18 public SimProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d) 62 public SimProfileData[] GetProfilesInRange(uint a, uint b, uint c, uint d)
19 { 63 {
20 return null; 64 return null;
21 } 65 }
22 66
67 /// <summary>
68 /// Returns a region located at the specified regionHandle (warning multiple regions may occupy the one spot, first found is returned)
69 /// </summary>
70 /// <param name="handle">The handle to search for</param>
71 /// <returns>A region profile</returns>
23 public SimProfileData GetProfileByHandle(ulong handle) { 72 public SimProfileData GetProfileByHandle(ulong handle) {
24 lock (manager.simProfiles) 73 lock (manager.simProfiles)
25 { 74 {
@@ -34,6 +83,11 @@ namespace OpenGrid.Framework.Data.DB4o
34 throw new Exception("Unable to find profile with handle (" + handle.ToString() + ")"); 83 throw new Exception("Unable to find profile with handle (" + handle.ToString() + ")");
35 } 84 }
36 85
86 /// <summary>
87 /// Returns a specific region
88 /// </summary>
89 /// <param name="uuid">The region ID code</param>
90 /// <returns>A region profile</returns>
37 public SimProfileData GetProfileByLLUUID(LLUUID uuid) 91 public SimProfileData GetProfileByLLUUID(LLUUID uuid)
38 { 92 {
39 lock (manager.simProfiles) 93 lock (manager.simProfiles)
@@ -44,6 +98,11 @@ namespace OpenGrid.Framework.Data.DB4o
44 throw new Exception("Unable to find profile with UUID (" + uuid.ToStringHyphenated() + ")"); 98 throw new Exception("Unable to find profile with UUID (" + uuid.ToStringHyphenated() + ")");
45 } 99 }
46 100
101 /// <summary>
102 /// Adds a new specified region to the database
103 /// </summary>
104 /// <param name="profile">The profile to add</param>
105 /// <returns>A dataresponse enum indicating success</returns>
47 public DataResponse AddProfile(SimProfileData profile) 106 public DataResponse AddProfile(SimProfileData profile)
48 { 107 {
49 lock (manager.simProfiles) 108 lock (manager.simProfiles)
@@ -59,22 +118,40 @@ namespace OpenGrid.Framework.Data.DB4o
59 } 118 }
60 } 119 }
61 120
121 /// <summary>
122 /// Authenticates a new region using the shared secrets. NOT SECURE.
123 /// </summary>
124 /// <param name="uuid">The UUID the region is authenticating with</param>
125 /// <param name="handle">The location the region is logging into (unused in Db4o)</param>
126 /// <param name="key">The shared secret</param>
127 /// <returns>Authenticated?</returns>
62 public bool AuthenticateSim(LLUUID uuid, ulong handle, string key) { 128 public bool AuthenticateSim(LLUUID uuid, ulong handle, string key) {
63 if (manager.simProfiles[uuid].regionRecvKey == key) 129 if (manager.simProfiles[uuid].regionRecvKey == key)
64 return true; 130 return true;
65 return false; 131 return false;
66 } 132 }
67 133
134 /// <summary>
135 /// Shuts down the database
136 /// </summary>
68 public void Close() 137 public void Close()
69 { 138 {
70 manager = null; 139 manager = null;
71 } 140 }
72 141
142 /// <summary>
143 /// Returns the providers name
144 /// </summary>
145 /// <returns>The name of the storage system</returns>
73 public string getName() 146 public string getName()
74 { 147 {
75 return "DB4o Grid Provider"; 148 return "DB4o Grid Provider";
76 } 149 }
77 150
151 /// <summary>
152 /// Returns the providers version
153 /// </summary>
154 /// <returns>The version of the storage system</returns>
78 public string getVersion() 155 public string getVersion()
79 { 156 {
80 return "0.1"; 157 return "0.1";
diff --git a/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oManager.cs b/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oManager.cs
index b30f889..408b213 100644
--- a/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oManager.cs
+++ b/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oManager.cs
@@ -1,3 +1,29 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
1using System; 27using System;
2using System.Collections.Generic; 28using System.Collections.Generic;
3using System.Text; 29using System.Text;
@@ -7,17 +33,31 @@ using libsecondlife;
7 33
8namespace OpenGrid.Framework.Data.DB4o 34namespace OpenGrid.Framework.Data.DB4o
9{ 35{
36 /// <summary>
37 /// A Database manager for Db4o
38 /// </summary>
10 class DB4oGridManager 39 class DB4oGridManager
11 { 40 {
41 /// <summary>
42 /// A list of the current regions connected (in-memory cache)
43 /// </summary>
12 public Dictionary<LLUUID, SimProfileData> simProfiles = new Dictionary<LLUUID, SimProfileData>(); 44 public Dictionary<LLUUID, SimProfileData> simProfiles = new Dictionary<LLUUID, SimProfileData>();
45 /// <summary>
46 /// Database File Name
47 /// </summary>
13 string dbfl; 48 string dbfl;
14 49
50 /// <summary>
51 /// Creates a new grid storage manager
52 /// </summary>
53 /// <param name="db4odb">Filename to the database file</param>
15 public DB4oGridManager(string db4odb) 54 public DB4oGridManager(string db4odb)
16 { 55 {
17 dbfl = db4odb; 56 dbfl = db4odb;
18 IObjectContainer database; 57 IObjectContainer database;
19 database = Db4oFactory.OpenFile(dbfl); 58 database = Db4oFactory.OpenFile(dbfl);
20 IObjectSet result = database.Get(typeof(SimProfileData)); 59 IObjectSet result = database.Get(typeof(SimProfileData));
60 // Loads the file into the in-memory cache
21 foreach(SimProfileData row in result) { 61 foreach(SimProfileData row in result) {
22 simProfiles.Add(row.UUID, row); 62 simProfiles.Add(row.UUID, row);
23 } 63 }
@@ -57,16 +97,30 @@ namespace OpenGrid.Framework.Data.DB4o
57 97
58 } 98 }
59 99
100 /// <summary>
101 /// A manager for the DB4o database (user profiles)
102 /// </summary>
60 class DB4oUserManager 103 class DB4oUserManager
61 { 104 {
105 /// <summary>
106 /// A list of the user profiles (in memory cache)
107 /// </summary>
62 public Dictionary<LLUUID, UserProfileData> userProfiles = new Dictionary<LLUUID, UserProfileData>(); 108 public Dictionary<LLUUID, UserProfileData> userProfiles = new Dictionary<LLUUID, UserProfileData>();
109 /// <summary>
110 /// Database filename
111 /// </summary>
63 string dbfl; 112 string dbfl;
64 113
114 /// <summary>
115 /// Initialises a new DB manager
116 /// </summary>
117 /// <param name="db4odb">The filename to the database</param>
65 public DB4oUserManager(string db4odb) 118 public DB4oUserManager(string db4odb)
66 { 119 {
67 dbfl = db4odb; 120 dbfl = db4odb;
68 IObjectContainer database; 121 IObjectContainer database;
69 database = Db4oFactory.OpenFile(dbfl); 122 database = Db4oFactory.OpenFile(dbfl);
123 // Load to cache
70 IObjectSet result = database.Get(typeof(UserProfileData)); 124 IObjectSet result = database.Get(typeof(UserProfileData));
71 foreach (UserProfileData row in result) 125 foreach (UserProfileData row in result)
72 { 126 {
diff --git a/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs b/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs
index b95219c..db4deb8 100644
--- a/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs
+++ b/OpenGridServices/OpenGrid.Framework.Data.DB4o/DB4oUserData.cs
@@ -1,3 +1,29 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
1using System; 27using System;
2using System.Collections.Generic; 28using System.Collections.Generic;
3using System.Text; 29using System.Text;
@@ -6,15 +32,29 @@ using libsecondlife;
6 32
7namespace OpenGrid.Framework.Data.DB4o 33namespace OpenGrid.Framework.Data.DB4o
8{ 34{
35 /// <summary>
36 /// A User storage interface for the DB4o database system
37 /// </summary>
9 public class DB4oUserData : IUserData 38 public class DB4oUserData : IUserData
10 { 39 {
40 /// <summary>
41 /// The database manager
42 /// </summary>
11 DB4oUserManager manager; 43 DB4oUserManager manager;
12 44
45 /// <summary>
46 /// Artificial constructor called upon plugin load
47 /// </summary>
13 public void Initialise() 48 public void Initialise()
14 { 49 {
15 manager = new DB4oUserManager("userprofiles.yap"); 50 manager = new DB4oUserManager("userprofiles.yap");
16 } 51 }
17 52
53 /// <summary>
54 /// Loads a specified user profile from a UUID
55 /// </summary>
56 /// <param name="uuid">The users UUID</param>
57 /// <returns>A user profile</returns>
18 public UserProfileData getUserByUUID(LLUUID uuid) 58 public UserProfileData getUserByUUID(LLUUID uuid)
19 { 59 {
20 if(manager.userProfiles.ContainsKey(uuid)) 60 if(manager.userProfiles.ContainsKey(uuid))
@@ -22,11 +62,22 @@ namespace OpenGrid.Framework.Data.DB4o
22 return null; 62 return null;
23 } 63 }
24 64
65 /// <summary>
66 /// Returns a user by searching for its name
67 /// </summary>
68 /// <param name="name">The users account name</param>
69 /// <returns>A matching users profile</returns>
25 public UserProfileData getUserByName(string name) 70 public UserProfileData getUserByName(string name)
26 { 71 {
27 return getUserByName(name.Split(' ')[0], name.Split(' ')[1]); 72 return getUserByName(name.Split(' ')[0], name.Split(' ')[1]);
28 } 73 }
29 74
75 /// <summary>
76 /// Returns a user by searching for its name
77 /// </summary>
78 /// <param name="fname">The first part of the users account name</param>
79 /// <param name="lname">The second part of the users account name</param>
80 /// <returns>A matching users profile</returns>
30 public UserProfileData getUserByName(string fname, string lname) 81 public UserProfileData getUserByName(string fname, string lname)
31 { 82 {
32 foreach (UserProfileData profile in manager.userProfiles.Values) 83 foreach (UserProfileData profile in manager.userProfiles.Values)
@@ -37,6 +88,11 @@ namespace OpenGrid.Framework.Data.DB4o
37 return null; 88 return null;
38 } 89 }
39 90
91 /// <summary>
92 /// Returns a user by UUID direct
93 /// </summary>
94 /// <param name="uuid">The users account ID</param>
95 /// <returns>A matching users profile</returns>
40 public UserAgentData getAgentByUUID(LLUUID uuid) 96 public UserAgentData getAgentByUUID(LLUUID uuid)
41 { 97 {
42 try 98 try
@@ -49,11 +105,22 @@ namespace OpenGrid.Framework.Data.DB4o
49 } 105 }
50 } 106 }
51 107
108 /// <summary>
109 /// Returns a session by account name
110 /// </summary>
111 /// <param name="name">The account name</param>
112 /// <returns>The users session agent</returns>
52 public UserAgentData getAgentByName(string name) 113 public UserAgentData getAgentByName(string name)
53 { 114 {
54 return getAgentByName(name.Split(' ')[0], name.Split(' ')[1]); 115 return getAgentByName(name.Split(' ')[0], name.Split(' ')[1]);
55 } 116 }
56 117
118 /// <summary>
119 /// Returns a session by account name
120 /// </summary>
121 /// <param name="fname">The first part of the users account name</param>
122 /// <param name="lname">The second part of the users account name</param>
123 /// <returns>A user agent</returns>
57 public UserAgentData getAgentByName(string fname, string lname) 124 public UserAgentData getAgentByName(string fname, string lname)
58 { 125 {
59 try 126 try
@@ -66,32 +133,69 @@ namespace OpenGrid.Framework.Data.DB4o
66 } 133 }
67 } 134 }
68 135
136 /// <summary>
137 /// Creates a new user profile
138 /// </summary>
139 /// <param name="user">The profile to add to the database</param>
69 public void addNewUserProfile(UserProfileData user) 140 public void addNewUserProfile(UserProfileData user)
70 { 141 {
71 manager.AddRow(user); 142 try
143 {
144 manager.AddRow(user);
145 }
146 catch (Exception e)
147 {
148 Console.WriteLine(e.ToString());
149 }
72 } 150 }
73 151
152 /// <summary>
153 /// Creates a new user agent
154 /// </summary>
155 /// <param name="agent">The agent to add to the database</param>
74 public void addNewUserAgent(UserAgentData agent) 156 public void addNewUserAgent(UserAgentData agent)
75 { 157 {
76 // Do nothing. yet. 158 // Do nothing. yet.
77 } 159 }
78 160
161 /// <summary>
162 /// Transfers money between two user accounts
163 /// </summary>
164 /// <param name="from">Starting account</param>
165 /// <param name="to">End account</param>
166 /// <param name="amount">The amount to move</param>
167 /// <returns>Success?</returns>
79 public bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount) 168 public bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount)
80 { 169 {
81 return true; 170 return true;
82 } 171 }
83 172
173 /// <summary>
174 /// Transfers inventory between two accounts
175 /// </summary>
176 /// <remarks>Move to inventory server</remarks>
177 /// <param name="from">Senders account</param>
178 /// <param name="to">Recievers account</param>
179 /// <param name="item">Inventory item</param>
180 /// <returns>Success?</returns>
84 public bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item) 181 public bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item)
85 { 182 {
86 return true; 183 return true;
87 } 184 }
88 185
89 186 /// <summary>
187 /// Returns the name of the storage provider
188 /// </summary>
189 /// <returns>Storage provider name</returns>
90 public string getName() 190 public string getName()
91 { 191 {
92 return "DB4o Userdata"; 192 return "DB4o Userdata";
93 } 193 }
94 194
195 /// <summary>
196 /// Returns the version of the storage provider
197 /// </summary>
198 /// <returns>Storage provider version</returns>
95 public string getVersion() 199 public string getVersion()
96 { 200 {
97 return "0.1"; 201 return "0.1";