Compare commits
1085 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d62acc7e37 | ||
|
|
0c8f3dddd8 | ||
|
|
e008d54cd4 | ||
|
|
4e92b55231 | ||
|
|
2766bf3fef | ||
|
|
15b38f0036 | ||
|
|
d7b9260496 | ||
|
|
6d3b409af2 | ||
|
|
fea18a909f | ||
|
|
a8860d79d8 | ||
|
|
8ae5ab809f | ||
|
|
ba233008cd | ||
|
|
108978be1e | ||
|
|
63b5c11b9c | ||
|
|
219d273418 | ||
|
|
bb9071e5f0 | ||
|
|
869191a51d | ||
|
|
b019fd5a95 | ||
|
|
82a5d00bc8 | ||
|
|
dac8703949 | ||
|
|
78c155cd12 | ||
|
|
4b73268cbd | ||
|
|
3d70db4a58 | ||
|
|
6e0e35cd66 | ||
|
|
20b47fce07 | ||
|
|
82b875317b | ||
|
|
60ad72357e | ||
|
|
d99c8e68a7 | ||
|
|
d0782c2bc0 | ||
|
|
9643792b34 | ||
|
|
4ba396b81c | ||
|
|
c3923a1aa6 | ||
|
|
889194db63 | ||
|
|
fe6dab7f13 | ||
|
|
cd031d129a | ||
|
|
9d2789aff8 | ||
|
|
abf85b7f19 | ||
|
|
a93799d03b | ||
|
|
ca2379ee83 | ||
|
|
481b7c71c3 | ||
|
|
c90b986d8b | ||
|
|
3fe9c7c49d | ||
|
|
4651cd1f50 | ||
|
|
f348928590 | ||
|
|
3cbdf3bfe0 | ||
|
|
7b2f125fb6 | ||
|
|
a0d6705fe6 | ||
|
|
db0c41501c | ||
|
|
ff892b5bcf | ||
|
|
5450b1b024 | ||
|
|
602587b8d5 | ||
|
|
b59812b4e3 | ||
|
|
4374ce9fbf | ||
|
|
696df33e5c | ||
|
|
c5f7184d1b | ||
|
|
dcd8e74584 | ||
|
|
7f0adfd203 | ||
|
|
31096fb1fe | ||
|
|
807fb8339b | ||
|
|
e86c765be3 | ||
|
|
c915791824 | ||
|
|
7f45ac72e1 | ||
|
|
8956cdc55f | ||
|
|
3552cfb1a5 | ||
|
|
0dc14b5f35 | ||
|
|
74cda2ad78 | ||
|
|
2766b37d8b | ||
|
|
b913f1c8ab | ||
|
|
fe779128b0 | ||
|
|
90de9df3e8 | ||
|
|
733763c4e2 | ||
|
|
5bb95a8a55 | ||
|
|
30cde52634 | ||
|
|
278530bf04 | ||
|
|
c1bdd22274 | ||
|
|
f8fe4dee8f | ||
|
|
77913eb679 | ||
|
|
0aa0dad478 | ||
|
|
3aa99b9a7f | ||
|
|
14a31c3e9b | ||
|
|
94d0ae0d91 | ||
|
|
0eaca7aafb | ||
|
|
2ff9ea3f80 | ||
|
|
a2ea844494 | ||
|
|
0300ec45eb | ||
|
|
22dade6463 | ||
|
|
db5a42ffac | ||
|
|
eaf595c008 | ||
|
|
d6f9f690e5 | ||
|
|
02a53665c9 | ||
|
|
bf5320eb26 | ||
|
|
3c992b028c | ||
|
|
a755c57b44 | ||
|
|
9ced61fbc2 | ||
|
|
0eede1467f | ||
|
|
35c7fb2038 | ||
|
|
8656b5e948 | ||
|
|
1efaf0c85c | ||
|
|
27597463da | ||
|
|
c32ccfb520 | ||
|
|
9ca86664bb | ||
|
|
464d31b70b | ||
|
|
5622cf68aa | ||
|
|
394ec508f6 | ||
|
|
bcaacb4e41 | ||
|
|
d131c57978 | ||
|
|
987c56984d | ||
|
|
e19c830a6c | ||
|
|
fab0389cb1 | ||
|
|
d2877b9cd4 | ||
|
|
b778bd9423 | ||
|
|
449548d7a4 | ||
|
|
33cc847c4a | ||
|
|
5aeaa7fcdd | ||
|
|
e68867c9b6 | ||
|
|
1fa3a6f1bd | ||
|
|
ff9da24465 | ||
|
|
227685bea4 | ||
|
|
20f20895cf | ||
|
|
9bae636ff0 | ||
|
|
cf95b65c10 | ||
|
|
250ea09328 | ||
|
|
b3a496d6f2 | ||
|
|
f55e153636 | ||
|
|
fbcb76383d | ||
|
|
72c67c5091 | ||
|
|
5015b0b485 | ||
|
|
c78a8271c4 | ||
|
|
fbed245596 | ||
|
|
174df94172 | ||
|
|
3fbaef9275 | ||
|
|
16bf38e1ab | ||
|
|
f8b8241239 | ||
|
|
bffc9ad184 | ||
|
|
15b50ae737 | ||
|
|
65a135f4d3 | ||
|
|
1b156b7fe8 | ||
|
|
b7c7293c7a | ||
|
|
f7b2aa0f49 | ||
|
|
04aa13a086 | ||
|
|
251b93d97e | ||
|
|
a1b291c889 | ||
|
|
5b433e101d | ||
|
|
d93275745b | ||
|
|
32070fa5f4 | ||
|
|
9479f64778 | ||
|
|
5ec3429843 | ||
|
|
77a331fce3 | ||
|
|
b46be88db6 | ||
|
|
3a6f312484 | ||
|
|
47b84875fd | ||
|
|
78733b979f | ||
|
|
dd30a29ba0 | ||
|
|
882af7195c | ||
|
|
96e5836b50 | ||
|
|
ab1472e5b7 | ||
|
|
922f76a3a7 | ||
|
|
0be9e3b079 | ||
|
|
4a74c4533c | ||
|
|
d2c738fc09 | ||
|
|
6dc1b113d0 | ||
|
|
d32d25634d | ||
|
|
7c12dfe185 | ||
|
|
2f7539a25b | ||
|
|
0c0ee95bd8 | ||
|
|
c23d37a509 | ||
|
|
4569c595bf | ||
|
|
484aa72ff8 | ||
|
|
8ad29fc5c8 | ||
|
|
87e2668529 | ||
|
|
515d373a8e | ||
|
|
bbc1dc6bce | ||
|
|
8457044b2f | ||
|
|
19d8f05584 | ||
|
|
7db4336f1c | ||
|
|
faf9ba53fc | ||
|
|
bf8f64e40e | ||
|
|
73891c7fd3 | ||
|
|
667a272cce | ||
|
|
f41809e07d | ||
|
|
afb938e579 | ||
|
|
a31393ba0b | ||
|
|
a845c1a893 | ||
|
|
093705efd1 | ||
|
|
f4cba27105 | ||
|
|
3db9b847bf | ||
|
|
2b33677402 | ||
|
|
812f5e124d | ||
|
|
2fbafc7465 | ||
|
|
e44450cce1 | ||
|
|
78015bbbdc | ||
|
|
9e83b43009 | ||
|
|
8b3c2f7d0c | ||
|
|
cecb446e0e | ||
|
|
0faba7dc33 | ||
|
|
e245638f24 | ||
|
|
c9742c826d | ||
|
|
539165e6bd | ||
|
|
95eeb4dde8 | ||
|
|
ef262799ca | ||
|
|
614b9e14c4 | ||
|
|
eb79c882ea | ||
|
|
1e5cff32fc | ||
|
|
df49196e17 | ||
|
|
0fe08c8799 | ||
|
|
7862d1e20d | ||
|
|
13b2ac1425 | ||
|
|
7f570636f8 | ||
|
|
5a10da3ee8 | ||
|
|
53b72ab4b8 | ||
|
|
3a2c099169 | ||
|
|
c31d93cb6f | ||
|
|
f0411dc128 | ||
|
|
7c121a2acc | ||
|
|
f0eeb47262 | ||
|
|
44f533d95a | ||
|
|
7bb673a854 | ||
|
|
5d01a1ff4d | ||
|
|
253110293a | ||
|
|
5fc61942e0 | ||
|
|
d4eee213a9 | ||
|
|
2dbc18054e | ||
|
|
88f7a833dc | ||
|
|
06e4fcd260 | ||
|
|
df89e15290 | ||
|
|
63aea3a5f2 | ||
|
|
cb8c3ba023 | ||
|
|
2e216aa056 | ||
|
|
9664273df6 | ||
|
|
2227f51b29 | ||
|
|
38acda9f29 | ||
|
|
904baa6da6 | ||
|
|
a108fcac95 | ||
|
|
2572ed9ed9 | ||
|
|
cf54df3ecf | ||
|
|
1d9a9e6004 | ||
|
|
0d898d8d8a | ||
|
|
463d0b2f8f | ||
|
|
bc06db3df4 | ||
|
|
e8a2eff2e8 | ||
|
|
d62f0bc35d | ||
|
|
d15a3b10a3 | ||
|
|
6efc203ce8 | ||
|
|
d1865c526d | ||
|
|
98c1940820 | ||
|
|
5dc0298f83 | ||
|
|
7180690a14 | ||
|
|
0b743045ef | ||
|
|
5092cbd77e | ||
|
|
cb1f2886cd | ||
|
|
7a5699224e | ||
|
|
328bc3b76e | ||
|
|
b01e73cf27 | ||
|
|
7eb12f96ec | ||
|
|
2506b3d89e | ||
|
|
018832522c | ||
|
|
ca78c8326e | ||
|
|
998d7009a6 | ||
|
|
617bc4710a | ||
|
|
2c9859314f | ||
|
|
eb5bfd14fa | ||
|
|
85f4357ce6 | ||
|
|
a893fd90cd | ||
|
|
93a9ed2a6d | ||
|
|
4cac87d9f4 | ||
|
|
538ff31b28 | ||
|
|
06db136fbc | ||
|
|
acc2c42a79 | ||
|
|
b065c02661 | ||
|
|
bc969a6b46 | ||
|
|
3f76f72137 | ||
|
|
52f8669169 | ||
|
|
853c0fccc8 | ||
|
|
090f9bcece | ||
|
|
3185db7f94 | ||
|
|
a780e01a54 | ||
|
|
63fd027494 | ||
|
|
b3ebec184f | ||
|
|
e1dd228f18 | ||
|
|
c8914d22eb | ||
|
|
574a11558d | ||
|
|
5d964a6424 | ||
|
|
18b91fdbe9 | ||
|
|
f0998a9222 | ||
|
|
7c148d9b2f | ||
|
|
de0ab04d00 | ||
|
|
530c86335d | ||
|
|
562a3cb338 | ||
|
|
32ad66c274 | ||
|
|
c725ad1577 | ||
|
|
06e0528d0b | ||
|
|
cf1686335f | ||
|
|
af406748a2 | ||
|
|
e00f1a0410 | ||
|
|
86105a1533 | ||
|
|
c0fd09b445 | ||
|
|
85d51e57a9 | ||
|
|
55cc8044cb | ||
|
|
f3508649f5 | ||
|
|
abe0f4a088 | ||
|
|
d4acaf25af | ||
|
|
cacbb5c165 | ||
|
|
86a2cd915c | ||
|
|
2c00b73cd2 | ||
|
|
8b8e1b88ec | ||
|
|
aec723b955 | ||
|
|
6b1d09813e | ||
|
|
50eec6df52 | ||
|
|
3c5b7d7b79 | ||
|
|
4aa483777b | ||
|
|
672bd9fc98 | ||
|
|
01daa74adf | ||
|
|
6d2893be67 | ||
|
|
65c4cb48ac | ||
|
|
9406db3047 | ||
|
|
e756457703 | ||
|
|
6ac9c9c972 | ||
|
|
91b7679db9 | ||
|
|
17929abd28 | ||
|
|
5cb4044539 | ||
|
|
e6d0dcd4e8 | ||
|
|
2051535ce1 | ||
|
|
0301c81b01 | ||
|
|
9211361b19 | ||
|
|
6b65895736 | ||
|
|
559c66afe6 | ||
|
|
aa217cf90f | ||
|
|
bbfda8e19e | ||
|
|
fad0fd7f75 | ||
|
|
d1c3f8eef5 | ||
|
|
ac16a667e1 | ||
|
|
7bafee28fa | ||
|
|
46095c058e | ||
|
|
e5a5b69b08 | ||
|
|
43eab5e163 | ||
|
|
444737c830 | ||
|
|
7cb1690589 | ||
|
|
0af8886400 | ||
|
|
4cbd45f3d5 | ||
|
|
59d0e3c3c8 | ||
|
|
635f3f77ab | ||
|
|
6557eba235 | ||
|
|
1fe504fee5 | ||
|
|
f360b687d6 | ||
|
|
ba5a236922 | ||
|
|
20640357ab | ||
|
|
45ada5ca2d | ||
|
|
9c7b28341c | ||
|
|
a15282f023 | ||
|
|
161c827a44 | ||
|
|
76add0fdb0 | ||
|
|
af54e6f370 | ||
|
|
e7fa8a4699 | ||
|
|
262892336b | ||
|
|
1247174db4 | ||
|
|
de941d2ec7 | ||
|
|
b0bae62c30 | ||
|
|
7a4c5b067d | ||
|
|
6c447f892e | ||
|
|
5e8dfb4f7e | ||
|
|
7a47c15edb | ||
|
|
14a7ddb885 | ||
|
|
2fbb906ff6 | ||
|
|
62a03a5cac | ||
|
|
d3387d591a | ||
|
|
cffea984f1 | ||
|
|
99308d64c6 | ||
|
|
6d1d58b654 | ||
|
|
14836e60ff | ||
|
|
9aec36156e | ||
|
|
fce3fca7f9 | ||
|
|
542bef20e8 | ||
|
|
dba33fee39 | ||
|
|
b1d8aa0b64 | ||
|
|
8ecab21b37 | ||
|
|
368b29a680 | ||
|
|
f90aee696a | ||
|
|
f901a38204 | ||
|
|
4289b71141 | ||
|
|
e131e73652 | ||
|
|
84d7227dfd | ||
|
|
b13214af27 | ||
|
|
e735f76553 | ||
|
|
4031933475 | ||
|
|
8555e54e22 | ||
|
|
7c0ebcb984 | ||
|
|
091f3a8000 | ||
|
|
e12c044eab | ||
|
|
8276a9e5f7 | ||
|
|
6a477e044d | ||
|
|
1769e93c42 | ||
|
|
1a32b35279 | ||
|
|
305f5110c6 | ||
|
|
35078e03e5 | ||
|
|
5fd9411143 | ||
|
|
0ff61341e4 | ||
|
|
8cec0b3fa1 | ||
|
|
1b30ae81b5 | ||
|
|
b9e0d0fdb2 | ||
|
|
1d4551e52f | ||
|
|
c8583e566d | ||
|
|
a2dd8f31de | ||
|
|
6edc446780 | ||
|
|
bf68dbabd7 | ||
|
|
89945f8829 | ||
|
|
edc04d4184 | ||
|
|
5b2af7f99e | ||
|
|
df9845a283 | ||
|
|
7496d0b0f7 | ||
|
|
4bccfed80c | ||
|
|
eaf99bf928 | ||
|
|
f5ae36d7e2 | ||
|
|
425d76bb98 | ||
|
|
921f0052f4 | ||
|
|
6734b94761 | ||
|
|
773ffcafc3 | ||
|
|
62b3bdf0fc | ||
|
|
b0cb0ec02f | ||
|
|
81c9952e99 | ||
|
|
db83208794 | ||
|
|
ff5c38534d | ||
|
|
58d7e3b8ed | ||
|
|
949139eb0b | ||
|
|
fe16a72a9a | ||
|
|
58def34dbe | ||
|
|
d4dad75a3c | ||
|
|
ebe7726cd7 | ||
|
|
a4d322dcd1 | ||
|
|
ccf18fd2ef | ||
|
|
3d0778bcd6 | ||
|
|
a5800f479e | ||
|
|
178a5a5585 | ||
|
|
6664079f84 | ||
|
|
fb312279c9 | ||
|
|
f8caf41bd8 | ||
|
|
47e7febebc | ||
|
|
33ae733006 | ||
|
|
da25903300 | ||
|
|
7f027552ec | ||
|
|
d04bb3ca9b | ||
|
|
bd6f734d3a | ||
|
|
b5f94c72b9 | ||
|
|
220ea9f687 | ||
|
|
61353dde80 | ||
|
|
cf97535d9e | ||
|
|
52b7b40034 | ||
|
|
1497b75361 | ||
|
|
9858766516 | ||
|
|
e6080a38c5 | ||
|
|
1d0a9e521c | ||
|
|
fad1d70180 | ||
|
|
9e0d419239 | ||
|
|
eed343ed8a | ||
|
|
7df325c275 | ||
|
|
fdcd392582 | ||
|
|
f27766d47b | ||
|
|
a660c0a750 | ||
|
|
8ce3fa646b | ||
|
|
e82d394ddf | ||
|
|
d5f5649750 | ||
|
|
c605c7a7b7 | ||
|
|
a53272c5fb | ||
|
|
ae56b946cf | ||
|
|
01520bbb3e | ||
|
|
f3e177814a | ||
|
|
873eee5431 | ||
|
|
6a279feb2f | ||
|
|
296d63e20b | ||
|
|
beba20846f | ||
|
|
7112ee0015 | ||
|
|
86630a1b70 | ||
|
|
d975b42f6a | ||
|
|
8edf4225f3 | ||
|
|
6b17c9bd98 | ||
|
|
71c808cd32 | ||
|
|
3e8f593bf2 | ||
|
|
742f505440 | ||
|
|
0237d9113d | ||
|
|
120f872d2b | ||
|
|
932c9e757b | ||
|
|
77e7bbcbf7 | ||
|
|
4f67286044 | ||
|
|
cfd3e8f0ea | ||
|
|
abcb2cdb36 | ||
|
|
a96601478c | ||
|
|
e3c4936dea | ||
|
|
da990d01f2 | ||
|
|
12f2648a57 | ||
|
|
9de3fe9410 | ||
|
|
8225e3f40c | ||
|
|
3c05d67094 | ||
|
|
6b7625a56b | ||
|
|
71918eeab4 | ||
|
|
ddd38a3dea | ||
|
|
58c0ed78d4 | ||
|
|
470d053443 | ||
|
|
ed14e97bb4 | ||
|
|
aa2fb1ec25 | ||
|
|
14569992e1 | ||
|
|
4e6f7435d0 | ||
|
|
39ed382ddf | ||
|
|
c9415fd763 | ||
|
|
31de7b845f | ||
|
|
5038a59ef3 | ||
|
|
88b1fc1382 | ||
|
|
94ad69faf2 | ||
|
|
5fafea6631 | ||
|
|
1f4f09ad69 | ||
|
|
91333b9267 | ||
|
|
ed760f2586 | ||
|
|
d7c9725ec0 | ||
|
|
6955190c7d | ||
|
|
ce5d308d23 | ||
|
|
0e23374aa2 | ||
|
|
26fe59c35e | ||
|
|
bc9952f901 | ||
|
|
fd1b2a1c57 | ||
|
|
0f03c64a0c | ||
|
|
d6837f5dc7 | ||
|
|
0b213af675 | ||
|
|
cddf1ec0dc | ||
|
|
97c74afca8 | ||
|
|
d27e188fe2 | ||
|
|
11b4f534c2 | ||
|
|
d50d169441 | ||
|
|
28419251bf | ||
|
|
d1bb73d068 | ||
|
|
4d1426e77d | ||
|
|
a2866b85f3 | ||
|
|
269a6410a0 | ||
|
|
c26f01ff8c | ||
|
|
fc9930e420 | ||
|
|
79200ed270 | ||
|
|
7fc289c039 | ||
|
|
877bdcdce1 | ||
|
|
bdbbeaa494 | ||
|
|
f6913e911e | ||
|
|
f74aafaf63 | ||
|
|
4fed301e65 | ||
|
|
733e067958 | ||
|
|
ffd0da23fb | ||
|
|
f49d513089 | ||
|
|
fc35b45e21 | ||
|
|
bc7fda39b4 | ||
|
|
e10012a7a6 | ||
|
|
3a7c8d1f32 | ||
|
|
c0cc5e0fa4 | ||
|
|
b83a224147 | ||
|
|
4a1c1fc009 | ||
|
|
cf61cdf58c | ||
|
|
1913ab5ad5 | ||
|
|
29c8461631 | ||
|
|
8f372b8ac8 | ||
|
|
342be228c6 | ||
|
|
87abf06956 | ||
|
|
f81841a2c5 | ||
|
|
1b41ec0a85 | ||
|
|
31cba5aa66 | ||
|
|
1aed6567a8 | ||
|
|
f0f852b27f | ||
|
|
1197658233 | ||
|
|
e1d1c27965 | ||
|
|
49c2213a01 | ||
|
|
41b6602a77 | ||
|
|
8c6a0cb44a | ||
|
|
2a4dd34616 | ||
|
|
9c97fb8e12 | ||
|
|
a8e64cd59a | ||
|
|
abb193ec94 | ||
|
|
b2878eb773 | ||
|
|
b8e22f02e7 | ||
|
|
1380b37d71 | ||
|
|
3d62f4369d | ||
|
|
d405254971 | ||
|
|
9db4090c07 | ||
|
|
c9550e473d | ||
|
|
257f9cec40 | ||
|
|
13bb9ea682 | ||
|
|
67ec95bde8 | ||
|
|
c467dfcd81 | ||
|
|
b73baeb4a4 | ||
|
|
b50e5704b8 | ||
|
|
7807b19a89 | ||
|
|
bdab05df0e | ||
|
|
0842e2e15b | ||
|
|
fbf33ef1de | ||
|
|
3f5c6c897f | ||
|
|
1900254e77 | ||
|
|
678c107915 | ||
|
|
dde0e547a7 | ||
|
|
226b5e4d75 | ||
|
|
cfe1bced7d | ||
|
|
2877c7d94d | ||
|
|
0c3493f619 | ||
|
|
d25265ae82 | ||
|
|
1d533b0f01 | ||
|
|
bfb0011cd3 | ||
|
|
e5d59dc696 | ||
|
|
8eec717f5f | ||
|
|
4faf11e001 | ||
|
|
cd35d298fa | ||
|
|
2cf224166f | ||
|
|
f7172095e0 | ||
|
|
8c2b41b01d | ||
|
|
a4017ee1eb | ||
|
|
1b86239f79 | ||
|
|
e2fbc88d98 | ||
|
|
49af6b53e7 | ||
|
|
13a9d5409c | ||
|
|
6831e58616 | ||
|
|
0eda7dd1c7 | ||
|
|
fea8345f56 | ||
|
|
c9b5ba78d9 | ||
|
|
4a9796a506 | ||
|
|
afb2e07111 | ||
|
|
674a3a5639 | ||
|
|
966ab21839 | ||
|
|
a2d5d810e0 | ||
|
|
a859464e91 | ||
|
|
4c362a83f9 | ||
|
|
83626e60e6 | ||
|
|
7bd42fc42f | ||
|
|
af58631f00 | ||
|
|
719810e9d8 | ||
|
|
1cae3664a5 | ||
|
|
5fc871027e | ||
|
|
2cf7478b9a | ||
|
|
2e78e89c36 | ||
|
|
8e72b53edc | ||
|
|
4800303abd | ||
|
|
36d8a24a86 | ||
|
|
95c926b2cd | ||
|
|
28723beb0c | ||
|
|
d1f16c4b4b | ||
|
|
68d83425c6 | ||
|
|
3018b2c5d7 | ||
|
|
ca0336d834 | ||
|
|
e8273fa8ad | ||
|
|
90fa3202c6 | ||
|
|
5e6a47f13f | ||
|
|
6fbfb47b92 | ||
|
|
dd6db72939 | ||
|
|
f127e4b4ee | ||
|
|
4fb3d314b8 | ||
|
|
54a4b9eab4 | ||
|
|
813f0da00b | ||
|
|
08fa0a6a8a | ||
|
|
60de0bc3c2 | ||
|
|
d466446df3 | ||
|
|
e9454d4672 | ||
|
|
50ea2e0d67 | ||
|
|
0cbe5f8424 | ||
|
|
b9453a8f6f | ||
|
|
427ffd3387 | ||
|
|
fc7ccfdafa | ||
|
|
ee8ba1ab9a | ||
|
|
d381da81d6 | ||
|
|
97fbb8ed45 | ||
|
|
12bfce7b9f | ||
|
|
b52b50ee56 | ||
|
|
9fefbcf7fc | ||
|
|
14c72d4a5b | ||
|
|
18e0d2f343 | ||
|
|
39e5785c0f | ||
|
|
4fa843ff19 | ||
|
|
f467121c51 | ||
|
|
3bc669ffc7 | ||
|
|
3ffd90496a | ||
|
|
1a8b56fa87 | ||
|
|
2d9d6fe922 | ||
|
|
46c2791fe2 | ||
|
|
21bc799a17 | ||
|
|
e99a7d879e | ||
|
|
4675a2fb29 | ||
|
|
797684115c | ||
|
|
cc5cffc212 | ||
|
|
1eea6fd452 | ||
|
|
3760d10cd0 | ||
|
|
1cf17a3cf7 | ||
|
|
239b85d7ce | ||
|
|
b5ef585069 | ||
|
|
bc0ff5e7d4 | ||
|
|
66e2e1c9c3 | ||
|
|
70dd4cf152 | ||
|
|
09e800f4b1 | ||
|
|
8c6b9ef865 | ||
|
|
08f2fc63cd | ||
|
|
68cbccb288 | ||
|
|
9050c152b4 | ||
|
|
da47bcae3e | ||
|
|
5e72de1908 | ||
|
|
88f01a4130 | ||
|
|
a94e1e0e08 | ||
|
|
91fd9c4670 | ||
|
|
13f31fdf85 | ||
|
|
32e9c16957 | ||
|
|
0155d42b80 | ||
|
|
38148bd4b6 | ||
|
|
8ff2ff1a36 | ||
|
|
7e32313a49 | ||
|
|
004ecee314 | ||
|
|
d9848943a9 | ||
|
|
dd96fef940 | ||
|
|
fd045d520e | ||
|
|
9984ecf862 | ||
|
|
eab9390e05 | ||
|
|
6869633d76 | ||
|
|
01c0bbf181 | ||
|
|
2d2bea4aa7 | ||
|
|
e5f7c8b6e8 | ||
|
|
b40b57776b | ||
|
|
5c9fa15f30 | ||
|
|
540fa84842 | ||
|
|
2f94165dcc | ||
|
|
f1cd813a29 | ||
|
|
871ac5b16c | ||
|
|
a5e4780547 | ||
|
|
b757ab2586 | ||
|
|
a01862509e | ||
|
|
68773ee7c4 | ||
|
|
e298bf41ff | ||
|
|
a5ca15c428 | ||
|
|
6937eec258 | ||
|
|
141d771a93 | ||
|
|
b03ec6137f | ||
|
|
fe01e7d1cc | ||
|
|
f69e91dc2d | ||
|
|
13a9a4b653 | ||
|
|
00e632ec3a | ||
|
|
51da52f904 | ||
|
|
38d7d46c17 | ||
|
|
957449e62c | ||
|
|
ee163b5751 | ||
|
|
e7a294e739 | ||
|
|
996a6c2eea | ||
|
|
63ccc3dbf5 | ||
|
|
bf826699a5 | ||
|
|
d656ec2a07 | ||
|
|
5ddd818238 | ||
|
|
bcb8c4068e | ||
|
|
d2d4ae541b | ||
|
|
54cc229768 | ||
|
|
11f177d6a8 | ||
|
|
1d605642f7 | ||
|
|
82ebb86d58 | ||
|
|
92aad6f1bb | ||
|
|
5b73b9c4a8 | ||
|
|
3df8990e6f | ||
|
|
97934e00e6 | ||
|
|
0875050161 | ||
|
|
8f221a3077 | ||
|
|
c0380d1bfe | ||
|
|
5047bd7b44 | ||
|
|
4058e5f709 | ||
|
|
aba2a44453 | ||
|
|
1496de7ce9 | ||
|
|
1842388bb4 | ||
|
|
4eb52eb19e | ||
|
|
04f8fc1ce9 | ||
|
|
823a175f07 | ||
|
|
9b76a46df0 | ||
|
|
bb4f4d9480 | ||
|
|
16aaba77d4 | ||
|
|
17b32b764a | ||
|
|
62a2d7836f | ||
|
|
31bacfbb63 | ||
|
|
6cd0d7a62b | ||
|
|
8ebad90800 | ||
|
|
96018afab4 | ||
|
|
4cde02a2a3 | ||
|
|
4bd4f1cd83 | ||
|
|
8b3a4367ea | ||
|
|
5f0e763062 | ||
|
|
84bfde3bdf | ||
|
|
ca079c378a | ||
|
|
868c0c2746 | ||
|
|
f9193e3c51 | ||
|
|
a64377149d | ||
|
|
109136c074 | ||
|
|
7aa00632b9 | ||
|
|
b8dd203378 | ||
|
|
13017034b1 | ||
|
|
73dadef8df | ||
|
|
e52a8d388f | ||
|
|
0785210e29 | ||
|
|
5a9ec0748b | ||
|
|
a3c72dafe6 | ||
|
|
36d146bf27 | ||
|
|
0ad45531a1 | ||
|
|
3193bcaae1 | ||
|
|
60e049ea39 | ||
|
|
1999b218fd | ||
|
|
a68d1fad73 | ||
|
|
eb172be541 | ||
|
|
910f07dffa | ||
|
|
5aa3236ebe | ||
|
|
b9e42aeb6e | ||
|
|
65304260af | ||
|
|
f3f3d390f7 | ||
|
|
8217b52d3a | ||
|
|
78649eb099 | ||
|
|
70e651a8d1 | ||
|
|
bd5c414618 | ||
|
|
ed1029712a | ||
|
|
9bdd3dc7de | ||
|
|
9f4a548a49 | ||
|
|
ff4e7de776 | ||
|
|
c896b4179e | ||
|
|
b44c69807d | ||
|
|
f9984a9685 | ||
|
|
b71952df49 | ||
|
|
9ba5a7e190 | ||
|
|
f94d07f2e2 | ||
|
|
79c1ed8cb9 | ||
|
|
ec4d96acc9 | ||
|
|
edd7e19463 | ||
|
|
62006baaef | ||
|
|
d728c1beb2 | ||
|
|
b58a474105 | ||
|
|
92fbe675b5 | ||
|
|
ecfb78dd16 | ||
|
|
346644016c | ||
|
|
604b39cea9 | ||
|
|
0595974a89 | ||
|
|
f63fd81a68 | ||
|
|
7cab41f422 | ||
|
|
b4932bda2a | ||
|
|
d67236c09d | ||
|
|
8114ae0f8b | ||
|
|
7da10850b0 | ||
|
|
869a23e223 | ||
|
|
d71ebb7ec8 | ||
|
|
4563e7e04a | ||
|
|
0f16612400 | ||
|
|
e2a1fa806d | ||
|
|
c12e68e34d | ||
|
|
7061784cc6 | ||
|
|
beeec1c467 | ||
|
|
a7a837550e | ||
|
|
fd24147afa | ||
|
|
9a9abd37eb | ||
|
|
ea9e96dd50 | ||
|
|
626a050159 | ||
|
|
5cef8bf64e | ||
|
|
3b2721c957 | ||
|
|
52ff860f30 | ||
|
|
f7bd0da026 | ||
|
|
0b4577d5b0 | ||
|
|
709814c194 | ||
|
|
e1ce3907f2 | ||
|
|
cd33972ed1 | ||
|
|
a75ce7423c | ||
|
|
d0854e4ace | ||
|
|
26fd29622d | ||
|
|
417836ac5e | ||
|
|
8e1bf55e7b | ||
|
|
caf2abe311 | ||
|
|
fb23f78928 | ||
|
|
2d315ec207 | ||
|
|
c931b16c1f | ||
|
|
f2810bf03a | ||
|
|
cd1a23fc14 | ||
|
|
ac94dc8a14 | ||
|
|
9bf363e9be | ||
|
|
79b031bd0c | ||
|
|
6df7d4219d | ||
|
|
f66737fe56 | ||
|
|
2b069a3b1e | ||
|
|
92c06a5d0b | ||
|
|
976530569a | ||
|
|
7faf286d00 | ||
|
|
ff5885ab23 | ||
|
|
ce94f990bb | ||
|
|
f4ded3af63 | ||
|
|
db32e5d304 | ||
|
|
c6395240f0 | ||
|
|
cc73ef4eb9 | ||
|
|
cc7065f9ee | ||
|
|
4c4a1cf715 | ||
|
|
50794c9008 | ||
|
|
3d5a7e9b19 | ||
|
|
b7c57294cc | ||
|
|
eb52d346c0 | ||
|
|
0e07fad2e1 | ||
|
|
39777db8ef | ||
|
|
46a4c32e27 | ||
|
|
fdd1c63c3c | ||
|
|
28f36d8db5 | ||
|
|
edaf0a98d6 | ||
|
|
26c2d9e627 | ||
|
|
39de7614ec | ||
|
|
2be0347f50 | ||
|
|
d23ef79f98 | ||
|
|
93d5d66fbd | ||
|
|
5be8f6632b | ||
|
|
df76e52310 | ||
|
|
31989bd51e | ||
|
|
cccdfcb59e | ||
|
|
5d61c4039d | ||
|
|
511122834b | ||
|
|
4830431eb0 | ||
|
|
a7e7bed660 | ||
|
|
84a149ecbf | ||
|
|
571a75f934 | ||
|
|
0094971186 | ||
|
|
1bd89ac287 | ||
|
|
6221356712 | ||
|
|
67ffb64764 | ||
|
|
f83343d302 | ||
|
|
8fdf70b87e | ||
|
|
c581506058 | ||
|
|
8937a2244d | ||
|
|
97bc5263de | ||
|
|
766a31431e | ||
|
|
d0c1780839 | ||
|
|
acfe603a5f | ||
|
|
d82d6bb1ec | ||
|
|
5ca7395e17 | ||
|
|
3e1ca2bd21 | ||
|
|
f106ba87ca | ||
|
|
a27c2432bb | ||
|
|
dbdcf2d995 | ||
|
|
daf44cc65e | ||
|
|
ff8a768258 | ||
|
|
2eade55471 | ||
|
|
8b5e2f2cd2 | ||
|
|
75f63ecfcd | ||
|
|
e7ea053c4a | ||
|
|
1df58d04b1 | ||
|
|
75fdd6054d | ||
|
|
f76cc6036e | ||
|
|
86bf79aa2b | ||
|
|
7416809077 | ||
|
|
25ae59b9eb | ||
|
|
9b150194f6 | ||
|
|
31246ecd04 | ||
|
|
85593d8d25 | ||
|
|
083eb7679b | ||
|
|
44580e2233 | ||
|
|
42bdf44658 | ||
|
|
970249a3c7 | ||
|
|
8c432c7c9b | ||
|
|
8c1d80fdfd | ||
|
|
aea5d3a842 | ||
|
|
fa1c688342 | ||
|
|
139639d25e | ||
|
|
317c04fe17 | ||
|
|
8996ac1a9c | ||
|
|
2cd95fac73 | ||
|
|
b16bc7b01c | ||
|
|
b704de9bf8 | ||
|
|
585d0800dd | ||
|
|
70b51f12cd | ||
|
|
d6d82dbd3c | ||
|
|
fbc9072a5c | ||
|
|
7fa64cce7d | ||
|
|
ab1474b5de | ||
|
|
0765a83a8c | ||
|
|
96abbbb6fb | ||
|
|
e24edada24 | ||
|
|
253f8de8cd | ||
|
|
babfbe8d6d | ||
|
|
4664090b34 | ||
|
|
b22c92368f | ||
|
|
32ddfc2740 | ||
|
|
732554be04 | ||
|
|
f384a6291e | ||
|
|
8de5c29e2c | ||
|
|
7889e7757a | ||
|
|
2dc92e7de1 | ||
|
|
a37c59b43e | ||
|
|
cbdfe96905 | ||
|
|
4c0ec86176 | ||
|
|
e2b3b7a2ae | ||
|
|
8502517d80 | ||
|
|
c01db5fbdd | ||
|
|
c6dea6ee78 | ||
|
|
35a6361b24 | ||
|
|
07d7a5fd76 | ||
|
|
c06a9ffe5c | ||
|
|
f1267730ef | ||
|
|
979b17165b | ||
|
|
b6f10780c2 | ||
|
|
03b2b5b77b | ||
|
|
6bdef1f70b | ||
|
|
3a9a8d2113 | ||
|
|
83c113896e | ||
|
|
997700c4aa | ||
|
|
ac0a527976 | ||
|
|
8999f06025 | ||
|
|
ddcbd4bb7d | ||
|
|
3ce46adb2a | ||
|
|
f4d82a56f4 | ||
|
|
7dbc93c62a | ||
|
|
1d2466889a | ||
|
|
845d2b193a | ||
|
|
69ec85f491 | ||
|
|
2603a2891b | ||
|
|
f99dae03cb | ||
|
|
60cf42cb8d | ||
|
|
3f0fa9f707 | ||
|
|
53de6d94ea | ||
|
|
07d6a0385f | ||
|
|
2d7adcb22f | ||
|
|
3c85afbb43 | ||
|
|
dacc20ee48 | ||
|
|
b29e9d37e7 | ||
|
|
8bcf753127 | ||
|
|
6e39cc316f | ||
|
|
e34385634b | ||
|
|
c5eabb28b4 | ||
|
|
5827b6e1aa | ||
|
|
cf2cdc191d | ||
|
|
7c54630a2d | ||
|
|
30b3657a66 | ||
|
|
67195618d5 | ||
|
|
3dbf4a1002 | ||
|
|
e0b457d3c3 | ||
|
|
d09c35f506 | ||
|
|
995314f91f | ||
|
|
4781297b4e | ||
|
|
6d83f3f021 | ||
|
|
e1120cb74d | ||
|
|
8755aeb348 | ||
|
|
f6fdfd16f5 | ||
|
|
455d36c4c7 | ||
|
|
b2a1348adc | ||
|
|
6aee08ac3c | ||
|
|
dff0fb5690 | ||
|
|
f3cc20050e | ||
|
|
c6a6631efc | ||
|
|
993bcec088 | ||
|
|
0971c7ae77 | ||
|
|
9a7d0e489c | ||
|
|
48ee73bfa7 | ||
|
|
725751fd6c | ||
|
|
663059ac5c | ||
|
|
ec5f17b2ce | ||
|
|
b05cb3b2bf | ||
|
|
a97f6f8668 | ||
|
|
08874d6b9e | ||
|
|
04619a9b13 | ||
|
|
b858be345a | ||
|
|
dc74a50225 | ||
|
|
c7ded0618c | ||
|
|
5f0d54c209 | ||
|
|
b781a23c44 | ||
|
|
9c3c9b7f5f | ||
|
|
76bd2e2d72 | ||
|
|
3dbe7313d1 | ||
|
|
1a2627031d | ||
|
|
9bd6271570 | ||
|
|
01cb8033a4 | ||
|
|
a89c56dcf1 | ||
|
|
9c65207936 | ||
|
|
431156f6c4 | ||
|
|
5f15ee95dc | ||
|
|
fc9f50d940 | ||
|
|
4035badd20 | ||
|
|
9643915093 | ||
|
|
857f24a5e2 | ||
|
|
5ce5ce6edb | ||
|
|
4cbadc3c49 | ||
|
|
56f565b601 | ||
|
|
a8c0e16e47 | ||
|
|
aa521fb385 | ||
|
|
0882cf0fc3 | ||
|
|
0dd9a68eb7 | ||
|
|
1b2830b929 | ||
|
|
60e4ce20b8 | ||
|
|
85824d2cd9 | ||
|
|
ec32c1d4b6 | ||
|
|
f0c0376660 | ||
|
|
5cd7bc2848 | ||
|
|
c7a8afbb8d | ||
|
|
6a24515269 | ||
|
|
c34e6f25b1 | ||
|
|
1a623bb266 | ||
|
|
0fbfef9649 | ||
|
|
050617ae0e | ||
|
|
04f4dd3dc7 | ||
|
|
2be786709b | ||
|
|
61c20bd06a | ||
|
|
065c5839b5 | ||
|
|
a9f9b0da9d |
7
.gitignore
vendored
7
.gitignore
vendored
@@ -10,6 +10,12 @@
|
||||
*.pidb
|
||||
*.dll.build
|
||||
*.dll
|
||||
|
||||
# Ignore .user and .suo files as these are user preference specific
|
||||
# http://stackoverflow.com/questions/72298/should-i-add-the-visual-studio-suo-and-user-files-to-source-control
|
||||
*.suo
|
||||
*.user
|
||||
|
||||
*.VisualState.xml
|
||||
*/*/obj
|
||||
*/*/*/obj
|
||||
@@ -65,7 +71,6 @@ bin/crashes/
|
||||
Examples/*.dll
|
||||
OpenSim.build
|
||||
OpenSim.sln
|
||||
OpenSim.suo
|
||||
OpenSim.userprefs
|
||||
Prebuild/Prebuild.build
|
||||
Prebuild/Prebuild.sln
|
||||
|
||||
@@ -19,10 +19,14 @@ Prereqs:
|
||||
|
||||
From the distribution type:
|
||||
* ./runprebuild.sh
|
||||
* nant (or xbuild)
|
||||
* nant (or !* xbuild)
|
||||
* cd bin
|
||||
* copy OpenSim.ini.example to OpenSim.ini and other appropriate files in bin/config-include
|
||||
* run mono OpenSim.exe
|
||||
!* xbuild option switches
|
||||
!* clean: xbuild /target:clean
|
||||
!* debug: (default) xbuild /property:Configuration=Debug
|
||||
!* release: xbuild /property:Configuration=Release
|
||||
|
||||
# Using Monodevelop
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<<<>>>>The following people have contributed to OpenSim (Thank you
|
||||
for your effort!)
|
||||
The following people have contributed to OpenSim (Thank you for your effort!)
|
||||
|
||||
= Current OpenSim Developers (in very rough order of appearance) =
|
||||
These folks represent the current core team for OpenSim, and are the
|
||||
@@ -7,16 +6,18 @@ people that make the day to day of OpenSim happen.
|
||||
|
||||
* justincc (OSVW Consulting, justincc.org)
|
||||
* chi11ken (Genkii)
|
||||
* dahlia
|
||||
* dahlia
|
||||
* Melanie Thielker
|
||||
* Diva (Crista Lopes, University of California, Irvine)
|
||||
* Dan Lake (Intel)
|
||||
* Dan Lake
|
||||
* Marck
|
||||
* Mic Bowman (Intel)
|
||||
* Mic Bowman
|
||||
* BlueWall (James Hughes)
|
||||
* Nebadon Izumi (Michael Cerquoni, OSgrid)
|
||||
* Snoopy Pfeffer
|
||||
* Robert Adams (Intel)
|
||||
* Robert Adams
|
||||
* Oren Hurvitz (Kitely)
|
||||
* Kevin Cozens
|
||||
|
||||
= Core Developers Following the White Rabbit =
|
||||
Core developers who have temporarily (we hope) gone chasing the white rabbit.
|
||||
@@ -61,11 +62,13 @@ where we are today.
|
||||
These folks have contributed code patches or content to OpenSimulator to help make it
|
||||
what it is today.
|
||||
|
||||
* aduffy70
|
||||
* A_Biondi
|
||||
* aduffy70
|
||||
* Ai Austin
|
||||
* alex_carnell
|
||||
* Alan Webb (IBM)
|
||||
* Aleric
|
||||
* Alicia Raven
|
||||
* Allen Kerensky
|
||||
* BigFootAg
|
||||
* BlueWall Slade
|
||||
@@ -75,18 +78,21 @@ what it is today.
|
||||
* Chris Yeoh (IBM)
|
||||
* controlbreak
|
||||
* coyled
|
||||
* ctrlaltdavid (David Rowe)
|
||||
* Daedius
|
||||
* daTwitch
|
||||
* Dev Random
|
||||
* devalnor-#708
|
||||
* dmiles (Daxtron Labs)
|
||||
* Dong Jun Lan (IBM)
|
||||
* DoranZemlja
|
||||
* dr0b3rts
|
||||
* dslake (Intel)
|
||||
* dslake
|
||||
* FredoChaplin
|
||||
* Garmin Kawaguichi
|
||||
* Gerhard
|
||||
* Godfrey
|
||||
* Greg C.
|
||||
* Grumly57
|
||||
* GuduleLapointe
|
||||
* Ewe Loon
|
||||
@@ -95,10 +101,12 @@ what it is today.
|
||||
* Flyte Xevious
|
||||
* Garmin Kawaguichi
|
||||
* Gryc Ueusp
|
||||
* H-H-H (ginge264)
|
||||
* Hiro Lecker
|
||||
* Iain Oliver
|
||||
* Imaze Rhiano
|
||||
* Intimidated
|
||||
* Jak Daniels
|
||||
* Jeremy Bongio (IBM)
|
||||
* jhurliman
|
||||
* John R Sohn (XenReborn)
|
||||
@@ -106,25 +114,30 @@ what it is today.
|
||||
* Jon Cundill
|
||||
* Junta Kohime
|
||||
* Kayne
|
||||
* Kevin Cozens
|
||||
* kinoc (Daxtron Labs)
|
||||
* Kira
|
||||
* Kitto Flora
|
||||
* KittyLiu
|
||||
* Kurt Taylor (IBM)
|
||||
* Lani Global
|
||||
* lillith_xue
|
||||
* lkalif
|
||||
* LuciusSirnah
|
||||
* lulurun
|
||||
* M.Igarashi
|
||||
* maimedleech
|
||||
* Mana Janus
|
||||
* MarcelEdward
|
||||
* Matt Lehmann
|
||||
* Mic Bowman
|
||||
* Michelle Argus
|
||||
* Michael Cortez (The Flotsam Project, http://osflotsam.org/)
|
||||
* Micheil Merlin
|
||||
* Mike Osias (IBM)
|
||||
* Mike Pitman (IBM)
|
||||
* mikemig
|
||||
* mikkopa/_someone - RealXtend
|
||||
* Misterblue (Intel)
|
||||
* Misterblue
|
||||
* Mircea Kitsune
|
||||
* mpallari
|
||||
* MrMonkE
|
||||
@@ -133,7 +146,6 @@ what it is today.
|
||||
* nornalbion
|
||||
* Omar Vera Ustariz (IBM)
|
||||
* openlifegrid.com
|
||||
* Oren Hurvitz (Kitely)
|
||||
* otakup0pe
|
||||
* Pixel Tomsen
|
||||
* ralphos
|
||||
@@ -142,6 +154,7 @@ what it is today.
|
||||
* Richard Alimi (IBM)
|
||||
* Rick Alther (IBM)
|
||||
* Rob Smart (IBM)
|
||||
* Roger Kirkman (zadark)
|
||||
* rtomita
|
||||
* Ruud Lathorp
|
||||
* SachaMagne
|
||||
@@ -170,23 +183,18 @@ what it is today.
|
||||
* Zha Ewry
|
||||
* ziah
|
||||
|
||||
|
||||
= LSL Devs =
|
||||
|
||||
* Alondria
|
||||
* CharlieO
|
||||
* Tedd
|
||||
* Melanie Thielker
|
||||
|
||||
|
||||
= Testers =
|
||||
|
||||
* Ai Austin
|
||||
* CharlieO (LSL)
|
||||
* Ckrinke
|
||||
* openlifegrid.com
|
||||
|
||||
|
||||
This software uses components from the following developers:
|
||||
* Sleepycat Software (Berkeley DB)
|
||||
* Aurora-Sim (http://aurora-sim.org)
|
||||
|
||||
@@ -56,8 +56,8 @@ namespace OpenSim.Groups
|
||||
private IGroupsServicesConnector m_groupData = null;
|
||||
|
||||
// Config Options
|
||||
private bool m_groupMessagingEnabled = false;
|
||||
private bool m_debugEnabled = true;
|
||||
private bool m_groupMessagingEnabled;
|
||||
private bool m_debugEnabled;
|
||||
|
||||
/// <summary>
|
||||
/// If enabled, module only tries to send group IMs to online users by querying cached presence information.
|
||||
@@ -83,7 +83,6 @@ namespace OpenSim.Groups
|
||||
private Dictionary<UUID, List<string>> m_groupsAgentsDroppedFromChatSession = new Dictionary<UUID, List<string>>();
|
||||
private Dictionary<UUID, List<string>> m_groupsAgentsInvitedToChatSession = new Dictionary<UUID, List<string>>();
|
||||
|
||||
|
||||
#region Region Module interfaceBase Members
|
||||
|
||||
public void Initialise(IConfigSource config)
|
||||
@@ -111,9 +110,17 @@ namespace OpenSim.Groups
|
||||
m_messageOnlineAgentsOnly = groupsConfig.GetBoolean("MessageOnlineUsersOnly", false);
|
||||
|
||||
if (m_messageOnlineAgentsOnly)
|
||||
{
|
||||
m_usersOnlineCache = new ExpiringCache<UUID, PresenceInfo[]>();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.Error("[Groups.Messaging]: GroupsMessagingModule V2 requires MessageOnlineUsersOnly = true");
|
||||
m_groupMessagingEnabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true);
|
||||
m_debugEnabled = groupsConfig.GetBoolean("MessagingDebugEnabled", m_debugEnabled);
|
||||
|
||||
m_log.InfoFormat(
|
||||
"[Groups.Messaging]: GroupsMessagingModule enabled with MessageOnlineOnly = {0}, DebugEnabled = {1}",
|
||||
@@ -133,6 +140,14 @@ namespace OpenSim.Groups
|
||||
scene.EventManager.OnMakeChildAgent += OnMakeChildAgent;
|
||||
scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
|
||||
scene.EventManager.OnClientLogin += OnClientLogin;
|
||||
|
||||
scene.AddCommand(
|
||||
"Debug",
|
||||
this,
|
||||
"debug groups messaging verbose",
|
||||
"debug groups messaging verbose <true|false>",
|
||||
"This setting turns on very verbose groups messaging debugging",
|
||||
HandleDebugGroupsMessagingVerbose);
|
||||
}
|
||||
|
||||
public void RegionLoaded(Scene scene)
|
||||
@@ -172,10 +187,8 @@ namespace OpenSim.Groups
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (m_presenceService == null)
|
||||
m_presenceService = scene.PresenceService;
|
||||
|
||||
}
|
||||
|
||||
public void RemoveRegion(Scene scene)
|
||||
@@ -222,6 +235,25 @@ namespace OpenSim.Groups
|
||||
|
||||
#endregion
|
||||
|
||||
private void HandleDebugGroupsMessagingVerbose(object modules, string[] args)
|
||||
{
|
||||
if (args.Length < 5)
|
||||
{
|
||||
MainConsole.Instance.Output("Usage: debug groups messaging verbose <true|false>");
|
||||
return;
|
||||
}
|
||||
|
||||
bool verbose = false;
|
||||
if (!bool.TryParse(args[4], out verbose))
|
||||
{
|
||||
MainConsole.Instance.Output("Usage: debug groups messaging verbose <true|false>");
|
||||
return;
|
||||
}
|
||||
|
||||
m_debugEnabled = verbose;
|
||||
|
||||
MainConsole.Instance.OutputFormat("{0} verbose logging set to {1}", Name, m_debugEnabled);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Not really needed, but does confirm that the group exists.
|
||||
@@ -242,11 +274,23 @@ namespace OpenSim.Groups
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void SendMessageToGroup(GridInstantMessage im, UUID groupID)
|
||||
{
|
||||
SendMessageToGroup(im, groupID, UUID.Zero, null);
|
||||
}
|
||||
|
||||
public void SendMessageToGroup(
|
||||
GridInstantMessage im, UUID groupID, UUID sendingAgentForGroupCalls, Func<GroupMembersData, bool> sendCondition)
|
||||
{
|
||||
int requestStartTick = Environment.TickCount;
|
||||
|
||||
UUID fromAgentID = new UUID(im.fromAgentID);
|
||||
|
||||
// Unlike current XmlRpcGroups, Groups V2 can accept UUID.Zero when a perms check for the requesting agent
|
||||
// is not necessary.
|
||||
List<GroupMembersData> groupMembers = m_groupData.GetGroupMembers(UUID.Zero.ToString(), groupID);
|
||||
|
||||
int groupMembersCount = groupMembers.Count;
|
||||
PresenceInfo[] onlineAgents = null;
|
||||
|
||||
@@ -254,7 +298,7 @@ namespace OpenSim.Groups
|
||||
// Sending to offline members is not an option.
|
||||
string[] t1 = groupMembers.ConvertAll<string>(gmd => gmd.AgentID.ToString()).ToArray();
|
||||
|
||||
// We cache in order not to overwhlem the presence service on large grids with many groups. This does
|
||||
// We cache in order not to overwhelm the presence service on large grids with many groups. This does
|
||||
// mean that members coming online will not see all group members until after m_usersOnlineCacheExpirySeconds has elapsed.
|
||||
// (assuming this is the same across all grid simulators).
|
||||
if (!m_usersOnlineCache.TryGetValue(groupID, out onlineAgents))
|
||||
@@ -273,8 +317,6 @@ namespace OpenSim.Groups
|
||||
// "[Groups.Messaging]: SendMessageToGroup called for group {0} with {1} visible members, {2} online",
|
||||
// groupID, groupMembersCount, groupMembers.Count());
|
||||
|
||||
int requestStartTick = Environment.TickCount;
|
||||
|
||||
im.imSessionID = groupID.Guid;
|
||||
im.fromGroup = true;
|
||||
IClientAPI thisClient = GetActiveClient(fromAgentID);
|
||||
@@ -299,12 +341,27 @@ namespace OpenSim.Groups
|
||||
|
||||
if (clientsAlreadySent.Contains(member.AgentID))
|
||||
continue;
|
||||
|
||||
clientsAlreadySent.Add(member.AgentID);
|
||||
|
||||
if (hasAgentDroppedGroupChatSession(member.AgentID.ToString(), groupID))
|
||||
if (sendCondition != null)
|
||||
{
|
||||
if (!sendCondition(member))
|
||||
{
|
||||
if (m_debugEnabled)
|
||||
m_log.DebugFormat(
|
||||
"[Groups.Messaging]: Not sending to {0} as they do not fulfill send condition",
|
||||
member.AgentID);
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (hasAgentDroppedGroupChatSession(member.AgentID.ToString(), groupID))
|
||||
{
|
||||
// Don't deliver messages to people who have dropped this session
|
||||
if (m_debugEnabled) m_log.DebugFormat("[Groups.Messaging]: {0} has dropped session, not delivering to them", member.AgentID);
|
||||
if (m_debugEnabled)
|
||||
m_log.DebugFormat("[Groups.Messaging]: {0} has dropped session, not delivering to them", member.AgentID);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,9 +45,6 @@ namespace OpenSim.Groups
|
||||
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GroupsModule")]
|
||||
public class GroupsModule : ISharedRegionModule, IGroupsModule
|
||||
{
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
|
||||
private static readonly ILog m_log =
|
||||
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
@@ -104,7 +101,7 @@ namespace OpenSim.Groups
|
||||
{
|
||||
scene.RegisterModuleInterface<IGroupsModule>(this);
|
||||
scene.AddCommand(
|
||||
"debug",
|
||||
"Debug",
|
||||
this,
|
||||
"debug groups verbose",
|
||||
"debug groups verbose <true|false>",
|
||||
@@ -466,6 +463,7 @@ namespace OpenSim.Groups
|
||||
OnNewGroupNotice(GroupID, NoticeID);
|
||||
}
|
||||
|
||||
|
||||
// Send notice out to everyone that wants notices
|
||||
foreach (GroupMembersData member in m_groupData.GetGroupMembers(GetRequestingAgentIDStr(remoteClient), GroupID))
|
||||
{
|
||||
@@ -498,12 +496,13 @@ namespace OpenSim.Groups
|
||||
Util.ParseUniversalUserIdentifier(notice.noticeData.AttachmentOwnerID, out giver, out tmp, out tmp, out tmp, out tmp);
|
||||
|
||||
m_log.DebugFormat("[Groups]: Giving inventory from {0} to {1}", giver, remoteClient.AgentId);
|
||||
string message;
|
||||
InventoryItemBase itemCopy = ((Scene)(remoteClient.Scene)).GiveInventoryItem(remoteClient.AgentId,
|
||||
giver, notice.noticeData.AttachmentItemID);
|
||||
giver, notice.noticeData.AttachmentItemID, out message);
|
||||
|
||||
if (itemCopy == null)
|
||||
{
|
||||
remoteClient.SendAgentAlertMessage("Can't find item to give. Nothing given.", false);
|
||||
remoteClient.SendAgentAlertMessage(message, false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace OpenSim.Groups
|
||||
Dictionary<string, object> sendData = new Dictionary<string, object>();
|
||||
if (GroupID != UUID.Zero)
|
||||
sendData["GroupID"] = GroupID.ToString();
|
||||
if (GroupName != null && GroupName != string.Empty)
|
||||
if (!string.IsNullOrEmpty(GroupName))
|
||||
sendData["Name"] = GroupsDataUtils.Sanitize(GroupName);
|
||||
|
||||
sendData["RequestingAgentID"] = RequestingAgentID;
|
||||
@@ -275,7 +275,7 @@ namespace OpenSim.Groups
|
||||
|
||||
//m_log.DebugFormat("[XXX]: reply was {0}", reply);
|
||||
|
||||
if (reply == string.Empty || reply == null)
|
||||
if (string.IsNullOrEmpty(reply))
|
||||
return null;
|
||||
|
||||
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
@@ -560,7 +560,7 @@ namespace OpenSim.Groups
|
||||
|
||||
// so we have the list of urls to send the notice to
|
||||
// this may take a long time...
|
||||
Util.FireAndForget(delegate
|
||||
Util.RunThreadNoTimeout(delegate
|
||||
{
|
||||
foreach (string u in urls)
|
||||
{
|
||||
@@ -571,7 +571,7 @@ namespace OpenSim.Groups
|
||||
hasAttachment, attType, attName, attItemID, AgentUUIForOutside(attOwnerID));
|
||||
}
|
||||
}
|
||||
});
|
||||
}, "AddGroupNotice", null);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -623,10 +623,13 @@ namespace OpenSim.Groups
|
||||
if (agent != null)
|
||||
break;
|
||||
}
|
||||
if (agent == null) // oops
|
||||
return AgentID.ToString();
|
||||
if (agent != null)
|
||||
return Util.ProduceUserUniversalIdentifier(agent);
|
||||
|
||||
// we don't know anything about this foreign user
|
||||
// try asking the user management module, which may know more
|
||||
return m_UserManagement.GetUserUUI(AgentID);
|
||||
|
||||
return Util.ProduceUserUniversalIdentifier(agent);
|
||||
}
|
||||
|
||||
private string AgentUUIForOutside(string AgentIDStr)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
@@ -158,7 +158,7 @@ namespace OpenSim.Groups
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.DebugFormat("[Groups.RobustHGConnector]: Exception {0}", e.StackTrace);
|
||||
m_log.Error(string.Format("[Groups.RobustHGConnector]: Exception {0} ", e.Message), e);
|
||||
}
|
||||
|
||||
return FailureResult();
|
||||
|
||||
@@ -30,7 +30,7 @@ using Mono.Addins;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("0.7.6.*")]
|
||||
[assembly: AssemblyVersion("0.8.1.*")]
|
||||
|
||||
[assembly: Addin("OpenSim.Groups", "0.1")]
|
||||
[assembly: AddinDependency("OpenSim", "0.5")]
|
||||
|
||||
@@ -32,27 +32,47 @@ using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.ServiceAuth;
|
||||
using OpenSim.Server.Base;
|
||||
|
||||
using OpenMetaverse;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
|
||||
namespace OpenSim.Groups
|
||||
{
|
||||
public class GroupsServiceRemoteConnector
|
||||
public class GroupsServiceRemoteConnector
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private string m_ServerURI;
|
||||
private IServiceAuth m_Auth;
|
||||
private object m_Lock = new object();
|
||||
|
||||
public GroupsServiceRemoteConnector(string url)
|
||||
public GroupsServiceRemoteConnector(IConfigSource config)
|
||||
{
|
||||
IConfig groupsConfig = config.Configs["Groups"];
|
||||
string url = groupsConfig.GetString("GroupsServerURI", string.Empty);
|
||||
if (!Uri.IsWellFormedUriString(url, UriKind.Absolute))
|
||||
throw new Exception(string.Format("[Groups.RemoteConnector]: Malformed groups server URL {0}. Fix it or disable the Groups feature.", url));
|
||||
|
||||
m_ServerURI = url;
|
||||
if (!m_ServerURI.EndsWith("/"))
|
||||
m_ServerURI += "/";
|
||||
|
||||
m_log.DebugFormat("[Groups.RemoteConnector]: Groups server at {0}", m_ServerURI);
|
||||
/// This is from BaseServiceConnector
|
||||
string authType = Util.GetConfigVarFromSections<string>(config, "AuthType", new string[] { "Network", "Groups" }, "None");
|
||||
|
||||
switch (authType)
|
||||
{
|
||||
case "BasicHttpAuthentication":
|
||||
m_Auth = new BasicHttpAuthentication(config, "Groups");
|
||||
break;
|
||||
}
|
||||
///
|
||||
|
||||
m_log.DebugFormat("[Groups.RemoteConnector]: Groups server at {0}, authentication {1}",
|
||||
m_ServerURI, (m_Auth == null ? "None" : m_Auth.GetType().ToString()));
|
||||
}
|
||||
|
||||
public ExtendedGroupRecord CreateGroup(string RequestingAgentID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment,
|
||||
@@ -106,7 +126,7 @@ namespace OpenSim.Groups
|
||||
sendData["OP"] = "UPDATE";
|
||||
Dictionary<string, object> ret = MakeRequest("PUTGROUP", sendData);
|
||||
|
||||
if (ret == null || (ret != null && ret["RESULT"].ToString() == "NULL"))
|
||||
if (ret == null || (ret != null && (!ret.ContainsKey("RESULT") || ret["RESULT"].ToString() == "NULL")))
|
||||
return null;
|
||||
|
||||
return GroupsDataUtils.GroupRecord((Dictionary<string, object>)ret["RESULT"]);
|
||||
@@ -120,14 +140,14 @@ namespace OpenSim.Groups
|
||||
Dictionary<string, object> sendData = new Dictionary<string, object>();
|
||||
if (GroupID != UUID.Zero)
|
||||
sendData["GroupID"] = GroupID.ToString();
|
||||
if (GroupName != null && GroupName != string.Empty)
|
||||
if (!string.IsNullOrEmpty(GroupName))
|
||||
sendData["Name"] = GroupsDataUtils.Sanitize(GroupName);
|
||||
|
||||
sendData["RequestingAgentID"] = RequestingAgentID;
|
||||
|
||||
Dictionary<string, object> ret = MakeRequest("GETGROUP", sendData);
|
||||
|
||||
if (ret == null || (ret != null && ret["RESULT"].ToString() == "NULL"))
|
||||
if (ret == null || (ret != null && (!ret.ContainsKey("RESULT") || ret["RESULT"].ToString() == "NULL")))
|
||||
return null;
|
||||
|
||||
return GroupsDataUtils.GroupRecord((Dictionary<string, object>)ret["RESULT"]);
|
||||
@@ -267,6 +287,7 @@ namespace OpenSim.Groups
|
||||
|
||||
if (ret["RESULT"].ToString() == "NULL")
|
||||
return members;
|
||||
|
||||
foreach (object v in ((Dictionary<string, object>)ret["RESULT"]).Values)
|
||||
{
|
||||
ExtendedGroupMembersData m = GroupsDataUtils.GroupMembersData((Dictionary<string, object>)v);
|
||||
@@ -357,6 +378,7 @@ namespace OpenSim.Groups
|
||||
|
||||
if (ret["RESULT"].ToString() == "NULL")
|
||||
return roles;
|
||||
|
||||
foreach (object v in ((Dictionary<string, object>)ret["RESULT"]).Values)
|
||||
{
|
||||
GroupRolesData m = GroupsDataUtils.GroupRolesData((Dictionary<string, object>)v);
|
||||
@@ -657,7 +679,8 @@ namespace OpenSim.Groups
|
||||
lock (m_Lock)
|
||||
reply = SynchronousRestFormsRequester.MakeRequest("POST",
|
||||
m_ServerURI + "groups",
|
||||
ServerUtils.BuildQueryString(sendData));
|
||||
ServerUtils.BuildQueryString(sendData),
|
||||
m_Auth);
|
||||
|
||||
if (reply == string.Empty)
|
||||
return null;
|
||||
@@ -667,7 +690,7 @@ namespace OpenSim.Groups
|
||||
|
||||
return replyData;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,12 +72,7 @@ namespace OpenSim.Groups
|
||||
|
||||
private void Init(IConfigSource config)
|
||||
{
|
||||
IConfig groupsConfig = config.Configs["Groups"];
|
||||
string url = groupsConfig.GetString("GroupsServerURI", string.Empty);
|
||||
if (!Uri.IsWellFormedUriString(url, UriKind.Absolute))
|
||||
throw new Exception(string.Format("[Groups.RemoteConnector]: Malformed groups server URL {0}. Fix it or disable the Groups feature.", url));
|
||||
|
||||
m_GroupsService = new GroupsServiceRemoteConnector(url);
|
||||
m_GroupsService = new GroupsServiceRemoteConnector(config);
|
||||
m_Scenes = new List<Scene>();
|
||||
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ using OpenSim.Framework;
|
||||
using OpenSim.Server.Base;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Framework.ServiceAuth;
|
||||
using OpenSim.Server.Handlers.Base;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
@@ -52,14 +53,26 @@ namespace OpenSim.Groups
|
||||
public GroupsServiceRobustConnector(IConfigSource config, IHttpServer server, string configName) :
|
||||
base(config, server, configName)
|
||||
{
|
||||
string key = string.Empty;
|
||||
if (configName != String.Empty)
|
||||
m_ConfigName = configName;
|
||||
|
||||
m_log.DebugFormat("[Groups.RobustConnector]: Starting with config name {0}", m_ConfigName);
|
||||
|
||||
IConfig groupsConfig = config.Configs[m_ConfigName];
|
||||
if (groupsConfig != null)
|
||||
{
|
||||
key = groupsConfig.GetString("SecretKey", string.Empty);
|
||||
m_log.DebugFormat("[Groups.RobustConnector]: Starting with secret key {0}", key);
|
||||
}
|
||||
// else
|
||||
// m_log.DebugFormat("[Groups.RobustConnector]: Unable to find {0} section in configuration", m_ConfigName);
|
||||
|
||||
m_GroupsService = new GroupsService(config);
|
||||
|
||||
server.AddStreamHandler(new GroupsServicePostHandler(m_GroupsService));
|
||||
IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName);
|
||||
|
||||
server.AddStreamHandler(new GroupsServicePostHandler(m_GroupsService, auth));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,8 +82,8 @@ namespace OpenSim.Groups
|
||||
|
||||
private GroupsService m_GroupsService;
|
||||
|
||||
public GroupsServicePostHandler(GroupsService service) :
|
||||
base("POST", "/groups")
|
||||
public GroupsServicePostHandler(GroupsService service, IServiceAuth auth) :
|
||||
base("POST", "/groups", auth)
|
||||
{
|
||||
m_GroupsService = service;
|
||||
}
|
||||
@@ -96,7 +109,7 @@ namespace OpenSim.Groups
|
||||
string method = request["METHOD"].ToString();
|
||||
request.Remove("METHOD");
|
||||
|
||||
m_log.DebugFormat("[Groups.Handler]: {0}", method);
|
||||
// m_log.DebugFormat("[Groups.Handler]: {0}", method);
|
||||
switch (method)
|
||||
{
|
||||
case "PUTGROUP":
|
||||
@@ -140,7 +153,7 @@ namespace OpenSim.Groups
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.DebugFormat("[GROUPS HANDLER]: Exception {0}", e.StackTrace);
|
||||
m_log.Error(string.Format("[GROUPS HANDLER]: Exception {0} ", e.Message), e);
|
||||
}
|
||||
|
||||
return FailureResult();
|
||||
@@ -652,7 +665,11 @@ namespace OpenSim.Groups
|
||||
GroupInviteInfo invite = m_GroupsService.GetAgentToGroupInvite(request["RequestingAgentID"].ToString(),
|
||||
new UUID(request["InviteID"].ToString()));
|
||||
|
||||
result["RESULT"] = GroupsDataUtils.GroupInviteInfo(invite);
|
||||
if (invite != null)
|
||||
result["RESULT"] = GroupsDataUtils.GroupInviteInfo(invite);
|
||||
else
|
||||
result["RESULT"] = "NULL";
|
||||
|
||||
return Util.UTF8NoBomEncoding.GetBytes(ServerUtils.BuildXmlResponse(result));
|
||||
}
|
||||
|
||||
@@ -784,6 +801,14 @@ namespace OpenSim.Groups
|
||||
string xmlString = ServerUtils.BuildXmlResponse(result);
|
||||
return Util.UTF8NoBomEncoding.GetBytes(xmlString);
|
||||
}
|
||||
|
||||
private byte[] FailureResult(string reason)
|
||||
{
|
||||
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||
NullResult(result, reason);
|
||||
string xmlString = ServerUtils.BuildXmlResponse(result);
|
||||
return Util.UTF8NoBomEncoding.GetBytes(xmlString);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace OpenSim.OfflineIM
|
||||
if (serviceLocation == string.Empty)
|
||||
m_OfflineIMService = new OfflineIMService(config);
|
||||
else
|
||||
m_OfflineIMService = new OfflineIMServiceRemoteConnector(serviceLocation);
|
||||
m_OfflineIMService = new OfflineIMServiceRemoteConnector(config);
|
||||
|
||||
m_ForwardOfflineGroupMessages = cnf.GetBoolean("ForwardOfflineGroupMessages", m_ForwardOfflineGroupMessages);
|
||||
m_log.DebugFormat("[OfflineIM.V2]: Offline messages enabled by {0}", Name);
|
||||
@@ -226,10 +226,6 @@ namespace OpenSim.OfflineIM
|
||||
return;
|
||||
}
|
||||
|
||||
Scene scene = FindScene(new UUID(im.fromAgentID));
|
||||
if (scene == null)
|
||||
scene = m_SceneList[0];
|
||||
|
||||
string reason = string.Empty;
|
||||
bool success = m_OfflineIMService.StoreMessage(im, out reason);
|
||||
|
||||
@@ -261,6 +257,11 @@ namespace OpenSim.OfflineIM
|
||||
return m_OfflineIMService.StoreMessage(im, out reason);
|
||||
}
|
||||
|
||||
public void DeleteMessages(UUID userID)
|
||||
{
|
||||
m_OfflineIMService.DeleteMessages(userID);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ using Mono.Addins;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("0.7.6.*")]
|
||||
[assembly: AssemblyVersion("0.8.1.*")]
|
||||
|
||||
[assembly: Addin("OpenSim.OfflineIM", "0.1")]
|
||||
[assembly: AddinDependency("OpenSim", "0.5")]
|
||||
|
||||
@@ -32,6 +32,7 @@ using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.ServiceAuth;
|
||||
using OpenSim.Server.Base;
|
||||
using OpenSim.Services.Interfaces;
|
||||
|
||||
@@ -46,6 +47,7 @@ namespace OpenSim.OfflineIM
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private string m_ServerURI = string.Empty;
|
||||
private IServiceAuth m_Auth;
|
||||
private object m_Lock = new object();
|
||||
|
||||
public OfflineIMServiceRemoteConnector(string url)
|
||||
@@ -65,6 +67,18 @@ namespace OpenSim.OfflineIM
|
||||
|
||||
m_ServerURI = cnf.GetString("OfflineMessageURL", string.Empty);
|
||||
|
||||
/// This is from BaseServiceConnector
|
||||
string authType = Util.GetConfigVarFromSections<string>(config, "AuthType", new string[] { "Network", "Messaging" }, "None");
|
||||
|
||||
switch (authType)
|
||||
{
|
||||
case "BasicHttpAuthentication":
|
||||
m_Auth = new BasicHttpAuthentication(config, "Messaging");
|
||||
break;
|
||||
}
|
||||
///
|
||||
m_log.DebugFormat("[OfflineIM.V2.RemoteConnector]: Offline IM server at {0} with auth {1}",
|
||||
m_ServerURI, (m_Auth == null ? "None" : m_Auth.GetType().ToString()));
|
||||
}
|
||||
|
||||
#region IOfflineIMService
|
||||
@@ -82,8 +96,13 @@ namespace OpenSim.OfflineIM
|
||||
if (!ret.ContainsKey("RESULT"))
|
||||
return ims;
|
||||
|
||||
if (ret["RESULT"].ToString() == "NULL")
|
||||
string result = ret["RESULT"].ToString();
|
||||
if (result == "NULL" || result.ToLower() == "false")
|
||||
{
|
||||
string reason = ret.ContainsKey("REASON") ? ret["REASON"].ToString() : "Unknown error";
|
||||
m_log.DebugFormat("[OfflineIM.V2.RemoteConnector]: GetMessages for {0} failed: {1}", principalID, reason);
|
||||
return ims;
|
||||
}
|
||||
|
||||
foreach (object v in ((Dictionary<string, object>)ret["RESULT"]).Values)
|
||||
{
|
||||
@@ -110,13 +129,21 @@ namespace OpenSim.OfflineIM
|
||||
string result = ret["RESULT"].ToString();
|
||||
if (result == "NULL" || result.ToLower() == "false")
|
||||
{
|
||||
reason = ret["REASON"].ToString();
|
||||
reason = ret.ContainsKey("REASON") ? ret["REASON"].ToString() : "Unknown error";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void DeleteMessages(UUID userID)
|
||||
{
|
||||
Dictionary<string, object> sendData = new Dictionary<string, object>();
|
||||
sendData["UserID"] = userID;
|
||||
|
||||
MakeRequest("DELETE", sendData);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -130,7 +157,8 @@ namespace OpenSim.OfflineIM
|
||||
lock (m_Lock)
|
||||
reply = SynchronousRestFormsRequester.MakeRequest("POST",
|
||||
m_ServerURI + "/offlineim",
|
||||
ServerUtils.BuildQueryString(sendData));
|
||||
ServerUtils.BuildQueryString(sendData),
|
||||
m_Auth);
|
||||
|
||||
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(
|
||||
reply);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
@@ -36,6 +36,7 @@ using OpenSim.Framework;
|
||||
using OpenSim.Server.Base;
|
||||
using OpenSim.Services.Interfaces;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Framework.ServiceAuth;
|
||||
using OpenSim.Server.Handlers.Base;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
@@ -59,7 +60,9 @@ namespace OpenSim.OfflineIM
|
||||
|
||||
m_OfflineIMService = new OfflineIMService(config);
|
||||
|
||||
server.AddStreamHandler(new OfflineIMServicePostHandler(m_OfflineIMService));
|
||||
IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName);
|
||||
|
||||
server.AddStreamHandler(new OfflineIMServicePostHandler(m_OfflineIMService, auth));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,8 +72,8 @@ namespace OpenSim.OfflineIM
|
||||
|
||||
private IOfflineIMService m_OfflineIMService;
|
||||
|
||||
public OfflineIMServicePostHandler(IOfflineIMService service) :
|
||||
base("POST", "/offlineim")
|
||||
public OfflineIMServicePostHandler(IOfflineIMService service, IServiceAuth auth) :
|
||||
base("POST", "/offlineim", auth)
|
||||
{
|
||||
m_OfflineIMService = service;
|
||||
}
|
||||
@@ -96,19 +99,20 @@ namespace OpenSim.OfflineIM
|
||||
string method = request["METHOD"].ToString();
|
||||
request.Remove("METHOD");
|
||||
|
||||
m_log.DebugFormat("[OfflineIM.V2.Handler]: {0}", method);
|
||||
switch (method)
|
||||
{
|
||||
case "GET":
|
||||
return HandleGet(request);
|
||||
case "STORE":
|
||||
return HandleStore(request);
|
||||
case "DELETE":
|
||||
return HandleDelete(request);
|
||||
}
|
||||
m_log.DebugFormat("[OFFLINE IM HANDLER]: unknown method request: {0}", method);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.DebugFormat("[OFFLINE IM HANDLER]: Exception {0}", e.StackTrace);
|
||||
m_log.Error(string.Format("[OFFLINE IM HANDLER]: Exception {0} ", e.Message), e);
|
||||
}
|
||||
|
||||
return FailureResult();
|
||||
@@ -159,6 +163,21 @@ namespace OpenSim.OfflineIM
|
||||
return Util.UTF8NoBomEncoding.GetBytes(xmlString);
|
||||
}
|
||||
|
||||
byte[] HandleDelete(Dictionary<string, object> request)
|
||||
{
|
||||
if (!request.ContainsKey("UserID"))
|
||||
{
|
||||
return FailureResult();
|
||||
}
|
||||
else
|
||||
{
|
||||
UUID userID = new UUID(request["UserID"].ToString());
|
||||
m_OfflineIMService.DeleteMessages(userID);
|
||||
|
||||
return SuccessResult();
|
||||
}
|
||||
}
|
||||
|
||||
#region Helpers
|
||||
|
||||
private void NullResult(Dictionary<string, object> result, string reason)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
@@ -91,7 +91,7 @@ namespace OpenSim.OfflineIM
|
||||
{
|
||||
reason = string.Empty;
|
||||
|
||||
// TODO Check limits
|
||||
// Check limits
|
||||
UUID principalID = new UUID(im.toAgentID);
|
||||
long count = m_Database.GetCount("PrincipalID", principalID.ToString());
|
||||
if (count >= MAX_IM)
|
||||
@@ -100,32 +100,36 @@ namespace OpenSim.OfflineIM
|
||||
return false;
|
||||
}
|
||||
|
||||
string imXml = string.Empty;
|
||||
string imXml;
|
||||
using (MemoryStream mstream = new MemoryStream())
|
||||
{
|
||||
XmlWriterSettings settings = new XmlWriterSettings();
|
||||
settings.Encoding = Encoding.UTF8;
|
||||
settings.Encoding = Util.UTF8NoBomEncoding;
|
||||
|
||||
using (XmlWriter writer = XmlWriter.Create(mstream, settings))
|
||||
{
|
||||
m_serializer.Serialize(writer, im);
|
||||
writer.Flush();
|
||||
|
||||
mstream.Position = 0;
|
||||
using (StreamReader sreader = new StreamReader(mstream))
|
||||
{
|
||||
imXml = sreader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
imXml = Util.UTF8NoBomEncoding.GetString(mstream.ToArray());
|
||||
}
|
||||
|
||||
OfflineIMData data = new OfflineIMData();
|
||||
data.PrincipalID = principalID;
|
||||
data.FromID = new UUID(im.fromAgentID);
|
||||
data.Data = new Dictionary<string, string>();
|
||||
data.Data["Message"] = imXml;
|
||||
|
||||
return m_Database.Store(data);
|
||||
|
||||
}
|
||||
|
||||
public void DeleteMessages(UUID userID)
|
||||
{
|
||||
m_Database.Delete("PrincipalID", userID.ToString());
|
||||
m_Database.Delete("FromID", userID.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ using OpenSim.Region.CoreModules.Avatar.InstantMessage;
|
||||
using OpenSim.Region.CoreModules.Scripting.DynamicTexture;
|
||||
using OpenSim.Region.CoreModules.Scripting.LoadImageURL;
|
||||
using OpenSim.Region.CoreModules.Scripting.XMLRPC;
|
||||
using OpenSim.Services.Interfaces;
|
||||
|
||||
namespace OpenSim.ApplicationPlugins.LoadRegions
|
||||
{
|
||||
@@ -130,7 +131,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
|
||||
createdScenes.Add(scene);
|
||||
|
||||
if (changed)
|
||||
regionsToLoad[i].EstateSettings.Save();
|
||||
m_openSim.EstateDataService.StoreEstateSettings(regionsToLoad[i].EstateSettings);
|
||||
}
|
||||
|
||||
foreach (IScene scene in createdScenes)
|
||||
|
||||
@@ -62,4 +62,4 @@ using System.Runtime.InteropServices;
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("0.7.6.*")]
|
||||
|
||||
[assembly : AssemblyVersion("0.7.6.*")]
|
||||
[assembly : AssemblyVersion("0.8.1.*")]
|
||||
|
||||
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("0.7.6.*")]
|
||||
[assembly: AssemblyVersion("0.8.1.*")]
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ using log4net;
|
||||
using Mono.Addins;
|
||||
using Nini.Config;
|
||||
using OpenSim;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
@@ -45,6 +46,12 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
|
||||
LogManager.GetLogger(
|
||||
MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
/// <summary>
|
||||
/// Controls whether we load modules from Mono.Addins.
|
||||
/// </summary>
|
||||
/// <remarks>For debug purposes. Defaults to true.</remarks>
|
||||
public bool LoadModulesFromAddins { get; set; }
|
||||
|
||||
// Config access
|
||||
private OpenSimBase m_openSim;
|
||||
|
||||
@@ -61,6 +68,11 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
|
||||
private List<ISharedRegionModule> m_sharedInstances =
|
||||
new List<ISharedRegionModule>();
|
||||
|
||||
public RegionModulesControllerPlugin()
|
||||
{
|
||||
LoadModulesFromAddins = true;
|
||||
}
|
||||
|
||||
#region IApplicationPlugin implementation
|
||||
|
||||
public void Initialise (OpenSimBase openSim)
|
||||
@@ -69,6 +81,9 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
|
||||
m_openSim.ApplicationRegistry.RegisterInterface<IRegionModulesController>(this);
|
||||
m_log.DebugFormat("[REGIONMODULES]: Initializing...");
|
||||
|
||||
if (!LoadModulesFromAddins)
|
||||
return;
|
||||
|
||||
// Who we are
|
||||
string id = AddinManager.CurrentAddin.Id;
|
||||
|
||||
@@ -88,40 +103,8 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
|
||||
Dictionary<RuntimeAddin, IList<int>> loadedModules = new Dictionary<RuntimeAddin, IList<int>>();
|
||||
|
||||
// Scan modules and load all that aren't disabled
|
||||
foreach (TypeExtensionNode node in
|
||||
AddinManager.GetExtensionNodes("/OpenSim/RegionModules"))
|
||||
{
|
||||
IList<int> loadedModuleData;
|
||||
|
||||
if (!loadedModules.ContainsKey(node.Addin))
|
||||
loadedModules.Add(node.Addin, new List<int> { 0, 0, 0 });
|
||||
|
||||
loadedModuleData = loadedModules[node.Addin];
|
||||
|
||||
if (node.Type.GetInterface(typeof(ISharedRegionModule).ToString()) != null)
|
||||
{
|
||||
if (CheckModuleEnabled(node, modulesConfig))
|
||||
{
|
||||
m_log.DebugFormat("[REGIONMODULES]: Found shared region module {0}, class {1}", node.Id, node.Type);
|
||||
m_sharedModules.Add(node);
|
||||
loadedModuleData[0]++;
|
||||
}
|
||||
}
|
||||
else if (node.Type.GetInterface(typeof(INonSharedRegionModule).ToString()) != null)
|
||||
{
|
||||
if (CheckModuleEnabled(node, modulesConfig))
|
||||
{
|
||||
m_log.DebugFormat("[REGIONMODULES]: Found non-shared region module {0}, class {1}", node.Id, node.Type);
|
||||
m_nonSharedModules.Add(node);
|
||||
loadedModuleData[1]++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.WarnFormat("[REGIONMODULES]: Found unknown type of module {0}, class {1}", node.Id, node.Type);
|
||||
loadedModuleData[2]++;
|
||||
}
|
||||
}
|
||||
foreach (TypeExtensionNode node in AddinManager.GetExtensionNodes("/OpenSim/RegionModules"))
|
||||
AddNode(node, modulesConfig, loadedModules);
|
||||
|
||||
foreach (KeyValuePair<RuntimeAddin, IList<int>> loadedModuleData in loadedModules)
|
||||
{
|
||||
@@ -194,6 +177,41 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
|
||||
|
||||
#region IPlugin implementation
|
||||
|
||||
private void AddNode(
|
||||
TypeExtensionNode node, IConfig modulesConfig, Dictionary<RuntimeAddin, IList<int>> loadedModules)
|
||||
{
|
||||
IList<int> loadedModuleData;
|
||||
|
||||
if (!loadedModules.ContainsKey(node.Addin))
|
||||
loadedModules.Add(node.Addin, new List<int> { 0, 0, 0 });
|
||||
|
||||
loadedModuleData = loadedModules[node.Addin];
|
||||
|
||||
if (node.Type.GetInterface(typeof(ISharedRegionModule).ToString()) != null)
|
||||
{
|
||||
if (CheckModuleEnabled(node, modulesConfig))
|
||||
{
|
||||
m_log.DebugFormat("[REGIONMODULES]: Found shared region module {0}, class {1}", node.Id, node.Type);
|
||||
m_sharedModules.Add(node);
|
||||
loadedModuleData[0]++;
|
||||
}
|
||||
}
|
||||
else if (node.Type.GetInterface(typeof(INonSharedRegionModule).ToString()) != null)
|
||||
{
|
||||
if (CheckModuleEnabled(node, modulesConfig))
|
||||
{
|
||||
m_log.DebugFormat("[REGIONMODULES]: Found non-shared region module {0}, class {1}", node.Id, node.Type);
|
||||
m_nonSharedModules.Add(node);
|
||||
loadedModuleData[1]++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.WarnFormat("[REGIONMODULES]: Found unknown type of module {0}, class {1}", node.Id, node.Type);
|
||||
loadedModuleData[2]++;
|
||||
}
|
||||
}
|
||||
|
||||
// We don't do that here
|
||||
//
|
||||
public void Initialise ()
|
||||
@@ -215,6 +233,7 @@ namespace OpenSim.ApplicationPlugins.RegionModulesController
|
||||
m_sharedInstances[0].Close();
|
||||
m_sharedInstances.RemoveAt(0);
|
||||
}
|
||||
|
||||
m_sharedModules.Clear();
|
||||
m_nonSharedModules.Clear();
|
||||
}
|
||||
|
||||
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("0.7.6.*")]
|
||||
[assembly: AssemblyVersion("0.8.1.*")]
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Net;
|
||||
@@ -51,6 +52,7 @@ using OpenSim.Services.Interfaces;
|
||||
using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
|
||||
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
|
||||
using PermissionMask = OpenSim.Framework.PermissionMask;
|
||||
using RegionInfo = OpenSim.Framework.RegionInfo;
|
||||
|
||||
namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
{
|
||||
@@ -145,6 +147,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
availableMethods["admin_create_user_email"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcCreateUserMethod);
|
||||
availableMethods["admin_exists_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcUserExistsMethod);
|
||||
availableMethods["admin_update_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcUpdateUserAccountMethod);
|
||||
availableMethods["admin_authenticate_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAuthenticateUserMethod);
|
||||
|
||||
// Region state management
|
||||
availableMethods["admin_load_xml"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcLoadXMLMethod);
|
||||
@@ -159,6 +162,9 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
availableMethods["admin_acl_list"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListList);
|
||||
availableMethods["admin_estate_reload"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcEstateReload);
|
||||
|
||||
// Land management
|
||||
availableMethods["admin_reset_land"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcResetLand);
|
||||
|
||||
// Either enable full remote functionality or just selected features
|
||||
string enabledMethods = m_config.GetString("enabled_methods", "all");
|
||||
|
||||
@@ -691,7 +697,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
region.EstateSettings.EstateName = (string) requestData["estate_name"];
|
||||
region.EstateSettings.EstateOwner = userID;
|
||||
// Persistence does not seem to effect the need to save a new estate
|
||||
region.EstateSettings.Save();
|
||||
m_application.EstateDataService.StoreEstateSettings(region.EstateSettings);
|
||||
|
||||
if (!m_application.EstateDataService.LinkRegion(region.RegionID, (int) region.EstateSettings.EstateID))
|
||||
throw new Exception("Failed to join estate.");
|
||||
@@ -721,7 +727,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
// If an access specification was provided, use it.
|
||||
// Otherwise accept the default.
|
||||
newScene.RegionInfo.EstateSettings.PublicAccess = GetBoolean(requestData, "public", m_publicAccess);
|
||||
newScene.RegionInfo.EstateSettings.Save();
|
||||
m_application.EstateDataService.StoreEstateSettings(newScene.RegionInfo.EstateSettings);
|
||||
|
||||
// enable voice on newly created region if
|
||||
// requested by either the XmlRpc request or the
|
||||
@@ -907,7 +913,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
scene.RegionInfo.EstateSettings.PublicAccess =
|
||||
GetBoolean(requestData,"public", scene.RegionInfo.EstateSettings.PublicAccess);
|
||||
if (scene.RegionInfo.Persistent)
|
||||
scene.RegionInfo.EstateSettings.Save();
|
||||
m_application.EstateDataService.StoreEstateSettings(scene.RegionInfo.EstateSettings);
|
||||
|
||||
if (requestData.ContainsKey("enable_voice"))
|
||||
{
|
||||
@@ -1019,7 +1025,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
// Set home position
|
||||
|
||||
GridRegion home = scene.GridService.GetRegionByPosition(scopeID,
|
||||
(int)(regionXLocation * Constants.RegionSize), (int)(regionYLocation * Constants.RegionSize));
|
||||
(int)Util.RegionToWorldLoc(regionXLocation), (int)Util.RegionToWorldLoc(regionYLocation));
|
||||
if (null == home)
|
||||
{
|
||||
m_log.WarnFormat("[RADMIN]: Unable to set home region for newly created user account {0} {1}", firstName, lastName);
|
||||
@@ -1249,7 +1255,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
if ((null != regionXLocation) && (null != regionYLocation))
|
||||
{
|
||||
GridRegion home = scene.GridService.GetRegionByPosition(scopeID,
|
||||
(int)(regionXLocation * Constants.RegionSize), (int)(regionYLocation * Constants.RegionSize));
|
||||
(int)Util.RegionToWorldLoc((uint)regionXLocation), (int)Util.RegionToWorldLoc((uint)regionYLocation));
|
||||
if (null == home) {
|
||||
m_log.WarnFormat("[RADMIN]: Unable to set home region for updated user account {0} {1}", firstName, lastName);
|
||||
} else {
|
||||
@@ -1280,6 +1286,139 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Authenticate an user.
|
||||
/// <summary>
|
||||
/// <param name="request">incoming XML RPC request</param>
|
||||
/// <remarks>
|
||||
/// XmlRpcAuthenticateUserMethod takes the following XMLRPC
|
||||
/// parameters
|
||||
/// <list type="table">
|
||||
/// <listheader><term>parameter name</term><description>description</description></listheader>
|
||||
/// <item><term>password</term>
|
||||
/// <description>admin password as set in OpenSim.ini</description></item>
|
||||
/// <item><term>user_firstname</term>
|
||||
/// <description>avatar's first name</description></item>
|
||||
/// <item><term>user_lastname</term>
|
||||
/// <description>avatar's last name</description></item>
|
||||
/// <item><term>user_password</term>
|
||||
/// <description>MD5 hash of avatar's password</description></item>
|
||||
/// <item><term>token_lifetime</term>
|
||||
/// <description>the lifetime of the returned token (upper bounded to 30s)</description></item>
|
||||
/// </list>
|
||||
///
|
||||
/// XmlRpcAuthenticateUserMethod returns
|
||||
/// <list type="table">
|
||||
/// <listheader><term>name</term><description>description</description></listheader>
|
||||
/// <item><term>success</term>
|
||||
/// <description>true or false</description></item>
|
||||
/// <item><term>token</term>
|
||||
/// <description>the authentication token sent by OpenSim</description></item>
|
||||
/// <item><term>error</term>
|
||||
/// <description>error message if success is false</description></item>
|
||||
/// </list>
|
||||
/// </remarks>
|
||||
private void XmlRpcAuthenticateUserMethod(XmlRpcRequest request, XmlRpcResponse response,
|
||||
IPEndPoint remoteClient)
|
||||
{
|
||||
m_log.Info("[RADMIN]: AuthenticateUser: new request");
|
||||
|
||||
var responseData = (Hashtable)response.Value;
|
||||
var requestData = (Hashtable)request.Params[0];
|
||||
|
||||
lock (m_requestLock)
|
||||
{
|
||||
try
|
||||
{
|
||||
CheckStringParameters(requestData, responseData, new[]
|
||||
{
|
||||
"user_firstname",
|
||||
"user_lastname",
|
||||
"user_password",
|
||||
"token_lifetime"
|
||||
});
|
||||
|
||||
var firstName = (string)requestData["user_firstname"];
|
||||
var lastName = (string)requestData["user_lastname"];
|
||||
var password = (string)requestData["user_password"];
|
||||
|
||||
var scene = m_application.SceneManager.CurrentOrFirstScene;
|
||||
|
||||
if (scene.Equals(null))
|
||||
{
|
||||
m_log.Debug("scene does not exist");
|
||||
throw new Exception("Scene does not exist.");
|
||||
}
|
||||
|
||||
var scopeID = scene.RegionInfo.ScopeID;
|
||||
var account = scene.UserAccountService.GetUserAccount(scopeID, firstName, lastName);
|
||||
|
||||
if (account.Equals(null) || account.PrincipalID.Equals(UUID.Zero))
|
||||
{
|
||||
m_log.DebugFormat("avatar {0} {1} does not exist", firstName, lastName);
|
||||
throw new Exception(String.Format("avatar {0} {1} does not exist", firstName, lastName));
|
||||
}
|
||||
|
||||
if (String.IsNullOrEmpty(password))
|
||||
{
|
||||
m_log.DebugFormat("[RADMIN]: AuthenticateUser: no password provided for {0} {1}", firstName,
|
||||
lastName);
|
||||
throw new Exception(String.Format("no password provided for {0} {1}", firstName,
|
||||
lastName));
|
||||
}
|
||||
|
||||
int lifetime;
|
||||
if (int.TryParse((string)requestData["token_lifetime"], NumberStyles.Integer, CultureInfo.InvariantCulture, out lifetime) == false)
|
||||
{
|
||||
m_log.DebugFormat("[RADMIN]: AuthenticateUser: no token lifetime provided for {0} {1}", firstName,
|
||||
lastName);
|
||||
throw new Exception(String.Format("no token lifetime provided for {0} {1}", firstName,
|
||||
lastName));
|
||||
}
|
||||
|
||||
// Upper bound on lifetime set to 30s.
|
||||
if (lifetime > 30)
|
||||
{
|
||||
m_log.DebugFormat("[RADMIN]: AuthenticateUser: token lifetime longer than 30s for {0} {1}", firstName,
|
||||
lastName);
|
||||
throw new Exception(String.Format("token lifetime longer than 30s for {0} {1}", firstName,
|
||||
lastName));
|
||||
}
|
||||
|
||||
var authModule = scene.RequestModuleInterface<IAuthenticationService>();
|
||||
if (authModule == null)
|
||||
{
|
||||
m_log.Debug("[RADMIN]: AuthenticateUser: no authentication module loded");
|
||||
throw new Exception("no authentication module loaded");
|
||||
}
|
||||
|
||||
var token = authModule.Authenticate(account.PrincipalID, password, lifetime);
|
||||
if (String.IsNullOrEmpty(token))
|
||||
{
|
||||
m_log.DebugFormat("[RADMIN]: AuthenticateUser: authentication failed for {0} {1}", firstName,
|
||||
lastName);
|
||||
throw new Exception(String.Format("authentication failed for {0} {1}", firstName,
|
||||
lastName));
|
||||
}
|
||||
|
||||
m_log.DebugFormat("[RADMIN]: AuthenticateUser: account for user {0} {1} identified with token {2}",
|
||||
firstName, lastName, token);
|
||||
|
||||
responseData["token"] = token;
|
||||
responseData["success"] = true;
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
responseData["success"] = false;
|
||||
responseData["error"] = e.Message;
|
||||
throw e;
|
||||
}
|
||||
|
||||
m_log.Info("[RADMIN]: AuthenticateUser: request complete");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load an OAR file into a region..
|
||||
/// <summary>
|
||||
@@ -1348,8 +1487,11 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
}
|
||||
|
||||
IRegionArchiverModule archiver = scene.RequestModuleInterface<IRegionArchiverModule>();
|
||||
Dictionary<string, object> archiveOptions = new Dictionary<string,object>();
|
||||
if (mergeOar) archiveOptions.Add("merge", null);
|
||||
if (skipAssets) archiveOptions.Add("skipAssets", null);
|
||||
if (archiver != null)
|
||||
archiver.DearchiveRegion(filename, mergeOar, skipAssets, Guid.Empty);
|
||||
archiver.DearchiveRegion(filename, Guid.Empty, archiveOptions);
|
||||
else
|
||||
throw new Exception("Archiver module not present for scene");
|
||||
|
||||
@@ -1408,7 +1550,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
/// </remarks>
|
||||
private void XmlRpcSaveOARMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
|
||||
{
|
||||
m_log.Info("[RADMIN]: Received Save OAR Administrator Request");
|
||||
m_log.Info("[RADMIN]: Received Save OAR Request");
|
||||
|
||||
Hashtable responseData = (Hashtable)response.Value;
|
||||
Hashtable requestData = (Hashtable)request.Params[0];
|
||||
@@ -1454,8 +1596,14 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
|
||||
if (archiver != null)
|
||||
{
|
||||
Guid requestId = Guid.NewGuid();
|
||||
scene.EventManager.OnOarFileSaved += RemoteAdminOarSaveCompleted;
|
||||
archiver.ArchiveRegion(filename, options);
|
||||
|
||||
m_log.InfoFormat(
|
||||
"[RADMIN]: Submitting save OAR request for {0} to file {1}, request ID {2}",
|
||||
scene.Name, filename, requestId);
|
||||
|
||||
archiver.ArchiveRegion(filename, requestId, options);
|
||||
|
||||
lock (m_saveOarLock)
|
||||
Monitor.Wait(m_saveOarLock,5000);
|
||||
@@ -1476,12 +1624,16 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
throw e;
|
||||
}
|
||||
|
||||
m_log.Info("[RADMIN]: Save OAR Administrator Request complete");
|
||||
m_log.Info("[RADMIN]: Save OAR Request complete");
|
||||
}
|
||||
|
||||
private void RemoteAdminOarSaveCompleted(Guid uuid, string name)
|
||||
{
|
||||
m_log.DebugFormat("[RADMIN]: File processing complete for {0}", name);
|
||||
if (name != "")
|
||||
m_log.ErrorFormat("[RADMIN]: Saving of OAR file with request ID {0} failed with message {1}", uuid, name);
|
||||
else
|
||||
m_log.DebugFormat("[RADMIN]: Saved OAR file for request {0}", uuid);
|
||||
|
||||
lock (m_saveOarLock)
|
||||
Monitor.Pulse(m_saveOarLock);
|
||||
}
|
||||
@@ -1643,7 +1795,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
scene.RegionInfo.EstateSettings.EstateAccess = new UUID[]{};
|
||||
|
||||
if (scene.RegionInfo.Persistent)
|
||||
scene.RegionInfo.EstateSettings.Save();
|
||||
m_application.EstateDataService.StoreEstateSettings(scene.RegionInfo.EstateSettings);
|
||||
|
||||
m_log.Info("[RADMIN]: Access List Clear Request complete");
|
||||
}
|
||||
@@ -1689,7 +1841,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
}
|
||||
scene.RegionInfo.EstateSettings.EstateAccess = accessControlList.ToArray();
|
||||
if (scene.RegionInfo.Persistent)
|
||||
scene.RegionInfo.EstateSettings.Save();
|
||||
m_application.EstateDataService.StoreEstateSettings(scene.RegionInfo.EstateSettings);
|
||||
}
|
||||
|
||||
responseData["added"] = addedUsers;
|
||||
@@ -1738,7 +1890,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
}
|
||||
scene.RegionInfo.EstateSettings.EstateAccess = accessControlList.ToArray();
|
||||
if (scene.RegionInfo.Persistent)
|
||||
scene.RegionInfo.EstateSettings.Save();
|
||||
m_application.EstateDataService.StoreEstateSettings(scene.RegionInfo.EstateSettings);
|
||||
}
|
||||
|
||||
responseData["removed"] = removedUsers;
|
||||
@@ -1914,6 +2066,56 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
responseData["success"] = true;
|
||||
}
|
||||
|
||||
private void XmlRpcResetLand(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
|
||||
{
|
||||
Hashtable requestData = (Hashtable)request.Params[0];
|
||||
Hashtable responseData = (Hashtable)response.Value;
|
||||
|
||||
string musicURL = string.Empty;
|
||||
UUID groupID = UUID.Zero;
|
||||
uint flags = 0;
|
||||
bool set_group = false, set_music = false, set_flags = false;
|
||||
|
||||
if (requestData.Contains("group") && requestData["group"] != null)
|
||||
set_group = UUID.TryParse(requestData["group"].ToString(), out groupID);
|
||||
if (requestData.Contains("music") && requestData["music"] != null)
|
||||
{
|
||||
musicURL = requestData["music"].ToString();
|
||||
set_music = true;
|
||||
}
|
||||
if (requestData.Contains("flags") && requestData["flags"] != null)
|
||||
set_flags = UInt32.TryParse(requestData["flags"].ToString(), out flags);
|
||||
|
||||
m_log.InfoFormat("[RADMIN]: Received Reset Land Request group={0} musicURL={1} flags={2}",
|
||||
(set_group ? groupID.ToString() : "unchanged"),
|
||||
(set_music ? musicURL : "unchanged"),
|
||||
(set_flags ? flags.ToString() : "unchanged"));
|
||||
|
||||
m_application.SceneManager.ForEachScene(delegate(Scene s)
|
||||
{
|
||||
List<ILandObject> parcels = s.LandChannel.AllParcels();
|
||||
foreach (ILandObject p in parcels)
|
||||
{
|
||||
if (set_music)
|
||||
p.LandData.MusicURL = musicURL;
|
||||
|
||||
if (set_group)
|
||||
p.LandData.GroupID = groupID;
|
||||
|
||||
if (set_flags)
|
||||
p.LandData.Flags = flags;
|
||||
|
||||
s.LandChannel.UpdateLandObject(p.LandData.LocalID, p.LandData);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
responseData["success"] = true;
|
||||
|
||||
m_log.Info("[RADMIN]: Reset Land Request complete");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Parse a float with the given parameter name from a request data hash table.
|
||||
/// </summary>
|
||||
@@ -2089,7 +2291,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
{
|
||||
account.ServiceURLs = new Dictionary<string, object>();
|
||||
account.ServiceURLs["HomeURI"] = string.Empty;
|
||||
account.ServiceURLs["GatekeeperURI"] = string.Empty;
|
||||
account.ServiceURLs["InventoryServerURI"] = string.Empty;
|
||||
account.ServiceURLs["AssetServerURI"] = string.Empty;
|
||||
}
|
||||
@@ -2617,15 +2818,13 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
/// </summary>
|
||||
private void ApplyNextOwnerPermissions(InventoryItemBase item)
|
||||
{
|
||||
if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0)
|
||||
if (item.InvType == (int)InventoryType.Object)
|
||||
{
|
||||
if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0)
|
||||
item.CurrentPermissions &= ~(uint)PermissionMask.Copy;
|
||||
if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0)
|
||||
item.CurrentPermissions &= ~(uint)PermissionMask.Transfer;
|
||||
if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0)
|
||||
item.CurrentPermissions &= ~(uint)PermissionMask.Modify;
|
||||
uint perms = item.CurrentPermissions;
|
||||
PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref perms);
|
||||
item.CurrentPermissions = perms;
|
||||
}
|
||||
|
||||
item.CurrentPermissions &= item.NextPermissions;
|
||||
item.BasePermissions &= item.NextPermissions;
|
||||
item.EveryOnePermissions &= item.NextPermissions;
|
||||
@@ -2737,7 +2936,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||
// Set home position
|
||||
|
||||
GridRegion home = scene.GridService.GetRegionByPosition(scopeID,
|
||||
(int)(regionXLocation * Constants.RegionSize), (int)(regionYLocation * Constants.RegionSize));
|
||||
(int)Util.RegionToWorldLoc(regionXLocation), (int)Util.RegionToWorldLoc(regionYLocation));
|
||||
if (null == home) {
|
||||
m_log.WarnFormat("[RADMIN]: Unable to set home region for newly created user account {0} {1}", names[0], names[1]);
|
||||
} else {
|
||||
|
||||
@@ -50,8 +50,7 @@ namespace OpenSim.Framework.Capabilities
|
||||
|
||||
public class Caps
|
||||
{
|
||||
// private static readonly ILog m_log =
|
||||
// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private string m_httpListenerHostName;
|
||||
private uint m_httpListenPort;
|
||||
@@ -152,6 +151,10 @@ namespace OpenSim.Framework.Capabilities
|
||||
|
||||
public void RegisterPollHandler(string capName, PollServiceEventArgs pollServiceHandler)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[CAPS]: Registering handler with name {0}, url {1} for {2}",
|
||||
// capName, pollServiceHandler.Url, m_agentID, m_regionName);
|
||||
|
||||
m_pollServiceHandlers.Add(capName, pollServiceHandler);
|
||||
|
||||
m_httpListener.AddPollServiceHTTPHandler(pollServiceHandler.Url, pollServiceHandler);
|
||||
|
||||
@@ -56,12 +56,15 @@ namespace OpenSim.Capabilities.Handlers
|
||||
public const string DefaultFormat = "x-j2c";
|
||||
|
||||
// TODO: Change this to a config option
|
||||
const string REDIRECT_URL = null;
|
||||
private string m_RedirectURL = null;
|
||||
|
||||
public GetTextureHandler(string path, IAssetService assService, string name, string description)
|
||||
public GetTextureHandler(string path, IAssetService assService, string name, string description, string redirectURL)
|
||||
: base("GET", path, name, description)
|
||||
{
|
||||
m_assetService = assService;
|
||||
m_RedirectURL = redirectURL;
|
||||
if (m_RedirectURL != null && !m_RedirectURL.EndsWith("/"))
|
||||
m_RedirectURL += "/";
|
||||
}
|
||||
|
||||
protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
@@ -85,7 +88,7 @@ namespace OpenSim.Capabilities.Handlers
|
||||
// m_log.DebugFormat("[GETTEXTURE]: Received request for texture id {0}", textureID);
|
||||
|
||||
string[] formats;
|
||||
if (format != null && format != string.Empty)
|
||||
if (!string.IsNullOrEmpty(format))
|
||||
{
|
||||
formats = new string[1] { format.ToLower() };
|
||||
}
|
||||
@@ -134,7 +137,7 @@ namespace OpenSim.Capabilities.Handlers
|
||||
if (format != DefaultFormat)
|
||||
fullID = fullID + "-" + format;
|
||||
|
||||
if (!String.IsNullOrEmpty(REDIRECT_URL))
|
||||
if (!String.IsNullOrEmpty(m_RedirectURL))
|
||||
{
|
||||
// Only try to fetch locally cached textures. Misses are redirected
|
||||
texture = m_assetService.GetCached(fullID);
|
||||
@@ -150,8 +153,9 @@ namespace OpenSim.Capabilities.Handlers
|
||||
}
|
||||
else
|
||||
{
|
||||
string textureUrl = REDIRECT_URL + textureID.ToString();
|
||||
string textureUrl = m_RedirectURL + "?texture_id="+ textureID.ToString();
|
||||
m_log.Debug("[GETTEXTURE]: Redirecting texture request to " + textureUrl);
|
||||
httpResponse.StatusCode = (int)OSHttpStatusCode.RedirectMovedPermanently;
|
||||
httpResponse.RedirectLocation = textureUrl;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -62,8 +62,10 @@ namespace OpenSim.Capabilities.Handlers
|
||||
if (m_AssetService == null)
|
||||
throw new Exception(String.Format("Failed to load AssetService from {0}; config is {1}", assetService, m_ConfigName));
|
||||
|
||||
string rurl = serverConfig.GetString("GetTextureRedirectURL");
|
||||
;
|
||||
server.AddStreamHandler(
|
||||
new GetTextureHandler("/CAPS/GetTexture/" /*+ UUID.Random() */, m_AssetService, "GetTexture", null));
|
||||
new GetTextureHandler("/CAPS/GetTexture/" /*+ UUID.Random() */, m_AssetService, "GetTexture", null, rurl));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ namespace OpenSim.Capabilities.Handlers.GetTexture.Tests
|
||||
// Overkill - we only really need the asset service, not a whole scene.
|
||||
Scene scene = new SceneHelpers().SetupScene();
|
||||
|
||||
GetTextureHandler handler = new GetTextureHandler(null, scene.AssetService, "TestGetTexture", null);
|
||||
GetTextureHandler handler = new GetTextureHandler(null, scene.AssetService, "TestGetTexture", null, null);
|
||||
TestOSHttpRequest req = new TestOSHttpRequest();
|
||||
TestOSHttpResponse resp = new TestOSHttpResponse();
|
||||
req.Url = new Uri("http://localhost/?texture_id=00000000-0000-1111-9999-000000000012");
|
||||
|
||||
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("0.7.6.*")]
|
||||
[assembly: AssemblyVersion("0.8.1.*")]
|
||||
|
||||
|
||||
@@ -238,7 +238,15 @@ namespace OpenSim.Capabilities.Handlers
|
||||
|
||||
if (folderID != UUID.Zero)
|
||||
{
|
||||
contents = m_InventoryService.GetFolderContent(agentID, folderID);
|
||||
InventoryCollection fetchedContents = m_InventoryService.GetFolderContent(agentID, folderID);
|
||||
|
||||
if (fetchedContents == null)
|
||||
{
|
||||
m_log.WarnFormat("[WEB FETCH INV DESC HANDLER]: Could not get contents of folder {0} for user {1}", folderID, agentID);
|
||||
return contents;
|
||||
}
|
||||
|
||||
contents = fetchedContents;
|
||||
InventoryFolderBase containingFolder = new InventoryFolderBase();
|
||||
containingFolder.ID = folderID;
|
||||
containingFolder.Owner = agentID;
|
||||
|
||||
@@ -37,9 +37,8 @@ namespace OpenSim.Data
|
||||
public abstract class AssetDataBase : IAssetDataPlugin
|
||||
{
|
||||
public abstract AssetBase GetAsset(UUID uuid);
|
||||
|
||||
public abstract void StoreAsset(AssetBase asset);
|
||||
public abstract bool ExistsAsset(UUID uuid);
|
||||
public abstract bool[] AssetsExist(UUID[] uuids);
|
||||
|
||||
public abstract List<AssetMetadata> FetchAssetMetadataSet(int start, int count);
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace OpenSim.Data
|
||||
{
|
||||
AssetBase GetAsset(UUID uuid);
|
||||
void StoreAsset(AssetBase asset);
|
||||
bool ExistsAsset(UUID uuid);
|
||||
bool[] AssetsExist(UUID[] uuids);
|
||||
List<AssetMetadata> FetchAssetMetadataSet(int start, int count);
|
||||
void Initialise(string connect);
|
||||
bool Delete(string id);
|
||||
|
||||
@@ -29,7 +29,7 @@ using System.Collections.Generic;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.Region.Framework.Interfaces
|
||||
namespace OpenSim.Data
|
||||
{
|
||||
public interface IEstateDataStore
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
@@ -34,6 +34,7 @@ namespace OpenSim.Data
|
||||
public class OfflineIMData
|
||||
{
|
||||
public UUID PrincipalID;
|
||||
public UUID FromID;
|
||||
public Dictionary<string, string> Data;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,8 @@ namespace OpenSim.Data
|
||||
bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result);
|
||||
bool UpdateAvatarInterests(UserProfileProperties up, ref string result);
|
||||
bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result);
|
||||
bool UpdateUserPreferences(ref UserPreferences pref, ref string result);
|
||||
bool GetUserPreferences(ref UserPreferences pref, ref string result);
|
||||
bool GetUserAppData(ref UserAppData props, ref string result);
|
||||
bool SetUserAppData(UserAppData props, ref string result);
|
||||
OSDArray GetUserImageAssets(UUID avatarId);
|
||||
|
||||
@@ -54,12 +54,12 @@ namespace OpenSim.Data
|
||||
/// <summary>
|
||||
/// Return the x-coordinate of this region.
|
||||
/// </summary>
|
||||
public int coordX { get { return posX / (int)Constants.RegionSize; } }
|
||||
public int coordX { get { return (int)Util.WorldToRegionLoc((uint)posX); } }
|
||||
|
||||
/// <summary>
|
||||
/// Return the y-coordinate of this region.
|
||||
/// </summary>
|
||||
public int coordY { get { return posY / (int)Constants.RegionSize; } }
|
||||
public int coordY { get { return (int)Util.WorldToRegionLoc((uint)posY); } }
|
||||
|
||||
public Dictionary<string, object> Data;
|
||||
}
|
||||
@@ -81,6 +81,7 @@ namespace OpenSim.Data
|
||||
bool Delete(UUID regionID);
|
||||
|
||||
List<RegionData> GetDefaultRegions(UUID scopeID);
|
||||
List<RegionData> GetDefaultHypergridRegions(UUID scopeID);
|
||||
List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y);
|
||||
List<RegionData> GetHyperlinks(UUID scopeID);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace OpenSim.Data
|
||||
{
|
||||
AssetBase GetAsset(UUID uuid);
|
||||
void StoreAsset(AssetBase asset);
|
||||
bool ExistsAsset(UUID uuid);
|
||||
bool[] AssetsExist(UUID[] uuids);
|
||||
List<AssetMetadata> FetchAssetMetadataSet(int start, int count);
|
||||
void Initialise(string connect);
|
||||
bool Delete(string id);
|
||||
|
||||
@@ -48,9 +48,57 @@ namespace OpenSim.Data
|
||||
public ulong everyonePowers;
|
||||
public ulong ownersPowers;
|
||||
|
||||
public Dictionary<UUID, XGroupMember> members = new Dictionary<UUID, XGroupMember>();
|
||||
public Dictionary<UUID, XGroupNotice> notices = new Dictionary<UUID, XGroupNotice>();
|
||||
|
||||
public XGroup Clone()
|
||||
{
|
||||
return (XGroup)MemberwiseClone();
|
||||
XGroup clone = (XGroup)MemberwiseClone();
|
||||
clone.members = new Dictionary<UUID, XGroupMember>();
|
||||
clone.notices = new Dictionary<UUID, XGroupNotice>();
|
||||
|
||||
foreach (KeyValuePair<UUID, XGroupMember> kvp in members)
|
||||
clone.members[kvp.Key] = kvp.Value.Clone();
|
||||
|
||||
foreach (KeyValuePair<UUID, XGroupNotice> kvp in notices)
|
||||
clone.notices[kvp.Key] = kvp.Value.Clone();
|
||||
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
|
||||
public class XGroupMember
|
||||
{
|
||||
public UUID agentID;
|
||||
public UUID groupID;
|
||||
public UUID roleID;
|
||||
public bool acceptNotices = true;
|
||||
public bool listInProfile = true;
|
||||
|
||||
public XGroupMember Clone()
|
||||
{
|
||||
return (XGroupMember)MemberwiseClone();
|
||||
}
|
||||
}
|
||||
|
||||
public class XGroupNotice
|
||||
{
|
||||
public UUID groupID;
|
||||
public UUID noticeID;
|
||||
public uint timestamp;
|
||||
public string fromName;
|
||||
public string subject;
|
||||
public string message;
|
||||
public byte[] binaryBucket;
|
||||
public bool hasAttachment;
|
||||
public int assetType;
|
||||
|
||||
public XGroupNotice Clone()
|
||||
{
|
||||
XGroupNotice clone = (XGroupNotice)MemberwiseClone();
|
||||
clone.binaryBucket = (byte[])binaryBucket.Clone();
|
||||
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,14 +106,13 @@ namespace OpenSim.Data
|
||||
/// Early stub interface for groups data, not final.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Currently in-use only for regression test purposes. Needs to be filled out over time.
|
||||
/// Currently in-use only for regression test purposes.
|
||||
/// </remarks>
|
||||
public interface IXGroupData
|
||||
{
|
||||
bool StoreGroup(XGroup group);
|
||||
XGroup[] GetGroups(string field, string val);
|
||||
XGroup[] GetGroups(string[] fields, string[] vals);
|
||||
bool DeleteGroups(string field, string val);
|
||||
bool DeleteGroups(string[] fields, string[] vals);
|
||||
XGroup GetGroup(UUID groupID);
|
||||
Dictionary<UUID, XGroup> GetGroups();
|
||||
bool DeleteGroup(UUID groupID);
|
||||
}
|
||||
}
|
||||
@@ -160,18 +160,18 @@ namespace OpenSim.Data.MSSQL
|
||||
@temporary, @create_time, @access_time, @creatorid, @asset_flags, @data)";
|
||||
|
||||
string assetName = asset.Name;
|
||||
if (asset.Name.Length > 64)
|
||||
if (asset.Name.Length > AssetBase.MAX_ASSET_NAME)
|
||||
{
|
||||
assetName = asset.Name.Substring(0, 64);
|
||||
assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
|
||||
m_log.WarnFormat(
|
||||
"[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
|
||||
asset.Name, asset.ID, asset.Name.Length, assetName.Length);
|
||||
}
|
||||
|
||||
string assetDescription = asset.Description;
|
||||
if (asset.Description.Length > 64)
|
||||
if (asset.Description.Length > AssetBase.MAX_ASSET_DESC)
|
||||
{
|
||||
assetDescription = asset.Description.Substring(0, 64);
|
||||
assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC);
|
||||
m_log.WarnFormat(
|
||||
"[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
|
||||
asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
|
||||
@@ -225,17 +225,38 @@ namespace OpenSim.Data.MSSQL
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// Check if asset exist in m_database
|
||||
/// Check if the assets exist in the database.
|
||||
/// </summary>
|
||||
/// <param name="uuid"></param>
|
||||
/// <returns>true if exist.</returns>
|
||||
override public bool ExistsAsset(UUID uuid)
|
||||
/// <param name="uuids">The assets' IDs</param>
|
||||
/// <returns>For each asset: true if it exists, false otherwise</returns>
|
||||
public override bool[] AssetsExist(UUID[] uuids)
|
||||
{
|
||||
if (GetAsset(uuid) != null)
|
||||
if (uuids.Length == 0)
|
||||
return new bool[0];
|
||||
|
||||
HashSet<UUID> exist = new HashSet<UUID>();
|
||||
|
||||
string ids = "'" + string.Join("','", uuids) + "'";
|
||||
string sql = string.Format("SELECT id FROM assets WHERE id IN ({0})", ids);
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
return true;
|
||||
conn.Open();
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
UUID id = DBGuid.FromDB(reader["id"]);
|
||||
exist.Add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
bool[] results = new bool[uuids.Length];
|
||||
for (int i = 0; i < uuids.Length; i++)
|
||||
results[i] = exist.Contains(uuids[i]);
|
||||
return results;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
@@ -55,7 +55,7 @@ namespace OpenSim.Data.MSSQL
|
||||
return Delete(principalID.ToString(), friend);
|
||||
}
|
||||
|
||||
public bool Delete(string principalID, string friend)
|
||||
public override bool Delete(string principalID, string friend)
|
||||
{
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
using (SqlCommand cmd = new SqlCommand())
|
||||
|
||||
@@ -315,6 +315,11 @@ namespace OpenSim.Data.MSSQL
|
||||
return Get((int)RegionFlags.DefaultRegion, scopeID);
|
||||
}
|
||||
|
||||
public List<RegionData> GetDefaultHypergridRegions(UUID scopeID)
|
||||
{
|
||||
return Get((int)RegionFlags.DefaultHGRegion, scopeID);
|
||||
}
|
||||
|
||||
public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y)
|
||||
{
|
||||
List<RegionData> regions = Get((int)RegionFlags.FallbackRegion, scopeID);
|
||||
|
||||
@@ -49,6 +49,7 @@ namespace OpenSim.Data.MSSQL
|
||||
|
||||
// private static FileSystemDataStore Instance = new FileSystemDataStore();
|
||||
private static readonly ILog _Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private static string LogHeader = "[REGION DB MSSQL]";
|
||||
|
||||
/// <summary>
|
||||
/// The database manager
|
||||
@@ -351,7 +352,7 @@ IF EXISTS (SELECT UUID FROM prims WHERE UUID = @UUID)
|
||||
ScriptAccessPin = @ScriptAccessPin, AllowedDrop = @AllowedDrop, DieAtEdge = @DieAtEdge, SalePrice = @SalePrice,
|
||||
SaleType = @SaleType, ColorR = @ColorR, ColorG = @ColorG, ColorB = @ColorB, ColorA = @ColorA, ParticleSystem = @ParticleSystem,
|
||||
ClickAction = @ClickAction, Material = @Material, CollisionSound = @CollisionSound, CollisionSoundVolume = @CollisionSoundVolume, PassTouches = @PassTouches,
|
||||
LinkNumber = @LinkNumber, MediaURL = @MediaURL, DynAttrs = @DynAttrs,
|
||||
LinkNumber = @LinkNumber, MediaURL = @MediaURL, AttachedPosX = @AttachedPosX, AttachedPosY = @AttachedPosY, AttachedPosZ = @AttachedPosZ, DynAttrs = @DynAttrs,
|
||||
PhysicsShapeType = @PhysicsShapeType, Density = @Density, GravityModifier = @GravityModifier, Friction = @Friction, Restitution = @Restitution
|
||||
WHERE UUID = @UUID
|
||||
END
|
||||
@@ -367,7 +368,7 @@ ELSE
|
||||
PayPrice, PayButton1, PayButton2, PayButton3, PayButton4, LoopedSound, LoopedSoundGain, TextureAnimation, OmegaX,
|
||||
OmegaY, OmegaZ, CameraEyeOffsetX, CameraEyeOffsetY, CameraEyeOffsetZ, CameraAtOffsetX, CameraAtOffsetY, CameraAtOffsetZ,
|
||||
ForceMouselook, ScriptAccessPin, AllowedDrop, DieAtEdge, SalePrice, SaleType, ColorR, ColorG, ColorB, ColorA,
|
||||
ParticleSystem, ClickAction, Material, CollisionSound, CollisionSoundVolume, PassTouches, LinkNumber, MediaURL, DynAttrs,
|
||||
ParticleSystem, ClickAction, Material, CollisionSound, CollisionSoundVolume, PassTouches, LinkNumber, MediaURL, AttachedPosX, AttachedPosY, AttachedPosZ, DynAttrs,
|
||||
PhysicsShapeType, Density, GravityModifier, Friction, Restitution
|
||||
) VALUES (
|
||||
@UUID, @CreationDate, @Name, @Text, @Description, @SitName, @TouchName, @ObjectFlags, @OwnerMask, @NextOwnerMask, @GroupMask,
|
||||
@@ -378,7 +379,7 @@ ELSE
|
||||
@PayPrice, @PayButton1, @PayButton2, @PayButton3, @PayButton4, @LoopedSound, @LoopedSoundGain, @TextureAnimation, @OmegaX,
|
||||
@OmegaY, @OmegaZ, @CameraEyeOffsetX, @CameraEyeOffsetY, @CameraEyeOffsetZ, @CameraAtOffsetX, @CameraAtOffsetY, @CameraAtOffsetZ,
|
||||
@ForceMouselook, @ScriptAccessPin, @AllowedDrop, @DieAtEdge, @SalePrice, @SaleType, @ColorR, @ColorG, @ColorB, @ColorA,
|
||||
@ParticleSystem, @ClickAction, @Material, @CollisionSound, @CollisionSoundVolume, @PassTouches, @LinkNumber, @MediaURL, @DynAttrs,
|
||||
@ParticleSystem, @ClickAction, @Material, @CollisionSound, @CollisionSoundVolume, @PassTouches, @LinkNumber, @MediaURL, @AttachedPosX, @AttachedPosY, @AttachedPosZ, @DynAttrs,
|
||||
@PhysicsShapeType, @Density, @GravityModifier, @Friction, @Restitution
|
||||
)
|
||||
END";
|
||||
@@ -530,43 +531,53 @@ ELSE
|
||||
/// <returns></returns>
|
||||
public double[,] LoadTerrain(UUID regionID)
|
||||
{
|
||||
double[,] terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize];
|
||||
terrain.Initialize();
|
||||
double[,] ret = null;
|
||||
TerrainData terrData = LoadTerrain(regionID, (int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionHeight);
|
||||
if (terrData != null)
|
||||
ret = terrData.GetDoubles();
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Returns 'null' if region not found
|
||||
public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
|
||||
{
|
||||
TerrainData terrData = null;
|
||||
|
||||
string sql = "select top 1 RegionUUID, Revision, Heightfield from terrain where RegionUUID = @RegionUUID order by Revision desc";
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
// MySqlParameter param = new MySqlParameter();
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionID));
|
||||
conn.Open();
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
int rev;
|
||||
if (reader.Read())
|
||||
// MySqlParameter param = new MySqlParameter();
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionID));
|
||||
conn.Open();
|
||||
using (SqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
MemoryStream str = new MemoryStream((byte[])reader["Heightfield"]);
|
||||
BinaryReader br = new BinaryReader(str);
|
||||
for (int x = 0; x < (int)Constants.RegionSize; x++)
|
||||
int rev;
|
||||
if (reader.Read())
|
||||
{
|
||||
for (int y = 0; y < (int)Constants.RegionSize; y++)
|
||||
{
|
||||
terrain[x, y] = br.ReadDouble();
|
||||
}
|
||||
rev = (int)reader["Revision"];
|
||||
byte[] blob = (byte[])reader["Heightfield"];
|
||||
terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob);
|
||||
}
|
||||
rev = (int)reader["Revision"];
|
||||
else
|
||||
{
|
||||
_Log.Info("[REGION DB]: No terrain found for region");
|
||||
return null;
|
||||
}
|
||||
_Log.Info("[REGION DB]: Loaded terrain revision r" + rev);
|
||||
}
|
||||
else
|
||||
{
|
||||
_Log.Info("[REGION DB]: No terrain found for region");
|
||||
return null;
|
||||
}
|
||||
_Log.Info("[REGION DB]: Loaded terrain revision r" + rev);
|
||||
}
|
||||
}
|
||||
|
||||
return terrain;
|
||||
return terrData;
|
||||
}
|
||||
|
||||
// Legacy entry point for when terrain was always a 256x256 hieghtmap
|
||||
public void StoreTerrain(double[,] ter, UUID regionID)
|
||||
{
|
||||
StoreTerrain(new HeightmapTerrainData(ter), regionID);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -574,10 +585,8 @@ ELSE
|
||||
/// </summary>
|
||||
/// <param name="terrain">terrain map data.</param>
|
||||
/// <param name="regionID">regionID.</param>
|
||||
public void StoreTerrain(double[,] terrain, UUID regionID)
|
||||
public void StoreTerrain(TerrainData terrData, UUID regionID)
|
||||
{
|
||||
int revision = Util.UnixTimeSinceEpoch();
|
||||
|
||||
//Delete old terrain map
|
||||
string sql = "delete from terrain where RegionUUID=@RegionUUID";
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
@@ -590,17 +599,23 @@ ELSE
|
||||
|
||||
sql = "insert into terrain(RegionUUID, Revision, Heightfield) values(@RegionUUID, @Revision, @Heightfield)";
|
||||
|
||||
int terrainDBRevision;
|
||||
Array terrainDBblob;
|
||||
terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(m_connectionString))
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionID));
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@Revision", revision));
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@Heightfield", serializeTerrain(terrain)));
|
||||
conn.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionID));
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@Revision", terrainDBRevision));
|
||||
cmd.Parameters.Add(_Database.CreateParameter("@Heightfield", terrainDBblob));
|
||||
conn.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
_Log.Info("[REGION DB]: Stored terrain revision r " + revision);
|
||||
_Log.InfoFormat("{0} Stored terrain revision r={1}", LogHeader, terrainDBRevision);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1344,30 +1359,6 @@ VALUES
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Serializes the terrain data for storage in DB.
|
||||
/// </summary>
|
||||
/// <param name="val">terrain data</param>
|
||||
/// <returns></returns>
|
||||
private static Array serializeTerrain(double[,] val)
|
||||
{
|
||||
MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) * sizeof(double));
|
||||
BinaryWriter bw = new BinaryWriter(str);
|
||||
|
||||
// TODO: COMPATIBILITY - Add byte-order conversions
|
||||
for (int x = 0; x < (int)Constants.RegionSize; x++)
|
||||
for (int y = 0; y < (int)Constants.RegionSize; y++)
|
||||
{
|
||||
double height = val[x, y];
|
||||
if (height == 0.0)
|
||||
height = double.Epsilon;
|
||||
|
||||
bw.Write(height);
|
||||
}
|
||||
|
||||
return str.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stores new regionsettings.
|
||||
/// </summary>
|
||||
@@ -1695,6 +1686,12 @@ VALUES
|
||||
if (!(primRow["MediaURL"] is System.DBNull))
|
||||
prim.MediaUrl = (string)primRow["MediaURL"];
|
||||
|
||||
if (!(primRow["AttachedPosX"] is System.DBNull))
|
||||
prim.AttachedPos = new Vector3(
|
||||
Convert.ToSingle(primRow["AttachedPosX"]),
|
||||
Convert.ToSingle(primRow["AttachedPosY"]),
|
||||
Convert.ToSingle(primRow["AttachedPosZ"]));
|
||||
|
||||
if (!(primRow["DynAttrs"] is System.DBNull))
|
||||
prim.DynAttrs = DAMap.FromXml((string)primRow["DynAttrs"]);
|
||||
else
|
||||
@@ -2099,7 +2096,10 @@ VALUES
|
||||
parameters.Add(_Database.CreateParameter("PassTouches", 0));
|
||||
parameters.Add(_Database.CreateParameter("LinkNumber", prim.LinkNum));
|
||||
parameters.Add(_Database.CreateParameter("MediaURL", prim.MediaUrl));
|
||||
|
||||
parameters.Add(_Database.CreateParameter("AttachedPosX", prim.AttachedPos.X));
|
||||
parameters.Add(_Database.CreateParameter("AttachedPosY", prim.AttachedPos.Y));
|
||||
parameters.Add(_Database.CreateParameter("AttachedPosZ", prim.AttachedPos.Z));
|
||||
|
||||
if (prim.DynAttrs.CountNamespaces > 0)
|
||||
parameters.Add(_Database.CreateParameter("DynAttrs", prim.DynAttrs.ToXml()));
|
||||
else
|
||||
|
||||
@@ -278,7 +278,7 @@ namespace OpenSim.Data.MSSQL
|
||||
// m_log.DebugFormat("[MYSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID);
|
||||
// Util.PrintCallStack();
|
||||
|
||||
string sql = "update inventoryfolders set version=version+1 where folderID = ?folderID";
|
||||
string sql = "update inventoryfolders set version=version+1 where folderID = @folderID";
|
||||
|
||||
using (SqlConnection conn = new SqlConnection(m_ConnectionString))
|
||||
{
|
||||
|
||||
@@ -61,5 +61,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly : AssemblyVersion("0.7.6.*")]
|
||||
[assembly : AssemblyVersion("0.8.1.*")]
|
||||
|
||||
|
||||
@@ -331,4 +331,12 @@ ALTER TABLE dbo.estate_map ADD CONSTRAINT
|
||||
|
||||
COMMIT
|
||||
|
||||
:VERSION 10
|
||||
|
||||
BEGIN transaction
|
||||
|
||||
ALTER TABLE estate_settings ADD AllowLandmark tinyint NOT NULL default 1;
|
||||
ALTER TABLE estate_settings ADD AllowParcelChanges tinyint NOT NULL default 1;
|
||||
ALTER TABLE estate_settings ADD AllowSetHome tinyint NOT NULL default 1;
|
||||
|
||||
COMMIT;
|
||||
@@ -1,4 +1,4 @@
|
||||
:VERSION 1
|
||||
:VERSION 1
|
||||
|
||||
BEGIN TRANSACTION
|
||||
|
||||
@@ -26,6 +26,14 @@ COMMIT
|
||||
|
||||
BEGIN TRANSACTION
|
||||
|
||||
ALTER TABLE Presence ADD LastSeen DateTime
|
||||
ALTER TABLE Presence ADD LastSeen DateTime;
|
||||
|
||||
COMMIT
|
||||
COMMIT
|
||||
|
||||
:VERSION 3
|
||||
|
||||
BEGIN TRANSACTION
|
||||
|
||||
CREATE INDEX RegionID ON Presence(RegionID);
|
||||
|
||||
COMMIT
|
||||
|
||||
@@ -1161,10 +1161,22 @@ COMMIT
|
||||
|
||||
BEGIN TRANSACTION
|
||||
|
||||
ALTER TABLE prims ADD `PhysicsShapeType` tinyint(4) NOT NULL default '0';
|
||||
ALTER TABLE prims ADD `Density` double NOT NULL default '1000';
|
||||
ALTER TABLE prims ADD `GravityModifier` double NOT NULL default '1';
|
||||
ALTER TABLE prims ADD `Friction` double NOT NULL default '0.6';
|
||||
ALTER TABLE prims ADD `Restitution` double NOT NULL default '0.5';
|
||||
ALTER TABLE prims ADD PhysicsShapeType tinyint NOT NULL default 0;
|
||||
ALTER TABLE prims ADD Density float NOT NULL default 1000;
|
||||
ALTER TABLE prims ADD GravityModifier float NOT NULL default 1;
|
||||
ALTER TABLE prims ADD Friction float NOT NULL default 0.6;
|
||||
ALTER TABLE prims ADD Restitution float NOT NULL default 0.5;
|
||||
|
||||
COMMIT
|
||||
|
||||
:VERSION 40 #---------------- Save Attachment info
|
||||
|
||||
BEGIN TRANSACTION
|
||||
|
||||
ALTER TABLE prims ADD AttachedPosX float(53) default 0.0;
|
||||
ALTER TABLE prims ADD AttachedPosY float(53) default 0.0;
|
||||
ALTER TABLE prims ADD AttachedPosZ float(53) default 0.0;
|
||||
ALTER TABLE primshapes ADD LastAttachPoint int not null default 0;
|
||||
|
||||
COMMIT
|
||||
|
||||
|
||||
@@ -171,18 +171,18 @@ namespace OpenSim.Data.MySQL
|
||||
dbcon))
|
||||
{
|
||||
string assetName = asset.Name;
|
||||
if (asset.Name.Length > 64)
|
||||
if (asset.Name.Length > AssetBase.MAX_ASSET_NAME)
|
||||
{
|
||||
assetName = asset.Name.Substring(0, 64);
|
||||
assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
|
||||
m_log.WarnFormat(
|
||||
"[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
|
||||
asset.Name, asset.ID, asset.Name.Length, assetName.Length);
|
||||
}
|
||||
|
||||
string assetDescription = asset.Description;
|
||||
if (asset.Description.Length > 64)
|
||||
if (asset.Description.Length > AssetBase.MAX_ASSET_DESC)
|
||||
{
|
||||
assetDescription = asset.Description.Substring(0, 64);
|
||||
assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC);
|
||||
m_log.WarnFormat(
|
||||
"[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
|
||||
asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
|
||||
@@ -257,46 +257,44 @@ namespace OpenSim.Data.MySQL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if the asset exists in the database
|
||||
/// Check if the assets exist in the database.
|
||||
/// </summary>
|
||||
/// <param name="uuid">The asset UUID</param>
|
||||
/// <returns>true if it exists, false otherwise.</returns>
|
||||
override public bool ExistsAsset(UUID uuid)
|
||||
/// <param name="uuidss">The assets' IDs</param>
|
||||
/// <returns>For each asset: true if it exists, false otherwise</returns>
|
||||
public override bool[] AssetsExist(UUID[] uuids)
|
||||
{
|
||||
// m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid);
|
||||
if (uuids.Length == 0)
|
||||
return new bool[0];
|
||||
|
||||
bool assetExists = false;
|
||||
HashSet<UUID> exist = new HashSet<UUID>();
|
||||
|
||||
string ids = "'" + string.Join("','", uuids) + "'";
|
||||
string sql = string.Format("SELECT id FROM assets WHERE id IN ({0})", ids);
|
||||
|
||||
lock (m_dbLock)
|
||||
{
|
||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||
{
|
||||
dbcon.Open();
|
||||
using (MySqlCommand cmd = new MySqlCommand("SELECT id FROM assets WHERE id=?id", dbcon))
|
||||
using (MySqlCommand cmd = new MySqlCommand(sql, dbcon))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?id", uuid.ToString());
|
||||
|
||||
try
|
||||
using (MySqlDataReader dbReader = cmd.ExecuteReader())
|
||||
{
|
||||
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
||||
while (dbReader.Read())
|
||||
{
|
||||
if (dbReader.Read())
|
||||
{
|
||||
// m_log.DebugFormat("[ASSETS DB]: Found asset {0}", uuid);
|
||||
assetExists = true;
|
||||
}
|
||||
UUID id = DBGuid.FromDB(dbReader["id"]);
|
||||
exist.Add(id);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error(
|
||||
string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", uuid), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return assetExists;
|
||||
bool[] results = new bool[uuids.Length];
|
||||
for (int i = 0; i < uuids.Length; i++)
|
||||
results[i] = exist.Contains(uuids[i]);
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -145,7 +145,11 @@ namespace OpenSim.Data.MySQL
|
||||
cmd.CommandText = sql;
|
||||
cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
|
||||
|
||||
return DoLoad(cmd, regionID, create);
|
||||
EstateSettings e = DoLoad(cmd, regionID, create);
|
||||
if (!create && e.EstateID == 0) // Not found
|
||||
return null;
|
||||
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -427,7 +431,10 @@ namespace OpenSim.Data.MySQL
|
||||
cmd.CommandText = sql;
|
||||
cmd.Parameters.AddWithValue("?EstateID", estateID);
|
||||
|
||||
return DoLoad(cmd, UUID.Zero, false);
|
||||
EstateSettings e = DoLoad(cmd, UUID.Zero, false);
|
||||
if (e.EstateID != estateID)
|
||||
return null;
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace OpenSim.Data.MySQL
|
||||
return Delete(principalID.ToString(), friend);
|
||||
}
|
||||
|
||||
public bool Delete(string principalID, string friend)
|
||||
public override bool Delete(string principalID, string friend)
|
||||
{
|
||||
using (MySqlCommand cmd = new MySqlCommand())
|
||||
{
|
||||
|
||||
@@ -86,11 +86,11 @@ namespace OpenSim.Data.MySQL
|
||||
public GroupData[] RetrieveGroups(string pattern)
|
||||
{
|
||||
if (string.IsNullOrEmpty(pattern))
|
||||
pattern = "1 ORDER BY Name LIMIT 100";
|
||||
pattern = "1";
|
||||
else
|
||||
pattern = string.Format("Name LIKE '%{0}%' ORDER BY Name LIMIT 100", pattern);
|
||||
pattern = string.Format("Name LIKE '%{0}%'", MySqlHelper.EscapeString(pattern));
|
||||
|
||||
return m_Groups.Get(pattern);
|
||||
return m_Groups.Get(string.Format("ShowInList=1 AND ({0}) ORDER BY Name LIMIT 100", pattern));
|
||||
}
|
||||
|
||||
public bool DeleteGroup(UUID groupID)
|
||||
|
||||
@@ -310,6 +310,11 @@ namespace OpenSim.Data.MySQL
|
||||
return Get((int)RegionFlags.DefaultRegion, scopeID);
|
||||
}
|
||||
|
||||
public List<RegionData> GetDefaultHypergridRegions(UUID scopeID)
|
||||
{
|
||||
return Get((int)RegionFlags.DefaultHGRegion, scopeID);
|
||||
}
|
||||
|
||||
public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y)
|
||||
{
|
||||
List<RegionData> regions = Get((int)RegionFlags.FallbackRegion, scopeID);
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace OpenSim.Data.MySQL
|
||||
public class MySQLSimulationData : ISimulationDataStore
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private static string LogHeader = "[REGION DB MYSQL]";
|
||||
|
||||
private string m_connectionString;
|
||||
private object m_dbLock = new object();
|
||||
@@ -91,7 +92,7 @@ namespace OpenSim.Data.MySQL
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[REGION DB]: MySQL error in ExecuteReader: " + e.Message);
|
||||
m_log.ErrorFormat("{0} MySQL error in ExecuteReader: {1}", LogHeader, e);
|
||||
throw;
|
||||
}
|
||||
|
||||
@@ -173,7 +174,8 @@ namespace OpenSim.Data.MySQL
|
||||
"ParticleSystem, ClickAction, Material, " +
|
||||
"CollisionSound, CollisionSoundVolume, " +
|
||||
"PassTouches, " +
|
||||
"LinkNumber, MediaURL, KeyframeMotion, " +
|
||||
"LinkNumber, MediaURL, AttachedPosX, " +
|
||||
"AttachedPosY, AttachedPosZ, KeyframeMotion, " +
|
||||
"PhysicsShapeType, Density, GravityModifier, " +
|
||||
"Friction, Restitution, DynAttrs " +
|
||||
") values (" + "?UUID, " +
|
||||
@@ -208,7 +210,8 @@ namespace OpenSim.Data.MySQL
|
||||
"?ColorB, ?ColorA, ?ParticleSystem, " +
|
||||
"?ClickAction, ?Material, ?CollisionSound, " +
|
||||
"?CollisionSoundVolume, ?PassTouches, " +
|
||||
"?LinkNumber, ?MediaURL, ?KeyframeMotion, " +
|
||||
"?LinkNumber, ?MediaURL, ?AttachedPosX, " +
|
||||
"?AttachedPosY, ?AttachedPosZ, ?KeyframeMotion, " +
|
||||
"?PhysicsShapeType, ?Density, ?GravityModifier, " +
|
||||
"?Friction, ?Restitution, ?DynAttrs)";
|
||||
|
||||
@@ -227,7 +230,7 @@ namespace OpenSim.Data.MySQL
|
||||
"PathTaperX, PathTaperY, PathTwist, " +
|
||||
"PathTwistBegin, ProfileBegin, ProfileEnd, " +
|
||||
"ProfileCurve, ProfileHollow, Texture, " +
|
||||
"ExtraParams, State, Media) " +
|
||||
"ExtraParams, State, LastAttachPoint, Media) " +
|
||||
"values (?UUID, " +
|
||||
"?Shape, ?ScaleX, ?ScaleY, ?ScaleZ, " +
|
||||
"?PCode, ?PathBegin, ?PathEnd, " +
|
||||
@@ -239,7 +242,7 @@ namespace OpenSim.Data.MySQL
|
||||
"?PathTwistBegin, ?ProfileBegin, " +
|
||||
"?ProfileEnd, ?ProfileCurve, " +
|
||||
"?ProfileHollow, ?Texture, ?ExtraParams, " +
|
||||
"?State, ?Media)";
|
||||
"?State, ?LastAttachPoint, ?Media)";
|
||||
|
||||
FillShapeCommand(cmd, prim);
|
||||
|
||||
@@ -570,10 +573,14 @@ namespace OpenSim.Data.MySQL
|
||||
}
|
||||
}
|
||||
|
||||
// Legacy entry point for when terrain was always a 256x256 hieghtmap
|
||||
public void StoreTerrain(double[,] ter, UUID regionID)
|
||||
{
|
||||
m_log.Info("[REGION DB]: Storing terrain");
|
||||
StoreTerrain(new HeightmapTerrainData(ter), regionID);
|
||||
}
|
||||
|
||||
public void StoreTerrain(TerrainData terrData, UUID regionID)
|
||||
{
|
||||
lock (m_dbLock)
|
||||
{
|
||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||
@@ -587,11 +594,18 @@ namespace OpenSim.Data.MySQL
|
||||
|
||||
ExecuteNonQuery(cmd);
|
||||
|
||||
cmd.CommandText = "insert into terrain (RegionUUID, " +
|
||||
"Revision, Heightfield) values (?RegionUUID, " +
|
||||
"1, ?Heightfield)";
|
||||
|
||||
cmd.Parameters.AddWithValue("Heightfield", SerializeTerrain(ter));
|
||||
int terrainDBRevision;
|
||||
Array terrainDBblob;
|
||||
terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);
|
||||
|
||||
m_log.InfoFormat("{0} Storing terrain. X={1}, Y={2}, rev={3}",
|
||||
LogHeader, terrData.SizeX, terrData.SizeY, terrainDBRevision);
|
||||
|
||||
cmd.CommandText = "insert into terrain (RegionUUID, Revision, Heightfield)"
|
||||
+ "values (?RegionUUID, ?Revision, ?Heightfield)";
|
||||
|
||||
cmd.Parameters.AddWithValue("Revision", terrainDBRevision);
|
||||
cmd.Parameters.AddWithValue("Heightfield", terrainDBblob);
|
||||
|
||||
ExecuteNonQuery(cmd);
|
||||
}
|
||||
@@ -599,9 +613,20 @@ namespace OpenSim.Data.MySQL
|
||||
}
|
||||
}
|
||||
|
||||
// Legacy region loading
|
||||
public double[,] LoadTerrain(UUID regionID)
|
||||
{
|
||||
double[,] terrain = null;
|
||||
double[,] ret = null;
|
||||
TerrainData terrData = LoadTerrain(regionID, (int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionHeight);
|
||||
if (terrData != null)
|
||||
ret = terrData.GetDoubles();
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Returns 'null' if region not found
|
||||
public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
|
||||
{
|
||||
TerrainData terrData = null;
|
||||
|
||||
lock (m_dbLock)
|
||||
{
|
||||
@@ -621,32 +646,15 @@ namespace OpenSim.Data.MySQL
|
||||
while (reader.Read())
|
||||
{
|
||||
int rev = Convert.ToInt32(reader["Revision"]);
|
||||
|
||||
terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize];
|
||||
terrain.Initialize();
|
||||
|
||||
using (MemoryStream mstr = new MemoryStream((byte[])reader["Heightfield"]))
|
||||
{
|
||||
using (BinaryReader br = new BinaryReader(mstr))
|
||||
{
|
||||
for (int x = 0; x < (int)Constants.RegionSize; x++)
|
||||
{
|
||||
for (int y = 0; y < (int)Constants.RegionSize; y++)
|
||||
{
|
||||
terrain[x, y] = br.ReadDouble();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_log.InfoFormat("[REGION DB]: Loaded terrain revision r{0}", rev);
|
||||
}
|
||||
byte[] blob = (byte[])reader["Heightfield"];
|
||||
terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return terrain;
|
||||
return terrData;
|
||||
}
|
||||
|
||||
public void RemoveLandObject(UUID globalID)
|
||||
@@ -687,7 +695,7 @@ namespace OpenSim.Data.MySQL
|
||||
"MusicURL, PassHours, PassPrice, SnapshotUUID, " +
|
||||
"UserLocationX, UserLocationY, UserLocationZ, " +
|
||||
"UserLookAtX, UserLookAtY, UserLookAtZ, " +
|
||||
"AuthbuyerID, OtherCleanTime, MediaType, MediaDescription, " +
|
||||
"AuthbuyerID, OtherCleanTime, Dwell, MediaType, MediaDescription, " +
|
||||
"MediaSize, MediaLoop, ObscureMusic, ObscureMedia) values (" +
|
||||
"?UUID, ?RegionUUID, " +
|
||||
"?LocalLandID, ?Bitmap, ?Name, ?Description, " +
|
||||
@@ -698,7 +706,7 @@ namespace OpenSim.Data.MySQL
|
||||
"?MusicURL, ?PassHours, ?PassPrice, ?SnapshotUUID, " +
|
||||
"?UserLocationX, ?UserLocationY, ?UserLocationZ, " +
|
||||
"?UserLookAtX, ?UserLookAtY, ?UserLookAtZ, " +
|
||||
"?AuthbuyerID, ?OtherCleanTime, ?MediaType, ?MediaDescription, "+
|
||||
"?AuthbuyerID, ?OtherCleanTime, ?Dwell, ?MediaType, ?MediaDescription, "+
|
||||
"CONCAT(?MediaWidth, ',', ?MediaHeight), ?MediaLoop, ?ObscureMusic, ?ObscureMedia)";
|
||||
|
||||
FillLandCommand(cmd, parcel.LandData, parcel.RegionUUID);
|
||||
@@ -1303,7 +1311,16 @@ namespace OpenSim.Data.MySQL
|
||||
|
||||
if (!(row["MediaURL"] is System.DBNull))
|
||||
prim.MediaUrl = (string)row["MediaURL"];
|
||||
|
||||
|
||||
if (!(row["AttachedPosX"] is System.DBNull))
|
||||
{
|
||||
prim.AttachedPos = new Vector3(
|
||||
(float)(double)row["AttachedPosX"],
|
||||
(float)(double)row["AttachedPosY"],
|
||||
(float)(double)row["AttachedPosZ"]
|
||||
);
|
||||
}
|
||||
|
||||
if (!(row["DynAttrs"] is System.DBNull))
|
||||
prim.DynAttrs = DAMap.FromXml((string)row["DynAttrs"]);
|
||||
else
|
||||
@@ -1467,6 +1484,7 @@ namespace OpenSim.Data.MySQL
|
||||
UUID.TryParse((string)row["AuthBuyerID"], out authedbuyer);
|
||||
UUID.TryParse((string)row["SnapshotUUID"], out snapshotID);
|
||||
newData.OtherCleanTime = Convert.ToInt32(row["OtherCleanTime"]);
|
||||
newData.Dwell = Convert.ToSingle(row["Dwell"]);
|
||||
|
||||
newData.AuthBuyerID = authedbuyer;
|
||||
newData.SnapshotID = snapshotID;
|
||||
@@ -1513,30 +1531,6 @@ namespace OpenSim.Data.MySQL
|
||||
return entry;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="val"></param>
|
||||
/// <returns></returns>
|
||||
private static Array SerializeTerrain(double[,] val)
|
||||
{
|
||||
MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) *sizeof (double));
|
||||
BinaryWriter bw = new BinaryWriter(str);
|
||||
|
||||
// TODO: COMPATIBILITY - Add byte-order conversions
|
||||
for (int x = 0; x < (int)Constants.RegionSize; x++)
|
||||
for (int y = 0; y < (int)Constants.RegionSize; y++)
|
||||
{
|
||||
double height = val[x, y];
|
||||
if (height == 0.0)
|
||||
height = double.Epsilon;
|
||||
|
||||
bw.Write(height);
|
||||
}
|
||||
|
||||
return str.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fill the prim command with prim values
|
||||
/// </summary>
|
||||
@@ -1673,6 +1667,12 @@ namespace OpenSim.Data.MySQL
|
||||
|
||||
cmd.Parameters.AddWithValue("LinkNumber", prim.LinkNum);
|
||||
cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl);
|
||||
if (prim.AttachedPos != null)
|
||||
{
|
||||
cmd.Parameters.AddWithValue("AttachedPosX", (double)prim.AttachedPos.X);
|
||||
cmd.Parameters.AddWithValue("AttachedPosY", (double)prim.AttachedPos.Y);
|
||||
cmd.Parameters.AddWithValue("AttachedPosZ", (double)prim.AttachedPos.Z);
|
||||
}
|
||||
|
||||
if (prim.KeyframeMotion != null)
|
||||
cmd.Parameters.AddWithValue("KeyframeMotion", prim.KeyframeMotion.Serialize());
|
||||
@@ -1816,6 +1816,7 @@ namespace OpenSim.Data.MySQL
|
||||
cmd.Parameters.AddWithValue("UserLookAtZ", land.UserLookAt.Z);
|
||||
cmd.Parameters.AddWithValue("AuthBuyerID", land.AuthBuyerID);
|
||||
cmd.Parameters.AddWithValue("OtherCleanTime", land.OtherCleanTime);
|
||||
cmd.Parameters.AddWithValue("Dwell", land.Dwell);
|
||||
cmd.Parameters.AddWithValue("MediaDescription", land.MediaDescription);
|
||||
cmd.Parameters.AddWithValue("MediaType", land.MediaType);
|
||||
cmd.Parameters.AddWithValue("MediaWidth", land.MediaWidth);
|
||||
@@ -1823,7 +1824,6 @@ namespace OpenSim.Data.MySQL
|
||||
cmd.Parameters.AddWithValue("MediaLoop", land.MediaLoop);
|
||||
cmd.Parameters.AddWithValue("ObscureMusic", land.ObscureMusic);
|
||||
cmd.Parameters.AddWithValue("ObscureMedia", land.ObscureMedia);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1879,6 +1879,7 @@ namespace OpenSim.Data.MySQL
|
||||
s.ExtraParams = (byte[])row["ExtraParams"];
|
||||
|
||||
s.State = (byte)(int)row["State"];
|
||||
s.LastAttachPoint = (byte)(int)row["LastAttachPoint"];
|
||||
|
||||
if (!(row["Media"] is System.DBNull))
|
||||
s.Media = PrimitiveBaseShape.MediaList.FromXml((string)row["Media"]);
|
||||
@@ -1925,6 +1926,7 @@ namespace OpenSim.Data.MySQL
|
||||
cmd.Parameters.AddWithValue("Texture", s.TextureEntry);
|
||||
cmd.Parameters.AddWithValue("ExtraParams", s.ExtraParams);
|
||||
cmd.Parameters.AddWithValue("State", s.State);
|
||||
cmd.Parameters.AddWithValue("LastAttachPoint", s.LastAttachPoint);
|
||||
cmd.Parameters.AddWithValue("Media", null == s.Media ? null : s.Media.ToXml());
|
||||
}
|
||||
|
||||
|
||||
@@ -546,6 +546,10 @@ namespace OpenSim.Data.MySQL
|
||||
reader.Read();
|
||||
notes.Notes = OSD.FromString((string)reader["notes"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
notes.Notes = OSD.FromString("");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -630,8 +634,6 @@ namespace OpenSim.Data.MySQL
|
||||
{
|
||||
if(reader.HasRows)
|
||||
{
|
||||
m_log.DebugFormat("[PROFILES_DATA]" +
|
||||
": Getting data for {0}.", props.UserId);
|
||||
reader.Read();
|
||||
props.WebUrl = (string)reader["profileURL"];
|
||||
UUID.TryParse((string)reader["profileImage"], out props.ImageId);
|
||||
@@ -647,9 +649,6 @@ namespace OpenSim.Data.MySQL
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.DebugFormat("[PROFILES_DATA]" +
|
||||
": No data for {0}", props.UserId);
|
||||
|
||||
props.WebUrl = string.Empty;
|
||||
props.ImageId = UUID.Zero;
|
||||
props.AboutText = string.Empty;
|
||||
@@ -736,7 +735,6 @@ namespace OpenSim.Data.MySQL
|
||||
string query = string.Empty;
|
||||
|
||||
query += "UPDATE userprofile SET ";
|
||||
query += "profilePartner=?profilePartner, ";
|
||||
query += "profileURL=?profileURL, ";
|
||||
query += "profileImage=?image, ";
|
||||
query += "profileAboutText=?abouttext,";
|
||||
@@ -752,7 +750,6 @@ namespace OpenSim.Data.MySQL
|
||||
using (MySqlCommand cmd = new MySqlCommand(query, dbcon))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?profileURL", props.WebUrl);
|
||||
cmd.Parameters.AddWithValue("?profilePartner", props.PartnerId.ToString());
|
||||
cmd.Parameters.AddWithValue("?image", props.ImageId.ToString());
|
||||
cmd.Parameters.AddWithValue("?abouttext", props.AboutText);
|
||||
cmd.Parameters.AddWithValue("?firstlifeimage", props.FirstLifeImageId.ToString());
|
||||
@@ -897,7 +894,7 @@ namespace OpenSim.Data.MySQL
|
||||
}
|
||||
|
||||
#region User Preferences
|
||||
public OSDArray GetUserPreferences(UUID avatarId)
|
||||
public bool GetUserPreferences(ref UserPreferences pref, ref string result)
|
||||
{
|
||||
string query = string.Empty;
|
||||
|
||||
@@ -914,31 +911,32 @@ namespace OpenSim.Data.MySQL
|
||||
dbcon.Open();
|
||||
using (MySqlCommand cmd = new MySqlCommand(query, dbcon))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?Id", avatarId.ToString());
|
||||
cmd.Parameters.AddWithValue("?Id", pref.UserId.ToString());
|
||||
|
||||
using (MySqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if(reader.HasRows)
|
||||
{
|
||||
reader.Read();
|
||||
OSDMap record = new OSDMap();
|
||||
|
||||
record.Add("imviaemail",OSD.FromString((string)reader["imviaemail"]));
|
||||
record.Add("visible",OSD.FromString((string)reader["visible"]));
|
||||
record.Add("email",OSD.FromString((string)reader["email"]));
|
||||
data.Add(record);
|
||||
bool.TryParse((string)reader["imviaemail"], out pref.IMViaEmail);
|
||||
bool.TryParse((string)reader["visible"], out pref.Visible);
|
||||
pref.EMail = (string)reader["email"];
|
||||
}
|
||||
else
|
||||
{
|
||||
dbcon.Close();
|
||||
dbcon.Open();
|
||||
|
||||
query = "INSERT INTO usersettings VALUES ";
|
||||
query += "(?uuid,'false','false', ?Email)";
|
||||
|
||||
using (MySqlCommand put = new MySqlCommand(query, dbcon))
|
||||
{
|
||||
query = "INSERT INTO usersettings VALUES ";
|
||||
query += "(?Id,'false','false', '')";
|
||||
|
||||
lock(Lock)
|
||||
{
|
||||
put.ExecuteNonQuery();
|
||||
}
|
||||
put.Parameters.AddWithValue("?Email", pref.EMail);
|
||||
put.Parameters.AddWithValue("?uuid", pref.UserId.ToString());
|
||||
|
||||
put.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -949,17 +947,19 @@ namespace OpenSim.Data.MySQL
|
||||
{
|
||||
m_log.DebugFormat("[PROFILES_DATA]" +
|
||||
": Get preferences exception {0}", e.Message);
|
||||
result = e.Message;
|
||||
return false;
|
||||
}
|
||||
return data;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool UpdateUserPreferences(bool emailIm, bool visible, UUID avatarId )
|
||||
public bool UpdateUserPreferences(ref UserPreferences pref, ref string result)
|
||||
{
|
||||
string query = string.Empty;
|
||||
|
||||
query += "UPDATE userpsettings SET ";
|
||||
|
||||
query += "UPDATE usersettings SET ";
|
||||
query += "imviaemail=?ImViaEmail, ";
|
||||
query += "visible=?Visible,";
|
||||
query += "visible=?Visible ";
|
||||
query += "WHERE useruuid=?uuid";
|
||||
|
||||
try
|
||||
@@ -969,14 +969,11 @@ namespace OpenSim.Data.MySQL
|
||||
dbcon.Open();
|
||||
using (MySqlCommand cmd = new MySqlCommand(query, dbcon))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?ImViaEmail", emailIm.ToString().ToLower ());
|
||||
cmd.Parameters.AddWithValue("?WantText", visible.ToString().ToLower ());
|
||||
cmd.Parameters.AddWithValue("?uuid", avatarId.ToString());
|
||||
|
||||
lock(Lock)
|
||||
{
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
cmd.Parameters.AddWithValue("?ImViaEmail", pref.IMViaEmail.ToString().ToLower());
|
||||
cmd.Parameters.AddWithValue("?Visible", pref.Visible.ToString().ToLower());
|
||||
cmd.Parameters.AddWithValue("?uuid", pref.UserId.ToString());
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -984,6 +981,7 @@ namespace OpenSim.Data.MySQL
|
||||
{
|
||||
m_log.DebugFormat("[PROFILES_DATA]" +
|
||||
": AgentInterestsUpdate exception {0}", e.Message);
|
||||
result = e.Message;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -210,18 +210,18 @@ namespace OpenSim.Data.MySQL
|
||||
using (MySqlTransaction transaction = dbcon.BeginTransaction())
|
||||
{
|
||||
string assetName = asset.Name;
|
||||
if (asset.Name.Length > 64)
|
||||
if (asset.Name.Length > AssetBase.MAX_ASSET_NAME)
|
||||
{
|
||||
assetName = asset.Name.Substring(0, 64);
|
||||
assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
|
||||
m_log.WarnFormat(
|
||||
"[XASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
|
||||
asset.Name, asset.ID, asset.Name.Length, assetName.Length);
|
||||
}
|
||||
|
||||
string assetDescription = asset.Description;
|
||||
if (asset.Description.Length > 64)
|
||||
if (asset.Description.Length > AssetBase.MAX_ASSET_DESC)
|
||||
{
|
||||
assetDescription = asset.Description.Substring(0, 64);
|
||||
assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC);
|
||||
m_log.WarnFormat(
|
||||
"[XASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
|
||||
asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
|
||||
@@ -346,7 +346,7 @@ namespace OpenSim.Data.MySQL
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (Exception)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[XASSET MYSQL DB]: Failure updating access_time for asset {0} with name {1}",
|
||||
@@ -397,45 +397,43 @@ namespace OpenSim.Data.MySQL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if the asset exists in the database
|
||||
/// Check if the assets exist in the database.
|
||||
/// </summary>
|
||||
/// <param name="uuid">The asset UUID</param>
|
||||
/// <returns>true if it exists, false otherwise.</returns>
|
||||
public bool ExistsAsset(UUID uuid)
|
||||
/// <param name="uuids">The asset UUID's</param>
|
||||
/// <returns>For each asset: true if it exists, false otherwise</returns>
|
||||
public bool[] AssetsExist(UUID[] uuids)
|
||||
{
|
||||
// m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid);
|
||||
if (uuids.Length == 0)
|
||||
return new bool[0];
|
||||
|
||||
bool assetExists = false;
|
||||
HashSet<UUID> exists = new HashSet<UUID>();
|
||||
|
||||
string ids = "'" + string.Join("','", uuids) + "'";
|
||||
string sql = string.Format("SELECT ID FROM assets WHERE ID IN ({0})", ids);
|
||||
|
||||
lock (m_dbLock)
|
||||
{
|
||||
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
|
||||
{
|
||||
dbcon.Open();
|
||||
using (MySqlCommand cmd = new MySqlCommand("SELECT ID FROM XAssetsMeta WHERE ID=?ID", dbcon))
|
||||
using (MySqlCommand cmd = new MySqlCommand(sql, dbcon))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?ID", uuid.ToString());
|
||||
|
||||
try
|
||||
using (MySqlDataReader dbReader = cmd.ExecuteReader())
|
||||
{
|
||||
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
||||
while (dbReader.Read())
|
||||
{
|
||||
if (dbReader.Read())
|
||||
{
|
||||
// m_log.DebugFormat("[ASSETS DB]: Found asset {0}", uuid);
|
||||
assetExists = true;
|
||||
}
|
||||
UUID id = DBGuid.FromDB(dbReader["ID"]);
|
||||
exists.Add(id);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error(string.Format("[XASSETS DB]: MySql failure fetching asset {0}", uuid), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return assetExists;
|
||||
bool[] results = new bool[uuids.Length];
|
||||
for (int i = 0; i < uuids.Length; i++)
|
||||
results[i] = exists.Contains(uuids[i]);
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -61,5 +61,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly : AssemblyVersion("0.7.6.*")]
|
||||
[assembly : AssemblyVersion("0.8.1.*")]
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
:VERSION 1 # --------------------------
|
||||
:VERSION 1 # --------------------------
|
||||
|
||||
BEGIN;
|
||||
|
||||
@@ -21,4 +21,22 @@ INSERT INTO `im_offline` SELECT * from `diva_im_offline`;
|
||||
DROP TABLE `diva_im_offline`;
|
||||
DELETE FROM `migrations` WHERE name='diva_im_Store';
|
||||
|
||||
COMMIT;
|
||||
COMMIT;
|
||||
|
||||
:VERSION 3 # --------------------------
|
||||
|
||||
BEGIN;
|
||||
|
||||
ALTER TABLE `im_offline`
|
||||
ADD `FromID` char(36) NOT NULL default '' AFTER `PrincipalID`,
|
||||
ADD KEY `FromID` (`FromID`);
|
||||
|
||||
COMMIT;
|
||||
|
||||
:VERSION 4 # --------------------------
|
||||
|
||||
BEGIN;
|
||||
|
||||
ALTER TABLE im_offline CONVERT TO CHARACTER SET utf8;
|
||||
|
||||
COMMIT;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
:VERSION 1 # --------------------------
|
||||
:VERSION 1 # --------------------------
|
||||
|
||||
BEGIN;
|
||||
|
||||
@@ -21,3 +21,11 @@ BEGIN;
|
||||
ALTER TABLE `Presence` ADD COLUMN LastSeen timestamp;
|
||||
|
||||
COMMIT;
|
||||
|
||||
:VERSION 3 # --------------------------
|
||||
|
||||
BEGIN;
|
||||
|
||||
CREATE INDEX RegionID ON Presence(RegionID);
|
||||
|
||||
COMMIT;
|
||||
|
||||
@@ -930,3 +930,13 @@ BEGIN;
|
||||
ALTER TABLE prims ADD COLUMN `KeyframeMotion` blob;
|
||||
|
||||
COMMIT;
|
||||
|
||||
:VERSION 49 #--------------------- Save attachment info
|
||||
|
||||
BEGIN;
|
||||
ALTER TABLE prims ADD COLUMN AttachedPosX double default 0;
|
||||
ALTER TABLE prims ADD COLUMN AttachedPosY double default 0;
|
||||
ALTER TABLE prims ADD COLUMN AttachedPosZ double default 0;
|
||||
ALTER TABLE primshapes ADD COLUMN LastAttachPoint int(4) not null default '0';
|
||||
COMMIT;
|
||||
|
||||
|
||||
@@ -81,3 +81,13 @@ CREATE TABLE IF NOT EXISTS `userdata` (
|
||||
|
||||
commit;
|
||||
|
||||
:VERSION 3 # -------------------------------
|
||||
begin;
|
||||
CREATE TABLE IF NOT EXISTS `usersettings` (
|
||||
`useruuid` varchar(36) NOT NULL,
|
||||
`imviaemail` enum('true','false') NOT NULL,
|
||||
`visible` enum('true','false') NOT NULL,
|
||||
`email` varchar(254) NOT NULL,
|
||||
PRIMARY KEY (`useruuid`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
commit;
|
||||
@@ -42,7 +42,7 @@ namespace OpenSim.Data.Null
|
||||
|
||||
// private string m_connectionString;
|
||||
|
||||
private Dictionary<uint, EstateSettings> m_knownEstates = new Dictionary<uint, EstateSettings>();
|
||||
// private Dictionary<uint, EstateSettings> m_knownEstates = new Dictionary<uint, EstateSettings>();
|
||||
private EstateSettings m_estate = null;
|
||||
|
||||
private EstateSettings GetEstate()
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace OpenSim.Data.Null
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private static NullPresenceData Instance;
|
||||
public static NullPresenceData Instance;
|
||||
|
||||
Dictionary<UUID, PresenceData> m_presenceData = new Dictionary<UUID, PresenceData>();
|
||||
|
||||
|
||||
@@ -239,6 +239,11 @@ namespace OpenSim.Data.Null
|
||||
return Get((int)RegionFlags.DefaultRegion, scopeID);
|
||||
}
|
||||
|
||||
public List<RegionData> GetDefaultHypergridRegions(UUID scopeID)
|
||||
{
|
||||
return Get((int)RegionFlags.DefaultHGRegion, scopeID);
|
||||
}
|
||||
|
||||
public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y)
|
||||
{
|
||||
List<RegionData> regions = Get((int)RegionFlags.FallbackRegion, scopeID);
|
||||
|
||||
@@ -132,15 +132,33 @@ namespace OpenSim.Data.Null
|
||||
return new List<SceneObjectGroup>();
|
||||
}
|
||||
|
||||
Dictionary<UUID, double[,]> m_terrains = new Dictionary<UUID, double[,]>();
|
||||
public void StoreTerrain(double[,] ter, UUID regionID)
|
||||
Dictionary<UUID, TerrainData> m_terrains = new Dictionary<UUID, TerrainData>();
|
||||
public void StoreTerrain(TerrainData ter, UUID regionID)
|
||||
{
|
||||
if (m_terrains.ContainsKey(regionID))
|
||||
m_terrains.Remove(regionID);
|
||||
m_terrains.Add(regionID, ter);
|
||||
}
|
||||
|
||||
// Legacy. Just don't do this.
|
||||
public void StoreTerrain(double[,] ter, UUID regionID)
|
||||
{
|
||||
TerrainData terrData = new HeightmapTerrainData(ter);
|
||||
StoreTerrain(terrData, regionID);
|
||||
}
|
||||
|
||||
// Legacy. Just don't do this.
|
||||
// Returns 'null' if region not found
|
||||
public double[,] LoadTerrain(UUID regionID)
|
||||
{
|
||||
if (m_terrains.ContainsKey(regionID))
|
||||
{
|
||||
return m_terrains[regionID].GetDoubles();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
|
||||
{
|
||||
if (m_terrains.ContainsKey(regionID))
|
||||
{
|
||||
|
||||
@@ -38,7 +38,7 @@ using OpenSim.Data;
|
||||
|
||||
namespace OpenSim.Data.Null
|
||||
{
|
||||
public class NullXGroupData : NullGenericDataHandler, IXGroupData
|
||||
public class NullXGroupData : IXGroupData
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
@@ -56,35 +56,31 @@ namespace OpenSim.Data.Null
|
||||
return true;
|
||||
}
|
||||
|
||||
public XGroup[] GetGroups(string field, string val)
|
||||
public XGroup GetGroup(UUID groupID)
|
||||
{
|
||||
return GetGroups(new string[] { field }, new string[] { val });
|
||||
XGroup group = null;
|
||||
|
||||
lock (m_groups)
|
||||
m_groups.TryGetValue(groupID, out group);
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
public XGroup[] GetGroups(string[] fields, string[] vals)
|
||||
public Dictionary<UUID, XGroup> GetGroups()
|
||||
{
|
||||
Dictionary<UUID, XGroup> groupsClone = new Dictionary<UUID, XGroup>();
|
||||
|
||||
lock (m_groups)
|
||||
foreach (XGroup group in m_groups.Values)
|
||||
groupsClone[group.groupID] = group.Clone();
|
||||
|
||||
return groupsClone;
|
||||
}
|
||||
|
||||
public bool DeleteGroup(UUID groupID)
|
||||
{
|
||||
lock (m_groups)
|
||||
{
|
||||
List<XGroup> origGroups = Get<XGroup>(fields, vals, m_groups.Values.ToList());
|
||||
|
||||
return origGroups.Select(g => g.Clone()).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public bool DeleteGroups(string field, string val)
|
||||
{
|
||||
return DeleteGroups(new string[] { field }, new string[] { val });
|
||||
}
|
||||
|
||||
public bool DeleteGroups(string[] fields, string[] vals)
|
||||
{
|
||||
lock (m_groups)
|
||||
{
|
||||
XGroup[] groupsToDelete = GetGroups(fields, vals);
|
||||
Array.ForEach(groupsToDelete, g => m_groups.Remove(g.groupID));
|
||||
}
|
||||
|
||||
return true;
|
||||
return m_groups.Remove(groupID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,5 +61,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly : AssemblyVersion("0.7.6.*")]
|
||||
[assembly : AssemblyVersion("0.8.1.*")]
|
||||
|
||||
|
||||
316
OpenSim/Data/PGSQL/PGSQLAssetData.cs
Normal file
316
OpenSim/Data/PGSQL/PGSQLAssetData.cs
Normal file
@@ -0,0 +1,316 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using OpenMetaverse;
|
||||
using log4net;
|
||||
using OpenSim.Framework;
|
||||
using Npgsql;
|
||||
using NpgsqlTypes;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
/// <summary>
|
||||
/// A PGSQL Interface for the Asset server
|
||||
/// </summary>
|
||||
public class PGSQLAssetData : AssetDataBase
|
||||
{
|
||||
private const string _migrationStore = "AssetStore";
|
||||
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private long m_ticksToEpoch;
|
||||
/// <summary>
|
||||
/// Database manager
|
||||
/// </summary>
|
||||
private PGSQLManager m_database;
|
||||
private string m_connectionString;
|
||||
|
||||
protected virtual Assembly Assembly
|
||||
{
|
||||
get { return GetType().Assembly; }
|
||||
}
|
||||
|
||||
#region IPlugin Members
|
||||
|
||||
override public void Dispose() { }
|
||||
|
||||
/// <summary>
|
||||
/// <para>Initialises asset interface</para>
|
||||
/// </summary>
|
||||
// [Obsolete("Cannot be default-initialized!")]
|
||||
override public void Initialise()
|
||||
{
|
||||
m_log.Info("[PGSQLAssetData]: " + Name + " cannot be default-initialized!");
|
||||
throw new PluginNotInitialisedException(Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialises asset interface
|
||||
/// </summary>
|
||||
/// <para>
|
||||
/// a string instead of file, if someone writes the support
|
||||
/// </para>
|
||||
/// <param name="connectionString">connect string</param>
|
||||
override public void Initialise(string connectionString)
|
||||
{
|
||||
m_ticksToEpoch = new System.DateTime(1970, 1, 1).Ticks;
|
||||
|
||||
m_database = new PGSQLManager(connectionString);
|
||||
m_connectionString = connectionString;
|
||||
|
||||
//New migration to check for DB changes
|
||||
m_database.CheckMigration(_migrationStore);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Database provider version.
|
||||
/// </summary>
|
||||
override public string Version
|
||||
{
|
||||
get { return m_database.getVersion(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name of this DB provider.
|
||||
/// </summary>
|
||||
override public string Name
|
||||
{
|
||||
get { return "PGSQL Asset storage engine"; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IAssetDataPlugin Members
|
||||
|
||||
/// <summary>
|
||||
/// Fetch Asset from m_database
|
||||
/// </summary>
|
||||
/// <param name="assetID">the asset UUID</param>
|
||||
/// <returns></returns>
|
||||
override public AssetBase GetAsset(UUID assetID)
|
||||
{
|
||||
string sql = "SELECT * FROM assets WHERE id = :id";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter("id", assetID));
|
||||
conn.Open();
|
||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
AssetBase asset = new AssetBase(
|
||||
DBGuid.FromDB(reader["id"]),
|
||||
(string)reader["name"],
|
||||
Convert.ToSByte(reader["assetType"]),
|
||||
reader["creatorid"].ToString()
|
||||
);
|
||||
// Region Main
|
||||
asset.Description = (string)reader["description"];
|
||||
asset.Local = Convert.ToBoolean(reader["local"]);
|
||||
asset.Temporary = Convert.ToBoolean(reader["temporary"]);
|
||||
asset.Flags = (AssetFlags)(Convert.ToInt32(reader["asset_flags"]));
|
||||
asset.Data = (byte[])reader["data"];
|
||||
return asset;
|
||||
}
|
||||
return null; // throw new Exception("No rows to return");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create asset in m_database
|
||||
/// </summary>
|
||||
/// <param name="asset">the asset</param>
|
||||
override public void StoreAsset(AssetBase asset)
|
||||
{
|
||||
|
||||
string sql =
|
||||
@"UPDATE assets set name = :name, description = :description, " + "\"assetType\" " + @" = :assetType,
|
||||
local = :local, temporary = :temporary, creatorid = :creatorid, data = :data
|
||||
WHERE id=:id;
|
||||
|
||||
INSERT INTO assets
|
||||
(id, name, description, " + "\"assetType\" " + @", local,
|
||||
temporary, create_time, access_time, creatorid, asset_flags, data)
|
||||
Select :id, :name, :description, :assetType, :local,
|
||||
:temporary, :create_time, :access_time, :creatorid, :asset_flags, :data
|
||||
Where not EXISTS(SELECT * FROM assets WHERE id=:id)
|
||||
";
|
||||
|
||||
string assetName = asset.Name;
|
||||
if (asset.Name.Length > AssetBase.MAX_ASSET_NAME)
|
||||
{
|
||||
assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
|
||||
m_log.WarnFormat(
|
||||
"[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
|
||||
asset.Name, asset.ID, asset.Name.Length, assetName.Length);
|
||||
}
|
||||
|
||||
string assetDescription = asset.Description;
|
||||
if (asset.Description.Length > AssetBase.MAX_ASSET_DESC)
|
||||
{
|
||||
assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC);
|
||||
m_log.WarnFormat(
|
||||
"[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
|
||||
asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
|
||||
}
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand command = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
int now = (int)((System.DateTime.Now.Ticks - m_ticksToEpoch) / 10000000);
|
||||
command.Parameters.Add(m_database.CreateParameter("id", asset.FullID));
|
||||
command.Parameters.Add(m_database.CreateParameter("name", assetName));
|
||||
command.Parameters.Add(m_database.CreateParameter("description", assetDescription));
|
||||
command.Parameters.Add(m_database.CreateParameter("assetType", asset.Type));
|
||||
command.Parameters.Add(m_database.CreateParameter("local", asset.Local));
|
||||
command.Parameters.Add(m_database.CreateParameter("temporary", asset.Temporary));
|
||||
command.Parameters.Add(m_database.CreateParameter("access_time", now));
|
||||
command.Parameters.Add(m_database.CreateParameter("create_time", now));
|
||||
command.Parameters.Add(m_database.CreateParameter("asset_flags", (int)asset.Flags));
|
||||
command.Parameters.Add(m_database.CreateParameter("creatorid", asset.Metadata.CreatorID));
|
||||
command.Parameters.Add(m_database.CreateParameter("data", asset.Data));
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
m_log.Error("[ASSET DB]: Error storing item :" + e.Message + " sql "+sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Commented out since currently unused - this probably should be called in GetAsset()
|
||||
// private void UpdateAccessTime(AssetBase asset)
|
||||
// {
|
||||
// using (AutoClosingSqlCommand cmd = m_database.Query("UPDATE assets SET access_time = :access_time WHERE id=:id"))
|
||||
// {
|
||||
// int now = (int)((System.DateTime.Now.Ticks - m_ticksToEpoch) / 10000000);
|
||||
// cmd.Parameters.AddWithValue(":id", asset.FullID.ToString());
|
||||
// cmd.Parameters.AddWithValue(":access_time", now);
|
||||
// try
|
||||
// {
|
||||
// cmd.ExecuteNonQuery();
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// m_log.Error(e.ToString());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// Check if the assets exist in the database.
|
||||
/// </summary>
|
||||
/// <param name="uuids">The assets' IDs</param>
|
||||
/// <returns>For each asset: true if it exists, false otherwise</returns>
|
||||
public override bool[] AssetsExist(UUID[] uuids)
|
||||
{
|
||||
if (uuids.Length == 0)
|
||||
return new bool[0];
|
||||
|
||||
HashSet<UUID> exist = new HashSet<UUID>();
|
||||
|
||||
string ids = "'" + string.Join("','", uuids) + "'";
|
||||
string sql = string.Format("SELECT id FROM assets WHERE id IN ({0})", ids);
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
conn.Open();
|
||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
UUID id = DBGuid.FromDB(reader["id"]);
|
||||
exist.Add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool[] results = new bool[uuids.Length];
|
||||
for (int i = 0; i < uuids.Length; i++)
|
||||
results[i] = exist.Contains(uuids[i]);
|
||||
return results;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of AssetMetadata objects. The list is a subset of
|
||||
/// the entire data set offset by <paramref name="start" /> containing
|
||||
/// <paramref name="count" /> elements.
|
||||
/// </summary>
|
||||
/// <param name="start">The number of results to discard from the total data set.</param>
|
||||
/// <param name="count">The number of rows the returned list should contain.</param>
|
||||
/// <returns>A list of AssetMetadata objects.</returns>
|
||||
public override List<AssetMetadata> FetchAssetMetadataSet(int start, int count)
|
||||
{
|
||||
List<AssetMetadata> retList = new List<AssetMetadata>(count);
|
||||
string sql = @" SELECT id, name, description, " + "\"assetType\"" + @", temporary, creatorid
|
||||
FROM assets
|
||||
order by id
|
||||
limit :stop
|
||||
offset :start;";
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter("start", start));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("stop", start + count - 1));
|
||||
conn.Open();
|
||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
AssetMetadata metadata = new AssetMetadata();
|
||||
metadata.FullID = DBGuid.FromDB(reader["id"]);
|
||||
metadata.Name = (string)reader["name"];
|
||||
metadata.Description = (string)reader["description"];
|
||||
metadata.Type = Convert.ToSByte(reader["assetType"]);
|
||||
metadata.Temporary = Convert.ToBoolean(reader["temporary"]);
|
||||
metadata.CreatorID = (string)reader["creatorid"];
|
||||
retList.Add(metadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retList;
|
||||
}
|
||||
|
||||
public override bool Delete(string id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
254
OpenSim/Data/PGSQL/PGSQLAuthenticationData.cs
Normal file
254
OpenSim/Data/PGSQL/PGSQLAuthenticationData.cs
Normal file
@@ -0,0 +1,254 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ''AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Data;
|
||||
using Npgsql;
|
||||
using NpgsqlTypes;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
public class PGSQLAuthenticationData : IAuthenticationData
|
||||
{
|
||||
private string m_Realm;
|
||||
private List<string> m_ColumnNames = null;
|
||||
private int m_LastExpire = 0;
|
||||
private string m_ConnectionString;
|
||||
private PGSQLManager m_database;
|
||||
|
||||
protected virtual Assembly Assembly
|
||||
{
|
||||
get { return GetType().Assembly; }
|
||||
}
|
||||
|
||||
public PGSQLAuthenticationData(string connectionString, string realm)
|
||||
{
|
||||
m_Realm = realm;
|
||||
m_ConnectionString = connectionString;
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
Migration m = new Migration(conn, GetType().Assembly, "AuthStore");
|
||||
m_database = new PGSQLManager(m_ConnectionString);
|
||||
m.Update();
|
||||
}
|
||||
}
|
||||
|
||||
public AuthenticationData Get(UUID principalID)
|
||||
{
|
||||
AuthenticationData ret = new AuthenticationData();
|
||||
ret.Data = new Dictionary<string, object>();
|
||||
|
||||
string sql = string.Format("select * from {0} where uuid = :principalID", m_Realm);
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter("principalID", principalID));
|
||||
conn.Open();
|
||||
using (NpgsqlDataReader result = cmd.ExecuteReader())
|
||||
{
|
||||
if (result.Read())
|
||||
{
|
||||
ret.PrincipalID = principalID;
|
||||
|
||||
if (m_ColumnNames == null)
|
||||
{
|
||||
m_ColumnNames = new List<string>();
|
||||
|
||||
DataTable schemaTable = result.GetSchemaTable();
|
||||
foreach (DataRow row in schemaTable.Rows)
|
||||
m_ColumnNames.Add(row["ColumnName"].ToString());
|
||||
}
|
||||
|
||||
foreach (string s in m_ColumnNames)
|
||||
{
|
||||
if (s == "UUID"||s == "uuid")
|
||||
continue;
|
||||
|
||||
ret.Data[s] = result[s].ToString();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool Store(AuthenticationData data)
|
||||
{
|
||||
if (data.Data.ContainsKey("UUID"))
|
||||
data.Data.Remove("UUID");
|
||||
if (data.Data.ContainsKey("uuid"))
|
||||
data.Data.Remove("uuid");
|
||||
|
||||
/*
|
||||
Dictionary<string, object> oAuth = new Dictionary<string, object>();
|
||||
|
||||
foreach (KeyValuePair<string, object> oDado in data.Data)
|
||||
{
|
||||
if (oDado.Key != oDado.Key.ToLower())
|
||||
{
|
||||
oAuth.Add(oDado.Key.ToLower(), oDado.Value);
|
||||
}
|
||||
}
|
||||
foreach (KeyValuePair<string, object> oDado in data.Data)
|
||||
{
|
||||
if (!oAuth.ContainsKey(oDado.Key.ToLower())) {
|
||||
oAuth.Add(oDado.Key.ToLower(), oDado.Value);
|
||||
}
|
||||
}
|
||||
*/
|
||||
string[] fields = new List<string>(data.Data.Keys).ToArray();
|
||||
StringBuilder updateBuilder = new StringBuilder();
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
updateBuilder.AppendFormat("update {0} set ", m_Realm);
|
||||
|
||||
bool first = true;
|
||||
foreach (string field in fields)
|
||||
{
|
||||
if (!first)
|
||||
updateBuilder.Append(", ");
|
||||
updateBuilder.AppendFormat("\"{0}\" = :{0}",field);
|
||||
|
||||
first = false;
|
||||
|
||||
cmd.Parameters.Add(m_database.CreateParameter("" + field, data.Data[field]));
|
||||
}
|
||||
|
||||
updateBuilder.Append(" where uuid = :principalID");
|
||||
|
||||
cmd.CommandText = updateBuilder.ToString();
|
||||
cmd.Connection = conn;
|
||||
cmd.Parameters.Add(m_database.CreateParameter("principalID", data.PrincipalID));
|
||||
|
||||
conn.Open();
|
||||
if (cmd.ExecuteNonQuery() < 1)
|
||||
{
|
||||
StringBuilder insertBuilder = new StringBuilder();
|
||||
|
||||
insertBuilder.AppendFormat("insert into {0} (uuid, \"", m_Realm);
|
||||
insertBuilder.Append(String.Join("\", \"", fields));
|
||||
insertBuilder.Append("\") values (:principalID, :");
|
||||
insertBuilder.Append(String.Join(", :", fields));
|
||||
insertBuilder.Append(")");
|
||||
|
||||
cmd.CommandText = insertBuilder.ToString();
|
||||
|
||||
if (cmd.ExecuteNonQuery() < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool SetDataItem(UUID principalID, string item, string value)
|
||||
{
|
||||
string sql = string.Format("update {0} set {1} = :{1} where uuid = :UUID", m_Realm, item);
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter("" + item, value));
|
||||
conn.Open();
|
||||
if (cmd.ExecuteNonQuery() > 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool SetToken(UUID principalID, string token, int lifetime)
|
||||
{
|
||||
if (System.Environment.TickCount - m_LastExpire > 30000)
|
||||
DoExpire();
|
||||
|
||||
string sql = "insert into tokens (uuid, token, validity) values (:principalID, :token, :lifetime)";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter("principalID", principalID));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("token", token));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("lifetime", DateTime.Now.AddMinutes(lifetime)));
|
||||
conn.Open();
|
||||
|
||||
if (cmd.ExecuteNonQuery() > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool CheckToken(UUID principalID, string token, int lifetime)
|
||||
{
|
||||
if (System.Environment.TickCount - m_LastExpire > 30000)
|
||||
DoExpire();
|
||||
|
||||
DateTime validDate = DateTime.Now.AddMinutes(lifetime);
|
||||
string sql = "update tokens set validity = :validDate where uuid = :principalID and token = :token and validity > (CURRENT_DATE + CURRENT_TIME)";
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter("principalID", principalID));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("token", token));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("validDate", validDate));
|
||||
conn.Open();
|
||||
|
||||
if (cmd.ExecuteNonQuery() > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void DoExpire()
|
||||
{
|
||||
DateTime currentDateTime = DateTime.Now;
|
||||
string sql = "delete from tokens where validity < :currentDateTime";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
conn.Open();
|
||||
cmd.Parameters.Add(m_database.CreateParameter("currentDateTime", currentDateTime));
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
m_LastExpire = System.Environment.TickCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
72
OpenSim/Data/PGSQL/PGSQLAvatarData.cs
Normal file
72
OpenSim/Data/PGSQL/PGSQLAvatarData.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using Npgsql;
|
||||
using NpgsqlTypes;
|
||||
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
/// <summary>
|
||||
/// A PGSQL Interface for Avatar Storage
|
||||
/// </summary>
|
||||
public class PGSQLAvatarData : PGSQLGenericTableHandler<AvatarBaseData>,
|
||||
IAvatarData
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public PGSQLAvatarData(string connectionString, string realm) :
|
||||
base(connectionString, realm, "Avatar")
|
||||
{
|
||||
}
|
||||
|
||||
public bool Delete(UUID principalID, string name)
|
||||
{
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
|
||||
cmd.CommandText = String.Format("DELETE FROM {0} where \"PrincipalID\" = :PrincipalID and \"Name\" = :Name", m_Realm);
|
||||
cmd.Parameters.Add(m_database.CreateParameter("PrincipalID", principalID));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("Name", name));
|
||||
cmd.Connection = conn;
|
||||
conn.Open();
|
||||
if (cmd.ExecuteNonQuery() > 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
602
OpenSim/Data/PGSQL/PGSQLEstateData.cs
Normal file
602
OpenSim/Data/PGSQL/PGSQLEstateData.cs
Normal file
@@ -0,0 +1,602 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using System.Data;
|
||||
using Npgsql;
|
||||
using NpgsqlTypes;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
public class PGSQLEstateStore : IEstateDataStore
|
||||
{
|
||||
private const string _migrationStore = "EstateStore";
|
||||
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private PGSQLManager _Database;
|
||||
private string m_connectionString;
|
||||
private FieldInfo[] _Fields;
|
||||
private Dictionary<string, FieldInfo> _FieldMap = new Dictionary<string, FieldInfo>();
|
||||
|
||||
#region Public methods
|
||||
|
||||
public PGSQLEstateStore()
|
||||
{
|
||||
}
|
||||
|
||||
public PGSQLEstateStore(string connectionString)
|
||||
{
|
||||
Initialise(connectionString);
|
||||
}
|
||||
|
||||
protected virtual Assembly Assembly
|
||||
{
|
||||
get { return GetType().Assembly; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialises the estatedata class.
|
||||
/// </summary>
|
||||
/// <param name="connectionString">connectionString.</param>
|
||||
public void Initialise(string connectionString)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(connectionString))
|
||||
{
|
||||
m_connectionString = connectionString;
|
||||
_Database = new PGSQLManager(connectionString);
|
||||
}
|
||||
|
||||
//Migration settings
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
Migration m = new Migration(conn, GetType().Assembly, "EstateStore");
|
||||
m.Update();
|
||||
}
|
||||
|
||||
//Interesting way to get parameters! Maybe implement that also with other types
|
||||
Type t = typeof(EstateSettings);
|
||||
_Fields = t.GetFields(BindingFlags.NonPublic |
|
||||
BindingFlags.Instance |
|
||||
BindingFlags.DeclaredOnly);
|
||||
|
||||
foreach (FieldInfo f in _Fields)
|
||||
{
|
||||
if (f.Name.Substring(0, 2) == "m_")
|
||||
_FieldMap[f.Name.Substring(2)] = f;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads the estate settings.
|
||||
/// </summary>
|
||||
/// <param name="regionID">region ID.</param>
|
||||
/// <returns></returns>
|
||||
public EstateSettings LoadEstateSettings(UUID regionID, bool create)
|
||||
{
|
||||
EstateSettings es = new EstateSettings();
|
||||
|
||||
string sql = "select estate_settings.\"" + String.Join("\",estate_settings.\"", FieldList) +
|
||||
"\" from estate_map left join estate_settings on estate_map.\"EstateID\" = estate_settings.\"EstateID\" " +
|
||||
" where estate_settings.\"EstateID\" is not null and \"RegionID\" = :RegionID";
|
||||
|
||||
bool insertEstate = false;
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(_Database.CreateParameter("RegionID", regionID));
|
||||
conn.Open();
|
||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
foreach (string name in FieldList)
|
||||
{
|
||||
FieldInfo f = _FieldMap[name];
|
||||
object v = reader[name];
|
||||
if (f.FieldType == typeof(bool))
|
||||
{
|
||||
f.SetValue(es, v);
|
||||
}
|
||||
else if (f.FieldType == typeof(UUID))
|
||||
{
|
||||
UUID estUUID = UUID.Zero;
|
||||
|
||||
UUID.TryParse(v.ToString(), out estUUID);
|
||||
|
||||
f.SetValue(es, estUUID);
|
||||
}
|
||||
else if (f.FieldType == typeof(string))
|
||||
{
|
||||
f.SetValue(es, v.ToString());
|
||||
}
|
||||
else if (f.FieldType == typeof(UInt32))
|
||||
{
|
||||
f.SetValue(es, Convert.ToUInt32(v));
|
||||
}
|
||||
else if (f.FieldType == typeof(Single))
|
||||
{
|
||||
f.SetValue(es, Convert.ToSingle(v));
|
||||
}
|
||||
else
|
||||
f.SetValue(es, v);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
insertEstate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (insertEstate && create)
|
||||
{
|
||||
DoCreate(es);
|
||||
LinkRegion(regionID, (int)es.EstateID);
|
||||
}
|
||||
|
||||
LoadBanList(es);
|
||||
|
||||
es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers");
|
||||
es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users");
|
||||
es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups");
|
||||
|
||||
//Set event
|
||||
es.OnSave += StoreEstateSettings;
|
||||
return es;
|
||||
}
|
||||
|
||||
public EstateSettings CreateNewEstate()
|
||||
{
|
||||
EstateSettings es = new EstateSettings();
|
||||
es.OnSave += StoreEstateSettings;
|
||||
|
||||
DoCreate(es);
|
||||
|
||||
LoadBanList(es);
|
||||
|
||||
es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers");
|
||||
es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users");
|
||||
es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups");
|
||||
|
||||
return es;
|
||||
}
|
||||
|
||||
private void DoCreate(EstateSettings es)
|
||||
{
|
||||
List<string> names = new List<string>(FieldList);
|
||||
|
||||
names.Remove("EstateID");
|
||||
|
||||
string sql = string.Format("insert into estate_settings (\"{0}\") values ( :{1} )", String.Join("\",\"", names.ToArray()), String.Join(", :", names.ToArray()));
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand insertCommand = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
insertCommand.CommandText = sql;
|
||||
|
||||
foreach (string name in names)
|
||||
{
|
||||
insertCommand.Parameters.Add(_Database.CreateParameter("" + name, _FieldMap[name].GetValue(es)));
|
||||
}
|
||||
//NpgsqlParameter idParameter = new NpgsqlParameter("ID", SqlDbType.Int);
|
||||
//idParameter.Direction = ParameterDirection.Output;
|
||||
//insertCommand.Parameters.Add(idParameter);
|
||||
conn.Open();
|
||||
|
||||
es.EstateID = 100;
|
||||
|
||||
if (insertCommand.ExecuteNonQuery() > 0)
|
||||
{
|
||||
insertCommand.CommandText = "Select cast(lastval() as int) as ID ;";
|
||||
|
||||
using (NpgsqlDataReader result = insertCommand.ExecuteReader())
|
||||
{
|
||||
if (result.Read())
|
||||
{
|
||||
es.EstateID = (uint)result.GetInt32(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//TODO check if this is needed??
|
||||
es.Save();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stores the estate settings.
|
||||
/// </summary>
|
||||
/// <param name="es">estate settings</param>
|
||||
public void StoreEstateSettings(EstateSettings es)
|
||||
{
|
||||
List<string> names = new List<string>(FieldList);
|
||||
|
||||
names.Remove("EstateID");
|
||||
|
||||
string sql = string.Format("UPDATE estate_settings SET ");
|
||||
foreach (string name in names)
|
||||
{
|
||||
sql += "\"" + name + "\" = :" + name + ", ";
|
||||
}
|
||||
sql = sql.Remove(sql.LastIndexOf(","));
|
||||
sql += " WHERE \"EstateID\" = :EstateID";
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
foreach (string name in names)
|
||||
{
|
||||
cmd.Parameters.Add(_Database.CreateParameter("" + name, _FieldMap[name].GetValue(es)));
|
||||
}
|
||||
|
||||
cmd.Parameters.Add(_Database.CreateParameter("EstateID", es.EstateID));
|
||||
conn.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
SaveBanList(es);
|
||||
SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers);
|
||||
SaveUUIDList(es.EstateID, "estate_users", es.EstateAccess);
|
||||
SaveUUIDList(es.EstateID, "estate_groups", es.EstateGroups);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private methods
|
||||
|
||||
private string[] FieldList
|
||||
{
|
||||
get { return new List<string>(_FieldMap.Keys).ToArray(); }
|
||||
}
|
||||
|
||||
private void LoadBanList(EstateSettings es)
|
||||
{
|
||||
es.ClearBans();
|
||||
|
||||
string sql = "select \"bannedUUID\" from estateban where \"EstateID\" = :EstateID";
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
NpgsqlParameter idParameter = new NpgsqlParameter("EstateID", DbType.Int32);
|
||||
idParameter.Value = es.EstateID;
|
||||
cmd.Parameters.Add(idParameter);
|
||||
conn.Open();
|
||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
EstateBan eb = new EstateBan();
|
||||
|
||||
eb.BannedUserID = new UUID((Guid)reader["bannedUUID"]); //uuid;
|
||||
eb.BannedHostAddress = "0.0.0.0";
|
||||
eb.BannedHostIPMask = "0.0.0.0";
|
||||
es.AddBan(eb);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private UUID[] LoadUUIDList(uint estateID, string table)
|
||||
{
|
||||
List<UUID> uuids = new List<UUID>();
|
||||
|
||||
string sql = string.Format("select uuid from {0} where \"EstateID\" = :EstateID", table);
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(_Database.CreateParameter("EstateID", estateID));
|
||||
conn.Open();
|
||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
uuids.Add(new UUID((Guid)reader["uuid"])); //uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return uuids.ToArray();
|
||||
}
|
||||
|
||||
private void SaveBanList(EstateSettings es)
|
||||
{
|
||||
//Delete first
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
using (NpgsqlCommand cmd = conn.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = "delete from estateban where \"EstateID\" = :EstateID";
|
||||
cmd.Parameters.AddWithValue("EstateID", (int)es.EstateID);
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
//Insert after
|
||||
cmd.CommandText = "insert into estateban (\"EstateID\", \"bannedUUID\",\"bannedIp\", \"bannedIpHostMask\", \"bannedNameMask\") values ( :EstateID, :bannedUUID, '','','' )";
|
||||
cmd.Parameters.AddWithValue("bannedUUID", Guid.Empty);
|
||||
foreach (EstateBan b in es.EstateBans)
|
||||
{
|
||||
cmd.Parameters["bannedUUID"].Value = b.BannedUserID.Guid;
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveUUIDList(uint estateID, string table, UUID[] data)
|
||||
{
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
using (NpgsqlCommand cmd = conn.CreateCommand())
|
||||
{
|
||||
cmd.Parameters.AddWithValue("EstateID", (int)estateID);
|
||||
cmd.CommandText = string.Format("delete from {0} where \"EstateID\" = :EstateID", table);
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
cmd.CommandText = string.Format("insert into {0} (\"EstateID\", uuid) values ( :EstateID, :uuid )", table);
|
||||
cmd.Parameters.AddWithValue("uuid", Guid.Empty);
|
||||
foreach (UUID uuid in data)
|
||||
{
|
||||
cmd.Parameters["uuid"].Value = uuid.Guid; //.ToString(); //TODO check if this works
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public EstateSettings LoadEstateSettings(int estateID)
|
||||
{
|
||||
EstateSettings es = new EstateSettings();
|
||||
string sql = "select estate_settings.\"" + String.Join("\",estate_settings.\"", FieldList) + "\" from estate_settings where \"EstateID\" = :EstateID";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("EstateID", (int)estateID);
|
||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
foreach (string name in FieldList)
|
||||
{
|
||||
FieldInfo f = _FieldMap[name];
|
||||
object v = reader[name];
|
||||
if (f.FieldType == typeof(bool))
|
||||
{
|
||||
f.SetValue(es, Convert.ToInt32(v) != 0);
|
||||
}
|
||||
else if (f.FieldType == typeof(UUID))
|
||||
{
|
||||
f.SetValue(es, new UUID((Guid)v)); // uuid);
|
||||
}
|
||||
else if (f.FieldType == typeof(string))
|
||||
{
|
||||
f.SetValue(es, v.ToString());
|
||||
}
|
||||
else if (f.FieldType == typeof(UInt32))
|
||||
{
|
||||
f.SetValue(es, Convert.ToUInt32(v));
|
||||
}
|
||||
else if (f.FieldType == typeof(Single))
|
||||
{
|
||||
f.SetValue(es, Convert.ToSingle(v));
|
||||
}
|
||||
else
|
||||
f.SetValue(es, v);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
LoadBanList(es);
|
||||
|
||||
es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers");
|
||||
es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users");
|
||||
es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups");
|
||||
|
||||
//Set event
|
||||
es.OnSave += StoreEstateSettings;
|
||||
return es;
|
||||
|
||||
}
|
||||
|
||||
public List<EstateSettings> LoadEstateSettingsAll()
|
||||
{
|
||||
List<EstateSettings> allEstateSettings = new List<EstateSettings>();
|
||||
|
||||
List<int> allEstateIds = GetEstatesAll();
|
||||
|
||||
foreach (int estateId in allEstateIds)
|
||||
allEstateSettings.Add(LoadEstateSettings(estateId));
|
||||
|
||||
return allEstateSettings;
|
||||
}
|
||||
|
||||
public List<int> GetEstates(string search)
|
||||
{
|
||||
List<int> result = new List<int>();
|
||||
string sql = "select \"EstateID\" from estate_settings where lower(\"EstateName\") = lower(:EstateName)";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("EstateName", search);
|
||||
|
||||
using (IDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
result.Add(Convert.ToInt32(reader["EstateID"]));
|
||||
}
|
||||
reader.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<int> GetEstatesAll()
|
||||
{
|
||||
List<int> result = new List<int>();
|
||||
string sql = "select \"EstateID\" from estate_settings";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
using (IDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
result.Add(Convert.ToInt32(reader["EstateID"]));
|
||||
}
|
||||
reader.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<int> GetEstatesByOwner(UUID ownerID)
|
||||
{
|
||||
List<int> result = new List<int>();
|
||||
string sql = "select \"estateID\" from estate_settings where \"EstateOwner\" = :EstateOwner";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("EstateOwner", ownerID);
|
||||
|
||||
using (IDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
result.Add(Convert.ToInt32(reader["EstateID"]));
|
||||
}
|
||||
reader.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool LinkRegion(UUID regionID, int estateID)
|
||||
{
|
||||
string deleteSQL = "delete from estate_map where \"RegionID\" = :RegionID";
|
||||
string insertSQL = "insert into estate_map values (:RegionID, :EstateID)";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
|
||||
NpgsqlTransaction transaction = conn.BeginTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(deleteSQL, conn))
|
||||
{
|
||||
cmd.Transaction = transaction;
|
||||
cmd.Parameters.AddWithValue("RegionID", regionID.Guid);
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(insertSQL, conn))
|
||||
{
|
||||
cmd.Transaction = transaction;
|
||||
cmd.Parameters.AddWithValue("RegionID", regionID.Guid);
|
||||
cmd.Parameters.AddWithValue("EstateID", estateID);
|
||||
|
||||
int ret = cmd.ExecuteNonQuery();
|
||||
|
||||
if (ret != 0)
|
||||
transaction.Commit();
|
||||
else
|
||||
transaction.Rollback();
|
||||
|
||||
return (ret != 0);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
m_log.Error("[REGION DB]: LinkRegion failed: " + ex.Message);
|
||||
transaction.Rollback();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<UUID> GetRegions(int estateID)
|
||||
{
|
||||
List<UUID> result = new List<UUID>();
|
||||
string sql = "select \"RegionID\" from estate_map where \"EstateID\" = :EstateID";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("EstateID", estateID);
|
||||
|
||||
using (IDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
result.Add(DBGuid.FromDB(reader["RegionID"]));
|
||||
}
|
||||
reader.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool DeleteEstate(int estateID)
|
||||
{
|
||||
// TODO: Implementation!
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
111
OpenSim/Data/PGSQL/PGSQLFramework.cs
Normal file
111
OpenSim/Data/PGSQL/PGSQLFramework.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Reflection;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using Npgsql;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
/// <summary>
|
||||
/// A database interface class to a user profile storage system
|
||||
/// </summary>
|
||||
public class PGSqlFramework
|
||||
{
|
||||
private static readonly log4net.ILog m_log =
|
||||
log4net.LogManager.GetLogger(
|
||||
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
protected string m_connectionString;
|
||||
protected object m_dbLock = new object();
|
||||
|
||||
protected PGSqlFramework(string connectionString)
|
||||
{
|
||||
m_connectionString = connectionString;
|
||||
InitializeMonoSecurity();
|
||||
}
|
||||
|
||||
public void InitializeMonoSecurity()
|
||||
{
|
||||
if (!Util.IsPlatformMono)
|
||||
{
|
||||
|
||||
if (AppDomain.CurrentDomain.GetData("MonoSecurityPostgresAdded") == null)
|
||||
{
|
||||
AppDomain.CurrentDomain.SetData("MonoSecurityPostgresAdded", "true");
|
||||
|
||||
AppDomain currentDomain = AppDomain.CurrentDomain;
|
||||
currentDomain.AssemblyResolve += new ResolveEventHandler(ResolveEventHandlerMonoSec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private System.Reflection.Assembly ResolveEventHandlerMonoSec(object sender, ResolveEventArgs args)
|
||||
{
|
||||
Assembly MyAssembly = null;
|
||||
|
||||
if (args.Name.Substring(0, args.Name.IndexOf(",")) == "Mono.Security")
|
||||
{
|
||||
MyAssembly = Assembly.LoadFrom("lib/NET/Mono.Security.dll");
|
||||
}
|
||||
|
||||
//Return the loaded assembly.
|
||||
return MyAssembly;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////
|
||||
//
|
||||
// All non queries are funneled through one connection
|
||||
// to increase performance a little
|
||||
//
|
||||
protected int ExecuteNonQuery(NpgsqlCommand cmd)
|
||||
{
|
||||
lock (m_dbLock)
|
||||
{
|
||||
using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString))
|
||||
{
|
||||
dbcon.Open();
|
||||
cmd.Connection = dbcon;
|
||||
|
||||
try
|
||||
{
|
||||
return cmd.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error(e.Message, e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
116
OpenSim/Data/PGSQL/PGSQLFriendsData.cs
Normal file
116
OpenSim/Data/PGSQL/PGSQLFriendsData.cs
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ''AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Npgsql;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
public class PGSQLFriendsData : PGSQLGenericTableHandler<FriendsData>, IFriendsData
|
||||
{
|
||||
public PGSQLFriendsData(string connectionString, string realm)
|
||||
: base(connectionString, realm, "FriendsStore")
|
||||
{
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
Migration m = new Migration(conn, GetType().Assembly, "FriendsStore");
|
||||
m.Update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override bool Delete(string principalID, string friend)
|
||||
{
|
||||
UUID princUUID = UUID.Zero;
|
||||
|
||||
bool ret = UUID.TryParse(principalID, out princUUID);
|
||||
|
||||
if (ret)
|
||||
return Delete(princUUID, friend);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Delete(UUID principalID, string friend)
|
||||
{
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
cmd.CommandText = String.Format("delete from {0} where \"PrincipalID\" = :PrincipalID and \"Friend\" = :Friend", m_Realm);
|
||||
cmd.Parameters.Add(m_database.CreateParameter("PrincipalID", principalID.ToString()));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("Friend", friend));
|
||||
cmd.Connection = conn;
|
||||
conn.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public FriendsData[] GetFriends(string principalID)
|
||||
{
|
||||
UUID princUUID = UUID.Zero;
|
||||
|
||||
bool ret = UUID.TryParse(principalID, out princUUID);
|
||||
|
||||
if (ret)
|
||||
return GetFriends(princUUID);
|
||||
else
|
||||
return new FriendsData[0];
|
||||
}
|
||||
|
||||
public FriendsData[] GetFriends(UUID principalID)
|
||||
{
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
|
||||
cmd.CommandText = String.Format("select a.*,case when b.\"Flags\" is null then '-1' else b.\"Flags\" end as \"TheirFlags\" from {0} as a " +
|
||||
" left join {0} as b on a.\"PrincipalID\" = b.\"Friend\" and a.\"Friend\" = b.\"PrincipalID\" " +
|
||||
" where a.\"PrincipalID\" = :PrincipalID", m_Realm);
|
||||
cmd.Parameters.Add(m_database.CreateParameter("PrincipalID", principalID.ToString()));
|
||||
cmd.Connection = conn;
|
||||
conn.Open();
|
||||
return DoQuery(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
public FriendsData[] GetFriends(Guid principalID)
|
||||
{
|
||||
return GetFriends(principalID);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
537
OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs
Normal file
537
OpenSim/Data/PGSQL/PGSQLGenericTableHandler.cs
Normal file
@@ -0,0 +1,537 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using System.Text;
|
||||
using Npgsql;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
public class PGSQLGenericTableHandler<T> : PGSqlFramework where T : class, new()
|
||||
{
|
||||
private static readonly ILog m_log =
|
||||
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
protected string m_ConnectionString;
|
||||
protected PGSQLManager m_database; //used for parameter type translation
|
||||
protected Dictionary<string, FieldInfo> m_Fields =
|
||||
new Dictionary<string, FieldInfo>();
|
||||
|
||||
protected Dictionary<string, string> m_FieldTypes = new Dictionary<string, string>();
|
||||
|
||||
protected List<string> m_ColumnNames = null;
|
||||
protected string m_Realm;
|
||||
protected FieldInfo m_DataField = null;
|
||||
|
||||
protected virtual Assembly Assembly
|
||||
{
|
||||
get { return GetType().Assembly; }
|
||||
}
|
||||
|
||||
public PGSQLGenericTableHandler(string connectionString,
|
||||
string realm, string storeName)
|
||||
: base(connectionString)
|
||||
{
|
||||
m_Realm = realm;
|
||||
|
||||
m_ConnectionString = connectionString;
|
||||
|
||||
if (storeName != String.Empty)
|
||||
{
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
Migration m = new Migration(conn, GetType().Assembly, storeName);
|
||||
m.Update();
|
||||
}
|
||||
|
||||
}
|
||||
m_database = new PGSQLManager(m_ConnectionString);
|
||||
|
||||
Type t = typeof(T);
|
||||
FieldInfo[] fields = t.GetFields(BindingFlags.Public |
|
||||
BindingFlags.Instance |
|
||||
BindingFlags.DeclaredOnly);
|
||||
|
||||
LoadFieldTypes();
|
||||
|
||||
if (fields.Length == 0)
|
||||
return;
|
||||
|
||||
foreach (FieldInfo f in fields)
|
||||
{
|
||||
if (f.Name != "Data")
|
||||
m_Fields[f.Name] = f;
|
||||
else
|
||||
m_DataField = f;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void LoadFieldTypes()
|
||||
{
|
||||
m_FieldTypes = new Dictionary<string, string>();
|
||||
|
||||
string query = string.Format(@"select column_name,data_type
|
||||
from INFORMATION_SCHEMA.COLUMNS
|
||||
where table_name = lower('{0}');
|
||||
|
||||
", m_Realm);
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(query, conn))
|
||||
{
|
||||
conn.Open();
|
||||
using (NpgsqlDataReader rdr = cmd.ExecuteReader())
|
||||
{
|
||||
while (rdr.Read())
|
||||
{
|
||||
// query produces 0 to many rows of single column, so always add the first item in each row
|
||||
m_FieldTypes.Add((string)rdr[0], (string)rdr[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckColumnNames(NpgsqlDataReader reader)
|
||||
{
|
||||
if (m_ColumnNames != null)
|
||||
return;
|
||||
|
||||
m_ColumnNames = new List<string>();
|
||||
|
||||
DataTable schemaTable = reader.GetSchemaTable();
|
||||
|
||||
foreach (DataRow row in schemaTable.Rows)
|
||||
{
|
||||
if (row["ColumnName"] != null &&
|
||||
(!m_Fields.ContainsKey(row["ColumnName"].ToString())))
|
||||
m_ColumnNames.Add(row["ColumnName"].ToString());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// TODO GET CONSTRAINTS FROM POSTGRESQL
|
||||
private List<string> GetConstraints()
|
||||
{
|
||||
List<string> constraints = new List<string>();
|
||||
string query = string.Format(@"SELECT kcu.column_name
|
||||
FROM information_schema.table_constraints tc
|
||||
LEFT JOIN information_schema.key_column_usage kcu
|
||||
ON tc.constraint_catalog = kcu.constraint_catalog
|
||||
AND tc.constraint_schema = kcu.constraint_schema
|
||||
AND tc.constraint_name = kcu.constraint_name
|
||||
|
||||
LEFT JOIN information_schema.referential_constraints rc
|
||||
ON tc.constraint_catalog = rc.constraint_catalog
|
||||
AND tc.constraint_schema = rc.constraint_schema
|
||||
AND tc.constraint_name = rc.constraint_name
|
||||
|
||||
LEFT JOIN information_schema.constraint_column_usage ccu
|
||||
ON rc.unique_constraint_catalog = ccu.constraint_catalog
|
||||
AND rc.unique_constraint_schema = ccu.constraint_schema
|
||||
AND rc.unique_constraint_name = ccu.constraint_name
|
||||
|
||||
where tc.table_name = lower('{0}')
|
||||
and lower(tc.constraint_type) in ('primary key')
|
||||
and kcu.column_name is not null
|
||||
;", m_Realm);
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(query, conn))
|
||||
{
|
||||
conn.Open();
|
||||
using (NpgsqlDataReader rdr = cmd.ExecuteReader())
|
||||
{
|
||||
while (rdr.Read())
|
||||
{
|
||||
// query produces 0 to many rows of single column, so always add the first item in each row
|
||||
constraints.Add((string)rdr[0]);
|
||||
}
|
||||
}
|
||||
return constraints;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual T[] Get(string field, string key)
|
||||
{
|
||||
return Get(new string[] { field }, new string[] { key });
|
||||
}
|
||||
|
||||
public virtual T[] Get(string[] fields, string[] keys)
|
||||
{
|
||||
if (fields.Length != keys.Length)
|
||||
return new T[0];
|
||||
|
||||
List<string> terms = new List<string>();
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
|
||||
for (int i = 0; i < fields.Length; i++)
|
||||
{
|
||||
if ( m_FieldTypes.ContainsKey(fields[i]) )
|
||||
cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i], m_FieldTypes[fields[i]]));
|
||||
else
|
||||
cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i]));
|
||||
|
||||
terms.Add(" \"" + fields[i] + "\" = :" + fields[i]);
|
||||
}
|
||||
|
||||
string where = String.Join(" AND ", terms.ToArray());
|
||||
|
||||
string query = String.Format("SELECT * FROM {0} WHERE {1}",
|
||||
m_Realm, where);
|
||||
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandText = query;
|
||||
conn.Open();
|
||||
return DoQuery(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
protected T[] DoQuery(NpgsqlCommand cmd)
|
||||
{
|
||||
List<T> result = new List<T>();
|
||||
if (cmd.Connection == null)
|
||||
{
|
||||
cmd.Connection = new NpgsqlConnection(m_connectionString);
|
||||
}
|
||||
if (cmd.Connection.State == ConnectionState.Closed)
|
||||
{
|
||||
cmd.Connection.Open();
|
||||
}
|
||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader == null)
|
||||
return new T[0];
|
||||
|
||||
CheckColumnNames(reader);
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
T row = new T();
|
||||
|
||||
foreach (string name in m_Fields.Keys)
|
||||
{
|
||||
if (m_Fields[name].GetValue(row) is bool)
|
||||
{
|
||||
int v = Convert.ToInt32(reader[name]);
|
||||
m_Fields[name].SetValue(row, v != 0 ? true : false);
|
||||
}
|
||||
else if (m_Fields[name].GetValue(row) is UUID)
|
||||
{
|
||||
UUID uuid = UUID.Zero;
|
||||
|
||||
UUID.TryParse(reader[name].ToString(), out uuid);
|
||||
m_Fields[name].SetValue(row, uuid);
|
||||
}
|
||||
else if (m_Fields[name].GetValue(row) is int)
|
||||
{
|
||||
int v = Convert.ToInt32(reader[name]);
|
||||
m_Fields[name].SetValue(row, v);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Fields[name].SetValue(row, reader[name]);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_DataField != null)
|
||||
{
|
||||
Dictionary<string, string> data =
|
||||
new Dictionary<string, string>();
|
||||
|
||||
foreach (string col in m_ColumnNames)
|
||||
{
|
||||
data[col] = reader[col].ToString();
|
||||
|
||||
if (data[col] == null)
|
||||
data[col] = String.Empty;
|
||||
}
|
||||
|
||||
m_DataField.SetValue(row, data);
|
||||
}
|
||||
|
||||
result.Add(row);
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual T[] Get(string where)
|
||||
{
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
|
||||
string query = String.Format("SELECT * FROM {0} WHERE {1}",
|
||||
m_Realm, where);
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandText = query;
|
||||
//m_log.WarnFormat("[PGSQLGenericTable]: SELECT {0} WHERE {1}", m_Realm, where);
|
||||
|
||||
conn.Open();
|
||||
return DoQuery(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual T[] Get(string where, NpgsqlParameter parameter)
|
||||
{
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
|
||||
string query = String.Format("SELECT * FROM {0} WHERE {1}",
|
||||
m_Realm, where);
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandText = query;
|
||||
//m_log.WarnFormat("[PGSQLGenericTable]: SELECT {0} WHERE {1}", m_Realm, where);
|
||||
|
||||
cmd.Parameters.Add(parameter);
|
||||
|
||||
conn.Open();
|
||||
return DoQuery(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool Store(T row)
|
||||
{
|
||||
List<string> constraintFields = GetConstraints();
|
||||
List<KeyValuePair<string, string>> constraints = new List<KeyValuePair<string, string>>();
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
|
||||
StringBuilder query = new StringBuilder();
|
||||
List<String> names = new List<String>();
|
||||
List<String> values = new List<String>();
|
||||
|
||||
foreach (FieldInfo fi in m_Fields.Values)
|
||||
{
|
||||
names.Add(fi.Name);
|
||||
values.Add(":" + fi.Name);
|
||||
// Temporarily return more information about what field is unexpectedly null for
|
||||
// http://opensimulator.org/mantis/view.php?id=5403. This might be due to a bug in the
|
||||
// InventoryTransferModule or we may be required to substitute a DBNull here.
|
||||
if (fi.GetValue(row) == null)
|
||||
throw new NullReferenceException(
|
||||
string.Format(
|
||||
"[PGSQL GENERIC TABLE HANDLER]: Trying to store field {0} for {1} which is unexpectedly null",
|
||||
fi.Name, row));
|
||||
|
||||
if (constraintFields.Count > 0 && constraintFields.Contains(fi.Name))
|
||||
{
|
||||
constraints.Add(new KeyValuePair<string, string>(fi.Name, fi.GetValue(row).ToString() ));
|
||||
}
|
||||
if (m_FieldTypes.ContainsKey(fi.Name))
|
||||
cmd.Parameters.Add(m_database.CreateParameter(fi.Name, fi.GetValue(row), m_FieldTypes[fi.Name]));
|
||||
else
|
||||
cmd.Parameters.Add(m_database.CreateParameter(fi.Name, fi.GetValue(row)));
|
||||
}
|
||||
|
||||
if (m_DataField != null)
|
||||
{
|
||||
Dictionary<string, string> data =
|
||||
(Dictionary<string, string>)m_DataField.GetValue(row);
|
||||
|
||||
foreach (KeyValuePair<string, string> kvp in data)
|
||||
{
|
||||
if (constraintFields.Count > 0 && constraintFields.Contains(kvp.Key))
|
||||
{
|
||||
constraints.Add(new KeyValuePair<string, string>(kvp.Key, kvp.Key));
|
||||
}
|
||||
names.Add(kvp.Key);
|
||||
values.Add(":" + kvp.Key);
|
||||
|
||||
if (m_FieldTypes.ContainsKey(kvp.Key))
|
||||
cmd.Parameters.Add(m_database.CreateParameter("" + kvp.Key, kvp.Value, m_FieldTypes[kvp.Key]));
|
||||
else
|
||||
cmd.Parameters.Add(m_database.CreateParameter("" + kvp.Key, kvp.Value));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
query.AppendFormat("UPDATE {0} SET ", m_Realm);
|
||||
int i = 0;
|
||||
for (i = 0; i < names.Count - 1; i++)
|
||||
{
|
||||
query.AppendFormat("\"{0}\" = {1}, ", names[i], values[i]);
|
||||
}
|
||||
query.AppendFormat("\"{0}\" = {1} ", names[i], values[i]);
|
||||
if (constraints.Count > 0)
|
||||
{
|
||||
List<string> terms = new List<string>();
|
||||
for (int j = 0; j < constraints.Count; j++)
|
||||
{
|
||||
terms.Add(String.Format(" \"{0}\" = :{0}", constraints[j].Key));
|
||||
}
|
||||
string where = String.Join(" AND ", terms.ToArray());
|
||||
query.AppendFormat(" WHERE {0} ", where);
|
||||
|
||||
}
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandText = query.ToString();
|
||||
|
||||
conn.Open();
|
||||
if (cmd.ExecuteNonQuery() > 0)
|
||||
{
|
||||
//m_log.WarnFormat("[PGSQLGenericTable]: Updating {0}", m_Realm);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// assume record has not yet been inserted
|
||||
|
||||
query = new StringBuilder();
|
||||
query.AppendFormat("INSERT INTO {0} (\"", m_Realm);
|
||||
query.Append(String.Join("\",\"", names.ToArray()));
|
||||
query.Append("\") values (" + String.Join(",", values.ToArray()) + ")");
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandText = query.ToString();
|
||||
|
||||
// m_log.WarnFormat("[PGSQLGenericTable]: Inserting into {0} sql {1}", m_Realm, cmd.CommandText);
|
||||
|
||||
if (conn.State != ConnectionState.Open)
|
||||
conn.Open();
|
||||
if (cmd.ExecuteNonQuery() > 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool Delete(string field, string key)
|
||||
{
|
||||
return Delete(new string[] { field }, new string[] { key });
|
||||
}
|
||||
|
||||
public virtual bool Delete(string[] fields, string[] keys)
|
||||
{
|
||||
if (fields.Length != keys.Length)
|
||||
return false;
|
||||
|
||||
List<string> terms = new List<string>();
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
for (int i = 0; i < fields.Length; i++)
|
||||
{
|
||||
if (m_FieldTypes.ContainsKey(fields[i]))
|
||||
cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i], m_FieldTypes[fields[i]]));
|
||||
else
|
||||
cmd.Parameters.Add(m_database.CreateParameter(fields[i], keys[i]));
|
||||
|
||||
terms.Add(" \"" + fields[i] + "\" = :" + fields[i]);
|
||||
}
|
||||
|
||||
string where = String.Join(" AND ", terms.ToArray());
|
||||
|
||||
string query = String.Format("DELETE FROM {0} WHERE {1}", m_Realm, where);
|
||||
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandText = query;
|
||||
conn.Open();
|
||||
|
||||
if (cmd.ExecuteNonQuery() > 0)
|
||||
{
|
||||
//m_log.Warn("[PGSQLGenericTable]: " + deleteCommand);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public long GetCount(string field, string key)
|
||||
{
|
||||
return GetCount(new string[] { field }, new string[] { key });
|
||||
}
|
||||
|
||||
public long GetCount(string[] fields, string[] keys)
|
||||
{
|
||||
if (fields.Length != keys.Length)
|
||||
return 0;
|
||||
|
||||
List<string> terms = new List<string>();
|
||||
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
for (int i = 0; i < fields.Length; i++)
|
||||
{
|
||||
cmd.Parameters.AddWithValue(fields[i], keys[i]);
|
||||
terms.Add("\"" + fields[i] + "\" = :" + fields[i]);
|
||||
}
|
||||
|
||||
string where = String.Join(" and ", terms.ToArray());
|
||||
|
||||
string query = String.Format("select count(*) from {0} where {1}",
|
||||
m_Realm, where);
|
||||
|
||||
cmd.CommandText = query;
|
||||
|
||||
Object result = DoQueryScalar(cmd);
|
||||
|
||||
return Convert.ToInt64(result);
|
||||
}
|
||||
}
|
||||
|
||||
public long GetCount(string where)
|
||||
{
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
string query = String.Format("select count(*) from {0} where {1}",
|
||||
m_Realm, where);
|
||||
|
||||
cmd.CommandText = query;
|
||||
|
||||
object result = DoQueryScalar(cmd);
|
||||
|
||||
return Convert.ToInt64(result);
|
||||
}
|
||||
}
|
||||
|
||||
public object DoQueryScalar(NpgsqlCommand cmd)
|
||||
{
|
||||
using (NpgsqlConnection dbcon = new NpgsqlConnection(m_ConnectionString))
|
||||
{
|
||||
dbcon.Open();
|
||||
cmd.Connection = dbcon;
|
||||
|
||||
return cmd.ExecuteScalar();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
68
OpenSim/Data/PGSQL/PGSQLGridUserData.cs
Normal file
68
OpenSim/Data/PGSQL/PGSQLGridUserData.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
/// <summary>
|
||||
/// A PGSQL Interface for Avatar Storage
|
||||
/// </summary>
|
||||
public class PGSQLGridUserData : PGSQLGenericTableHandler<GridUserData>,
|
||||
IGridUserData
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public PGSQLGridUserData(string connectionString, string realm) :
|
||||
base(connectionString, realm, "GridUserStore")
|
||||
{
|
||||
}
|
||||
|
||||
public new GridUserData Get(string userID)
|
||||
{
|
||||
GridUserData[] ret = Get("UserID", userID);
|
||||
|
||||
if (ret.Length == 0)
|
||||
return null;
|
||||
|
||||
return ret[0];
|
||||
}
|
||||
|
||||
public GridUserData[] GetAll(string userID)
|
||||
{
|
||||
return base.Get(String.Format("\"UserID\" LIKE '{0}%'", userID));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
485
OpenSim/Data/PGSQL/PGSQLGroupsData.cs
Normal file
485
OpenSim/Data/PGSQL/PGSQLGroupsData.cs
Normal file
@@ -0,0 +1,485 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using OpenSim.Framework;
|
||||
using OpenMetaverse;
|
||||
using Npgsql;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
public class PGSQLGroupsData : IGroupsData
|
||||
{
|
||||
private PGSqlGroupsGroupsHandler m_Groups;
|
||||
private PGSqlGroupsMembershipHandler m_Membership;
|
||||
private PGSqlGroupsRolesHandler m_Roles;
|
||||
private PGSqlGroupsRoleMembershipHandler m_RoleMembership;
|
||||
private PGSqlGroupsInvitesHandler m_Invites;
|
||||
private PGSqlGroupsNoticesHandler m_Notices;
|
||||
private PGSqlGroupsPrincipalsHandler m_Principals;
|
||||
|
||||
public PGSQLGroupsData(string connectionString, string realm)
|
||||
{
|
||||
m_Groups = new PGSqlGroupsGroupsHandler(connectionString, realm + "_groups", realm + "_Store");
|
||||
m_Membership = new PGSqlGroupsMembershipHandler(connectionString, realm + "_membership");
|
||||
m_Roles = new PGSqlGroupsRolesHandler(connectionString, realm + "_roles");
|
||||
m_RoleMembership = new PGSqlGroupsRoleMembershipHandler(connectionString, realm + "_rolemembership");
|
||||
m_Invites = new PGSqlGroupsInvitesHandler(connectionString, realm + "_invites");
|
||||
m_Notices = new PGSqlGroupsNoticesHandler(connectionString, realm + "_notices");
|
||||
m_Principals = new PGSqlGroupsPrincipalsHandler(connectionString, realm + "_principals");
|
||||
}
|
||||
|
||||
#region groups table
|
||||
public bool StoreGroup(GroupData data)
|
||||
{
|
||||
return m_Groups.Store(data);
|
||||
}
|
||||
|
||||
public GroupData RetrieveGroup(UUID groupID)
|
||||
{
|
||||
GroupData[] groups = m_Groups.Get("GroupID", groupID.ToString());
|
||||
if (groups.Length > 0)
|
||||
return groups[0];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public GroupData RetrieveGroup(string name)
|
||||
{
|
||||
GroupData[] groups = m_Groups.Get("Name", name);
|
||||
if (groups.Length > 0)
|
||||
return groups[0];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public GroupData[] RetrieveGroups(string pattern)
|
||||
{
|
||||
if (string.IsNullOrEmpty(pattern)) // True for where clause
|
||||
{
|
||||
pattern = " true ORDER BY lower(\"Name\") LIMIT 100";
|
||||
return m_Groups.Get(pattern);
|
||||
}
|
||||
else
|
||||
{
|
||||
pattern = " lower(\"Name\") LIKE lower('%:pattern%') ORDER BY lower(\"Name\") LIMIT 100";
|
||||
return m_Groups.Get(pattern, new NpgsqlParameter("pattern", pattern));
|
||||
}
|
||||
}
|
||||
|
||||
public bool DeleteGroup(UUID groupID)
|
||||
{
|
||||
return m_Groups.Delete("GroupID", groupID.ToString());
|
||||
}
|
||||
|
||||
public int GroupsCount()
|
||||
{
|
||||
return (int)m_Groups.GetCount(" \"Location\" = \"\"");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region membership table
|
||||
public MembershipData[] RetrieveMembers(UUID groupID)
|
||||
{
|
||||
return m_Membership.Get("GroupID", groupID.ToString());
|
||||
}
|
||||
|
||||
public MembershipData RetrieveMember(UUID groupID, string pricipalID)
|
||||
{
|
||||
MembershipData[] m = m_Membership.Get(new string[] { "GroupID", "PrincipalID" },
|
||||
new string[] { groupID.ToString(), pricipalID });
|
||||
if (m != null && m.Length > 0)
|
||||
return m[0];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public MembershipData[] RetrieveMemberships(string pricipalID)
|
||||
{
|
||||
return m_Membership.Get("PrincipalID", pricipalID.ToString());
|
||||
}
|
||||
|
||||
public bool StoreMember(MembershipData data)
|
||||
{
|
||||
return m_Membership.Store(data);
|
||||
}
|
||||
|
||||
public bool DeleteMember(UUID groupID, string pricipalID)
|
||||
{
|
||||
return m_Membership.Delete(new string[] { "GroupID", "PrincipalID" },
|
||||
new string[] { groupID.ToString(), pricipalID });
|
||||
}
|
||||
|
||||
public int MemberCount(UUID groupID)
|
||||
{
|
||||
return (int)m_Membership.GetCount("GroupID", groupID.ToString());
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region roles table
|
||||
public bool StoreRole(RoleData data)
|
||||
{
|
||||
return m_Roles.Store(data);
|
||||
}
|
||||
|
||||
public RoleData RetrieveRole(UUID groupID, UUID roleID)
|
||||
{
|
||||
RoleData[] data = m_Roles.Get(new string[] { "GroupID", "RoleID" },
|
||||
new string[] { groupID.ToString(), roleID.ToString() });
|
||||
|
||||
if (data != null && data.Length > 0)
|
||||
return data[0];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public RoleData[] RetrieveRoles(UUID groupID)
|
||||
{
|
||||
//return m_Roles.RetrieveRoles(groupID);
|
||||
return m_Roles.Get("GroupID", groupID.ToString());
|
||||
}
|
||||
|
||||
public bool DeleteRole(UUID groupID, UUID roleID)
|
||||
{
|
||||
return m_Roles.Delete(new string[] { "GroupID", "RoleID" },
|
||||
new string[] { groupID.ToString(), roleID.ToString() });
|
||||
}
|
||||
|
||||
public int RoleCount(UUID groupID)
|
||||
{
|
||||
return (int)m_Roles.GetCount("GroupID", groupID.ToString());
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region rolememberhip table
|
||||
public RoleMembershipData[] RetrieveRolesMembers(UUID groupID)
|
||||
{
|
||||
RoleMembershipData[] data = m_RoleMembership.Get("GroupID", groupID.ToString());
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public RoleMembershipData[] RetrieveRoleMembers(UUID groupID, UUID roleID)
|
||||
{
|
||||
RoleMembershipData[] data = m_RoleMembership.Get(new string[] { "GroupID", "RoleID" },
|
||||
new string[] { groupID.ToString(), roleID.ToString() });
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public RoleMembershipData[] RetrieveMemberRoles(UUID groupID, string principalID)
|
||||
{
|
||||
RoleMembershipData[] data = m_RoleMembership.Get(new string[] { "GroupID", "PrincipalID" },
|
||||
new string[] { groupID.ToString(), principalID.ToString() });
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public RoleMembershipData RetrieveRoleMember(UUID groupID, UUID roleID, string principalID)
|
||||
{
|
||||
RoleMembershipData[] data = m_RoleMembership.Get(new string[] { "GroupID", "RoleID", "PrincipalID" },
|
||||
new string[] { groupID.ToString(), roleID.ToString(), principalID.ToString() });
|
||||
|
||||
if (data != null && data.Length > 0)
|
||||
return data[0];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public int RoleMemberCount(UUID groupID, UUID roleID)
|
||||
{
|
||||
return (int)m_RoleMembership.GetCount(new string[] { "GroupID", "RoleID" },
|
||||
new string[] { groupID.ToString(), roleID.ToString() });
|
||||
}
|
||||
|
||||
public bool StoreRoleMember(RoleMembershipData data)
|
||||
{
|
||||
return m_RoleMembership.Store(data);
|
||||
}
|
||||
|
||||
public bool DeleteRoleMember(RoleMembershipData data)
|
||||
{
|
||||
return m_RoleMembership.Delete(new string[] { "GroupID", "RoleID", "PrincipalID"},
|
||||
new string[] { data.GroupID.ToString(), data.RoleID.ToString(), data.PrincipalID });
|
||||
}
|
||||
|
||||
public bool DeleteMemberAllRoles(UUID groupID, string principalID)
|
||||
{
|
||||
return m_RoleMembership.Delete(new string[] { "GroupID", "PrincipalID" },
|
||||
new string[] { groupID.ToString(), principalID });
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region principals table
|
||||
public bool StorePrincipal(PrincipalData data)
|
||||
{
|
||||
return m_Principals.Store(data);
|
||||
}
|
||||
|
||||
public PrincipalData RetrievePrincipal(string principalID)
|
||||
{
|
||||
PrincipalData[] p = m_Principals.Get("PrincipalID", principalID);
|
||||
if (p != null && p.Length > 0)
|
||||
return p[0];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool DeletePrincipal(string principalID)
|
||||
{
|
||||
return m_Principals.Delete("PrincipalID", principalID);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region invites table
|
||||
|
||||
public bool StoreInvitation(InvitationData data)
|
||||
{
|
||||
return m_Invites.Store(data);
|
||||
}
|
||||
|
||||
public InvitationData RetrieveInvitation(UUID inviteID)
|
||||
{
|
||||
InvitationData[] invites = m_Invites.Get("InviteID", inviteID.ToString());
|
||||
|
||||
if (invites != null && invites.Length > 0)
|
||||
return invites[0];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public InvitationData RetrieveInvitation(UUID groupID, string principalID)
|
||||
{
|
||||
InvitationData[] invites = m_Invites.Get(new string[] { "GroupID", "PrincipalID" },
|
||||
new string[] { groupID.ToString(), principalID });
|
||||
|
||||
if (invites != null && invites.Length > 0)
|
||||
return invites[0];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool DeleteInvite(UUID inviteID)
|
||||
{
|
||||
return m_Invites.Delete("InviteID", inviteID.ToString());
|
||||
}
|
||||
|
||||
public void DeleteOldInvites()
|
||||
{
|
||||
m_Invites.DeleteOld();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region notices table
|
||||
|
||||
public bool StoreNotice(NoticeData data)
|
||||
{
|
||||
return m_Notices.Store(data);
|
||||
}
|
||||
|
||||
public NoticeData RetrieveNotice(UUID noticeID)
|
||||
{
|
||||
NoticeData[] notices = m_Notices.Get("NoticeID", noticeID.ToString());
|
||||
|
||||
if (notices != null && notices.Length > 0)
|
||||
return notices[0];
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public NoticeData[] RetrieveNotices(UUID groupID)
|
||||
{
|
||||
NoticeData[] notices = m_Notices.Get("GroupID", groupID.ToString());
|
||||
|
||||
return notices;
|
||||
}
|
||||
|
||||
public bool DeleteNotice(UUID noticeID)
|
||||
{
|
||||
return m_Notices.Delete("NoticeID", noticeID.ToString());
|
||||
}
|
||||
|
||||
public void DeleteOldNotices()
|
||||
{
|
||||
m_Notices.DeleteOld();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region combinations
|
||||
public MembershipData RetrievePrincipalGroupMembership(string principalID, UUID groupID)
|
||||
{
|
||||
// TODO
|
||||
return null;
|
||||
}
|
||||
public MembershipData[] RetrievePrincipalGroupMemberships(string principalID)
|
||||
{
|
||||
// TODO
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class PGSqlGroupsGroupsHandler : PGSQLGenericTableHandler<GroupData>
|
||||
{
|
||||
protected override Assembly Assembly
|
||||
{
|
||||
// WARNING! Moving migrations to this assembly!!!
|
||||
get { return GetType().Assembly; }
|
||||
}
|
||||
|
||||
public PGSqlGroupsGroupsHandler(string connectionString, string realm, string store)
|
||||
: base(connectionString, realm, store)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class PGSqlGroupsMembershipHandler : PGSQLGenericTableHandler<MembershipData>
|
||||
{
|
||||
protected override Assembly Assembly
|
||||
{
|
||||
// WARNING! Moving migrations to this assembly!!!
|
||||
get { return GetType().Assembly; }
|
||||
}
|
||||
|
||||
public PGSqlGroupsMembershipHandler(string connectionString, string realm)
|
||||
: base(connectionString, realm, string.Empty)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class PGSqlGroupsRolesHandler : PGSQLGenericTableHandler<RoleData>
|
||||
{
|
||||
protected override Assembly Assembly
|
||||
{
|
||||
// WARNING! Moving migrations to this assembly!!!
|
||||
get { return GetType().Assembly; }
|
||||
}
|
||||
|
||||
public PGSqlGroupsRolesHandler(string connectionString, string realm)
|
||||
: base(connectionString, realm, string.Empty)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class PGSqlGroupsRoleMembershipHandler : PGSQLGenericTableHandler<RoleMembershipData>
|
||||
{
|
||||
protected override Assembly Assembly
|
||||
{
|
||||
// WARNING! Moving migrations to this assembly!!!
|
||||
get { return GetType().Assembly; }
|
||||
}
|
||||
|
||||
public PGSqlGroupsRoleMembershipHandler(string connectionString, string realm)
|
||||
: base(connectionString, realm, string.Empty)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class PGSqlGroupsInvitesHandler : PGSQLGenericTableHandler<InvitationData>
|
||||
{
|
||||
protected override Assembly Assembly
|
||||
{
|
||||
// WARNING! Moving migrations to this assembly!!!
|
||||
get { return GetType().Assembly; }
|
||||
}
|
||||
|
||||
public PGSqlGroupsInvitesHandler(string connectionString, string realm)
|
||||
: base(connectionString, realm, string.Empty)
|
||||
{
|
||||
}
|
||||
|
||||
public void DeleteOld()
|
||||
{
|
||||
uint now = (uint)Util.UnixTimeSinceEpoch();
|
||||
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
cmd.CommandText = String.Format("delete from {0} where \"TMStamp\" < :tstamp", m_Realm);
|
||||
cmd.Parameters.AddWithValue("tstamp", now - 14 * 24 * 60 * 60); // > 2 weeks old
|
||||
|
||||
ExecuteNonQuery(cmd);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class PGSqlGroupsNoticesHandler : PGSQLGenericTableHandler<NoticeData>
|
||||
{
|
||||
protected override Assembly Assembly
|
||||
{
|
||||
// WARNING! Moving migrations to this assembly!!!
|
||||
get { return GetType().Assembly; }
|
||||
}
|
||||
|
||||
public PGSqlGroupsNoticesHandler(string connectionString, string realm)
|
||||
: base(connectionString, realm, string.Empty)
|
||||
{
|
||||
}
|
||||
|
||||
public void DeleteOld()
|
||||
{
|
||||
uint now = (uint)Util.UnixTimeSinceEpoch();
|
||||
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
cmd.CommandText = String.Format("delete from {0} where \"TMStamp\" < :tstamp", m_Realm);
|
||||
cmd.Parameters.AddWithValue("tstamp", now - 14 * 24 * 60 * 60); // > 2 weeks old
|
||||
|
||||
ExecuteNonQuery(cmd);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class PGSqlGroupsPrincipalsHandler : PGSQLGenericTableHandler<PrincipalData>
|
||||
{
|
||||
protected override Assembly Assembly
|
||||
{
|
||||
// WARNING! Moving migrations to this assembly!!!
|
||||
get { return GetType().Assembly; }
|
||||
}
|
||||
|
||||
public PGSqlGroupsPrincipalsHandler(string connectionString, string realm)
|
||||
: base(connectionString, realm, string.Empty)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
80
OpenSim/Data/PGSQL/PGSQLHGTravelData.cs
Normal file
80
OpenSim/Data/PGSQL/PGSQLHGTravelData.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using Npgsql;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
/// <summary>
|
||||
/// A PGSQL Interface for user grid data
|
||||
/// </summary>
|
||||
public class PGSQLHGTravelData : PGSQLGenericTableHandler<HGTravelingData>, IHGTravelingData
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public PGSQLHGTravelData(string connectionString, string realm) : base(connectionString, realm, "HGTravelStore") { }
|
||||
|
||||
public HGTravelingData Get(UUID sessionID)
|
||||
{
|
||||
HGTravelingData[] ret = Get("SessionID", sessionID.ToString());
|
||||
|
||||
if (ret.Length == 0)
|
||||
return null;
|
||||
|
||||
return ret[0];
|
||||
}
|
||||
|
||||
public HGTravelingData[] GetSessions(UUID userID)
|
||||
{
|
||||
return base.Get("UserID", userID.ToString());
|
||||
}
|
||||
|
||||
public bool Delete(UUID sessionID)
|
||||
{
|
||||
return Delete("SessionID", sessionID.ToString());
|
||||
}
|
||||
|
||||
public void DeleteOld()
|
||||
{
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
cmd.CommandText = String.Format(@"delete from {0} where ""TMStamp"" < CURRENT_DATE - INTERVAL '2 day'", m_Realm);
|
||||
|
||||
ExecuteNonQuery(cmd);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
831
OpenSim/Data/PGSQL/PGSQLInventoryData.cs
Normal file
831
OpenSim/Data/PGSQL/PGSQLInventoryData.cs
Normal file
@@ -0,0 +1,831 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using Npgsql;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
/// <summary>
|
||||
/// A PGSQL interface for the inventory server
|
||||
/// </summary>
|
||||
public class PGSQLInventoryData : IInventoryDataPlugin
|
||||
{
|
||||
private const string _migrationStore = "InventoryStore";
|
||||
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
/// <summary>
|
||||
/// The database manager
|
||||
/// </summary>
|
||||
private PGSQLManager database;
|
||||
private string m_connectionString;
|
||||
|
||||
#region IPlugin members
|
||||
|
||||
[Obsolete("Cannot be default-initialized!")]
|
||||
public void Initialise()
|
||||
{
|
||||
m_log.Info("[PGSQLInventoryData]: " + Name + " cannot be default-initialized!");
|
||||
throw new PluginNotInitialisedException(Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads and initialises the PGSQL inventory storage interface
|
||||
/// </summary>
|
||||
/// <param name="connectionString">connect string</param>
|
||||
/// <remarks>use PGSQL_connection.ini</remarks>
|
||||
public void Initialise(string connectionString)
|
||||
{
|
||||
m_connectionString = connectionString;
|
||||
database = new PGSQLManager(connectionString);
|
||||
|
||||
//New migrations check of store
|
||||
database.CheckMigration(_migrationStore);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name of this DB provider
|
||||
/// </summary>
|
||||
/// <returns>A string containing the name of the DB provider</returns>
|
||||
public string Name
|
||||
{
|
||||
get { return "PGSQL Inventory Data Interface"; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes this DB provider
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
database = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the version of this DB provider
|
||||
/// </summary>
|
||||
/// <returns>A string containing the DB provider</returns>
|
||||
public string Version
|
||||
{
|
||||
get { return database.getVersion(); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Folder methods
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of the root folders within a users inventory
|
||||
/// </summary>
|
||||
/// <param name="user">The user whos inventory is to be searched</param>
|
||||
/// <returns>A list of folder objects</returns>
|
||||
public List<InventoryFolderBase> getUserRootFolders(UUID user)
|
||||
{
|
||||
if (user == UUID.Zero)
|
||||
return new List<InventoryFolderBase>();
|
||||
|
||||
return getInventoryFolders(UUID.Zero, user);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// see InventoryItemBase.getUserRootFolder
|
||||
/// </summary>
|
||||
/// <param name="user">the User UUID</param>
|
||||
/// <returns></returns>
|
||||
public InventoryFolderBase getUserRootFolder(UUID user)
|
||||
{
|
||||
List<InventoryFolderBase> items = getUserRootFolders(user);
|
||||
|
||||
InventoryFolderBase rootFolder = null;
|
||||
|
||||
// There should only ever be one root folder for a user. However, if there's more
|
||||
// than one we'll simply use the first one rather than failing. It would be even
|
||||
// nicer to print some message to this effect, but this feels like it's too low a
|
||||
// to put such a message out, and it's too minor right now to spare the time to
|
||||
// suitably refactor.
|
||||
if (items.Count > 0)
|
||||
{
|
||||
rootFolder = items[0];
|
||||
}
|
||||
|
||||
return rootFolder;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of folders in a users inventory contained within the specified folder
|
||||
/// </summary>
|
||||
/// <param name="parentID">The folder to search</param>
|
||||
/// <returns>A list of inventory folders</returns>
|
||||
public List<InventoryFolderBase> getInventoryFolders(UUID parentID)
|
||||
{
|
||||
return getInventoryFolders(parentID, UUID.Zero);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a specified inventory folder
|
||||
/// </summary>
|
||||
/// <param name="folderID">The folder to return</param>
|
||||
/// <returns>A folder class</returns>
|
||||
public InventoryFolderBase getInventoryFolder(UUID folderID)
|
||||
{
|
||||
string sql = "SELECT * FROM inventoryfolders WHERE \"folderID\" = :folderID";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(database.CreateParameter("folderID", folderID));
|
||||
conn.Open();
|
||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
return readInventoryFolder(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
m_log.InfoFormat("[INVENTORY DB] : Found no inventory folder with ID : {0}", folderID);
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns all child folders in the hierarchy from the parent folder and down.
|
||||
/// Does not return the parent folder itself.
|
||||
/// </summary>
|
||||
/// <param name="parentID">The folder to get subfolders for</param>
|
||||
/// <returns>A list of inventory folders</returns>
|
||||
public List<InventoryFolderBase> getFolderHierarchy(UUID parentID)
|
||||
{
|
||||
//Note maybe change this to use a Dataset that loading in all folders of a user and then go throw it that way.
|
||||
//Note this is changed so it opens only one connection to the database and not everytime it wants to get data.
|
||||
|
||||
/* NOTE: the implementation below is very inefficient (makes a separate request to get subfolders for
|
||||
* every found folder, recursively). Inventory code for other DBs has been already rewritten to get ALL
|
||||
* inventory for a specific user at once.
|
||||
*
|
||||
* Meanwhile, one little thing is corrected: getFolderHierarchy(UUID.Zero) doesn't make sense and should never
|
||||
* be used, so check for that and return an empty list.
|
||||
*/
|
||||
|
||||
List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
|
||||
|
||||
if (parentID == UUID.Zero)
|
||||
return folders;
|
||||
|
||||
string sql = "SELECT * FROM inventoryfolders WHERE \"parentFolderID\" = :parentID";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(database.CreateParameter("parentID", parentID));
|
||||
conn.Open();
|
||||
folders.AddRange(getInventoryFolders(cmd));
|
||||
|
||||
List<InventoryFolderBase> tempFolders = new List<InventoryFolderBase>();
|
||||
|
||||
foreach (InventoryFolderBase folderBase in folders)
|
||||
{
|
||||
tempFolders.AddRange(getFolderHierarchy(folderBase.ID, cmd));
|
||||
}
|
||||
if (tempFolders.Count > 0)
|
||||
{
|
||||
folders.AddRange(tempFolders);
|
||||
}
|
||||
}
|
||||
return folders;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new inventory folder
|
||||
/// </summary>
|
||||
/// <param name="folder">Folder to create</param>
|
||||
public void addInventoryFolder(InventoryFolderBase folder)
|
||||
{
|
||||
string sql = "INSERT INTO inventoryfolders (\"folderID\", \"agentID\", \"parentFolderID\", \"folderName\", type, version) " +
|
||||
" VALUES (:folderID, :agentID, :parentFolderID, :folderName, :type, :version);";
|
||||
|
||||
string folderName = folder.Name;
|
||||
if (folderName.Length > 64)
|
||||
{
|
||||
folderName = folderName.Substring(0, 64);
|
||||
m_log.Warn("[INVENTORY DB]: Name field truncated from " + folder.Name.Length.ToString() + " to " + folderName.Length + " characters on add");
|
||||
}
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(database.CreateParameter("folderID", folder.ID));
|
||||
cmd.Parameters.Add(database.CreateParameter("agentID", folder.Owner));
|
||||
cmd.Parameters.Add(database.CreateParameter("parentFolderID", folder.ParentID));
|
||||
cmd.Parameters.Add(database.CreateParameter("folderName", folderName));
|
||||
cmd.Parameters.Add(database.CreateParameter("type", folder.Type));
|
||||
cmd.Parameters.Add(database.CreateParameter("version", folder.Version));
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[INVENTORY DB]: Error : {0}", e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates an inventory folder
|
||||
/// </summary>
|
||||
/// <param name="folder">Folder to update</param>
|
||||
public void updateInventoryFolder(InventoryFolderBase folder)
|
||||
{
|
||||
string sql = @"UPDATE inventoryfolders SET ""agentID"" = :agentID,
|
||||
""parentFolderID"" = :parentFolderID,
|
||||
""folderName"" = :folderName,
|
||||
type = :type,
|
||||
version = :version
|
||||
WHERE folderID = :folderID";
|
||||
|
||||
string folderName = folder.Name;
|
||||
if (folderName.Length > 64)
|
||||
{
|
||||
folderName = folderName.Substring(0, 64);
|
||||
m_log.Warn("[INVENTORY DB]: Name field truncated from " + folder.Name.Length.ToString() + " to " + folderName.Length + " characters on update");
|
||||
}
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(database.CreateParameter("folderID", folder.ID));
|
||||
cmd.Parameters.Add(database.CreateParameter("agentID", folder.Owner));
|
||||
cmd.Parameters.Add(database.CreateParameter("parentFolderID", folder.ParentID));
|
||||
cmd.Parameters.Add(database.CreateParameter("folderName", folderName));
|
||||
cmd.Parameters.Add(database.CreateParameter("type", folder.Type));
|
||||
cmd.Parameters.Add(database.CreateParameter("version", folder.Version));
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[INVENTORY DB]: Error : {0}", e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates an inventory folder
|
||||
/// </summary>
|
||||
/// <param name="folder">Folder to update</param>
|
||||
public void moveInventoryFolder(InventoryFolderBase folder)
|
||||
{
|
||||
string sql = @"UPDATE inventoryfolders SET ""parentFolderID"" = :parentFolderID WHERE ""folderID"" = :folderID";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(database.CreateParameter("parentFolderID", folder.ParentID));
|
||||
cmd.Parameters.Add(database.CreateParameter("folderID", folder.ID));
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[INVENTORY DB]: Error : {0}", e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete an inventory folder
|
||||
/// </summary>
|
||||
/// <param name="folderID">Id of folder to delete</param>
|
||||
public void deleteInventoryFolder(UUID folderID)
|
||||
{
|
||||
string sql = @"SELECT * FROM inventoryfolders WHERE ""parentFolderID"" = :parentID";
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
List<InventoryFolderBase> subFolders;
|
||||
cmd.Parameters.Add(database.CreateParameter("parentID", UUID.Zero));
|
||||
conn.Open();
|
||||
subFolders = getFolderHierarchy(folderID, cmd);
|
||||
|
||||
|
||||
//Delete all sub-folders
|
||||
foreach (InventoryFolderBase f in subFolders)
|
||||
{
|
||||
DeleteOneFolder(f.ID, conn);
|
||||
DeleteItemsInFolder(f.ID, conn);
|
||||
}
|
||||
|
||||
//Delete the actual row
|
||||
DeleteOneFolder(folderID, conn);
|
||||
DeleteItemsInFolder(folderID, conn);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Item Methods
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of items in a specified folder
|
||||
/// </summary>
|
||||
/// <param name="folderID">The folder to search</param>
|
||||
/// <returns>A list containing inventory items</returns>
|
||||
public List<InventoryItemBase> getInventoryInFolder(UUID folderID)
|
||||
{
|
||||
string sql = @"SELECT * FROM inventoryitems WHERE ""parentFolderID"" = :parentFolderID";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(database.CreateParameter("parentFolderID", folderID));
|
||||
conn.Open();
|
||||
List<InventoryItemBase> items = new List<InventoryItemBase>();
|
||||
|
||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
items.Add(readInventoryItem(reader));
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a specified inventory item
|
||||
/// </summary>
|
||||
/// <param name="itemID">The item ID</param>
|
||||
/// <returns>An inventory item</returns>
|
||||
public InventoryItemBase getInventoryItem(UUID itemID)
|
||||
{
|
||||
string sql = @"SELECT * FROM inventoryitems WHERE ""inventoryID"" = :inventoryID";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(database.CreateParameter("inventoryID", itemID));
|
||||
conn.Open();
|
||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
return readInventoryItem(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_log.InfoFormat("[INVENTORY DB]: Found no inventory item with ID : {0}", itemID);
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a specified item to the database
|
||||
/// </summary>
|
||||
/// <param name="item">The inventory item</param>
|
||||
public void addInventoryItem(InventoryItemBase item)
|
||||
{
|
||||
if (getInventoryItem(item.ID) != null)
|
||||
{
|
||||
updateInventoryItem(item);
|
||||
return;
|
||||
}
|
||||
|
||||
string sql = @"INSERT INTO inventoryitems
|
||||
(""inventoryID"", ""assetID"", ""assetType"", ""parentFolderID"", ""avatarID"", ""inventoryName"",
|
||||
""inventoryDescription"", ""inventoryNextPermissions"", ""inventoryCurrentPermissions"",
|
||||
""invType"", ""creatorID"", ""inventoryBasePermissions"", ""inventoryEveryOnePermissions"", ""inventoryGroupPermissions"",
|
||||
""salePrice"", ""SaleType"", ""creationDate"", ""groupID"", ""groupOwned"", flags)
|
||||
VALUES
|
||||
(:inventoryID, :assetID, :assetType, :parentFolderID, :avatarID, :inventoryName, :inventoryDescription,
|
||||
:inventoryNextPermissions, :inventoryCurrentPermissions, :invType, :creatorID,
|
||||
:inventoryBasePermissions, :inventoryEveryOnePermissions, :inventoryGroupPermissions, :SalePrice, :SaleType,
|
||||
:creationDate, :groupID, :groupOwned, :flags)";
|
||||
|
||||
string itemName = item.Name;
|
||||
if (item.Name.Length > 64)
|
||||
{
|
||||
itemName = item.Name.Substring(0, 64);
|
||||
m_log.Warn("[INVENTORY DB]: Name field truncated from " + item.Name.Length.ToString() + " to " + itemName.Length.ToString() + " characters");
|
||||
}
|
||||
|
||||
string itemDesc = item.Description;
|
||||
if (item.Description.Length > 128)
|
||||
{
|
||||
itemDesc = item.Description.Substring(0, 128);
|
||||
m_log.Warn("[INVENTORY DB]: Description field truncated from " + item.Description.Length.ToString() + " to " + itemDesc.Length.ToString() + " characters");
|
||||
}
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand command = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("inventoryID", item.ID));
|
||||
command.Parameters.Add(database.CreateParameter("assetID", item.AssetID));
|
||||
command.Parameters.Add(database.CreateParameter("assetType", item.AssetType));
|
||||
command.Parameters.Add(database.CreateParameter("parentFolderID", item.Folder));
|
||||
command.Parameters.Add(database.CreateParameter("avatarID", item.Owner));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryName", itemName));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryDescription", itemDesc));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryNextPermissions", item.NextPermissions));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryCurrentPermissions", item.CurrentPermissions));
|
||||
command.Parameters.Add(database.CreateParameter("invType", item.InvType));
|
||||
command.Parameters.Add(database.CreateParameter("creatorID", item.CreatorId));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryBasePermissions", item.BasePermissions));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryEveryOnePermissions", item.EveryOnePermissions));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryGroupPermissions", item.GroupPermissions));
|
||||
command.Parameters.Add(database.CreateParameter("SalePrice", item.SalePrice));
|
||||
command.Parameters.Add(database.CreateParameter("SaleType", item.SaleType));
|
||||
command.Parameters.Add(database.CreateParameter("creationDate", item.CreationDate));
|
||||
command.Parameters.Add(database.CreateParameter("groupID", item.GroupID));
|
||||
command.Parameters.Add(database.CreateParameter("groupOwned", item.GroupOwned));
|
||||
command.Parameters.Add(database.CreateParameter("flags", item.Flags));
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[INVENTORY DB]: Error inserting item :" + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
sql = @"UPDATE inventoryfolders SET version = version + 1 WHERE ""folderID"" = @folderID";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand command = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("folderID", item.Folder.ToString()));
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[INVENTORY DB] Error updating inventory folder for new item :" + e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the specified inventory item
|
||||
/// </summary>
|
||||
/// <param name="item">Inventory item to update</param>
|
||||
public void updateInventoryItem(InventoryItemBase item)
|
||||
{
|
||||
string sql = @"UPDATE inventoryitems SET ""assetID"" = :assetID,
|
||||
""assetType"" = :assetType,
|
||||
""parentFolderID"" = :parentFolderID,
|
||||
""avatarID"" = :avatarID,
|
||||
""inventoryName"" = :inventoryName,
|
||||
""inventoryDescription"" = :inventoryDescription,
|
||||
""inventoryNextPermissions"" = :inventoryNextPermissions,
|
||||
""inventoryCurrentPermissions"" = :inventoryCurrentPermissions,
|
||||
""invType"" = :invType,
|
||||
""creatorID"" = :creatorID,
|
||||
""inventoryBasePermissions"" = :inventoryBasePermissions,
|
||||
""inventoryEveryOnePermissions"" = :inventoryEveryOnePermissions,
|
||||
""inventoryGroupPermissions"" = :inventoryGroupPermissions,
|
||||
""salePrice"" = :SalePrice,
|
||||
""saleType"" = :SaleType,
|
||||
""creationDate"" = :creationDate,
|
||||
""groupID"" = :groupID,
|
||||
""groupOwned"" = :groupOwned,
|
||||
flags = :flags
|
||||
WHERE ""inventoryID"" = :inventoryID";
|
||||
|
||||
string itemName = item.Name;
|
||||
if (item.Name.Length > 64)
|
||||
{
|
||||
itemName = item.Name.Substring(0, 64);
|
||||
m_log.Warn("[INVENTORY DB]: Name field truncated from " + item.Name.Length.ToString() + " to " + itemName.Length.ToString() + " characters on update");
|
||||
}
|
||||
|
||||
string itemDesc = item.Description;
|
||||
if (item.Description.Length > 128)
|
||||
{
|
||||
itemDesc = item.Description.Substring(0, 128);
|
||||
m_log.Warn("[INVENTORY DB]: Description field truncated from " + item.Description.Length.ToString() + " to " + itemDesc.Length.ToString() + " characters on update");
|
||||
}
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand command = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("inventoryID", item.ID));
|
||||
command.Parameters.Add(database.CreateParameter("assetID", item.AssetID));
|
||||
command.Parameters.Add(database.CreateParameter("assetType", item.AssetType));
|
||||
command.Parameters.Add(database.CreateParameter("parentFolderID", item.Folder));
|
||||
command.Parameters.Add(database.CreateParameter("avatarID", item.Owner));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryName", itemName));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryDescription", itemDesc));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryNextPermissions", item.NextPermissions));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryCurrentPermissions", item.CurrentPermissions));
|
||||
command.Parameters.Add(database.CreateParameter("invType", item.InvType));
|
||||
command.Parameters.Add(database.CreateParameter("creatorID", item.CreatorId));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryBasePermissions", item.BasePermissions));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryEveryOnePermissions", item.EveryOnePermissions));
|
||||
command.Parameters.Add(database.CreateParameter("inventoryGroupPermissions", item.GroupPermissions));
|
||||
command.Parameters.Add(database.CreateParameter("SalePrice", item.SalePrice));
|
||||
command.Parameters.Add(database.CreateParameter("SaleType", item.SaleType));
|
||||
command.Parameters.Add(database.CreateParameter("creationDate", item.CreationDate));
|
||||
command.Parameters.Add(database.CreateParameter("groupID", item.GroupID));
|
||||
command.Parameters.Add(database.CreateParameter("groupOwned", item.GroupOwned));
|
||||
command.Parameters.Add(database.CreateParameter("flags", item.Flags));
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[INVENTORY DB]: Error updating item :" + e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// See IInventoryDataPlugin
|
||||
|
||||
/// <summary>
|
||||
/// Delete an item in inventory database
|
||||
/// </summary>
|
||||
/// <param name="itemID">the item UUID</param>
|
||||
public void deleteInventoryItem(UUID itemID)
|
||||
{
|
||||
string sql = @"DELETE FROM inventoryitems WHERE ""inventoryID""=:inventoryID";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(database.CreateParameter("inventoryID", itemID));
|
||||
try
|
||||
{
|
||||
conn.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[INVENTORY DB]: Error deleting item :" + e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public InventoryItemBase queryInventoryItem(UUID itemID)
|
||||
{
|
||||
return getInventoryItem(itemID);
|
||||
}
|
||||
|
||||
public InventoryFolderBase queryInventoryFolder(UUID folderID)
|
||||
{
|
||||
return getInventoryFolder(folderID);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns all activated gesture-items in the inventory of the specified avatar.
|
||||
/// </summary>
|
||||
/// <param name="avatarID">The <see cref="UUID"/> of the avatar</param>
|
||||
/// <returns>
|
||||
/// The list of gestures (<see cref="InventoryItemBase"/>s)
|
||||
/// </returns>
|
||||
public List<InventoryItemBase> fetchActiveGestures(UUID avatarID)
|
||||
{
|
||||
string sql = @"SELECT * FROM inventoryitems WHERE ""avatarID"" = :uuid AND ""assetType"" = :assetType and flags = 1";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(database.CreateParameter("uuid", avatarID));
|
||||
cmd.Parameters.Add(database.CreateParameter("assetType", (int)AssetType.Gesture));
|
||||
conn.Open();
|
||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
List<InventoryItemBase> gestureList = new List<InventoryItemBase>();
|
||||
while (reader.Read())
|
||||
{
|
||||
gestureList.Add(readInventoryItem(reader));
|
||||
}
|
||||
return gestureList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private methods
|
||||
|
||||
/// <summary>
|
||||
/// Delete an item in inventory database
|
||||
/// </summary>
|
||||
/// <param name="folderID">the item ID</param>
|
||||
/// <param name="connection">connection to the database</param>
|
||||
private void DeleteItemsInFolder(UUID folderID, NpgsqlConnection connection)
|
||||
{
|
||||
using (NpgsqlCommand command = new NpgsqlCommand(@"DELETE FROM inventoryitems WHERE ""folderID""=:folderID", connection))
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("folderID", folderID));
|
||||
|
||||
try
|
||||
{
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[INVENTORY DB] Error deleting item :" + e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the folder hierarchy in a loop.
|
||||
/// </summary>
|
||||
/// <param name="parentID">parent ID.</param>
|
||||
/// <param name="command">SQL command/connection to database</param>
|
||||
/// <returns></returns>
|
||||
private static List<InventoryFolderBase> getFolderHierarchy(UUID parentID, NpgsqlCommand command)
|
||||
{
|
||||
command.Parameters["parentID"].Value = parentID.Guid; //.ToString();
|
||||
|
||||
List<InventoryFolderBase> folders = getInventoryFolders(command);
|
||||
|
||||
if (folders.Count > 0)
|
||||
{
|
||||
List<InventoryFolderBase> tempFolders = new List<InventoryFolderBase>();
|
||||
|
||||
foreach (InventoryFolderBase folderBase in folders)
|
||||
{
|
||||
tempFolders.AddRange(getFolderHierarchy(folderBase.ID, command));
|
||||
}
|
||||
|
||||
if (tempFolders.Count > 0)
|
||||
{
|
||||
folders.AddRange(tempFolders);
|
||||
}
|
||||
}
|
||||
return folders;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the inventory folders.
|
||||
/// </summary>
|
||||
/// <param name="parentID">parentID, use UUID.Zero to get root</param>
|
||||
/// <param name="user">user id, use UUID.Zero, if you want all folders from a parentID.</param>
|
||||
/// <returns></returns>
|
||||
private List<InventoryFolderBase> getInventoryFolders(UUID parentID, UUID user)
|
||||
{
|
||||
string sql = @"SELECT * FROM inventoryfolders WHERE ""parentFolderID"" = :parentID AND ""agentID"" = :uuid";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
using (NpgsqlCommand command = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
if (user == UUID.Zero)
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("uuid", "%"));
|
||||
}
|
||||
else
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("uuid", user));
|
||||
}
|
||||
command.Parameters.Add(database.CreateParameter("parentID", parentID));
|
||||
conn.Open();
|
||||
return getInventoryFolders(command);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the inventory folders.
|
||||
/// </summary>
|
||||
/// <param name="command">SQLcommand.</param>
|
||||
/// <returns></returns>
|
||||
private static List<InventoryFolderBase> getInventoryFolders(NpgsqlCommand command)
|
||||
{
|
||||
using (NpgsqlDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
|
||||
List<InventoryFolderBase> items = new List<InventoryFolderBase>();
|
||||
while (reader.Read())
|
||||
{
|
||||
items.Add(readInventoryFolder(reader));
|
||||
}
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a list of inventory folders returned by a query.
|
||||
/// </summary>
|
||||
/// <param name="reader">A PGSQL Data Reader</param>
|
||||
/// <returns>A List containing inventory folders</returns>
|
||||
protected static InventoryFolderBase readInventoryFolder(NpgsqlDataReader reader)
|
||||
{
|
||||
try
|
||||
{
|
||||
InventoryFolderBase folder = new InventoryFolderBase();
|
||||
folder.Owner = DBGuid.FromDB(reader["agentID"]);
|
||||
folder.ParentID = DBGuid.FromDB(reader["parentFolderID"]);
|
||||
folder.ID = DBGuid.FromDB(reader["folderID"]);
|
||||
folder.Name = (string)reader["folderName"];
|
||||
folder.Type = (short)reader["type"];
|
||||
folder.Version = Convert.ToUInt16(reader["version"]);
|
||||
|
||||
return folder;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[INVENTORY DB] Error reading inventory folder :" + e.Message);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a one item from an SQL result
|
||||
/// </summary>
|
||||
/// <param name="reader">The SQL Result</param>
|
||||
/// <returns>the item read</returns>
|
||||
private static InventoryItemBase readInventoryItem(IDataRecord reader)
|
||||
{
|
||||
try
|
||||
{
|
||||
InventoryItemBase item = new InventoryItemBase();
|
||||
|
||||
item.ID = DBGuid.FromDB(reader["inventoryID"]);
|
||||
item.AssetID = DBGuid.FromDB(reader["assetID"]);
|
||||
item.AssetType = Convert.ToInt32(reader["assetType"].ToString());
|
||||
item.Folder = DBGuid.FromDB(reader["parentFolderID"]);
|
||||
item.Owner = DBGuid.FromDB(reader["avatarID"]);
|
||||
item.Name = reader["inventoryName"].ToString();
|
||||
item.Description = reader["inventoryDescription"].ToString();
|
||||
item.NextPermissions = Convert.ToUInt32(reader["inventoryNextPermissions"]);
|
||||
item.CurrentPermissions = Convert.ToUInt32(reader["inventoryCurrentPermissions"]);
|
||||
item.InvType = Convert.ToInt32(reader["invType"].ToString());
|
||||
item.CreatorId = reader["creatorID"].ToString();
|
||||
item.BasePermissions = Convert.ToUInt32(reader["inventoryBasePermissions"]);
|
||||
item.EveryOnePermissions = Convert.ToUInt32(reader["inventoryEveryOnePermissions"]);
|
||||
item.GroupPermissions = Convert.ToUInt32(reader["inventoryGroupPermissions"]);
|
||||
item.SalePrice = Convert.ToInt32(reader["salePrice"]);
|
||||
item.SaleType = Convert.ToByte(reader["saleType"]);
|
||||
item.CreationDate = Convert.ToInt32(reader["creationDate"]);
|
||||
item.GroupID = DBGuid.FromDB(reader["groupID"]);
|
||||
item.GroupOwned = Convert.ToBoolean(reader["groupOwned"]);
|
||||
item.Flags = Convert.ToUInt32(reader["flags"]);
|
||||
|
||||
return item;
|
||||
}
|
||||
catch (NpgsqlException e)
|
||||
{
|
||||
m_log.Error("[INVENTORY DB]: Error reading inventory item :" + e.Message);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete a folder in inventory databasae
|
||||
/// </summary>
|
||||
/// <param name="folderID">the folder UUID</param>
|
||||
/// <param name="connection">connection to database</param>
|
||||
private void DeleteOneFolder(UUID folderID, NpgsqlConnection connection)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (NpgsqlCommand command = new NpgsqlCommand(@"DELETE FROM inventoryfolders WHERE ""folderID""=:folderID and type=-1", connection))
|
||||
{
|
||||
command.Parameters.Add(database.CreateParameter("folderID", folderID));
|
||||
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
catch (NpgsqlException e)
|
||||
{
|
||||
m_log.Error("[INVENTORY DB]: Error deleting folder :" + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
350
OpenSim/Data/PGSQL/PGSQLManager.cs
Normal file
350
OpenSim/Data/PGSQL/PGSQLManager.cs
Normal file
@@ -0,0 +1,350 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using OpenSim.Framework;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using Npgsql;
|
||||
using NpgsqlTypes;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
/// <summary>
|
||||
/// A management class for the MS SQL Storage Engine
|
||||
/// </summary>
|
||||
public class PGSQLManager
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
/// <summary>
|
||||
/// Connection string for ADO.net
|
||||
/// </summary>
|
||||
private readonly string connectionString;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the manager and set the connectionstring
|
||||
/// </summary>
|
||||
/// <param name="connection"></param>
|
||||
public PGSQLManager(string connection)
|
||||
{
|
||||
connectionString = connection;
|
||||
InitializeMonoSecurity();
|
||||
}
|
||||
|
||||
public void InitializeMonoSecurity()
|
||||
{
|
||||
if (!Util.IsPlatformMono)
|
||||
{
|
||||
if (AppDomain.CurrentDomain.GetData("MonoSecurityPostgresAdded") == null)
|
||||
{
|
||||
AppDomain.CurrentDomain.SetData("MonoSecurityPostgresAdded", "true");
|
||||
|
||||
AppDomain currentDomain = AppDomain.CurrentDomain;
|
||||
currentDomain.AssemblyResolve += new ResolveEventHandler(ResolveEventHandlerMonoSec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private System.Reflection.Assembly ResolveEventHandlerMonoSec(object sender, ResolveEventArgs args)
|
||||
{
|
||||
Assembly MyAssembly = null;
|
||||
|
||||
if (args.Name.Substring(0, args.Name.IndexOf(",")) == "Mono.Security")
|
||||
{
|
||||
MyAssembly = Assembly.LoadFrom("lib/NET/Mono.Security.dll");
|
||||
}
|
||||
|
||||
//Return the loaded assembly.
|
||||
return MyAssembly;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Type conversion to a SQLDbType functions
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
internal NpgsqlDbType DbtypeFromType(Type type)
|
||||
{
|
||||
if (type == typeof(string))
|
||||
{
|
||||
return NpgsqlDbType.Varchar;
|
||||
}
|
||||
if (type == typeof(double))
|
||||
{
|
||||
return NpgsqlDbType.Double;
|
||||
}
|
||||
if (type == typeof(Single))
|
||||
{
|
||||
return NpgsqlDbType.Double;
|
||||
}
|
||||
if (type == typeof(int))
|
||||
{
|
||||
return NpgsqlDbType.Integer;
|
||||
}
|
||||
if (type == typeof(bool))
|
||||
{
|
||||
return NpgsqlDbType.Boolean;
|
||||
}
|
||||
if (type == typeof(UUID))
|
||||
{
|
||||
return NpgsqlDbType.Uuid;
|
||||
}
|
||||
if (type == typeof(byte))
|
||||
{
|
||||
return NpgsqlDbType.Smallint;
|
||||
}
|
||||
if (type == typeof(sbyte))
|
||||
{
|
||||
return NpgsqlDbType.Integer;
|
||||
}
|
||||
if (type == typeof(Byte[]))
|
||||
{
|
||||
return NpgsqlDbType.Bytea;
|
||||
}
|
||||
if (type == typeof(uint) || type == typeof(ushort))
|
||||
{
|
||||
return NpgsqlDbType.Integer;
|
||||
}
|
||||
if (type == typeof(ulong))
|
||||
{
|
||||
return NpgsqlDbType.Bigint;
|
||||
}
|
||||
if (type == typeof(DateTime))
|
||||
{
|
||||
return NpgsqlDbType.Timestamp;
|
||||
}
|
||||
|
||||
return NpgsqlDbType.Varchar;
|
||||
}
|
||||
|
||||
internal NpgsqlDbType DbtypeFromString(Type type, string PGFieldType)
|
||||
{
|
||||
if (PGFieldType == "")
|
||||
{
|
||||
return DbtypeFromType(type);
|
||||
}
|
||||
|
||||
if (PGFieldType == "character varying")
|
||||
{
|
||||
return NpgsqlDbType.Varchar;
|
||||
}
|
||||
if (PGFieldType == "double precision")
|
||||
{
|
||||
return NpgsqlDbType.Double;
|
||||
}
|
||||
if (PGFieldType == "integer")
|
||||
{
|
||||
return NpgsqlDbType.Integer;
|
||||
}
|
||||
if (PGFieldType == "smallint")
|
||||
{
|
||||
return NpgsqlDbType.Smallint;
|
||||
}
|
||||
if (PGFieldType == "boolean")
|
||||
{
|
||||
return NpgsqlDbType.Boolean;
|
||||
}
|
||||
if (PGFieldType == "uuid")
|
||||
{
|
||||
return NpgsqlDbType.Uuid;
|
||||
}
|
||||
if (PGFieldType == "bytea")
|
||||
{
|
||||
return NpgsqlDbType.Bytea;
|
||||
}
|
||||
|
||||
return DbtypeFromType(type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates value for parameter.
|
||||
/// </summary>
|
||||
/// <param name="value">The value.</param>
|
||||
/// <returns></returns>
|
||||
private static object CreateParameterValue(object value)
|
||||
{
|
||||
Type valueType = value.GetType();
|
||||
|
||||
if (valueType == typeof(UUID)) //TODO check if this works
|
||||
{
|
||||
return ((UUID) value).Guid;
|
||||
}
|
||||
if (valueType == typeof(UUID))
|
||||
{
|
||||
return ((UUID)value).Guid;
|
||||
}
|
||||
if (valueType == typeof(bool))
|
||||
{
|
||||
return (bool)value;
|
||||
}
|
||||
if (valueType == typeof(Byte[]))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
if (valueType == typeof(int))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create value for parameter based on PGSQL Schema
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="PGFieldType"></param>
|
||||
/// <returns></returns>
|
||||
internal static object CreateParameterValue(object value, string PGFieldType)
|
||||
{
|
||||
if (PGFieldType == "uuid")
|
||||
{
|
||||
UUID uidout;
|
||||
UUID.TryParse(value.ToString(), out uidout);
|
||||
return uidout;
|
||||
}
|
||||
if (PGFieldType == "integer")
|
||||
{
|
||||
int intout;
|
||||
int.TryParse(value.ToString(), out intout);
|
||||
return intout;
|
||||
}
|
||||
if (PGFieldType == "boolean")
|
||||
{
|
||||
return (value.ToString() == "true");
|
||||
}
|
||||
if (PGFieldType == "timestamp with time zone")
|
||||
{
|
||||
return (DateTime)value;
|
||||
}
|
||||
if (PGFieldType == "timestamp without time zone")
|
||||
{
|
||||
return (DateTime)value;
|
||||
}
|
||||
return CreateParameterValue(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a parameter for a command
|
||||
/// </summary>
|
||||
/// <param name="parameterName">Name of the parameter.</param>
|
||||
/// <param name="parameterObject">parameter object.</param>
|
||||
/// <returns></returns>
|
||||
internal NpgsqlParameter CreateParameter(string parameterName, object parameterObject)
|
||||
{
|
||||
return CreateParameter(parameterName, parameterObject, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the parameter for a command.
|
||||
/// </summary>
|
||||
/// <param name="parameterName">Name of the parameter.</param>
|
||||
/// <param name="parameterObject">parameter object.</param>
|
||||
/// <param name="parameterOut">if set to <c>true</c> parameter is a output parameter</param>
|
||||
/// <returns></returns>
|
||||
internal NpgsqlParameter CreateParameter(string parameterName, object parameterObject, bool parameterOut)
|
||||
{
|
||||
//Tweak so we dont always have to add : sign
|
||||
if (parameterName.StartsWith(":")) parameterName = parameterName.Replace(":","");
|
||||
|
||||
//HACK if object is null, it is turned into a string, there are no nullable type till now
|
||||
if (parameterObject == null) parameterObject = "";
|
||||
|
||||
NpgsqlParameter parameter = new NpgsqlParameter(parameterName, DbtypeFromType(parameterObject.GetType()));
|
||||
|
||||
if (parameterOut)
|
||||
{
|
||||
parameter.Direction = ParameterDirection.Output;
|
||||
}
|
||||
else
|
||||
{
|
||||
parameter.Direction = ParameterDirection.Input;
|
||||
parameter.Value = CreateParameterValue(parameterObject);
|
||||
}
|
||||
|
||||
return parameter;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a parameter with PGSQL schema type
|
||||
/// </summary>
|
||||
/// <param name="parameterName"></param>
|
||||
/// <param name="parameterObject"></param>
|
||||
/// <param name="PGFieldType"></param>
|
||||
/// <returns></returns>
|
||||
internal NpgsqlParameter CreateParameter(string parameterName, object parameterObject, string PGFieldType)
|
||||
{
|
||||
//Tweak so we dont always have to add : sign
|
||||
if (parameterName.StartsWith(":")) parameterName = parameterName.Replace(":", "");
|
||||
|
||||
//HACK if object is null, it is turned into a string, there are no nullable type till now
|
||||
if (parameterObject == null) parameterObject = "";
|
||||
|
||||
NpgsqlParameter parameter = new NpgsqlParameter(parameterName, DbtypeFromString(parameterObject.GetType(), PGFieldType));
|
||||
|
||||
parameter.Direction = ParameterDirection.Input;
|
||||
parameter.Value = CreateParameterValue(parameterObject, PGFieldType);
|
||||
|
||||
return parameter;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if we need to do some migrations to the database
|
||||
/// </summary>
|
||||
/// <param name="migrationStore">migrationStore.</param>
|
||||
public void CheckMigration(string migrationStore)
|
||||
{
|
||||
using (NpgsqlConnection connection = new NpgsqlConnection(connectionString))
|
||||
{
|
||||
connection.Open();
|
||||
Assembly assem = GetType().Assembly;
|
||||
PGSQLMigration migration = new PGSQLMigration(connection, assem, migrationStore);
|
||||
|
||||
migration.Update();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the version of this DB provider
|
||||
/// </summary>
|
||||
/// <returns>A string containing the DB provider</returns>
|
||||
public string getVersion()
|
||||
{
|
||||
Module module = GetType().Module;
|
||||
// string dllName = module.Assembly.ManifestModule.Name;
|
||||
Version dllVersion = module.Assembly.GetName().Version;
|
||||
|
||||
return
|
||||
string.Format("{0}.{1}.{2}.{3}", dllVersion.Major, dllVersion.Minor, dllVersion.Build,
|
||||
dllVersion.Revision);
|
||||
}
|
||||
}
|
||||
}
|
||||
102
OpenSim/Data/PGSQL/PGSQLMigration.cs
Normal file
102
OpenSim/Data/PGSQL/PGSQLMigration.cs
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using Npgsql;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Reflection;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
public class PGSQLMigration : Migration
|
||||
{
|
||||
public PGSQLMigration(NpgsqlConnection conn, Assembly assem, string type)
|
||||
: base(conn, assem, type)
|
||||
{
|
||||
}
|
||||
|
||||
public PGSQLMigration(NpgsqlConnection conn, Assembly assem, string subtype, string type)
|
||||
: base(conn, assem, subtype, type)
|
||||
{
|
||||
}
|
||||
|
||||
protected override int FindVersion(DbConnection conn, string type)
|
||||
{
|
||||
int version = 0;
|
||||
NpgsqlConnection lcConn = (NpgsqlConnection)conn;
|
||||
|
||||
using (NpgsqlCommand cmd = lcConn.CreateCommand())
|
||||
{
|
||||
try
|
||||
{
|
||||
cmd.CommandText = "select version from migrations where name = '" + type + "' " +
|
||||
" order by version desc limit 1"; //Must be
|
||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
version = Convert.ToInt32(reader["version"]);
|
||||
}
|
||||
reader.Close();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Return -1 to indicate table does not exist
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
protected override void ExecuteScript(DbConnection conn, string[] script)
|
||||
{
|
||||
if (!(conn is NpgsqlConnection))
|
||||
{
|
||||
base.ExecuteScript(conn, script);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (string sql in script)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, (NpgsqlConnection)conn))
|
||||
{
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new Exception(sql);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,38 +26,31 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using OpenSim.Framework;
|
||||
using OpenMetaverse;
|
||||
using Npgsql;
|
||||
|
||||
namespace OpenSim.Framework.Configuration.HTTP
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
public class RemoteConfigSettings
|
||||
public class PGSQLOfflineIMData : PGSQLGenericTableHandler<OfflineIMData>, IOfflineIMData
|
||||
{
|
||||
private ConfigurationMember configMember;
|
||||
|
||||
public string baseConfigURL = String.Empty;
|
||||
|
||||
public RemoteConfigSettings(string filename)
|
||||
public PGSQLOfflineIMData(string connectionString, string realm)
|
||||
: base(connectionString, realm, "IM_Store")
|
||||
{
|
||||
configMember =
|
||||
new ConfigurationMember(filename, "REMOTE CONFIG SETTINGS", loadConfigurationOptions,
|
||||
handleIncomingConfiguration,true);
|
||||
configMember.forceConfigurationPluginLibrary("OpenSim.Framework.Configuration.XML.dll");
|
||||
configMember.performConfigurationRetrieve();
|
||||
}
|
||||
|
||||
public void loadConfigurationOptions()
|
||||
public void DeleteOld()
|
||||
{
|
||||
configMember.addConfigurationOption("base_config_url",
|
||||
ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
|
||||
"URL Containing Configuration Files", "http://localhost/", false);
|
||||
}
|
||||
|
||||
public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
|
||||
{
|
||||
if (configuration_key == "base_config_url")
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
baseConfigURL = (string) configuration_result;
|
||||
cmd.CommandText = String.Format("delete from {0} where \"TMStamp\" < CURRENT_DATE - INTERVAL '2 week'", m_Realm);
|
||||
|
||||
ExecuteNonQuery(cmd);
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
115
OpenSim/Data/PGSQL/PGSQLPresenceData.cs
Normal file
115
OpenSim/Data/PGSQL/PGSQLPresenceData.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using Npgsql;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
/// <summary>
|
||||
/// A PGSQL Interface for the Presence Server
|
||||
/// </summary>
|
||||
public class PGSQLPresenceData : PGSQLGenericTableHandler<PresenceData>,
|
||||
IPresenceData
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public PGSQLPresenceData(string connectionString, string realm) :
|
||||
base(connectionString, realm, "Presence")
|
||||
{
|
||||
}
|
||||
|
||||
public PresenceData Get(UUID sessionID)
|
||||
{
|
||||
PresenceData[] ret = Get("SessionID", sessionID.ToString());
|
||||
|
||||
if (ret.Length == 0)
|
||||
return null;
|
||||
|
||||
return ret[0];
|
||||
}
|
||||
|
||||
public void LogoutRegionAgents(UUID regionID)
|
||||
{
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
|
||||
cmd.CommandText = String.Format(@"DELETE FROM {0} WHERE ""RegionID""=:RegionID", m_Realm);
|
||||
|
||||
cmd.Parameters.Add(m_database.CreateParameter("RegionID", regionID));
|
||||
cmd.Connection = conn;
|
||||
conn.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
|
||||
public bool ReportAgent(UUID sessionID, UUID regionID)
|
||||
{
|
||||
PresenceData[] pd = Get("SessionID", sessionID.ToString());
|
||||
if (pd.Length == 0)
|
||||
return false;
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
|
||||
cmd.CommandText = String.Format(@"UPDATE {0} SET
|
||||
""RegionID"" = :RegionID
|
||||
WHERE ""SessionID"" = :SessionID", m_Realm);
|
||||
|
||||
cmd.Parameters.Add(m_database.CreateParameter("SessionID", sessionID));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("RegionID", regionID));
|
||||
cmd.Connection = conn;
|
||||
conn.Open();
|
||||
if (cmd.ExecuteNonQuery() == 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool VerifyAgent(UUID agentId, UUID secureSessionID)
|
||||
{
|
||||
PresenceData[] ret = Get("SecureSessionID", secureSessionID.ToString());
|
||||
|
||||
if (ret.Length == 0)
|
||||
return false;
|
||||
|
||||
if(ret[0].UserID != agentId.ToString())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
392
OpenSim/Data/PGSQL/PGSQLRegionData.cs
Normal file
392
OpenSim/Data/PGSQL/PGSQLRegionData.cs
Normal file
@@ -0,0 +1,392 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ''AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using RegionFlags = OpenSim.Framework.RegionFlags;
|
||||
using Npgsql;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
/// <summary>
|
||||
/// A PGSQL Interface for the Region Server.
|
||||
/// </summary>
|
||||
public class PGSQLRegionData : IRegionData
|
||||
{
|
||||
private string m_Realm;
|
||||
private List<string> m_ColumnNames = null;
|
||||
private string m_ConnectionString;
|
||||
private PGSQLManager m_database;
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
protected Dictionary<string, string> m_FieldTypes = new Dictionary<string, string>();
|
||||
|
||||
protected virtual Assembly Assembly
|
||||
{
|
||||
get { return GetType().Assembly; }
|
||||
}
|
||||
|
||||
public PGSQLRegionData(string connectionString, string realm)
|
||||
{
|
||||
m_Realm = realm;
|
||||
m_ConnectionString = connectionString;
|
||||
m_database = new PGSQLManager(connectionString);
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
Migration m = new Migration(conn, GetType().Assembly, "GridStore");
|
||||
m.Update();
|
||||
}
|
||||
LoadFieldTypes();
|
||||
}
|
||||
|
||||
private void LoadFieldTypes()
|
||||
{
|
||||
m_FieldTypes = new Dictionary<string, string>();
|
||||
|
||||
string query = string.Format(@"select column_name,data_type
|
||||
from INFORMATION_SCHEMA.COLUMNS
|
||||
where table_name = lower('{0}');
|
||||
|
||||
", m_Realm);
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(query, conn))
|
||||
{
|
||||
conn.Open();
|
||||
using (NpgsqlDataReader rdr = cmd.ExecuteReader())
|
||||
{
|
||||
while (rdr.Read())
|
||||
{
|
||||
// query produces 0 to many rows of single column, so always add the first item in each row
|
||||
m_FieldTypes.Add((string)rdr[0], (string)rdr[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<RegionData> Get(string regionName, UUID scopeID)
|
||||
{
|
||||
string sql = "select * from "+m_Realm+" where lower(\"regionName\") like lower(:regionName) ";
|
||||
if (scopeID != UUID.Zero)
|
||||
sql += " and \"ScopeID\" = :scopeID";
|
||||
sql += " order by lower(\"regionName\")";
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter("regionName", regionName));
|
||||
if (scopeID != UUID.Zero)
|
||||
cmd.Parameters.Add(m_database.CreateParameter("scopeID", scopeID));
|
||||
conn.Open();
|
||||
return RunCommand(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
public RegionData Get(int posX, int posY, UUID scopeID)
|
||||
{
|
||||
string sql = "select * from "+m_Realm+" where \"locX\" = :posX and \"locY\" = :posY";
|
||||
if (scopeID != UUID.Zero)
|
||||
sql += " and \"ScopeID\" = :scopeID";
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter("posX", posX));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("posY", posY));
|
||||
if (scopeID != UUID.Zero)
|
||||
cmd.Parameters.Add(m_database.CreateParameter("scopeID", scopeID));
|
||||
conn.Open();
|
||||
List<RegionData> ret = RunCommand(cmd);
|
||||
if (ret.Count == 0)
|
||||
return null;
|
||||
|
||||
return ret[0];
|
||||
}
|
||||
}
|
||||
|
||||
public RegionData Get(UUID regionID, UUID scopeID)
|
||||
{
|
||||
string sql = "select * from "+m_Realm+" where uuid = :regionID";
|
||||
if (scopeID != UUID.Zero)
|
||||
sql += " and \"ScopeID\" = :scopeID";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter("regionID", regionID));
|
||||
if (scopeID != UUID.Zero)
|
||||
cmd.Parameters.Add(m_database.CreateParameter("scopeID", scopeID));
|
||||
conn.Open();
|
||||
List<RegionData> ret = RunCommand(cmd);
|
||||
if (ret.Count == 0)
|
||||
return null;
|
||||
|
||||
return ret[0];
|
||||
}
|
||||
}
|
||||
|
||||
public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID)
|
||||
{
|
||||
string sql = "select * from "+m_Realm+" where \"locX\" between :startX and :endX and \"locY\" between :startY and :endY";
|
||||
if (scopeID != UUID.Zero)
|
||||
sql += " and \"ScopeID\" = :scopeID";
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter("startX", startX));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("startY", startY));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("endX", endX));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("endY", endY));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("scopeID", scopeID));
|
||||
conn.Open();
|
||||
return RunCommand(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
public List<RegionData> RunCommand(NpgsqlCommand cmd)
|
||||
{
|
||||
List<RegionData> retList = new List<RegionData>();
|
||||
|
||||
NpgsqlDataReader result = cmd.ExecuteReader();
|
||||
|
||||
while (result.Read())
|
||||
{
|
||||
RegionData ret = new RegionData();
|
||||
ret.Data = new Dictionary<string, object>();
|
||||
|
||||
UUID regionID;
|
||||
UUID.TryParse(result["uuid"].ToString(), out regionID);
|
||||
ret.RegionID = regionID;
|
||||
UUID scope;
|
||||
UUID.TryParse(result["ScopeID"].ToString(), out scope);
|
||||
ret.ScopeID = scope;
|
||||
ret.RegionName = result["regionName"].ToString();
|
||||
ret.posX = Convert.ToInt32(result["locX"]);
|
||||
ret.posY = Convert.ToInt32(result["locY"]);
|
||||
ret.sizeX = Convert.ToInt32(result["sizeX"]);
|
||||
ret.sizeY = Convert.ToInt32(result["sizeY"]);
|
||||
|
||||
if (m_ColumnNames == null)
|
||||
{
|
||||
m_ColumnNames = new List<string>();
|
||||
|
||||
DataTable schemaTable = result.GetSchemaTable();
|
||||
foreach (DataRow row in schemaTable.Rows)
|
||||
m_ColumnNames.Add(row["ColumnName"].ToString());
|
||||
}
|
||||
|
||||
foreach (string s in m_ColumnNames)
|
||||
{
|
||||
if (s == "uuid")
|
||||
continue;
|
||||
if (s == "ScopeID")
|
||||
continue;
|
||||
if (s == "regionName")
|
||||
continue;
|
||||
if (s == "locX")
|
||||
continue;
|
||||
if (s == "locY")
|
||||
continue;
|
||||
|
||||
ret.Data[s] = result[s].ToString();
|
||||
}
|
||||
|
||||
retList.Add(ret);
|
||||
}
|
||||
return retList;
|
||||
}
|
||||
|
||||
public bool Store(RegionData data)
|
||||
{
|
||||
if (data.Data.ContainsKey("uuid"))
|
||||
data.Data.Remove("uuid");
|
||||
if (data.Data.ContainsKey("ScopeID"))
|
||||
data.Data.Remove("ScopeID");
|
||||
if (data.Data.ContainsKey("regionName"))
|
||||
data.Data.Remove("regionName");
|
||||
if (data.Data.ContainsKey("posX"))
|
||||
data.Data.Remove("posX");
|
||||
if (data.Data.ContainsKey("posY"))
|
||||
data.Data.Remove("posY");
|
||||
if (data.Data.ContainsKey("sizeX"))
|
||||
data.Data.Remove("sizeX");
|
||||
if (data.Data.ContainsKey("sizeY"))
|
||||
data.Data.Remove("sizeY");
|
||||
if (data.Data.ContainsKey("locX"))
|
||||
data.Data.Remove("locX");
|
||||
if (data.Data.ContainsKey("locY"))
|
||||
data.Data.Remove("locY");
|
||||
|
||||
string[] fields = new List<string>(data.Data.Keys).ToArray();
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
|
||||
string update = "update " + m_Realm + " set \"locX\"=:posX, \"locY\"=:posY, \"sizeX\"=:sizeX, \"sizeY\"=:sizeY ";
|
||||
|
||||
foreach (string field in fields)
|
||||
{
|
||||
|
||||
update += ", ";
|
||||
update += " \"" + field + "\" = :" + field;
|
||||
|
||||
if (m_FieldTypes.ContainsKey(field))
|
||||
cmd.Parameters.Add(m_database.CreateParameter(field, data.Data[field], m_FieldTypes[field]));
|
||||
else
|
||||
cmd.Parameters.Add(m_database.CreateParameter(field, data.Data[field]));
|
||||
}
|
||||
|
||||
update += " where uuid = :regionID";
|
||||
|
||||
if (data.ScopeID != UUID.Zero)
|
||||
update += " and \"ScopeID\" = :scopeID";
|
||||
|
||||
cmd.CommandText = update;
|
||||
cmd.Connection = conn;
|
||||
cmd.Parameters.Add(m_database.CreateParameter("regionID", data.RegionID));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("regionName", data.RegionName));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("scopeID", data.ScopeID));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("posX", data.posX));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("posY", data.posY));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("sizeX", data.sizeX));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("sizeY", data.sizeY));
|
||||
conn.Open();
|
||||
try
|
||||
{
|
||||
if (cmd.ExecuteNonQuery() < 1)
|
||||
{
|
||||
string insert = "insert into " + m_Realm + " (uuid, \"ScopeID\", \"locX\", \"locY\", \"sizeX\", \"sizeY\", \"regionName\", \"" +
|
||||
String.Join("\", \"", fields) +
|
||||
"\") values (:regionID, :scopeID, :posX, :posY, :sizeX, :sizeY, :regionName, :" + String.Join(", :", fields) + ")";
|
||||
|
||||
cmd.CommandText = insert;
|
||||
|
||||
try
|
||||
{
|
||||
if (cmd.ExecuteNonQuery() < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
m_log.Warn("[PGSQL Grid]: Error inserting into Regions table: " + ex.Message + ", INSERT sql: " + insert);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
m_log.Warn("[PGSQL Grid]: Error updating Regions table: " + ex.Message + ", UPDATE sql: " + update);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool SetDataItem(UUID regionID, string item, string value)
|
||||
{
|
||||
string sql = "update " + m_Realm +
|
||||
" set \"" + item + "\" = :" + item + " where uuid = :UUID";
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter("" + item, value));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("UUID", regionID));
|
||||
conn.Open();
|
||||
if (cmd.ExecuteNonQuery() > 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Delete(UUID regionID)
|
||||
{
|
||||
string sql = "delete from " + m_Realm +
|
||||
" where uuid = :UUID";
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter("UUID", regionID));
|
||||
conn.Open();
|
||||
if (cmd.ExecuteNonQuery() > 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<RegionData> GetDefaultRegions(UUID scopeID)
|
||||
{
|
||||
return Get((int)RegionFlags.DefaultRegion, scopeID);
|
||||
}
|
||||
|
||||
public List<RegionData> GetDefaultHypergridRegions(UUID scopeID)
|
||||
{
|
||||
return Get((int)RegionFlags.DefaultHGRegion, scopeID);
|
||||
}
|
||||
|
||||
public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y)
|
||||
{
|
||||
List<RegionData> regions = Get((int)RegionFlags.FallbackRegion, scopeID);
|
||||
RegionDataDistanceCompare distanceComparer = new RegionDataDistanceCompare(x, y);
|
||||
regions.Sort(distanceComparer);
|
||||
|
||||
return regions;
|
||||
}
|
||||
|
||||
public List<RegionData> GetHyperlinks(UUID scopeID)
|
||||
{
|
||||
return Get((int)RegionFlags.Hyperlink, scopeID);
|
||||
}
|
||||
|
||||
private List<RegionData> Get(int regionFlags, UUID scopeID)
|
||||
{
|
||||
string sql = "SELECT * FROM " + m_Realm + " WHERE (\"flags\" & " + regionFlags.ToString() + ") <> 0";
|
||||
if (scopeID != UUID.Zero)
|
||||
sql += " AND \"ScopeID\" = :scopeID";
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter("scopeID", scopeID));
|
||||
conn.Open();
|
||||
return RunCommand(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2243
OpenSim/Data/PGSQL/PGSQLSimulationData.cs
Normal file
2243
OpenSim/Data/PGSQL/PGSQLSimulationData.cs
Normal file
File diff suppressed because it is too large
Load Diff
325
OpenSim/Data/PGSQL/PGSQLUserAccountData.cs
Normal file
325
OpenSim/Data/PGSQL/PGSQLUserAccountData.cs
Normal file
@@ -0,0 +1,325 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ''AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using System.Text;
|
||||
using Npgsql;
|
||||
using log4net;
|
||||
using System.Reflection;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
public class PGSQLUserAccountData : PGSQLGenericTableHandler<UserAccountData>,IUserAccountData
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
|
||||
public PGSQLUserAccountData(string connectionString, string realm) :
|
||||
base(connectionString, realm, "UserAccount")
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
private string m_Realm;
|
||||
private List<string> m_ColumnNames = null;
|
||||
private PGSQLManager m_database;
|
||||
|
||||
public PGSQLUserAccountData(string connectionString, string realm) :
|
||||
base(connectionString, realm, "UserAccount")
|
||||
{
|
||||
m_Realm = realm;
|
||||
m_ConnectionString = connectionString;
|
||||
m_database = new PGSQLManager(connectionString);
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
{
|
||||
conn.Open();
|
||||
Migration m = new Migration(conn, GetType().Assembly, "UserAccount");
|
||||
m.Update();
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*
|
||||
public List<UserAccountData> Query(UUID principalID, UUID scopeID, string query)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
public override UserAccountData[] Get(string[] fields, string[] keys)
|
||||
{
|
||||
UserAccountData[] retUA = base.Get(fields,keys);
|
||||
|
||||
if (retUA.Length > 0)
|
||||
{
|
||||
Dictionary<string, string> data = retUA[0].Data;
|
||||
Dictionary<string, string> data2 = new Dictionary<string, string>();
|
||||
|
||||
foreach (KeyValuePair<string,string> chave in data)
|
||||
{
|
||||
string s2 = chave.Key;
|
||||
|
||||
data2[s2] = chave.Value;
|
||||
|
||||
if (!m_FieldTypes.ContainsKey(chave.Key))
|
||||
{
|
||||
string tipo = "";
|
||||
m_FieldTypes.TryGetValue(chave.Key, out tipo);
|
||||
m_FieldTypes.Add(s2, tipo);
|
||||
}
|
||||
}
|
||||
foreach (KeyValuePair<string, string> chave in data2)
|
||||
{
|
||||
if (!retUA[0].Data.ContainsKey(chave.Key))
|
||||
retUA[0].Data.Add(chave.Key, chave.Value);
|
||||
}
|
||||
}
|
||||
|
||||
return retUA;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
public UserAccountData Get(UUID principalID, UUID scopeID)
|
||||
{
|
||||
UserAccountData ret = new UserAccountData();
|
||||
ret.Data = new Dictionary<string, string>();
|
||||
|
||||
string sql = string.Format(@"select * from {0} where ""PrincipalID"" = :principalID", m_Realm);
|
||||
if (scopeID != UUID.Zero)
|
||||
sql += @" and ""ScopeID"" = :scopeID";
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
cmd.Parameters.Add(m_database.CreateParameter("principalID", principalID));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("scopeID", scopeID));
|
||||
|
||||
conn.Open();
|
||||
using (NpgsqlDataReader result = cmd.ExecuteReader())
|
||||
{
|
||||
if (result.Read())
|
||||
{
|
||||
ret.PrincipalID = principalID;
|
||||
UUID scope;
|
||||
UUID.TryParse(result["scopeid"].ToString(), out scope);
|
||||
ret.ScopeID = scope;
|
||||
|
||||
if (m_ColumnNames == null)
|
||||
{
|
||||
m_ColumnNames = new List<string>();
|
||||
|
||||
DataTable schemaTable = result.GetSchemaTable();
|
||||
foreach (DataRow row in schemaTable.Rows)
|
||||
m_ColumnNames.Add(row["ColumnName"].ToString());
|
||||
}
|
||||
|
||||
foreach (string s in m_ColumnNames)
|
||||
{
|
||||
string s2 = s;
|
||||
if (s2 == "uuid")
|
||||
continue;
|
||||
if (s2 == "scopeid")
|
||||
continue;
|
||||
|
||||
ret.Data[s] = result[s].ToString();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public override bool Store(UserAccountData data)
|
||||
{
|
||||
if (data.Data.ContainsKey("PrincipalID"))
|
||||
data.Data.Remove("PrincipalID");
|
||||
if (data.Data.ContainsKey("ScopeID"))
|
||||
data.Data.Remove("ScopeID");
|
||||
|
||||
string[] fields = new List<string>(data.Data.Keys).ToArray();
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
m_log.DebugFormat("[USER]: Try to update user {0} {1}", data.FirstName, data.LastName);
|
||||
|
||||
StringBuilder updateBuilder = new StringBuilder();
|
||||
updateBuilder.AppendFormat("update {0} set ", m_Realm);
|
||||
bool first = true;
|
||||
foreach (string field in fields)
|
||||
{
|
||||
if (!first)
|
||||
updateBuilder.Append(", ");
|
||||
updateBuilder.AppendFormat("\"{0}\" = :{0}", field);
|
||||
|
||||
first = false;
|
||||
if (m_FieldTypes.ContainsKey(field))
|
||||
cmd.Parameters.Add(m_database.CreateParameter("" + field, data.Data[field], m_FieldTypes[field]));
|
||||
else
|
||||
cmd.Parameters.Add(m_database.CreateParameter("" + field, data.Data[field]));
|
||||
}
|
||||
|
||||
updateBuilder.Append(" where \"PrincipalID\" = :principalID");
|
||||
|
||||
if (data.ScopeID != UUID.Zero)
|
||||
updateBuilder.Append(" and \"ScopeID\" = :scopeID");
|
||||
|
||||
cmd.CommandText = updateBuilder.ToString();
|
||||
cmd.Connection = conn;
|
||||
cmd.Parameters.Add(m_database.CreateParameter("principalID", data.PrincipalID));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("scopeID", data.ScopeID));
|
||||
|
||||
m_log.DebugFormat("[USER]: SQL update user {0} ", cmd.CommandText);
|
||||
|
||||
conn.Open();
|
||||
|
||||
m_log.DebugFormat("[USER]: CON opened update user {0} ", cmd.CommandText);
|
||||
|
||||
int conta = 0;
|
||||
try
|
||||
{
|
||||
conta = cmd.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e){
|
||||
m_log.ErrorFormat("[USER]: ERROR opened update user {0} ", e.Message);
|
||||
}
|
||||
|
||||
|
||||
if (conta < 1)
|
||||
{
|
||||
m_log.DebugFormat("[USER]: Try to insert user {0} {1}", data.FirstName, data.LastName);
|
||||
|
||||
StringBuilder insertBuilder = new StringBuilder();
|
||||
insertBuilder.AppendFormat(@"insert into {0} (""PrincipalID"", ""ScopeID"", ""FirstName"", ""LastName"", """, m_Realm);
|
||||
insertBuilder.Append(String.Join(@""", """, fields));
|
||||
insertBuilder.Append(@""") values (:principalID, :scopeID, :FirstName, :LastName, :");
|
||||
insertBuilder.Append(String.Join(", :", fields));
|
||||
insertBuilder.Append(");");
|
||||
|
||||
cmd.Parameters.Add(m_database.CreateParameter("FirstName", data.FirstName));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("LastName", data.LastName));
|
||||
|
||||
cmd.CommandText = insertBuilder.ToString();
|
||||
|
||||
if (cmd.ExecuteNonQuery() < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
m_log.DebugFormat("[USER]: User {0} {1} exists", data.FirstName, data.LastName);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public bool Store(UserAccountData data, UUID principalID, string token)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public bool SetDataItem(UUID principalID, string item, string value)
|
||||
{
|
||||
string sql = string.Format(@"update {0} set {1} = :{1} where ""UUID"" = :UUID", m_Realm, item);
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
if (m_FieldTypes.ContainsKey(item))
|
||||
cmd.Parameters.Add(m_database.CreateParameter("" + item, value, m_FieldTypes[item]));
|
||||
else
|
||||
cmd.Parameters.Add(m_database.CreateParameter("" + item, value));
|
||||
|
||||
cmd.Parameters.Add(m_database.CreateParameter("UUID", principalID));
|
||||
conn.Open();
|
||||
|
||||
if (cmd.ExecuteNonQuery() > 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
public UserAccountData[] Get(string[] keys, string[] vals)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
*/
|
||||
|
||||
public UserAccountData[] GetUsers(UUID scopeID, string query)
|
||||
{
|
||||
string[] words = query.Split(new char[] { ' ' });
|
||||
|
||||
for (int i = 0; i < words.Length; i++)
|
||||
{
|
||||
if (words[i].Length < 3)
|
||||
{
|
||||
if (i != words.Length - 1)
|
||||
Array.Copy(words, i + 1, words, i, words.Length - i - 1);
|
||||
Array.Resize(ref words, words.Length - 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (words.Length == 0)
|
||||
return new UserAccountData[0];
|
||||
|
||||
if (words.Length > 2)
|
||||
return new UserAccountData[0];
|
||||
|
||||
string sql = "";
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
if (words.Length == 1)
|
||||
{
|
||||
sql = String.Format(@"select * from {0} where (""ScopeID""=:ScopeID or ""ScopeID""='00000000-0000-0000-0000-000000000000') and (""FirstName"" ilike :search or ""LastName"" ilike :search)", m_Realm);
|
||||
cmd.Parameters.Add(m_database.CreateParameter("scopeID", scopeID));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("search", "%" + words[0] + "%"));
|
||||
}
|
||||
else
|
||||
{
|
||||
sql = String.Format(@"select * from {0} where (""ScopeID""=:ScopeID or ""ScopeID""='00000000-0000-0000-0000-000000000000') and (""FirstName"" ilike :searchFirst or ""LastName"" ilike :searchLast)", m_Realm);
|
||||
cmd.Parameters.Add(m_database.CreateParameter("searchFirst", "%" + words[0] + "%"));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("searchLast", "%" + words[1] + "%"));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("ScopeID", scopeID.ToString()));
|
||||
}
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandText = sql;
|
||||
conn.Open();
|
||||
return DoQuery(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1072
OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs
Normal file
1072
OpenSim/Data/PGSQL/PGSQLUserProfilesData.cs
Normal file
File diff suppressed because it is too large
Load Diff
572
OpenSim/Data/PGSQL/PGSQLXAssetData.cs
Normal file
572
OpenSim/Data/PGSQL/PGSQLXAssetData.cs
Normal file
@@ -0,0 +1,572 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Data;
|
||||
using Npgsql;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
public class PGSQLXAssetData : IXAssetDataPlugin
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
protected virtual Assembly Assembly
|
||||
{
|
||||
get { return GetType().Assembly; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Number of days that must pass before we update the access time on an asset when it has been fetched.
|
||||
/// </summary>
|
||||
private const int DaysBetweenAccessTimeUpdates = 30;
|
||||
|
||||
private bool m_enableCompression = false;
|
||||
private string m_connectionString;
|
||||
private object m_dbLock = new object();
|
||||
|
||||
/// <summary>
|
||||
/// We can reuse this for all hashing since all methods are single-threaded through m_dbBLock
|
||||
/// </summary>
|
||||
private HashAlgorithm hasher = new SHA256CryptoServiceProvider();
|
||||
|
||||
#region IPlugin Members
|
||||
|
||||
public string Version { get { return "1.0.0.0"; } }
|
||||
|
||||
/// <summary>
|
||||
/// <para>Initialises Asset interface</para>
|
||||
/// <para>
|
||||
/// <list type="bullet">
|
||||
/// <item>Loads and initialises the PGSQL storage plugin.</item>
|
||||
/// <item>Warns and uses the obsolete pgsql_connection.ini if connect string is empty.</item>
|
||||
/// <item>Check for migration</item>
|
||||
/// </list>
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <param name="connect">connect string</param>
|
||||
public void Initialise(string connect)
|
||||
{
|
||||
m_log.ErrorFormat("[PGSQL XASSETDATA]: ***********************************************************");
|
||||
m_log.ErrorFormat("[PGSQL XASSETDATA]: ***********************************************************");
|
||||
m_log.ErrorFormat("[PGSQL XASSETDATA]: ***********************************************************");
|
||||
m_log.ErrorFormat("[PGSQL XASSETDATA]: THIS PLUGIN IS STRICTLY EXPERIMENTAL.");
|
||||
m_log.ErrorFormat("[PGSQL XASSETDATA]: DO NOT USE FOR ANY DATA THAT YOU DO NOT MIND LOSING.");
|
||||
m_log.ErrorFormat("[PGSQL XASSETDATA]: DATABASE TABLES CAN CHANGE AT ANY TIME, CAUSING EXISTING DATA TO BE LOST.");
|
||||
m_log.ErrorFormat("[PGSQL XASSETDATA]: ***********************************************************");
|
||||
m_log.ErrorFormat("[PGSQL XASSETDATA]: ***********************************************************");
|
||||
m_log.ErrorFormat("[PGSQL XASSETDATA]: ***********************************************************");
|
||||
|
||||
m_connectionString = connect;
|
||||
|
||||
using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString))
|
||||
{
|
||||
dbcon.Open();
|
||||
Migration m = new Migration(dbcon, Assembly, "XAssetStore");
|
||||
m.Update();
|
||||
}
|
||||
}
|
||||
|
||||
public void Initialise()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Dispose() { }
|
||||
|
||||
/// <summary>
|
||||
/// The name of this DB provider
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get { return "PGSQL XAsset storage engine"; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IAssetDataPlugin Members
|
||||
|
||||
/// <summary>
|
||||
/// Fetch Asset <paramref name="assetID"/> from database
|
||||
/// </summary>
|
||||
/// <param name="assetID">Asset UUID to fetch</param>
|
||||
/// <returns>Return the asset</returns>
|
||||
/// <remarks>On failure : throw an exception and attempt to reconnect to database</remarks>
|
||||
public AssetBase GetAsset(UUID assetID)
|
||||
{
|
||||
// m_log.DebugFormat("[PGSQL XASSET DATA]: Looking for asset {0}", assetID);
|
||||
|
||||
AssetBase asset = null;
|
||||
lock (m_dbLock)
|
||||
{
|
||||
using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString))
|
||||
{
|
||||
dbcon.Open();
|
||||
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(
|
||||
@"SELECT ""Name"", ""Description"", ""AccessTime"", ""AssetType"", ""Local"", ""Temporary"", ""AssetFlags"", ""CreatorID"", ""Data""
|
||||
FROM XAssetsMeta
|
||||
JOIN XAssetsData ON XAssetsMeta.Hash = XAssetsData.Hash WHERE ""ID""=:ID",
|
||||
dbcon))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("ID", assetID.ToString());
|
||||
|
||||
try
|
||||
{
|
||||
using (NpgsqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
||||
{
|
||||
if (dbReader.Read())
|
||||
{
|
||||
asset = new AssetBase(assetID, (string)dbReader["Name"], (sbyte)dbReader["AssetType"], dbReader["CreatorID"].ToString());
|
||||
asset.Data = (byte[])dbReader["Data"];
|
||||
asset.Description = (string)dbReader["Description"];
|
||||
|
||||
string local = dbReader["Local"].ToString();
|
||||
if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase))
|
||||
asset.Local = true;
|
||||
else
|
||||
asset.Local = false;
|
||||
|
||||
asset.Temporary = Convert.ToBoolean(dbReader["Temporary"]);
|
||||
asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]);
|
||||
|
||||
if (m_enableCompression)
|
||||
{
|
||||
using (GZipStream decompressionStream = new GZipStream(new MemoryStream(asset.Data), CompressionMode.Decompress))
|
||||
{
|
||||
MemoryStream outputStream = new MemoryStream();
|
||||
WebUtil.CopyStream(decompressionStream, outputStream, int.MaxValue);
|
||||
// int compressedLength = asset.Data.Length;
|
||||
asset.Data = outputStream.ToArray();
|
||||
|
||||
// m_log.DebugFormat(
|
||||
// "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}",
|
||||
// asset.ID, asset.Name, asset.Data.Length, compressedLength);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateAccessTime(asset.Metadata, (int)dbReader["AccessTime"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error(string.Format("[PGSQL XASSET DATA]: Failure fetching asset {0}", assetID), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return asset;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an asset in database, or update it if existing.
|
||||
/// </summary>
|
||||
/// <param name="asset">Asset UUID to create</param>
|
||||
/// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks>
|
||||
public void StoreAsset(AssetBase asset)
|
||||
{
|
||||
// m_log.DebugFormat("[XASSETS DB]: Storing asset {0} {1}", asset.Name, asset.ID);
|
||||
|
||||
lock (m_dbLock)
|
||||
{
|
||||
using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString))
|
||||
{
|
||||
dbcon.Open();
|
||||
|
||||
using (NpgsqlTransaction transaction = dbcon.BeginTransaction())
|
||||
{
|
||||
string assetName = asset.Name;
|
||||
if (asset.Name.Length > 64)
|
||||
{
|
||||
assetName = asset.Name.Substring(0, 64);
|
||||
m_log.WarnFormat(
|
||||
"[XASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
|
||||
asset.Name, asset.ID, asset.Name.Length, assetName.Length);
|
||||
}
|
||||
|
||||
string assetDescription = asset.Description;
|
||||
if (asset.Description.Length > 64)
|
||||
{
|
||||
assetDescription = asset.Description.Substring(0, 64);
|
||||
m_log.WarnFormat(
|
||||
"[XASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
|
||||
asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
|
||||
}
|
||||
|
||||
if (m_enableCompression)
|
||||
{
|
||||
MemoryStream outputStream = new MemoryStream();
|
||||
|
||||
using (GZipStream compressionStream = new GZipStream(outputStream, CompressionMode.Compress, false))
|
||||
{
|
||||
// Console.WriteLine(WebUtil.CopyTo(new MemoryStream(asset.Data), compressionStream, int.MaxValue));
|
||||
// We have to close the compression stream in order to make sure it writes everything out to the underlying memory output stream.
|
||||
compressionStream.Close();
|
||||
byte[] compressedData = outputStream.ToArray();
|
||||
asset.Data = compressedData;
|
||||
}
|
||||
}
|
||||
|
||||
byte[] hash = hasher.ComputeHash(asset.Data);
|
||||
|
||||
// m_log.DebugFormat(
|
||||
// "[XASSET DB]: Compressed data size for {0} {1}, hash {2} is {3}",
|
||||
// asset.ID, asset.Name, hash, compressedData.Length);
|
||||
|
||||
try
|
||||
{
|
||||
using (NpgsqlCommand cmd =
|
||||
new NpgsqlCommand(
|
||||
@"insert INTO XAssetsMeta(""ID"", ""Hash"", ""Name"", ""Description"", ""AssetType"", ""Local"", ""Temporary"", ""CreateTime"", ""AccessTime"", ""AssetFlags"", ""CreatorID"")
|
||||
Select :ID, :Hash, :Name, :Description, :AssetType, :Local, :Temporary, :CreateTime, :AccessTime, :AssetFlags, :CreatorID
|
||||
where not exists( Select ""ID"" from XAssetsMeta where ""ID"" = :ID ;
|
||||
|
||||
update XAssetsMeta
|
||||
set ""ID"" = :ID, ""Hash"" = :Hash, ""Name"" = :Name, ""Description"" = :Description,
|
||||
""AssetType"" = :AssetType, ""Local"" = :Local, ""Temporary"" = :Temporary, ""CreateTime"" = :CreateTime,
|
||||
""AccessTime"" = :AccessTime, ""AssetFlags"" = :AssetFlags, ""CreatorID"" = :CreatorID
|
||||
where ""ID"" = :ID;
|
||||
",
|
||||
dbcon))
|
||||
{
|
||||
// create unix epoch time
|
||||
int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
|
||||
cmd.Parameters.AddWithValue("ID", asset.ID);
|
||||
cmd.Parameters.AddWithValue("Hash", hash);
|
||||
cmd.Parameters.AddWithValue("Name", assetName);
|
||||
cmd.Parameters.AddWithValue("Description", assetDescription);
|
||||
cmd.Parameters.AddWithValue("AssetType", asset.Type);
|
||||
cmd.Parameters.AddWithValue("Local", asset.Local);
|
||||
cmd.Parameters.AddWithValue("Temporary", asset.Temporary);
|
||||
cmd.Parameters.AddWithValue("CreateTime", now);
|
||||
cmd.Parameters.AddWithValue("AccessTime", now);
|
||||
cmd.Parameters.AddWithValue("CreatorID", asset.Metadata.CreatorID);
|
||||
cmd.Parameters.AddWithValue("AssetFlags", (int)asset.Flags);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[ASSET DB]: PGSQL failure creating asset metadata {0} with name \"{1}\". Error: {2}",
|
||||
asset.FullID, asset.Name, e.Message);
|
||||
|
||||
transaction.Rollback();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ExistsData(dbcon, transaction, hash))
|
||||
{
|
||||
try
|
||||
{
|
||||
using (NpgsqlCommand cmd =
|
||||
new NpgsqlCommand(
|
||||
@"INSERT INTO XAssetsData(""Hash"", ""Data"") VALUES(:Hash, :Data)",
|
||||
dbcon))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("Hash", hash);
|
||||
cmd.Parameters.AddWithValue("Data", asset.Data);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[XASSET DB]: PGSQL failure creating asset data {0} with name \"{1}\". Error: {2}",
|
||||
asset.FullID, asset.Name, e.Message);
|
||||
|
||||
transaction.Rollback();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
transaction.Commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the access time of the asset if it was accessed above a given threshhold amount of time.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This gives us some insight into assets which haven't ben accessed for a long period. This is only done
|
||||
/// over the threshold time to avoid excessive database writes as assets are fetched.
|
||||
/// </remarks>
|
||||
/// <param name='asset'></param>
|
||||
/// <param name='accessTime'></param>
|
||||
private void UpdateAccessTime(AssetMetadata assetMetadata, int accessTime)
|
||||
{
|
||||
DateTime now = DateTime.UtcNow;
|
||||
|
||||
if ((now - Utils.UnixTimeToDateTime(accessTime)).TotalDays < DaysBetweenAccessTimeUpdates)
|
||||
return;
|
||||
|
||||
lock (m_dbLock)
|
||||
{
|
||||
using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString))
|
||||
{
|
||||
dbcon.Open();
|
||||
NpgsqlCommand cmd =
|
||||
new NpgsqlCommand(@"update XAssetsMeta set ""AccessTime""=:AccessTime where ID=:ID", dbcon);
|
||||
|
||||
try
|
||||
{
|
||||
using (cmd)
|
||||
{
|
||||
// create unix epoch time
|
||||
cmd.Parameters.AddWithValue("ID", assetMetadata.ID);
|
||||
cmd.Parameters.AddWithValue("AccessTime", (int)Utils.DateTimeToUnixTime(now));
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[XASSET PGSQL DB]: Failure updating access_time for asset {0} with name {1} : {2}",
|
||||
assetMetadata.ID, assetMetadata.Name, e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// We assume we already have the m_dbLock.
|
||||
/// </summary>
|
||||
/// TODO: need to actually use the transaction.
|
||||
/// <param name="dbcon"></param>
|
||||
/// <param name="transaction"></param>
|
||||
/// <param name="hash"></param>
|
||||
/// <returns></returns>
|
||||
private bool ExistsData(NpgsqlConnection dbcon, NpgsqlTransaction transaction, byte[] hash)
|
||||
{
|
||||
// m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid);
|
||||
|
||||
bool exists = false;
|
||||
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(@"SELECT ""Hash"" FROM XAssetsData WHERE ""Hash""=:Hash", dbcon))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("Hash", hash);
|
||||
|
||||
try
|
||||
{
|
||||
using (NpgsqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
||||
{
|
||||
if (dbReader.Read())
|
||||
{
|
||||
// m_log.DebugFormat("[ASSETS DB]: Found asset {0}", uuid);
|
||||
exists = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[XASSETS DB]: PGSql failure in ExistsData fetching hash {0}. Exception {1}{2}",
|
||||
hash, e.Message, e.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
return exists;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if the assets exist in the database.
|
||||
/// </summary>
|
||||
/// <param name="uuids">The assets' IDs</param>
|
||||
/// <returns>For each asset: true if it exists, false otherwise</returns>
|
||||
public bool[] AssetsExist(UUID[] uuids)
|
||||
{
|
||||
if (uuids.Length == 0)
|
||||
return new bool[0];
|
||||
|
||||
HashSet<UUID> exist = new HashSet<UUID>();
|
||||
|
||||
string ids = "'" + string.Join("','", uuids) + "'";
|
||||
string sql = string.Format(@"SELECT ""ID"" FROM XAssetsMeta WHERE ""ID"" IN ({0})", ids);
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
|
||||
{
|
||||
conn.Open();
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
UUID id = DBGuid.FromDB(reader["id"]);
|
||||
exist.Add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool[] results = new bool[uuids.Length];
|
||||
for (int i = 0; i < uuids.Length; i++)
|
||||
results[i] = exist.Contains(uuids[i]);
|
||||
return results;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if the asset exists in the database
|
||||
/// </summary>
|
||||
/// <param name="uuid">The asset UUID</param>
|
||||
/// <returns>true if it exists, false otherwise.</returns>
|
||||
public bool ExistsAsset(UUID uuid)
|
||||
{
|
||||
// m_log.DebugFormat("[ASSETS DB]: Checking for asset {0}", uuid);
|
||||
|
||||
bool assetExists = false;
|
||||
|
||||
lock (m_dbLock)
|
||||
{
|
||||
using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString))
|
||||
{
|
||||
dbcon.Open();
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(@"SELECT ""ID"" FROM XAssetsMeta WHERE ""ID""=:ID", dbcon))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("ID", uuid.ToString());
|
||||
|
||||
try
|
||||
{
|
||||
using (NpgsqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
||||
{
|
||||
if (dbReader.Read())
|
||||
{
|
||||
// m_log.DebugFormat("[ASSETS DB]: Found asset {0}", uuid);
|
||||
assetExists = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error(string.Format("[XASSETS DB]: PGSql failure fetching asset {0}", uuid), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return assetExists;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of AssetMetadata objects. The list is a subset of
|
||||
/// the entire data set offset by <paramref name="start" /> containing
|
||||
/// <paramref name="count" /> elements.
|
||||
/// </summary>
|
||||
/// <param name="start">The number of results to discard from the total data set.</param>
|
||||
/// <param name="count">The number of rows the returned list should contain.</param>
|
||||
/// <returns>A list of AssetMetadata objects.</returns>
|
||||
public List<AssetMetadata> FetchAssetMetadataSet(int start, int count)
|
||||
{
|
||||
List<AssetMetadata> retList = new List<AssetMetadata>(count);
|
||||
|
||||
lock (m_dbLock)
|
||||
{
|
||||
using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString))
|
||||
{
|
||||
dbcon.Open();
|
||||
NpgsqlCommand cmd = new NpgsqlCommand( @"SELECT ""Name"", ""Description"", ""AccessTime"", ""AssetType"", ""Temporary"", ""ID"", ""AssetFlags"", ""CreatorID""
|
||||
FROM XAssetsMeta
|
||||
LIMIT :start, :count", dbcon);
|
||||
cmd.Parameters.AddWithValue("start", start);
|
||||
cmd.Parameters.AddWithValue("count", count);
|
||||
|
||||
try
|
||||
{
|
||||
using (NpgsqlDataReader dbReader = cmd.ExecuteReader())
|
||||
{
|
||||
while (dbReader.Read())
|
||||
{
|
||||
AssetMetadata metadata = new AssetMetadata();
|
||||
metadata.Name = (string)dbReader["Name"];
|
||||
metadata.Description = (string)dbReader["Description"];
|
||||
metadata.Type = (sbyte)dbReader["AssetType"];
|
||||
metadata.Temporary = Convert.ToBoolean(dbReader["Temporary"]); // Not sure if this is correct.
|
||||
metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]);
|
||||
metadata.FullID = DBGuid.FromDB(dbReader["ID"]);
|
||||
metadata.CreatorID = dbReader["CreatorID"].ToString();
|
||||
|
||||
// We'll ignore this for now - it appears unused!
|
||||
// metadata.SHA1 = dbReader["hash"]);
|
||||
|
||||
UpdateAccessTime(metadata, (int)dbReader["AccessTime"]);
|
||||
|
||||
retList.Add(metadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("[XASSETS DB]: PGSql failure fetching asset set" + Environment.NewLine + e.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retList;
|
||||
}
|
||||
|
||||
public bool Delete(string id)
|
||||
{
|
||||
// m_log.DebugFormat("[XASSETS DB]: Deleting asset {0}", id);
|
||||
|
||||
lock (m_dbLock)
|
||||
{
|
||||
using (NpgsqlConnection dbcon = new NpgsqlConnection(m_connectionString))
|
||||
{
|
||||
dbcon.Open();
|
||||
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(@"delete from XAssetsMeta where ""ID""=:ID", dbcon))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("ID", id);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
// TODO: How do we deal with data from deleted assets? Probably not easily reapable unless we
|
||||
// keep a reference count (?)
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
330
OpenSim/Data/PGSQL/PGSQLXInventoryData.cs
Normal file
330
OpenSim/Data/PGSQL/PGSQLXInventoryData.cs
Normal file
@@ -0,0 +1,330 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ''AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using log4net;
|
||||
using Npgsql;
|
||||
using NpgsqlTypes;
|
||||
|
||||
namespace OpenSim.Data.PGSQL
|
||||
{
|
||||
public class PGSQLXInventoryData : IXInventoryData
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(
|
||||
// MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private PGSQLFolderHandler m_Folders;
|
||||
private PGSQLItemHandler m_Items;
|
||||
|
||||
public PGSQLXInventoryData(string conn, string realm)
|
||||
{
|
||||
m_Folders = new PGSQLFolderHandler(
|
||||
conn, "inventoryfolders", "InventoryStore");
|
||||
m_Items = new PGSQLItemHandler(
|
||||
conn, "inventoryitems", String.Empty);
|
||||
}
|
||||
|
||||
public static UUID str2UUID(string strUUID)
|
||||
{
|
||||
UUID newUUID = UUID.Zero;
|
||||
|
||||
UUID.TryParse(strUUID, out newUUID);
|
||||
|
||||
return newUUID;
|
||||
}
|
||||
|
||||
public XInventoryFolder[] GetFolders(string[] fields, string[] vals)
|
||||
{
|
||||
return m_Folders.Get(fields, vals);
|
||||
}
|
||||
|
||||
public XInventoryItem[] GetItems(string[] fields, string[] vals)
|
||||
{
|
||||
return m_Items.Get(fields, vals);
|
||||
}
|
||||
|
||||
public bool StoreFolder(XInventoryFolder folder)
|
||||
{
|
||||
if (folder.folderName.Length > 64)
|
||||
folder.folderName = folder.folderName.Substring(0, 64);
|
||||
return m_Folders.Store(folder);
|
||||
}
|
||||
|
||||
public bool StoreItem(XInventoryItem item)
|
||||
{
|
||||
if (item.inventoryName.Length > 64)
|
||||
item.inventoryName = item.inventoryName.Substring(0, 64);
|
||||
if (item.inventoryDescription.Length > 128)
|
||||
item.inventoryDescription = item.inventoryDescription.Substring(0, 128);
|
||||
|
||||
return m_Items.Store(item);
|
||||
}
|
||||
|
||||
public bool DeleteFolders(string field, string val)
|
||||
{
|
||||
return m_Folders.Delete(field, val);
|
||||
}
|
||||
|
||||
public bool DeleteFolders(string[] fields, string[] vals)
|
||||
{
|
||||
return m_Folders.Delete(fields, vals);
|
||||
}
|
||||
|
||||
public bool DeleteItems(string field, string val)
|
||||
{
|
||||
return m_Items.Delete(field, val);
|
||||
}
|
||||
|
||||
public bool DeleteItems(string[] fields, string[] vals)
|
||||
{
|
||||
return m_Items.Delete(fields, vals);
|
||||
}
|
||||
|
||||
public bool MoveItem(string id, string newParent)
|
||||
{
|
||||
return m_Items.MoveItem(id, newParent);
|
||||
}
|
||||
|
||||
public bool MoveFolder(string id, string newParent)
|
||||
{
|
||||
return m_Folders.MoveFolder(id, newParent);
|
||||
}
|
||||
|
||||
public XInventoryItem[] GetActiveGestures(UUID principalID)
|
||||
{
|
||||
return m_Items.GetActiveGestures(principalID.ToString());
|
||||
}
|
||||
|
||||
public int GetAssetPermissions(UUID principalID, UUID assetID)
|
||||
{
|
||||
return m_Items.GetAssetPermissions(principalID, assetID);
|
||||
}
|
||||
}
|
||||
|
||||
public class PGSQLItemHandler : PGSQLInventoryHandler<XInventoryItem>
|
||||
{
|
||||
public PGSQLItemHandler(string c, string t, string m) :
|
||||
base(c, t, m)
|
||||
{
|
||||
}
|
||||
|
||||
public bool MoveItem(string id, string newParent)
|
||||
{
|
||||
XInventoryItem[] retrievedItems = Get(new string[] { "inventoryID" }, new string[] { id });
|
||||
if (retrievedItems.Length == 0)
|
||||
return false;
|
||||
|
||||
UUID oldParent = retrievedItems[0].parentFolderID;
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
{
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
cmd.CommandText = String.Format(@"update {0} set ""parentFolderID"" = :ParentFolderID where ""inventoryID"" = :InventoryID", m_Realm);
|
||||
cmd.Parameters.Add(m_database.CreateParameter("ParentFolderID", newParent));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("InventoryID", id ));
|
||||
cmd.Connection = conn;
|
||||
conn.Open();
|
||||
|
||||
if (cmd.ExecuteNonQuery() == 0)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
IncrementFolderVersion(oldParent);
|
||||
IncrementFolderVersion(newParent);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public XInventoryItem[] GetActiveGestures(string principalID)
|
||||
{
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
{
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
cmd.CommandText = String.Format(@"select * from inventoryitems where ""avatarID"" = :uuid and ""assetType"" = :type and ""flags"" = 1", m_Realm);
|
||||
|
||||
UUID princID = UUID.Zero;
|
||||
UUID.TryParse(principalID, out princID);
|
||||
|
||||
cmd.Parameters.Add(m_database.CreateParameter("uuid", principalID));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("type", (int)AssetType.Gesture));
|
||||
cmd.Connection = conn;
|
||||
conn.Open();
|
||||
return DoQuery(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int GetAssetPermissions(UUID principalID, UUID assetID)
|
||||
{
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
{
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
cmd.CommandText = String.Format(@"select bit_or(""inventoryCurrentPermissions"") as ""inventoryCurrentPermissions""
|
||||
from inventoryitems
|
||||
where ""avatarID"" = :PrincipalID
|
||||
and ""assetID"" = :AssetID
|
||||
group by ""assetID"" ", m_Realm);
|
||||
|
||||
cmd.Parameters.Add(m_database.CreateParameter("PrincipalID", principalID));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("AssetID", assetID));
|
||||
cmd.Connection = conn;
|
||||
conn.Open();
|
||||
using (NpgsqlDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
|
||||
int perms = 0;
|
||||
|
||||
if (reader.Read())
|
||||
{
|
||||
perms = Convert.ToInt32(reader["inventoryCurrentPermissions"]);
|
||||
}
|
||||
|
||||
return perms;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Store(XInventoryItem item)
|
||||
{
|
||||
if (!base.Store(item))
|
||||
return false;
|
||||
|
||||
IncrementFolderVersion(item.parentFolderID);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class PGSQLFolderHandler : PGSQLInventoryHandler<XInventoryFolder>
|
||||
{
|
||||
public PGSQLFolderHandler(string c, string t, string m) :
|
||||
base(c, t, m)
|
||||
{
|
||||
}
|
||||
|
||||
public bool MoveFolder(string id, string newParentFolderID)
|
||||
{
|
||||
XInventoryFolder[] folders = Get(new string[] { "folderID" }, new string[] { id });
|
||||
|
||||
if (folders.Length == 0)
|
||||
return false;
|
||||
|
||||
UUID oldParentFolderUUID = folders[0].parentFolderID;
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
{
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand())
|
||||
{
|
||||
UUID foldID = UUID.Zero;
|
||||
UUID.TryParse(id, out foldID);
|
||||
|
||||
UUID newPar = UUID.Zero;
|
||||
UUID.TryParse(newParentFolderID, out newPar);
|
||||
|
||||
cmd.CommandText = String.Format(@"update {0} set ""parentFolderID"" = :ParentFolderID where ""folderID"" = :folderID", m_Realm);
|
||||
cmd.Parameters.Add(m_database.CreateParameter("ParentFolderID", newPar));
|
||||
cmd.Parameters.Add(m_database.CreateParameter("folderID", foldID));
|
||||
cmd.Connection = conn;
|
||||
conn.Open();
|
||||
|
||||
if (cmd.ExecuteNonQuery() == 0)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
IncrementFolderVersion(oldParentFolderUUID);
|
||||
IncrementFolderVersion(newParentFolderID);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Store(XInventoryFolder folder)
|
||||
{
|
||||
if (!base.Store(folder))
|
||||
return false;
|
||||
|
||||
IncrementFolderVersion(folder.parentFolderID);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class PGSQLInventoryHandler<T> : PGSQLGenericTableHandler<T> where T: class, new()
|
||||
{
|
||||
public PGSQLInventoryHandler(string c, string t, string m) : base(c, t, m) {}
|
||||
|
||||
protected bool IncrementFolderVersion(UUID folderID)
|
||||
{
|
||||
return IncrementFolderVersion(folderID.ToString());
|
||||
}
|
||||
|
||||
protected bool IncrementFolderVersion(string folderID)
|
||||
{
|
||||
// m_log.DebugFormat("[PGSQL ITEM HANDLER]: Incrementing version on folder {0}", folderID);
|
||||
// Util.PrintCallStack();
|
||||
|
||||
string sql = @"update inventoryfolders set version=version+1 where ""folderID"" = :folderID";
|
||||
|
||||
using (NpgsqlConnection conn = new NpgsqlConnection(m_ConnectionString))
|
||||
{
|
||||
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
|
||||
{
|
||||
UUID foldID = UUID.Zero;
|
||||
UUID.TryParse(folderID, out foldID);
|
||||
|
||||
conn.Open();
|
||||
|
||||
cmd.Parameters.Add( m_database.CreateParameter("folderID", foldID) );
|
||||
|
||||
try
|
||||
{
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
65
OpenSim/Data/PGSQL/Properties/AssemblyInfo.cs
Normal file
65
OpenSim/Data/PGSQL/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
|
||||
[assembly : AssemblyTitle("OpenSim.Data.PGSQL")]
|
||||
[assembly : AssemblyDescription("")]
|
||||
[assembly : AssemblyConfiguration("")]
|
||||
[assembly : AssemblyCompany("http://opensimulator.org")]
|
||||
[assembly : AssemblyProduct("OpenSim.Data.PGSQL")]
|
||||
[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")]
|
||||
[assembly : AssemblyTrademark("")]
|
||||
[assembly : AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
|
||||
[assembly : ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
|
||||
[assembly : Guid("0e1c1ca4-2cf2-4315-b0e7-432c02feea8a")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly : AssemblyVersion("0.8.1.*")]
|
||||
|
||||
94
OpenSim/Data/PGSQL/Resources/AssetStore.migrations
Normal file
94
OpenSim/Data/PGSQL/Resources/AssetStore.migrations
Normal file
@@ -0,0 +1,94 @@
|
||||
:VERSION 1
|
||||
|
||||
CREATE TABLE assets (
|
||||
"id" varchar(36) NOT NULL PRIMARY KEY,
|
||||
"name" varchar(64) NOT NULL,
|
||||
"description" varchar(64) NOT NULL,
|
||||
"assetType" smallint NOT NULL,
|
||||
"local" smallint NOT NULL,
|
||||
"temporary" smallint NOT NULL,
|
||||
"data" bytea NOT NULL
|
||||
) ;
|
||||
|
||||
:VERSION 2
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE TABLE Tmp_assets
|
||||
(
|
||||
"id" varchar(36) NOT NULL,
|
||||
"name" varchar(64) NOT NULL,
|
||||
"description" varchar(64) NOT NULL,
|
||||
"assetType" smallint NOT NULL,
|
||||
"local" boolean NOT NULL,
|
||||
"temporary" boolean NOT NULL,
|
||||
"data" bytea NOT NULL
|
||||
) ;
|
||||
|
||||
INSERT INTO Tmp_assets ("id", "name", "description", "assetType", "local", "temporary", "data")
|
||||
SELECT "id", "name", "description", "assetType", case when "local" = 1 then true else false end, case when "temporary" = 1 then true else false end, "data"
|
||||
FROM assets ;
|
||||
|
||||
DROP TABLE assets;
|
||||
|
||||
Alter table Tmp_assets
|
||||
rename to assets;
|
||||
|
||||
ALTER TABLE assets ADD PRIMARY KEY ("id");
|
||||
|
||||
COMMIT;
|
||||
|
||||
|
||||
:VERSION 3
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
ALTER TABLE assets add "create_time" integer default 0;
|
||||
ALTER TABLE assets add "access_time" integer default 0;
|
||||
|
||||
COMMIT;
|
||||
|
||||
|
||||
:VERSION 4
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE TABLE Tmp_assets
|
||||
(
|
||||
"id" uuid NOT NULL,
|
||||
"name" varchar(64) NOT NULL,
|
||||
"description" varchar(64) NOT NULL,
|
||||
"assetType" smallint NOT NULL,
|
||||
"local" boolean NOT NULL,
|
||||
"temporary" boolean NOT NULL,
|
||||
"data" bytea NOT NULL,
|
||||
"create_time" int NULL,
|
||||
"access_time" int NULL
|
||||
) ;
|
||||
|
||||
|
||||
INSERT INTO Tmp_assets ("id", "name", "description", "assetType", "local", "temporary", "data", "create_time", "access_time")
|
||||
SELECT cast("id" as uuid), "name", "description", "assetType", "local", "temporary", "data", "create_time", "access_time"
|
||||
FROM assets ;
|
||||
|
||||
DROP TABLE assets;
|
||||
|
||||
Alter table Tmp_assets
|
||||
rename to assets;
|
||||
|
||||
ALTER TABLE assets ADD PRIMARY KEY ("id");
|
||||
|
||||
COMMIT;
|
||||
|
||||
|
||||
:VERSION 5
|
||||
|
||||
DELETE FROM assets WHERE "id" = 'dc4b9f0b-d008-45c6-96a4-01dd947ac621';
|
||||
|
||||
:VERSION 6
|
||||
|
||||
ALTER TABLE assets ADD "asset_flags" INTEGER NOT NULL DEFAULT 0;
|
||||
|
||||
:VERSION 7
|
||||
|
||||
alter table assets add "creatorid" varchar(36) not null default '';
|
||||
32
OpenSim/Data/PGSQL/Resources/AuthStore.migrations
Normal file
32
OpenSim/Data/PGSQL/Resources/AuthStore.migrations
Normal file
@@ -0,0 +1,32 @@
|
||||
:VERSION 1
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE TABLE auth (
|
||||
uuid uuid NOT NULL default '00000000-0000-0000-0000-000000000000',
|
||||
"passwordHash" varchar(32) NOT NULL,
|
||||
"passwordSalt" varchar(32) NOT NULL,
|
||||
"webLoginKey" varchar(255) NOT NULL,
|
||||
"accountType" VARCHAR(32) NOT NULL DEFAULT 'UserAccount'
|
||||
) ;
|
||||
|
||||
CREATE TABLE tokens (
|
||||
uuid uuid NOT NULL default '00000000-0000-0000-0000-000000000000',
|
||||
token varchar(255) NOT NULL,
|
||||
validity TIMESTAMP NOT NULL )
|
||||
;
|
||||
|
||||
COMMIT;
|
||||
|
||||
:VERSION 2
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
INSERT INTO auth (uuid, "passwordHash", "passwordSalt", "webLoginKey", "accountType")
|
||||
SELECT uuid AS UUID, passwordHash AS passwordHash, passwordSalt AS passwordSalt, webLoginKey AS webLoginKey, 'UserAccount' as accountType
|
||||
FROM users
|
||||
where exists ( Select * from information_schema.tables where table_name = 'users' )
|
||||
;
|
||||
|
||||
COMMIT;
|
||||
|
||||
59
OpenSim/Data/PGSQL/Resources/Avatar.migrations
Normal file
59
OpenSim/Data/PGSQL/Resources/Avatar.migrations
Normal file
@@ -0,0 +1,59 @@
|
||||
:VERSION 1
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE TABLE Avatars (
|
||||
"PrincipalID" uuid NOT NULL PRIMARY KEY,
|
||||
"Name" varchar(32) NOT NULL,
|
||||
"Value" varchar(255) NOT NULL DEFAULT ''
|
||||
);
|
||||
|
||||
|
||||
COMMIT;
|
||||
|
||||
:VERSION 2
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE TABLE Tmp_Avatars
|
||||
(
|
||||
"PrincipalID" uuid NOT NULL,
|
||||
"Name" varchar(32) NOT NULL,
|
||||
"Value" text NOT NULL DEFAULT ''
|
||||
) ;
|
||||
|
||||
INSERT INTO Tmp_Avatars ("PrincipalID", "Name", "Value")
|
||||
SELECT "PrincipalID", cast("Name" as text), "Value"
|
||||
FROM Avatars ;
|
||||
|
||||
DROP TABLE Avatars;
|
||||
|
||||
Alter table Tmp_Avatars
|
||||
rename to Avatars;
|
||||
|
||||
COMMIT;
|
||||
|
||||
:VERSION 3
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE TABLE Tmp_Avatars
|
||||
(
|
||||
"PrincipalID" uuid NOT NULL,
|
||||
"Name" varchar(32) NOT NULL,
|
||||
"Value" text NOT NULL DEFAULT ''
|
||||
);
|
||||
|
||||
ALTER TABLE Tmp_Avatars ADD PRIMARY KEY ("PrincipalID", "Name");
|
||||
|
||||
|
||||
INSERT INTO Tmp_Avatars ("PrincipalID", "Name", "Value")
|
||||
SELECT "PrincipalID", "Name", cast("Value" as text) FROM Avatars ;
|
||||
|
||||
DROP TABLE Avatars;
|
||||
|
||||
Alter table Tmp_Avatars
|
||||
rename to Avatars;
|
||||
|
||||
COMMIT;
|
||||
|
||||
307
OpenSim/Data/PGSQL/Resources/EstateStore.migrations
Normal file
307
OpenSim/Data/PGSQL/Resources/EstateStore.migrations
Normal file
@@ -0,0 +1,307 @@
|
||||
:VERSION 1
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE TABLE estate_managers(
|
||||
"EstateID" int NOT NULL Primary Key,
|
||||
uuid varchar(36) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE estate_groups(
|
||||
"EstateID" int NOT NULL,
|
||||
uuid varchar(36) NOT NULL
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE estate_users(
|
||||
"EstateID" int NOT NULL,
|
||||
uuid varchar(36) NOT NULL
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE estateban(
|
||||
"EstateID" int NOT NULL,
|
||||
"bannedUUID" varchar(36) NOT NULL,
|
||||
"bannedIp" varchar(16) NOT NULL,
|
||||
"bannedIpHostMask" varchar(16) NOT NULL,
|
||||
"bannedNameMask" varchar(64) NULL DEFAULT NULL
|
||||
);
|
||||
|
||||
Create Sequence estate_settings_id increment by 100 start with 100;
|
||||
|
||||
CREATE TABLE estate_settings(
|
||||
"EstateID" integer DEFAULT nextval('estate_settings_id') NOT NULL,
|
||||
"EstateName" varchar(64) NULL DEFAULT (NULL),
|
||||
"AbuseEmailToEstateOwner" boolean NOT NULL,
|
||||
"DenyAnonymous" boolean NOT NULL,
|
||||
"ResetHomeOnTeleport" boolean NOT NULL,
|
||||
"FixedSun" boolean NOT NULL,
|
||||
"DenyTransacted" boolean NOT NULL,
|
||||
"BlockDwell" boolean NOT NULL,
|
||||
"DenyIdentified" boolean NOT NULL,
|
||||
"AllowVoice" boolean NOT NULL,
|
||||
"UseGlobalTime" boolean NOT NULL,
|
||||
"PricePerMeter" int NOT NULL,
|
||||
"TaxFree" boolean NOT NULL,
|
||||
"AllowDirectTeleport" boolean NOT NULL,
|
||||
"RedirectGridX" int NOT NULL,
|
||||
"RedirectGridY" int NOT NULL,
|
||||
"ParentEstateID" int NOT NULL,
|
||||
"SunPosition" double precision NOT NULL,
|
||||
"EstateSkipScripts" boolean NOT NULL,
|
||||
"BillableFactor" double precision NOT NULL,
|
||||
"PublicAccess" boolean NOT NULL,
|
||||
"AbuseEmail" varchar(255) NOT NULL,
|
||||
"EstateOwner" varchar(36) NOT NULL,
|
||||
"DenyMinors" boolean NOT NULL
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE estate_map(
|
||||
"RegionID" varchar(36) NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'),
|
||||
"EstateID" int NOT NULL
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
|
||||
:VERSION 2
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE INDEX IX_estate_managers ON estate_managers
|
||||
(
|
||||
"EstateID"
|
||||
);
|
||||
|
||||
|
||||
CREATE INDEX IX_estate_groups ON estate_groups
|
||||
(
|
||||
"EstateID"
|
||||
);
|
||||
|
||||
|
||||
CREATE INDEX IX_estate_users ON estate_users
|
||||
(
|
||||
"EstateID"
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
|
||||
:VERSION 3
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE TABLE Tmp_estateban
|
||||
(
|
||||
"EstateID" int NOT NULL,
|
||||
"bannedUUID" varchar(36) NOT NULL,
|
||||
"bannedIp" varchar(16) NULL,
|
||||
"bannedIpHostMask" varchar(16) NULL,
|
||||
"bannedNameMask" varchar(64) NULL
|
||||
);
|
||||
|
||||
INSERT INTO Tmp_estateban ("EstateID", "bannedUUID", "bannedIp", "bannedIpHostMask", "bannedNameMask")
|
||||
SELECT "EstateID", "bannedUUID", "bannedIp", "bannedIpHostMask", "bannedNameMask" FROM estateban;
|
||||
|
||||
DROP TABLE estateban;
|
||||
|
||||
Alter table Tmp_estateban
|
||||
rename to estateban;
|
||||
|
||||
CREATE INDEX IX_estateban ON estateban
|
||||
(
|
||||
"EstateID"
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
|
||||
|
||||
:VERSION 4
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE TABLE Tmp_estate_managers
|
||||
(
|
||||
"EstateID" int NOT NULL,
|
||||
uuid uuid NOT NULL
|
||||
);
|
||||
|
||||
INSERT INTO Tmp_estate_managers ("EstateID", uuid)
|
||||
SELECT "EstateID", cast(uuid as uuid) FROM estate_managers;
|
||||
|
||||
DROP TABLE estate_managers;
|
||||
|
||||
Alter table Tmp_estate_managers
|
||||
rename to estate_managers;
|
||||
|
||||
CREATE INDEX IX_estate_managers ON estate_managers
|
||||
(
|
||||
"EstateID"
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
|
||||
|
||||
:VERSION 5
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE TABLE Tmp_estate_groups
|
||||
(
|
||||
"EstateID" int NOT NULL,
|
||||
uuid uuid NOT NULL
|
||||
) ;
|
||||
|
||||
INSERT INTO Tmp_estate_groups ("EstateID", uuid)
|
||||
SELECT "EstateID", cast(uuid as uuid) FROM estate_groups;
|
||||
|
||||
DROP TABLE estate_groups;
|
||||
|
||||
Alter table Tmp_estate_groups
|
||||
rename to estate_groups;
|
||||
|
||||
CREATE INDEX IX_estate_groups ON estate_groups
|
||||
(
|
||||
"EstateID"
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
|
||||
|
||||
:VERSION 6
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE TABLE Tmp_estate_users
|
||||
(
|
||||
"EstateID" int NOT NULL,
|
||||
uuid uuid NOT NULL
|
||||
);
|
||||
|
||||
INSERT INTO Tmp_estate_users ("EstateID", uuid)
|
||||
SELECT "EstateID", cast(uuid as uuid) FROM estate_users ;
|
||||
|
||||
DROP TABLE estate_users;
|
||||
|
||||
Alter table Tmp_estate_users
|
||||
rename to estate_users;
|
||||
|
||||
CREATE INDEX IX_estate_users ON estate_users
|
||||
(
|
||||
"EstateID"
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
|
||||
|
||||
:VERSION 7
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE TABLE Tmp_estateban
|
||||
(
|
||||
"EstateID" int NOT NULL,
|
||||
"bannedUUID" uuid NOT NULL,
|
||||
"bannedIp" varchar(16) NULL,
|
||||
"bannedIpHostMask" varchar(16) NULL,
|
||||
"bannedNameMask" varchar(64) NULL
|
||||
);
|
||||
|
||||
INSERT INTO Tmp_estateban ("EstateID", "bannedUUID", "bannedIp", "bannedIpHostMask", "bannedNameMask")
|
||||
SELECT "EstateID", cast("bannedUUID" as uuid), "bannedIp", "bannedIpHostMask", "bannedNameMask" FROM estateban ;
|
||||
|
||||
DROP TABLE estateban;
|
||||
|
||||
Alter table Tmp_estateban
|
||||
rename to estateban;
|
||||
|
||||
CREATE INDEX IX_estateban ON estateban
|
||||
(
|
||||
"EstateID"
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
|
||||
|
||||
:VERSION 8
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE TABLE Tmp_estate_settings
|
||||
(
|
||||
"EstateID" integer default nextval('estate_settings_id') NOT NULL,
|
||||
"EstateName" varchar(64) NULL DEFAULT (NULL),
|
||||
"AbuseEmailToEstateOwner" boolean NOT NULL,
|
||||
"DenyAnonymous" boolean NOT NULL,
|
||||
"ResetHomeOnTeleport" boolean NOT NULL,
|
||||
"FixedSun" boolean NOT NULL,
|
||||
"DenyTransacted" boolean NOT NULL,
|
||||
"BlockDwell" boolean NOT NULL,
|
||||
"DenyIdentified" boolean NOT NULL,
|
||||
"AllowVoice" boolean NOT NULL,
|
||||
"UseGlobalTime" boolean NOT NULL,
|
||||
"PricePerMeter" int NOT NULL,
|
||||
"TaxFree" boolean NOT NULL,
|
||||
"AllowDirectTeleport" boolean NOT NULL,
|
||||
"RedirectGridX" int NOT NULL,
|
||||
"RedirectGridY" int NOT NULL,
|
||||
"ParentEstateID" int NOT NULL,
|
||||
"SunPosition" double precision NOT NULL,
|
||||
"EstateSkipScripts" boolean NOT NULL,
|
||||
"BillableFactor" double precision NOT NULL,
|
||||
"PublicAccess" boolean NOT NULL,
|
||||
"AbuseEmail" varchar(255) NOT NULL,
|
||||
"EstateOwner" uuid NOT NULL,
|
||||
"DenyMinors" boolean NOT NULL
|
||||
);
|
||||
|
||||
INSERT INTO Tmp_estate_settings ("EstateID", "EstateName", "AbuseEmailToEstateOwner", "DenyAnonymous", "ResetHomeOnTeleport", "FixedSun", "DenyTransacted", "BlockDwell", "DenyIdentified", "AllowVoice", "UseGlobalTime", "PricePerMeter", "TaxFree", "AllowDirectTeleport", "RedirectGridX", "RedirectGridY", "ParentEstateID", "SunPosition", "EstateSkipScripts", "BillableFactor", "PublicAccess", "AbuseEmail", "EstateOwner", "DenyMinors")
|
||||
SELECT "EstateID", "EstateName", "AbuseEmailToEstateOwner", "DenyAnonymous", "ResetHomeOnTeleport", "FixedSun", "DenyTransacted", "BlockDwell", "DenyIdentified", "AllowVoice", "UseGlobalTime", "PricePerMeter", "TaxFree", "AllowDirectTeleport", "RedirectGridX", "RedirectGridY", "ParentEstateID", "SunPosition", "EstateSkipScripts", "BillableFactor", "PublicAccess", "AbuseEmail", cast("EstateOwner" as uuid), "DenyMinors" FROM estate_settings ;
|
||||
|
||||
DROP TABLE estate_settings;
|
||||
|
||||
|
||||
Alter table Tmp_estate_settings
|
||||
rename to estate_settings;
|
||||
|
||||
|
||||
Create index on estate_settings (lower("EstateName"));
|
||||
|
||||
COMMIT;
|
||||
|
||||
|
||||
:VERSION 9
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE TABLE Tmp_estate_map
|
||||
(
|
||||
"RegionID" uuid NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'),
|
||||
"EstateID" int NOT NULL
|
||||
);
|
||||
|
||||
INSERT INTO Tmp_estate_map ("RegionID", "EstateID")
|
||||
SELECT cast("RegionID" as uuid), "EstateID" FROM estate_map ;
|
||||
|
||||
DROP TABLE estate_map;
|
||||
|
||||
Alter table Tmp_estate_map
|
||||
rename to estate_map;
|
||||
|
||||
COMMIT;
|
||||
|
||||
:VERSION 10
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
ALTER TABLE estate_settings ADD COLUMN "AllowLandmark" boolean NOT NULL default true;
|
||||
ALTER TABLE estate_settings ADD COLUMN "AllowParcelChanges" boolean NOT NULL default true;
|
||||
ALTER TABLE estate_settings ADD COLUMN "AllowSetHome" boolean NOT NULL default true;
|
||||
COMMIT;
|
||||
|
||||
:VERSION 11
|
||||
|
||||
Begin transaction;
|
||||
|
||||
|
||||
Commit;
|
||||
|
||||
44
OpenSim/Data/PGSQL/Resources/FriendsStore.migrations
Normal file
44
OpenSim/Data/PGSQL/Resources/FriendsStore.migrations
Normal file
@@ -0,0 +1,44 @@
|
||||
:VERSION 1
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE TABLE Friends (
|
||||
"PrincipalID" uuid NOT NULL,
|
||||
"Friend" varchar(255) NOT NULL,
|
||||
"Flags" char(16) NOT NULL DEFAULT '0',
|
||||
"Offered" varchar(32) NOT NULL DEFAULT 0);
|
||||
|
||||
|
||||
COMMIT;
|
||||
|
||||
:VERSION 2
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
INSERT INTO Friends ("PrincipalID", "Friend", "Flags", "Offered")
|
||||
SELECT "ownerID", "friendID", "friendPerms", 0 FROM userfriends;
|
||||
|
||||
COMMIT;
|
||||
|
||||
:VERSION 3
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE TABLE Tmp_Friends
|
||||
("PrincipalID" varchar(255) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
|
||||
"Friend" varchar(255) NOT NULL,
|
||||
"Flags" char(16) NOT NULL DEFAULT '0',
|
||||
"Offered" varchar(32) NOT NULL DEFAULT 0) ;
|
||||
|
||||
INSERT INTO Tmp_Friends ("PrincipalID", "Friend", "Flags", "Offered")
|
||||
SELECT cast("PrincipalID" as varchar(255)), "Friend", "Flags", "Offered" FROM Friends ;
|
||||
|
||||
DROP TABLE Friends;
|
||||
|
||||
Alter table Tmp_Friends
|
||||
rename to Friends;
|
||||
|
||||
ALTER TABLE Friends ADD PRIMARY KEY("PrincipalID", "Friend");
|
||||
|
||||
|
||||
COMMIT;
|
||||
242
OpenSim/Data/PGSQL/Resources/GridStore.migrations
Normal file
242
OpenSim/Data/PGSQL/Resources/GridStore.migrations
Normal file
@@ -0,0 +1,242 @@
|
||||
:VERSION 1
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE TABLE regions(
|
||||
"regionHandle" varchar(255) NULL,
|
||||
"regionName" varchar(255) NULL,
|
||||
uuid varchar(255) NOT NULL PRIMARY KEY,
|
||||
"regionRecvKey" varchar(255) NULL,
|
||||
"regionSecret" varchar(255) NULL,
|
||||
"regionSendKey" varchar(255) NULL,
|
||||
"regionDataURI" varchar(255) NULL,
|
||||
"serverIP" varchar(255) NULL,
|
||||
"serverPort" varchar(255) NULL,
|
||||
"serverURI" varchar(255) NULL,
|
||||
"locX" varchar(255) NULL,
|
||||
"locY" varchar(255) NULL,
|
||||
"locZ" varchar(255) NULL,
|
||||
"eastOverrideHandle" varchar(255) NULL,
|
||||
"westOverrideHandle" varchar(255) NULL,
|
||||
"southOverrideHandle" varchar(255) NULL,
|
||||
"northOverrideHandle" varchar(255) NULL,
|
||||
"regionAssetURI" varchar(255) NULL,
|
||||
"regionAssetRecvKey" varchar(255) NULL,
|
||||
"regionAssetSendKey" varchar(255) NULL,
|
||||
"regionUserURI" varchar(255) NULL,
|
||||
"regionUserRecvKey" varchar(255) NULL,
|
||||
"regionUserSendKey" varchar(255) NULL,
|
||||
"regionMapTexture" varchar(255) NULL,
|
||||
"serverHttpPort" varchar(255) NULL,
|
||||
"serverRemotingPort" varchar(255) NULL,
|
||||
"owner_uuid" varchar(36) NULL
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
|
||||
|
||||
:VERSION 2
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE TABLE Tmp_regions
|
||||
(
|
||||
uuid varchar(36) NOT NULL,
|
||||
"regionHandle" bigint NULL,
|
||||
"regionName" varchar(20) NULL,
|
||||
"regionRecvKey" varchar(128) NULL,
|
||||
"regionSendKey" varchar(128) NULL,
|
||||
"regionSecret" varchar(128) NULL,
|
||||
"regionDataURI" varchar(128) NULL,
|
||||
"serverIP" varchar(64) NULL,
|
||||
"serverPort" int NULL,
|
||||
"serverURI" varchar(255) NULL,
|
||||
"locX" int NULL,
|
||||
"locY" int NULL,
|
||||
"locZ" int NULL,
|
||||
"eastOverrideHandle" bigint NULL,
|
||||
"westOverrideHandle" bigint NULL,
|
||||
"southOverrideHandle" bigint NULL,
|
||||
"northOverrideHandle" bigint NULL,
|
||||
"regionAssetURI" varchar(255) NULL,
|
||||
"regionAssetRecvKey" varchar(128) NULL,
|
||||
"regionAssetSendKey" varchar(128) NULL,
|
||||
"regionUserURI" varchar(255) NULL,
|
||||
"regionUserRecvKey" varchar(128) NULL,
|
||||
"regionUserSendKey" varchar(128) NULL,
|
||||
"regionMapTexture" varchar(36) NULL,
|
||||
"serverHttpPort" int NULL,
|
||||
"serverRemotingPort" int NULL,
|
||||
"owner_uuid" varchar(36) NULL,
|
||||
"originUUID" varchar(36) NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000')
|
||||
);
|
||||
|
||||
INSERT INTO Tmp_regions (uuid, "regionHandle", "regionName", "regionRecvKey", "regionSendKey", "regionSecret", "regionDataURI", "serverIP", "serverPort", "serverURI", "locX", "locY", "locZ", "eastOverrideHandle", "westOverrideHandle", "southOverrideHandle", "northOverrideHandle", "regionAssetURI", "regionAssetRecvKey", "regionAssetSendKey", "regionUserURI", "regionUserRecvKey", "regionUserSendKey", "regionMapTexture", "serverHttpPort", "serverRemotingPort", "owner_uuid")
|
||||
SELECT cast(uuid as varchar(36)), cast("regionHandle" as bigint), cast("regionName" as varchar(20)), cast("regionRecvKey" as varchar(128)), cast("regionSendKey" as varchar(128)), cast("regionSecret" as varchar(128)), cast("regionDataURI" as varchar(128)), cast("serverIP" as varchar(64)), cast("serverPort" as int), "serverURI", cast("locX" as int), cast("locY" as int), cast("locZ" as int), cast("eastOverrideHandle" as bigint), cast("westOverrideHandle" as bigint),
|
||||
cast("southOverrideHandle" as bigint), cast("northOverrideHandle" as bigint), "regionAssetURI", cast("regionAssetRecvKey" as varchar(128)), cast("regionAssetSendKey" as varchar(128)), "regionUserURI", cast("regionUserRecvKey" as varchar(128)), cast("regionUserSendKey" as varchar(128)), cast("regionMapTexture" as varchar(36)),
|
||||
cast("serverHttpPort" as int), cast("serverRemotingPort" as int), "owner_uuid"
|
||||
FROM regions;
|
||||
|
||||
DROP TABLE regions;
|
||||
|
||||
alter table Tmp_regions
|
||||
rename to regions;
|
||||
|
||||
COMMIT;
|
||||
|
||||
:VERSION 3
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE INDEX IX_regions_name ON regions
|
||||
(
|
||||
"regionName"
|
||||
);
|
||||
|
||||
CREATE INDEX IX_regions_handle ON regions
|
||||
(
|
||||
"regionHandle"
|
||||
);
|
||||
|
||||
|
||||
CREATE INDEX IX_regions_override ON regions
|
||||
(
|
||||
"eastOverrideHandle",
|
||||
"westOverrideHandle",
|
||||
"southOverrideHandle",
|
||||
"northOverrideHandle"
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
|
||||
|
||||
:VERSION 4
|
||||
|
||||
/* To prevent any potential data loss issues, you should review this script in detail before running it outside the cotext of the database designer.*/
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE TABLE Tmp_regions
|
||||
(
|
||||
uuid uuid NOT NULL,
|
||||
"regionHandle" bigint NULL,
|
||||
"regionName" varchar(20) NULL,
|
||||
"regionRecvKey" varchar(128) NULL,
|
||||
"regionSendKey" varchar(128) NULL,
|
||||
"regionSecret" varchar(128) NULL,
|
||||
"regionDataURI" varchar(128) NULL,
|
||||
"serverIP" varchar(64) NULL,
|
||||
"serverPort" int NULL,
|
||||
"serverURI" varchar(255) NULL,
|
||||
"locX" int NULL,
|
||||
"locY" int NULL,
|
||||
"locZ" int NULL,
|
||||
"eastOverrideHandle" bigint NULL,
|
||||
"westOverrideHandle" bigint NULL,
|
||||
"southOverrideHandle" bigint NULL,
|
||||
"northOverrideHandle" bigint NULL,
|
||||
"regionAssetURI" varchar(255) NULL,
|
||||
"regionAssetRecvKey" varchar(128) NULL,
|
||||
"regionAssetSendKey" varchar(128) NULL,
|
||||
"regionUserURI" varchar(255) NULL,
|
||||
"regionUserRecvKey" varchar(128) NULL,
|
||||
"regionUserSendKey" varchar(128) NULL,
|
||||
"regionMapTexture" uuid NULL,
|
||||
"serverHttpPort" int NULL,
|
||||
"serverRemotingPort" int NULL,
|
||||
"owner_uuid" uuid NOT NULL,
|
||||
"originUUID" uuid NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000')
|
||||
);
|
||||
|
||||
|
||||
INSERT INTO Tmp_regions (uuid, "regionHandle", "regionName", "regionRecvKey", "regionSendKey", "regionSecret", "regionDataURI", "serverIP", "serverPort", "serverURI", "locX", "locY", "locZ", "eastOverrideHandle", "westOverrideHandle", "southOverrideHandle", "northOverrideHandle", "regionAssetURI", "regionAssetRecvKey", "regionAssetSendKey", "regionUserURI", "regionUserRecvKey", "regionUserSendKey", "regionMapTexture", "serverHttpPort", "serverRemotingPort", "owner_uuid", "originUUID")
|
||||
SELECT cast(uuid as uuid), "regionHandle", "regionName", "regionRecvKey", "regionSendKey", "regionSecret", "regionDataURI", "serverIP", "serverPort", "serverURI", "locX", "locY", "locZ", "eastOverrideHandle", "westOverrideHandle", "southOverrideHandle", "northOverrideHandle", "regionAssetURI", "regionAssetRecvKey", "regionAssetSendKey", "regionUserURI", "regionUserRecvKey", "regionUserSendKey", cast("regionMapTexture" as uuid), "serverHttpPort", "serverRemotingPort", cast( "owner_uuid" as uuid), cast("originUUID" as uuid) FROM regions ;
|
||||
|
||||
|
||||
DROP TABLE regions;
|
||||
|
||||
alter table Tmp_regions rename to regions;
|
||||
|
||||
ALTER TABLE regions ADD CONSTRAINT
|
||||
PK__regions__uuid PRIMARY KEY
|
||||
(
|
||||
uuid
|
||||
);
|
||||
|
||||
CREATE INDEX IX_regions_name ON regions
|
||||
(
|
||||
"regionName"
|
||||
);
|
||||
|
||||
CREATE INDEX IX_regions_handle ON regions
|
||||
(
|
||||
"regionHandle"
|
||||
);
|
||||
|
||||
CREATE INDEX IX_regions_override ON regions
|
||||
(
|
||||
"eastOverrideHandle",
|
||||
"westOverrideHandle",
|
||||
"southOverrideHandle",
|
||||
"northOverrideHandle"
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
|
||||
|
||||
:VERSION 5
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
ALTER TABLE regions ADD access int default 0;
|
||||
|
||||
COMMIT;
|
||||
|
||||
|
||||
:VERSION 6
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
ALTER TABLE regions ADD "ScopeID" uuid default '00000000-0000-0000-0000-000000000000';
|
||||
ALTER TABLE regions alter column "owner_uuid" set DEFAULT ('00000000-0000-0000-0000-000000000000');
|
||||
ALTER TABLE regions ADD "sizeX" integer not null default 0;
|
||||
ALTER TABLE regions ADD "sizeY" integer not null default 0;
|
||||
|
||||
COMMIT;
|
||||
|
||||
|
||||
:VERSION 7
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
ALTER TABLE regions ADD "flags" integer NOT NULL DEFAULT 0;
|
||||
CREATE INDEX flags ON regions("flags");
|
||||
ALTER TABLE regions ADD "last_seen" integer NOT NULL DEFAULT 0;
|
||||
ALTER TABLE regions ADD "PrincipalID" uuid NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000';
|
||||
ALTER TABLE regions ADD "Token" varchar(255) NOT NULL DEFAULT 0;
|
||||
|
||||
COMMIT;
|
||||
|
||||
:VERSION 8
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
ALTER TABLE regions ALTER COLUMN "regionName" type VarChar(128) ;
|
||||
|
||||
DROP INDEX IX_regions_name;
|
||||
ALTER TABLE regions ALTER COLUMN "regionName" type VarChar(128),
|
||||
ALTER COLUMN "regionName" SET NOT NULL;
|
||||
|
||||
CREATE INDEX IX_regions_name ON regions
|
||||
(
|
||||
"regionName"
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
|
||||
:VERSION 9
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
ALTER TABLE regions ADD "parcelMapTexture" uuid NULL;
|
||||
|
||||
COMMIT;
|
||||
|
||||
60
OpenSim/Data/PGSQL/Resources/GridUserStore.migrations
Normal file
60
OpenSim/Data/PGSQL/Resources/GridUserStore.migrations
Normal file
@@ -0,0 +1,60 @@
|
||||
:VERSION 1 # --------------------------
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE TABLE GridUser (
|
||||
"UserID" VARCHAR(255) NOT NULL Primary Key,
|
||||
"HomeRegionID" CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
|
||||
"HomePosition" CHAR(64) NOT NULL DEFAULT '<0,0,0>',
|
||||
"HomeLookAt" CHAR(64) NOT NULL DEFAULT '<0,0,0>',
|
||||
"LastRegionID" CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
|
||||
"LastPosition" CHAR(64) NOT NULL DEFAULT '<0,0,0>',
|
||||
"LastLookAt" CHAR(64) NOT NULL DEFAULT '<0,0,0>',
|
||||
"Online" CHAR(5) NOT NULL DEFAULT 'false',
|
||||
"Login" CHAR(16) NOT NULL DEFAULT '0',
|
||||
"Logout" CHAR(16) NOT NULL DEFAULT '0'
|
||||
) ;
|
||||
|
||||
COMMIT;
|
||||
|
||||
:VERSION 2 # --------------------------
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE TABLE GridUser_tmp (
|
||||
"UserID" VARCHAR(255) NOT NULL PRIMARY KEY,
|
||||
"HomeRegionID" uuid NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
|
||||
"HomePosition" CHAR(64) NOT NULL DEFAULT '<0,0,0>',
|
||||
"HomeLookAt" CHAR(64) NOT NULL DEFAULT '<0,0,0>',
|
||||
"LastRegionID" uuid NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
|
||||
"LastPosition" CHAR(64) NOT NULL DEFAULT '<0,0,0>',
|
||||
"LastLookAt" CHAR(64) NOT NULL DEFAULT '<0,0,0>',
|
||||
"Online" CHAR(5) NOT NULL DEFAULT 'false',
|
||||
"Login" CHAR(16) NOT NULL DEFAULT '0',
|
||||
"Logout" CHAR(16) NOT NULL DEFAULT '0'
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
|
||||
|
||||
INSERT INTO GridUser_tmp ("UserID"
|
||||
,"HomeRegionID"
|
||||
,"HomePosition"
|
||||
,"HomeLookAt"
|
||||
,"LastRegionID"
|
||||
,"LastPosition"
|
||||
,"LastLookAt"
|
||||
,"Online"
|
||||
,"Login"
|
||||
,"Logout")
|
||||
SELECT "UserID", cast("HomeRegionID" as uuid), "HomePosition" ,"HomeLookAt" , cast("LastRegionID" as uuid),
|
||||
"LastPosition"
|
||||
,"LastLookAt"
|
||||
,"Online"
|
||||
,"Login"
|
||||
,"Logout" FROM GridUser;
|
||||
|
||||
DROP TABLE GridUser;
|
||||
|
||||
alter table GridUser_tmp rename to GridUser;
|
||||
|
||||
17
OpenSim/Data/PGSQL/Resources/HGTravelStore.migrations
Normal file
17
OpenSim/Data/PGSQL/Resources/HGTravelStore.migrations
Normal file
@@ -0,0 +1,17 @@
|
||||
:VERSION 1 # --------------------------
|
||||
|
||||
BEGIN;
|
||||
|
||||
CREATE TABLE hg_traveling_data (
|
||||
"SessionID" VARCHAR(36) NOT NULL Primary Key,
|
||||
"UserID" VARCHAR(36) NOT NULL,
|
||||
"GridExternalName" VARCHAR(255) NOT NULL DEFAULT '',
|
||||
"ServiceToken" VARCHAR(255) NOT NULL DEFAULT '',
|
||||
"ClientIPAddress" VARCHAR(16) NOT NULL DEFAULT '',
|
||||
"MyIPAddress" VARCHAR(16) NOT NULL DEFAULT '',
|
||||
"TMStamp" timestamp NOT NULL default now()
|
||||
);
|
||||
|
||||
|
||||
COMMIT;
|
||||
|
||||
26
OpenSim/Data/PGSQL/Resources/IM_Store.migrations
Normal file
26
OpenSim/Data/PGSQL/Resources/IM_Store.migrations
Normal file
@@ -0,0 +1,26 @@
|
||||
:VERSION 1 # --------------------------
|
||||
|
||||
BEGIN Transaction;
|
||||
|
||||
Create Sequence im_offiline_id increment by 1 start with 1;
|
||||
|
||||
CREATE TABLE im_offline (
|
||||
"ID" integer PRIMARY KEY NOT NULL DEFAULT nextval('im_offiline_id') ,
|
||||
"PrincipalID" char(36) NOT NULL default '',
|
||||
"Message" text NOT NULL,
|
||||
"TMStamp" timestamp NOT NULL default now()
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
|
||||
:VERSION 2 # --------------------------
|
||||
|
||||
BEGIN;
|
||||
|
||||
/*
|
||||
INSERT INTO `im_offline` SELECT * from `diva_im_offline`;
|
||||
DROP TABLE `diva_im_offline`;
|
||||
DELETE FROM `migrations` WHERE name='diva_im_Store';
|
||||
*/
|
||||
|
||||
COMMIT;
|
||||
220
OpenSim/Data/PGSQL/Resources/InventoryStore.migrations
Normal file
220
OpenSim/Data/PGSQL/Resources/InventoryStore.migrations
Normal file
@@ -0,0 +1,220 @@
|
||||
:VERSION 1
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE TABLE inventoryfolders (
|
||||
"folderID" varchar(36) NOT NULL default '' PRIMARY KEY,
|
||||
"agentID" varchar(36) default NULL,
|
||||
"parentFolderID" varchar(36) default NULL,
|
||||
"folderName" varchar(64) default NULL,
|
||||
"type" smallint NOT NULL default 0,
|
||||
"version" int NOT NULL default 0
|
||||
);
|
||||
|
||||
|
||||
CREATE INDEX owner ON inventoryfolders
|
||||
(
|
||||
"agentID" ASC
|
||||
);
|
||||
|
||||
CREATE INDEX parent ON inventoryfolders
|
||||
(
|
||||
"parentFolderID" ASC
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE inventoryitems (
|
||||
"inventoryID" varchar(36) NOT NULL default '' Primary Key,
|
||||
"assetID" varchar(36) default NULL,
|
||||
"assetType" int default NULL,
|
||||
"parentFolderID" varchar(36) default NULL,
|
||||
"avatarID" varchar(36) default NULL,
|
||||
"inventoryName" varchar(64) default NULL,
|
||||
"inventoryDescription" varchar(128) default NULL,
|
||||
"inventoryNextPermissions" int default NULL,
|
||||
"inventoryCurrentPermissions" int default NULL,
|
||||
"invType" int default NULL,
|
||||
"creatorID" varchar(36) default NULL,
|
||||
"inventoryBasePermissions" int NOT NULL default 0,
|
||||
"inventoryEveryOnePermissions" int NOT NULL default 0,
|
||||
"salePrice" int default NULL,
|
||||
"saleType" smallint default NULL,
|
||||
"creationDate" int default NULL,
|
||||
"groupID" varchar(36) default NULL,
|
||||
"groupOwned" boolean default NULL,
|
||||
"flags" int default NULL
|
||||
);
|
||||
|
||||
|
||||
CREATE INDEX ii_owner ON inventoryitems
|
||||
(
|
||||
"avatarID" ASC
|
||||
);
|
||||
|
||||
CREATE INDEX ii_folder ON inventoryitems
|
||||
(
|
||||
"parentFolderID" ASC
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
|
||||
|
||||
:VERSION 2
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
ALTER TABLE inventoryitems ADD "inventoryGroupPermissions" INTEGER NOT NULL default 0;
|
||||
|
||||
COMMIT;
|
||||
|
||||
:VERSION 3
|
||||
|
||||
/* To prevent any potential data loss issues, you should review this script in detail before running it outside the cotext of the database designer.*/
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE TABLE Tmp_inventoryfolders
|
||||
(
|
||||
"folderID" uuid NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'),
|
||||
"agentID" uuid NULL DEFAULT (NULL),
|
||||
"parentFolderID" uuid NULL DEFAULT (NULL),
|
||||
"folderName" varchar(64) NULL DEFAULT (NULL),
|
||||
"type" smallint NOT NULL DEFAULT ((0)),
|
||||
"version" int NOT NULL DEFAULT ((0))
|
||||
);
|
||||
|
||||
INSERT INTO Tmp_inventoryfolders ("folderID", "agentID", "parentFolderID", "folderName", type, version)
|
||||
SELECT cast("folderID" as uuid), cast("agentID" as uuid), cast("parentFolderID" as uuid), "folderName", "type", "version"
|
||||
FROM inventoryfolders;
|
||||
|
||||
DROP TABLE inventoryfolders;
|
||||
|
||||
alter table Tmp_inventoryfolders rename to inventoryfolders;
|
||||
|
||||
ALTER TABLE inventoryfolders ADD CONSTRAINT
|
||||
PK__inventor__C2FABFB3173876EA PRIMARY KEY
|
||||
(
|
||||
"folderID"
|
||||
);
|
||||
|
||||
CREATE INDEX owner ON inventoryfolders
|
||||
(
|
||||
"agentID"
|
||||
);
|
||||
|
||||
CREATE INDEX parent ON inventoryfolders
|
||||
(
|
||||
"parentFolderID"
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
|
||||
|
||||
:VERSION 4
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE TABLE Tmp_inventoryitems
|
||||
(
|
||||
"inventoryID" uuid NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'),
|
||||
"assetID" uuid NULL DEFAULT (NULL),
|
||||
"assetType" int NULL DEFAULT (NULL),
|
||||
"parentFolderID" uuid NULL DEFAULT (NULL),
|
||||
"avatarID" uuid NULL DEFAULT (NULL),
|
||||
"inventoryName" varchar(64) NULL DEFAULT (NULL),
|
||||
"inventoryDescription" varchar(128) NULL DEFAULT (NULL),
|
||||
"inventoryNextPermissions" int NULL DEFAULT (NULL),
|
||||
"inventoryCurrentPermissions" int NULL DEFAULT (NULL),
|
||||
"invType" int NULL DEFAULT (NULL),
|
||||
"creatorID" uuid NULL DEFAULT (NULL),
|
||||
"inventoryBasePermissions" int NOT NULL DEFAULT ((0)),
|
||||
"inventoryEveryOnePermissions" int NOT NULL DEFAULT ((0)),
|
||||
"salePrice" int NULL DEFAULT (NULL),
|
||||
"SaleType" smallint NULL DEFAULT (NULL),
|
||||
"creationDate" int NULL DEFAULT (NULL),
|
||||
"groupID" uuid NULL DEFAULT (NULL),
|
||||
"groupOwned" boolean NULL DEFAULT (NULL),
|
||||
"flags" int NULL DEFAULT (NULL),
|
||||
"inventoryGroupPermissions" int NOT NULL DEFAULT ((0))
|
||||
);
|
||||
|
||||
|
||||
INSERT INTO Tmp_inventoryitems ("inventoryID", "assetID", "assetType", "parentFolderID", "avatarID", "inventoryName", "inventoryDescription", "inventoryNextPermissions", "inventoryCurrentPermissions", "invType", "creatorID", "inventoryBasePermissions", "inventoryEveryOnePermissions", "salePrice", "SaleType", "creationDate", "groupID", "groupOwned", "flags", "inventoryGroupPermissions")
|
||||
SELECT cast("inventoryID" as uuid), cast("assetID" as uuid), "assetType", cast("parentFolderID" as uuid), cast("avatarID" as uuid), "inventoryName", "inventoryDescription", "inventoryNextPermissions", "inventoryCurrentPermissions", "invType", cast("creatorID" as uuid), "inventoryBasePermissions", "inventoryEveryOnePermissions", "salePrice", "SaleType", "creationDate", cast("groupID" as uuid), "groupOwned", "flags", "inventoryGroupPermissions"
|
||||
FROM inventoryitems ;
|
||||
|
||||
DROP TABLE inventoryitems;
|
||||
|
||||
alter table Tmp_inventoryitems rename to inventoryitems;
|
||||
|
||||
ALTER TABLE inventoryitems ADD CONSTRAINT
|
||||
PK__inventor__C4B7BC2220C1E124 PRIMARY KEY
|
||||
(
|
||||
"inventoryID"
|
||||
);
|
||||
|
||||
|
||||
CREATE INDEX ii2_owner ON inventoryitems
|
||||
(
|
||||
"avatarID"
|
||||
);
|
||||
|
||||
CREATE INDEX ii2_folder ON inventoryitems
|
||||
(
|
||||
"parentFolderID"
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
|
||||
:VERSION 5
|
||||
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
-- # Restoring defaults:
|
||||
-- # NOTE: "inventoryID" does NOT need one: it's NOT NULL PK and a unique Guid must be provided every time anyway!
|
||||
|
||||
alter table inventoryitems
|
||||
alter column "inventoryBasePermissions" set default 0;
|
||||
alter table inventoryitems
|
||||
alter column "inventoryEveryOnePermissions" set default 0;
|
||||
alter table inventoryitems
|
||||
alter column "inventoryGroupPermissions" set default 0 ;
|
||||
|
||||
COMMIT ;
|
||||
|
||||
:VERSION 7
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
-- # "creatorID" goes back to VARCHAR(36) (???)
|
||||
|
||||
alter table inventoryitems
|
||||
alter column "creatorID" type varchar(36);
|
||||
|
||||
COMMIT ;
|
||||
|
||||
:VERSION 8
|
||||
|
||||
ALTER TABLE inventoryitems
|
||||
alter column "creatorID" set DEFAULT '00000000-0000-0000-0000-000000000000';
|
||||
|
||||
|
||||
:VERSION 9
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
--# "creatorID" goes up to VARCHAR(255)
|
||||
|
||||
alter table inventoryitems
|
||||
alter column "creatorID" type varchar(255);
|
||||
|
||||
Commit;
|
||||
|
||||
:VERSION 10
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
Alter table inventoryitems Rename Column "SaleType" to "saleType";
|
||||
|
||||
Commit;
|
||||
|
||||
16
OpenSim/Data/PGSQL/Resources/LogStore.migrations
Normal file
16
OpenSim/Data/PGSQL/Resources/LogStore.migrations
Normal file
@@ -0,0 +1,16 @@
|
||||
:VERSION 1
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE TABLE logs (
|
||||
"logID" int NOT NULL Primary Key,
|
||||
"target" varchar(36) default NULL,
|
||||
"server" varchar(64) default NULL,
|
||||
"method" varchar(64) default NULL,
|
||||
"arguments" varchar(255) default NULL,
|
||||
"priority" int default NULL,
|
||||
"message" text
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
|
||||
30
OpenSim/Data/PGSQL/Resources/Presence.migrations
Normal file
30
OpenSim/Data/PGSQL/Resources/Presence.migrations
Normal file
@@ -0,0 +1,30 @@
|
||||
:VERSION 1
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE TABLE Presence (
|
||||
"UserID" varchar(255) NOT NULL,
|
||||
"RegionID" uuid NOT NULL,
|
||||
"SessionID" uuid NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
|
||||
"SecureSessionID" uuid NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'
|
||||
);
|
||||
|
||||
|
||||
COMMIT;
|
||||
|
||||
:VERSION 2
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
CREATE UNIQUE INDEX SessionID ON Presence("SessionID");
|
||||
CREATE INDEX UserID ON Presence("UserID");
|
||||
|
||||
COMMIT;
|
||||
|
||||
:VERSION 2
|
||||
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
ALTER TABLE Presence ADD "LastSeen" Timestamp;
|
||||
|
||||
COMMIT;
|
||||
1154
OpenSim/Data/PGSQL/Resources/RegionStore.migrations
Normal file
1154
OpenSim/Data/PGSQL/Resources/RegionStore.migrations
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user