aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/AssetInventoryServer/Metadata.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Grid/AssetInventoryServer/Metadata.cs')
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Metadata.cs170
1 files changed, 85 insertions, 85 deletions
diff --git a/OpenSim/Grid/AssetInventoryServer/Metadata.cs b/OpenSim/Grid/AssetInventoryServer/Metadata.cs
index 3735ea4..ee96eec 100644
--- a/OpenSim/Grid/AssetInventoryServer/Metadata.cs
+++ b/OpenSim/Grid/AssetInventoryServer/Metadata.cs
@@ -1,85 +1,85 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Xml; 3using System.Xml;
4using OpenMetaverse; 4using OpenMetaverse;
5using OpenMetaverse.StructuredData; 5using OpenMetaverse.StructuredData;
6 6
7namespace OpenSim.Grid.AssetInventoryServer 7namespace OpenSim.Grid.AssetInventoryServer
8{ 8{
9 public class Metadata 9 public class Metadata
10 { 10 {
11 public UUID ID; 11 public UUID ID;
12 public string Name; 12 public string Name;
13 public string Description; 13 public string Description;
14 public DateTime CreationDate; 14 public DateTime CreationDate;
15 public string ContentType; 15 public string ContentType;
16 public byte[] SHA1; 16 public byte[] SHA1;
17 public bool Temporary; 17 public bool Temporary;
18 public Dictionary<string, Uri> Methods = new Dictionary<string, Uri>(); 18 public Dictionary<string, Uri> Methods = new Dictionary<string, Uri>();
19 public OSDMap ExtraData; 19 public OSDMap ExtraData;
20 20
21 public OSDMap SerializeToOSD() 21 public OSDMap SerializeToOSD()
22 { 22 {
23 OSDMap osdata = new OSDMap(); 23 OSDMap osdata = new OSDMap();
24 24
25 if (ID != UUID.Zero) osdata["id"] = OSD.FromUUID(ID); 25 if (ID != UUID.Zero) osdata["id"] = OSD.FromUUID(ID);
26 osdata["name"] = OSD.FromString(Name); 26 osdata["name"] = OSD.FromString(Name);
27 osdata["description"] = OSD.FromString(Description); 27 osdata["description"] = OSD.FromString(Description);
28 osdata["creation_date"] = OSD.FromDate(CreationDate); 28 osdata["creation_date"] = OSD.FromDate(CreationDate);
29 osdata["type"] = OSD.FromString(ContentType); 29 osdata["type"] = OSD.FromString(ContentType);
30 osdata["sha1"] = OSD.FromBinary(SHA1); 30 osdata["sha1"] = OSD.FromBinary(SHA1);
31 osdata["temporary"] = OSD.FromBoolean(Temporary); 31 osdata["temporary"] = OSD.FromBoolean(Temporary);
32 32
33 OSDMap methods = new OSDMap(Methods.Count); 33 OSDMap methods = new OSDMap(Methods.Count);
34 foreach (KeyValuePair<string, Uri> kvp in Methods) 34 foreach (KeyValuePair<string, Uri> kvp in Methods)
35 methods.Add(kvp.Key, OSD.FromUri(kvp.Value)); 35 methods.Add(kvp.Key, OSD.FromUri(kvp.Value));
36 osdata["methods"] = methods; 36 osdata["methods"] = methods;
37 37
38 if (ExtraData != null) osdata["extra_data"] = ExtraData; 38 if (ExtraData != null) osdata["extra_data"] = ExtraData;
39 39
40 return osdata; 40 return osdata;
41 } 41 }
42 42
43 public byte[] SerializeToBytes() 43 public byte[] SerializeToBytes()
44 { 44 {
45 LitJson.JsonData jsonData = OSDParser.SerializeJson(SerializeToOSD()); 45 LitJson.JsonData jsonData = OSDParser.SerializeJson(SerializeToOSD());
46 return System.Text.Encoding.UTF8.GetBytes(jsonData.ToJson()); 46 return System.Text.Encoding.UTF8.GetBytes(jsonData.ToJson());
47 } 47 }
48 48
49 public void Deserialize(byte[] data) 49 public void Deserialize(byte[] data)
50 { 50 {
51 OSD osdata = OSDParser.DeserializeJson(System.Text.Encoding.UTF8.GetString(data)); 51 OSD osdata = OSDParser.DeserializeJson(System.Text.Encoding.UTF8.GetString(data));
52 Deserialize(osdata); 52 Deserialize(osdata);
53 } 53 }
54 54
55 public void Deserialize(string data) 55 public void Deserialize(string data)
56 { 56 {
57 OSD osdata = OSDParser.DeserializeJson(data); 57 OSD osdata = OSDParser.DeserializeJson(data);
58 Deserialize(osdata); 58 Deserialize(osdata);
59 } 59 }
60 60
61 public void Deserialize(OSD osdata) 61 public void Deserialize(OSD osdata)
62 { 62 {
63 if (osdata.Type == OSDType.Map) 63 if (osdata.Type == OSDType.Map)
64 { 64 {
65 OSDMap map = (OSDMap)osdata; 65 OSDMap map = (OSDMap)osdata;
66 ID = map["id"].AsUUID(); 66 ID = map["id"].AsUUID();
67 Name = map["name"].AsString(); 67 Name = map["name"].AsString();
68 Description = map["description"].AsString(); 68 Description = map["description"].AsString();
69 CreationDate = map["creation_date"].AsDate(); 69 CreationDate = map["creation_date"].AsDate();
70 ContentType = map["type"].AsString(); 70 ContentType = map["type"].AsString();
71 SHA1 = map["sha1"].AsBinary(); 71 SHA1 = map["sha1"].AsBinary();
72 Temporary = map["temporary"].AsBoolean(); 72 Temporary = map["temporary"].AsBoolean();
73 73
74 OSDMap methods = map["methods"] as OSDMap; 74 OSDMap methods = map["methods"] as OSDMap;
75 if (methods != null) 75 if (methods != null)
76 { 76 {
77 foreach (KeyValuePair<string, OSD> kvp in methods) 77 foreach (KeyValuePair<string, OSD> kvp in methods)
78 Methods.Add(kvp.Key, kvp.Value.AsUri()); 78 Methods.Add(kvp.Key, kvp.Value.AsUri());
79 } 79 }
80 80
81 ExtraData = map["extra_data"] as OSDMap; 81 ExtraData = map["extra_data"] as OSDMap;
82 } 82 }
83 } 83 }
84 } 84 }
85} 85}