aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/AssetService
diff options
context:
space:
mode:
authordiva2009-06-15 23:29:00 +0000
committerdiva2009-06-15 23:29:00 +0000
commite1fd76ace627dcef3798ca20f330397c93e13151 (patch)
tree8444597dd5c6dc6078e41872149bd5f9606336cb /OpenSim/Services/AssetService
parentRenamed two of the in connector modules, to make things consistent. (diff)
downloadopensim-SC-e1fd76ace627dcef3798ca20f330397c93e13151.zip
opensim-SC-e1fd76ace627dcef3798ca20f330397c93e13151.tar.gz
opensim-SC-e1fd76ace627dcef3798ca20f330397c93e13151.tar.bz2
opensim-SC-e1fd76ace627dcef3798ca20f330397c93e13151.tar.xz
Moving these nice HG connectors to their homes.
Diffstat (limited to 'OpenSim/Services/AssetService')
-rw-r--r--OpenSim/Services/AssetService/HGAssetService.cs179
1 files changed, 0 insertions, 179 deletions
diff --git a/OpenSim/Services/AssetService/HGAssetService.cs b/OpenSim/Services/AssetService/HGAssetService.cs
deleted file mode 100644
index b3e3f17..0000000
--- a/OpenSim/Services/AssetService/HGAssetService.cs
+++ /dev/null
@@ -1,179 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using log4net;
29using Nini.Config;
30using System;
31using System.Collections.Generic;
32using System.Reflection;
33using OpenSim.Framework;
34using OpenSim.Services.Interfaces;
35using OpenSim.Services.Connectors;
36
37namespace OpenSim.Services.AssetService
38{
39 public class HGAssetService : IAssetService
40 {
41 private static readonly ILog m_log =
42 LogManager.GetLogger(
43 MethodBase.GetCurrentMethod().DeclaringType);
44
45 private Dictionary<string, AssetServicesConnector> m_connectors = new Dictionary<string, AssetServicesConnector>();
46
47 public HGAssetService(IConfigSource source)
48 {
49 IConfig moduleConfig = source.Configs["Modules"];
50 if (moduleConfig != null)
51 {
52 // string name = moduleConfig.GetString("AssetServices", "");
53
54 IConfig assetConfig = source.Configs["AssetService"];
55 if (assetConfig == null)
56 {
57 m_log.Error("[HG ASSET SERVICE]: AssetService missing from OpanSim.ini");
58 return;
59 }
60
61 m_log.Info("[HG ASSET SERVICE]: HG asset service enabled");
62 }
63 }
64
65 private bool StringToUrlAndAssetID(string id, out string url, out string assetID)
66 {
67 url = String.Empty;
68 assetID = String.Empty;
69
70 Uri assetUri;
71
72 if (Uri.TryCreate(id, UriKind.Absolute, out assetUri) &&
73 assetUri.Scheme == Uri.UriSchemeHttp)
74 {
75 url = "http://" + assetUri.Authority;
76 assetID = assetUri.LocalPath.Trim(new char[] {'/'});
77 return true;
78 }
79
80 return false;
81 }
82
83 private IAssetService GetConnector(string url)
84 {
85 AssetServicesConnector connector = null;
86 lock (m_connectors)
87 {
88 if (m_connectors.ContainsKey(url))
89 {
90 connector = m_connectors[url];
91 }
92 else
93 {
94 // We're instantiating this class explicitly, but this won't
95 // work in general, because the remote grid may be running
96 // an asset server that has a different protocol.
97 // Eventually we will want a piece of protocol asking
98 // the remote server about its kind. Definitely cool thing to do!
99 connector = new AssetServicesConnector(url);
100 m_connectors.Add(url, connector);
101 }
102 }
103 return connector;
104 }
105
106 public AssetBase Get(string id)
107 {
108 string url = string.Empty;
109 string assetID = string.Empty;
110
111 if (StringToUrlAndAssetID(id, out url, out assetID))
112 {
113 IAssetService connector = GetConnector(url);
114 return connector.Get(assetID);
115 }
116
117 return null;
118 }
119
120 public AssetMetadata GetMetadata(string id)
121 {
122 string url = string.Empty;
123 string assetID = string.Empty;
124
125 if (StringToUrlAndAssetID(id, out url, out assetID))
126 {
127 IAssetService connector = GetConnector(url);
128 return connector.GetMetadata(assetID);
129 }
130
131 return null;
132 }
133
134 public byte[] GetData(string id)
135 {
136 return null;
137 }
138
139 public bool Get(string id, Object sender, AssetRetrieved handler)
140 {
141 string url = string.Empty;
142 string assetID = string.Empty;
143
144 if (StringToUrlAndAssetID(id, out url, out assetID))
145 {
146 IAssetService connector = GetConnector(url);
147 return connector.Get(assetID, sender, handler);
148 }
149
150 return false;
151 }
152
153 public string Store(AssetBase asset)
154 {
155 string url = string.Empty;
156 string assetID = string.Empty;
157
158 if (StringToUrlAndAssetID(asset.ID, out url, out assetID))
159 {
160 IAssetService connector = GetConnector(url);
161 // Restore the assetID to a simple UUID
162 asset.ID = assetID;
163 return connector.Store(asset);
164 }
165
166 return String.Empty;
167 }
168
169 public bool UpdateContent(string id, byte[] data)
170 {
171 return false;
172 }
173
174 public bool Delete(string id)
175 {
176 return false;
177 }
178 }
179}