aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Servers/Asset
diff options
context:
space:
mode:
authorMelanie Thielker2009-05-09 00:39:01 +0000
committerMelanie Thielker2009-05-09 00:39:01 +0000
commita582d1b1a201224df97d1e4030ae7d471aa7f120 (patch)
treed5ac7f936ac3841fe37b6b48524ea43910e35e83 /OpenSim/Servers/Asset
parent* Fix windows build. Thanks RemedyTomm for the patch (diff)
downloadopensim-SC_OLD-a582d1b1a201224df97d1e4030ae7d471aa7f120.zip
opensim-SC_OLD-a582d1b1a201224df97d1e4030ae7d471aa7f120.tar.gz
opensim-SC_OLD-a582d1b1a201224df97d1e4030ae7d471aa7f120.tar.bz2
opensim-SC_OLD-a582d1b1a201224df97d1e4030ae7d471aa7f120.tar.xz
Add the /data and /metadata retrieval modes to the new asset server.
Not functional yet.
Diffstat (limited to 'OpenSim/Servers/Asset')
-rw-r--r--OpenSim/Servers/Asset/AssetServerGetHandler.cs96
1 files changed, 40 insertions, 56 deletions
diff --git a/OpenSim/Servers/Asset/AssetServerGetHandler.cs b/OpenSim/Servers/Asset/AssetServerGetHandler.cs
index 6c4d9b3..80226d4 100644
--- a/OpenSim/Servers/Asset/AssetServerGetHandler.cs
+++ b/OpenSim/Servers/Asset/AssetServerGetHandler.cs
@@ -33,6 +33,7 @@ using System.Text;
33using System.Text.RegularExpressions; 33using System.Text.RegularExpressions;
34using System.Xml; 34using System.Xml;
35using System.Xml.Serialization; 35using System.Xml.Serialization;
36using OpenSim.Servers.Base;
36using OpenSim.Services.Interfaces; 37using OpenSim.Services.Interfaces;
37using OpenSim.Services.AssetService; 38using OpenSim.Services.AssetService;
38using OpenSim.Framework; 39using OpenSim.Framework;
@@ -60,77 +61,60 @@ namespace OpenSim.Servers.AssetServer
60 if (p.Length == 0) 61 if (p.Length == 0)
61 return result; 62 return result;
62 63
63 AssetBase asset = m_AssetService.Get(p[0]); 64 if (p.Length > 1 && p[1] == "data")
65 {
66 result = m_AssetService.GetData(p[0]);
67 if (result == null)
68 result = new byte[0];
64 69
65 if (asset != null) 70 httpResponse.StatusCode = (int)HttpStatusCode.OK;
71 httpResponse.ContentType = "application/octet-stream";
72 }
73 else if(p.Length > 1 && p[1] == "metadata")
66 { 74 {
67 if (p.Length > 1 && p[1] == "data") 75 AssetMetadata metadata = m_AssetService.GetMetadata(p[0]);
76
77 if (metadata != null)
68 { 78 {
79 XmlSerializer xs =
80 new XmlSerializer(typeof(AssetMetadata));
81 result = SerializeResult(xs, metadata);
82
69 httpResponse.StatusCode = (int)HttpStatusCode.OK; 83 httpResponse.StatusCode = (int)HttpStatusCode.OK;
70 httpResponse.ContentType = 84 httpResponse.ContentType =
71 SLAssetTypeToContentType(asset.Type); 85 ServerUtils.SLAssetTypeToContentType(metadata.Type);
72
73 result = asset.Data;
74 } 86 }
75 else 87 }
88 else
89 {
90 AssetBase asset = m_AssetService.Get(p[0]);
91
92 if (asset != null)
76 { 93 {
77 XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); 94 XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
78 MemoryStream ms = new MemoryStream(); 95 result = SerializeResult(xs, asset);
79 XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8);
80 xw.Formatting = Formatting.Indented;
81 xs.Serialize(xw, asset);
82 xw.Flush();
83 96
84 ms.Seek(0, SeekOrigin.Begin); 97 httpResponse.StatusCode = (int)HttpStatusCode.OK;
85 result = ms.GetBuffer(); 98 httpResponse.ContentType =
86 99 ServerUtils.SLAssetTypeToContentType(asset.Type);
87 Array.Resize<byte>(ref result, (int)ms.Length);
88 } 100 }
89 } 101 }
90 return result; 102 return result;
91 } 103 }
92 104
93 private string SLAssetTypeToContentType(int assetType) 105 private byte[] SerializeResult(XmlSerializer xs, object data)
94 { 106 {
95 switch (assetType) 107 MemoryStream ms = new MemoryStream();
96 { 108 XmlTextWriter xw = new XmlTextWriter(ms, Encoding.UTF8);
97 case 0: 109 xw.Formatting = Formatting.Indented;
98 return "image/jp2"; 110 xs.Serialize(xw, data);
99 case 1: 111 xw.Flush();
100 return "application/ogg"; 112
101 case 2: 113 ms.Seek(0, SeekOrigin.Begin);
102 return "application/x-metaverse-callingcard"; 114 byte[] ret = ms.GetBuffer();
103 case 3: 115 Array.Resize<byte>(ref ret, (int)ms.Length);
104 return "application/x-metaverse-landmark"; 116
105 case 5: 117 return ret;
106 return "application/x-metaverse-clothing";
107 case 6:
108 return "application/x-metaverse-primitive";
109 case 7:
110 return "application/x-metaverse-notecard";
111 case 8:
112 return "application/x-metaverse-folder";
113 case 10:
114 return "application/x-metaverse-lsl";
115 case 11:
116 return "application/x-metaverse-lso";
117 case 12:
118 return "image/tga";
119 case 13:
120 return "application/x-metaverse-bodypart";
121 case 17:
122 return "audio/x-wav";
123 case 19:
124 return "image/jpeg";
125 case 20:
126 return "application/x-metaverse-animation";
127 case 21:
128 return "application/x-metaverse-gesture";
129 case 22:
130 return "application/x-metaverse-simstate";
131 default:
132 return "application/octet-stream";
133 }
134 } 118 }
135 } 119 }
136} 120}