diff options
Diffstat (limited to 'OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs')
-rw-r--r-- | OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs | 347 |
1 files changed, 175 insertions, 172 deletions
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs index b2b4aa7..0a45eff 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs | |||
@@ -135,152 +135,153 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
135 | 135 | ||
136 | private void DoAppearance(RequestData hdata) | 136 | private void DoAppearance(RequestData hdata) |
137 | { | 137 | { |
138 | 138 | // !!! REFACTORIMG PROBLEM. This needs rewriting for 0.7 | |
139 | AppearanceRequestData rdata = (AppearanceRequestData) hdata; | 139 | |
140 | 140 | //AppearanceRequestData rdata = (AppearanceRequestData) hdata; | |
141 | Rest.Log.DebugFormat("{0} DoAppearance ENTRY", MsgId); | 141 | |
142 | 142 | //Rest.Log.DebugFormat("{0} DoAppearance ENTRY", MsgId); | |
143 | // If we're disabled, do nothing. | 143 | |
144 | 144 | //// If we're disabled, do nothing. | |
145 | if (!enabled) | 145 | |
146 | { | 146 | //if (!enabled) |
147 | return; | 147 | //{ |
148 | } | 148 | // return; |
149 | 149 | //} | |
150 | // Now that we know this is a serious attempt to | 150 | |
151 | // access inventory data, we should find out who | 151 | //// Now that we know this is a serious attempt to |
152 | // is asking, and make sure they are authorized | 152 | //// access inventory data, we should find out who |
153 | // to do so. We need to validate the caller's | 153 | //// is asking, and make sure they are authorized |
154 | // identity before revealing anything about the | 154 | //// to do so. We need to validate the caller's |
155 | // status quo. Authenticate throws an exception | 155 | //// identity before revealing anything about the |
156 | // via Fail if no identity information is present. | 156 | //// status quo. Authenticate throws an exception |
157 | // | 157 | //// via Fail if no identity information is present. |
158 | // With the present HTTP server we can't use the | 158 | //// |
159 | // builtin authentication mechanisms because they | 159 | //// With the present HTTP server we can't use the |
160 | // would be enforced for all in-bound requests. | 160 | //// builtin authentication mechanisms because they |
161 | // Instead we look at the headers ourselves and | 161 | //// would be enforced for all in-bound requests. |
162 | // handle authentication directly. | 162 | //// Instead we look at the headers ourselves and |
163 | 163 | //// handle authentication directly. | |
164 | try | 164 | |
165 | { | 165 | //try |
166 | if (!rdata.IsAuthenticated) | 166 | //{ |
167 | { | 167 | // if (!rdata.IsAuthenticated) |
168 | rdata.Fail(Rest.HttpStatusCodeNotAuthorized,String.Format("user \"{0}\" could not be authenticated", rdata.userName)); | 168 | // { |
169 | } | 169 | // rdata.Fail(Rest.HttpStatusCodeNotAuthorized,String.Format("user \"{0}\" could not be authenticated", rdata.userName)); |
170 | } | 170 | // } |
171 | catch (RestException e) | 171 | //} |
172 | { | 172 | //catch (RestException e) |
173 | if (e.statusCode == Rest.HttpStatusCodeNotAuthorized) | 173 | //{ |
174 | { | 174 | // if (e.statusCode == Rest.HttpStatusCodeNotAuthorized) |
175 | Rest.Log.WarnFormat("{0} User not authenticated", MsgId); | 175 | // { |
176 | Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, rdata.request.Headers.Get("Authorization")); | 176 | // Rest.Log.WarnFormat("{0} User not authenticated", MsgId); |
177 | } | 177 | // Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, rdata.request.Headers.Get("Authorization")); |
178 | else | 178 | // } |
179 | { | 179 | // else |
180 | Rest.Log.ErrorFormat("{0} User authentication failed", MsgId); | 180 | // { |
181 | Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, rdata.request.Headers.Get("Authorization")); | 181 | // Rest.Log.ErrorFormat("{0} User authentication failed", MsgId); |
182 | } | 182 | // Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, rdata.request.Headers.Get("Authorization")); |
183 | throw (e); | 183 | // } |
184 | } | 184 | // throw (e); |
185 | 185 | //} | |
186 | Rest.Log.DebugFormat("{0} Authenticated {1}", MsgId, rdata.userName); | 186 | |
187 | 187 | //Rest.Log.DebugFormat("{0} Authenticated {1}", MsgId, rdata.userName); | |
188 | // We can only get here if we are authorized | 188 | |
189 | // | 189 | //// We can only get here if we are authorized |
190 | // The requestor may have specified an UUID or | 190 | //// |
191 | // a conjoined FirstName LastName string. We'll | 191 | //// The requestor may have specified an UUID or |
192 | // try both. If we fail with the first, UUID, | 192 | //// a conjoined FirstName LastName string. We'll |
193 | // attempt, we try the other. As an example, the | 193 | //// try both. If we fail with the first, UUID, |
194 | // URI for a valid inventory request might be: | 194 | //// attempt, we try the other. As an example, the |
195 | // | 195 | //// URI for a valid inventory request might be: |
196 | // http://<host>:<port>/admin/inventory/Arthur Dent | 196 | //// |
197 | // | 197 | //// http://<host>:<port>/admin/inventory/Arthur Dent |
198 | // Indicating that this is an inventory request for | 198 | //// |
199 | // an avatar named Arthur Dent. This is ALL that is | 199 | //// Indicating that this is an inventory request for |
200 | // required to designate a GET for an entire | 200 | //// an avatar named Arthur Dent. This is ALL that is |
201 | // inventory. | 201 | //// required to designate a GET for an entire |
202 | // | 202 | //// inventory. |
203 | 203 | //// | |
204 | // Do we have at least a user agent name? | 204 | |
205 | 205 | //// Do we have at least a user agent name? | |
206 | if (rdata.Parameters.Length < 1) | 206 | |
207 | { | 207 | //if (rdata.Parameters.Length < 1) |
208 | Rest.Log.WarnFormat("{0} Appearance: No user agent identifier specified", MsgId); | 208 | //{ |
209 | rdata.Fail(Rest.HttpStatusCodeBadRequest, "no user identity specified"); | 209 | // Rest.Log.WarnFormat("{0} Appearance: No user agent identifier specified", MsgId); |
210 | } | 210 | // rdata.Fail(Rest.HttpStatusCodeBadRequest, "no user identity specified"); |
211 | 211 | //} | |
212 | // The first parameter MUST be the agent identification, either an UUID | 212 | |
213 | // or a space-separated First-name Last-Name specification. We check for | 213 | //// The first parameter MUST be the agent identification, either an UUID |
214 | // an UUID first, if anyone names their character using a valid UUID | 214 | //// or a space-separated First-name Last-Name specification. We check for |
215 | // that identifies another existing avatar will cause this a problem... | 215 | //// an UUID first, if anyone names their character using a valid UUID |
216 | 216 | //// that identifies another existing avatar will cause this a problem... | |
217 | try | 217 | |
218 | { | 218 | //try |
219 | rdata.uuid = new UUID(rdata.Parameters[PARM_USERID]); | 219 | //{ |
220 | Rest.Log.DebugFormat("{0} UUID supplied", MsgId); | 220 | // rdata.uuid = new UUID(rdata.Parameters[PARM_USERID]); |
221 | rdata.userProfile = Rest.UserServices.GetUserProfile(rdata.uuid); | 221 | // Rest.Log.DebugFormat("{0} UUID supplied", MsgId); |
222 | } | 222 | // rdata.userProfile = Rest.UserServices.GetUserProfile(rdata.uuid); |
223 | catch | 223 | //} |
224 | { | 224 | //catch |
225 | string[] names = rdata.Parameters[PARM_USERID].Split(Rest.CA_SPACE); | 225 | //{ |
226 | if (names.Length == 2) | 226 | // string[] names = rdata.Parameters[PARM_USERID].Split(Rest.CA_SPACE); |
227 | { | 227 | // if (names.Length == 2) |
228 | Rest.Log.DebugFormat("{0} Agent Name supplied [2]", MsgId); | 228 | // { |
229 | rdata.userProfile = Rest.UserServices.GetUserProfile(names[0],names[1]); | 229 | // Rest.Log.DebugFormat("{0} Agent Name supplied [2]", MsgId); |
230 | } | 230 | // rdata.userProfile = Rest.UserServices.GetUserProfile(names[0],names[1]); |
231 | else | 231 | // } |
232 | { | 232 | // else |
233 | Rest.Log.WarnFormat("{0} A Valid UUID or both first and last names must be specified", MsgId); | 233 | // { |
234 | rdata.Fail(Rest.HttpStatusCodeBadRequest, "invalid user identity"); | 234 | // Rest.Log.WarnFormat("{0} A Valid UUID or both first and last names must be specified", MsgId); |
235 | } | 235 | // rdata.Fail(Rest.HttpStatusCodeBadRequest, "invalid user identity"); |
236 | } | 236 | // } |
237 | 237 | //} | |
238 | // If the user profile is null then either the server is broken, or the | 238 | |
239 | // user is not known. We always assume the latter case. | 239 | //// If the user profile is null then either the server is broken, or the |
240 | 240 | //// user is not known. We always assume the latter case. | |
241 | if (rdata.userProfile != null) | 241 | |
242 | { | 242 | //if (rdata.userProfile != null) |
243 | Rest.Log.DebugFormat("{0} User profile obtained for agent {1} {2}", | 243 | //{ |
244 | MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName); | 244 | // Rest.Log.DebugFormat("{0} User profile obtained for agent {1} {2}", |
245 | } | 245 | // MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName); |
246 | else | 246 | //} |
247 | { | 247 | //else |
248 | Rest.Log.WarnFormat("{0} No user profile for {1}", MsgId, rdata.path); | 248 | //{ |
249 | rdata.Fail(Rest.HttpStatusCodeNotFound, "unrecognized user identity"); | 249 | // Rest.Log.WarnFormat("{0} No user profile for {1}", MsgId, rdata.path); |
250 | } | 250 | // rdata.Fail(Rest.HttpStatusCodeNotFound, "unrecognized user identity"); |
251 | 251 | //} | |
252 | // If we get to here, then we have effectively validated the user's | 252 | |
253 | 253 | //// If we get to here, then we have effectively validated the user's | |
254 | switch (rdata.method) | 254 | |
255 | { | 255 | //switch (rdata.method) |
256 | case Rest.HEAD : // Do the processing, set the status code, suppress entity | 256 | //{ |
257 | DoGet(rdata); | 257 | // case Rest.HEAD : // Do the processing, set the status code, suppress entity |
258 | rdata.buffer = null; | 258 | // DoGet(rdata); |
259 | break; | 259 | // rdata.buffer = null; |
260 | 260 | // break; | |
261 | case Rest.GET : // Do the processing, set the status code, return entity | 261 | |
262 | DoGet(rdata); | 262 | // case Rest.GET : // Do the processing, set the status code, return entity |
263 | break; | 263 | // DoGet(rdata); |
264 | 264 | // break; | |
265 | case Rest.PUT : // Update named element | 265 | |
266 | DoUpdate(rdata); | 266 | // case Rest.PUT : // Update named element |
267 | break; | 267 | // DoUpdate(rdata); |
268 | 268 | // break; | |
269 | case Rest.POST : // Add new information to identified context. | 269 | |
270 | DoExtend(rdata); | 270 | // case Rest.POST : // Add new information to identified context. |
271 | break; | 271 | // DoExtend(rdata); |
272 | 272 | // break; | |
273 | case Rest.DELETE : // Delete information | 273 | |
274 | DoDelete(rdata); | 274 | // case Rest.DELETE : // Delete information |
275 | break; | 275 | // DoDelete(rdata); |
276 | 276 | // break; | |
277 | default : | 277 | |
278 | Rest.Log.WarnFormat("{0} Method {1} not supported for {2}", | 278 | // default : |
279 | MsgId, rdata.method, rdata.path); | 279 | // Rest.Log.WarnFormat("{0} Method {1} not supported for {2}", |
280 | rdata.Fail(Rest.HttpStatusCodeMethodNotAllowed, | 280 | // MsgId, rdata.method, rdata.path); |
281 | String.Format("{0} not supported", rdata.method)); | 281 | // rdata.Fail(Rest.HttpStatusCodeMethodNotAllowed, |
282 | break; | 282 | // String.Format("{0} not supported", rdata.method)); |
283 | } | 283 | // break; |
284 | //} | ||
284 | } | 285 | } |
285 | 286 | ||
286 | #endregion Interface | 287 | #endregion Interface |
@@ -391,37 +392,39 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
391 | private void DoUpdate(AppearanceRequestData rdata) | 392 | private void DoUpdate(AppearanceRequestData rdata) |
392 | { | 393 | { |
393 | 394 | ||
394 | bool created = false; | 395 | // REFACTORING PROBLEM This was commented out. It doesn't work for 0.7 |
395 | bool modified = false; | ||
396 | 396 | ||
397 | //bool created = false; | ||
398 | //bool modified = false; | ||
397 | 399 | ||
398 | rdata.userAppearance = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID); | ||
399 | 400 | ||
400 | // If the user exists then this is considered a modification regardless | 401 | //rdata.userAppearance = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID); |
401 | // of what may, or may not be, specified in the payload. | ||
402 | 402 | ||
403 | if (rdata.userAppearance != null) | 403 | //// If the user exists then this is considered a modification regardless |
404 | { | 404 | //// of what may, or may not be, specified in the payload. |
405 | modified = true; | ||
406 | Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance); | ||
407 | Rest.UserServices.UpdateUserProfile(rdata.userProfile); | ||
408 | } | ||
409 | 405 | ||
410 | if (created) | 406 | //if (rdata.userAppearance != null) |
411 | { | 407 | //{ |
412 | rdata.Complete(Rest.HttpStatusCodeCreated); | 408 | // modified = true; |
413 | } | 409 | // Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance); |
414 | else | 410 | // Rest.UserServices.UpdateUserProfile(rdata.userProfile); |
415 | { | 411 | //} |
416 | if (modified) | 412 | |
417 | { | 413 | //if (created) |
418 | rdata.Complete(Rest.HttpStatusCodeOK); | 414 | //{ |
419 | } | 415 | // rdata.Complete(Rest.HttpStatusCodeCreated); |
420 | else | 416 | //} |
421 | { | 417 | //else |
422 | rdata.Complete(Rest.HttpStatusCodeNoContent); | 418 | //{ |
423 | } | 419 | // if (modified) |
424 | } | 420 | // { |
421 | // rdata.Complete(Rest.HttpStatusCodeOK); | ||
422 | // } | ||
423 | // else | ||
424 | // { | ||
425 | // rdata.Complete(Rest.HttpStatusCodeNoContent); | ||
426 | // } | ||
427 | //} | ||
425 | 428 | ||
426 | rdata.Respond(String.Format("Appearance {0} : Normal completion", rdata.method)); | 429 | rdata.Respond(String.Format("Appearance {0} : Normal completion", rdata.method)); |
427 | 430 | ||