aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
authorMelanie2019-07-13 13:33:34 +0100
committerMelanie2019-07-13 13:33:34 +0100
commit2f52a3b12447580d3c1c25feb41593fba62b26da (patch)
treefd7ab5ec199f936eb128682cbac5dd2dc6b100aa /OpenSim/Services
parentMerge branch 'master' of brain.opensimulator.org:/var/git/opensim (diff)
downloadopensim-SC-2f52a3b12447580d3c1c25feb41593fba62b26da.zip
opensim-SC-2f52a3b12447580d3c1c25feb41593fba62b26da.tar.gz
opensim-SC-2f52a3b12447580d3c1c25feb41593fba62b26da.tar.bz2
opensim-SC-2f52a3b12447580d3c1c25feb41593fba62b26da.tar.xz
When using FSAssets, the HGAssetService would still use AssetService.
This introduces a new HGAssetService config option named BackingService, which defaults to the old behaviour, loading AssetService. It can, however, be used to load FSAssets for HG assets, which eliminates numerous problems.
Diffstat (limited to 'OpenSim/Services')
-rwxr-xr-x[-rw-r--r--]OpenSim/Services/HypergridService/HGAssetService.cs83
1 files changed, 70 insertions, 13 deletions
diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs
index a66478e..8fef57a 100644..100755
--- a/OpenSim/Services/HypergridService/HGAssetService.cs
+++ b/OpenSim/Services/HypergridService/HGAssetService.cs
@@ -39,6 +39,7 @@ using OpenSim.Framework.Serialization.External;
39using OpenSim.Server.Base; 39using OpenSim.Server.Base;
40using OpenSim.Services.Interfaces; 40using OpenSim.Services.Interfaces;
41using OpenSim.Services.AssetService; 41using OpenSim.Services.AssetService;
42using OpenSim.Services.Base;
42 43
43namespace OpenSim.Services.HypergridService 44namespace OpenSim.Services.HypergridService
44{ 45{
@@ -47,7 +48,7 @@ namespace OpenSim.Services.HypergridService
47 /// but implements it in ways that are appropriate for inter-grid 48 /// but implements it in ways that are appropriate for inter-grid
48 /// asset exchanges. 49 /// asset exchanges.
49 /// </summary> 50 /// </summary>
50 public class HGAssetService : OpenSim.Services.AssetService.AssetService, IAssetService 51 public class HGAssetService : ServiceBase, IAssetService
51 { 52 {
52 private static readonly ILog m_log = 53 private static readonly ILog m_log =
53 LogManager.GetLogger( 54 LogManager.GetLogger(
@@ -60,7 +61,9 @@ namespace OpenSim.Services.HypergridService
60 61
61 private AssetPermissions m_AssetPerms; 62 private AssetPermissions m_AssetPerms;
62 63
63 public HGAssetService(IConfigSource config, string configName) : base(config, configName) 64 IAssetService m_assetService = null;
65
66 public HGAssetService(IConfigSource config, string configName) : base(config)
64 { 67 {
65 m_log.Debug("[HGAsset Service]: Starting"); 68 m_log.Debug("[HGAsset Service]: Starting");
66 IConfig assetConfig = config.Configs[configName]; 69 IConfig assetConfig = config.Configs[configName];
@@ -86,12 +89,30 @@ namespace OpenSim.Services.HypergridService
86 // Permissions 89 // Permissions
87 m_AssetPerms = new AssetPermissions(assetConfig); 90 m_AssetPerms = new AssetPermissions(assetConfig);
88 91
92 string str = assetConfig.GetString("BackingService", "OpenSim.Services.AssetService.dll:AssetService");
93
94 if (str != string.Empty)
95 {
96 args = new object[] { config };
97 m_assetService = LoadPlugin<IAssetService>(str, args);
98 if (m_assetService != null)
99 {
100 m_log.InfoFormat("[HGASSETS]: Backing service loaded: {0}", str);
101 }
102 else
103 {
104 m_log.ErrorFormat("[HGASSETS]: Failed to load backing service {0}", str);
105 }
106 }
107
108
109
89 } 110 }
90 111
91 #region IAssetService overrides 112 #region IAssetService
92 public override AssetBase Get(string id) 113 public AssetBase Get(string id)
93 { 114 {
94 AssetBase asset = base.Get(id); 115 AssetBase asset = m_assetService.Get(id);
95 116
96 if (asset == null) 117 if (asset == null)
97 return null; 118 return null;
@@ -107,9 +128,9 @@ namespace OpenSim.Services.HypergridService
107 return asset; 128 return asset;
108 } 129 }
109 130
110 public override AssetMetadata GetMetadata(string id) 131 public AssetMetadata GetMetadata(string id)
111 { 132 {
112 AssetMetadata meta = base.GetMetadata(id); 133 AssetMetadata meta = m_assetService.GetMetadata(id);
113 134
114 if (meta == null) 135 if (meta == null)
115 return null; 136 return null;
@@ -119,7 +140,7 @@ namespace OpenSim.Services.HypergridService
119 return meta; 140 return meta;
120 } 141 }
121 142
122 public override byte[] GetData(string id) 143 public byte[] GetData(string id)
123 { 144 {
124 AssetBase asset = Get(id); 145 AssetBase asset = Get(id);
125 146
@@ -142,7 +163,7 @@ namespace OpenSim.Services.HypergridService
142 163
143 //public virtual bool Get(string id, Object sender, AssetRetrieved handler) 164 //public virtual bool Get(string id, Object sender, AssetRetrieved handler)
144 165
145 public override string Store(AssetBase asset) 166 public string Store(AssetBase asset)
146 { 167 {
147 if (!m_AssetPerms.AllowedImport(asset.Type)) 168 if (!m_AssetPerms.AllowedImport(asset.Type))
148 return string.Empty; 169 return string.Empty;
@@ -155,15 +176,53 @@ namespace OpenSim.Services.HypergridService
155 asset.Data = Utils.StringToBytes(xml); 176 asset.Data = Utils.StringToBytes(xml);
156 } 177 }
157 178
158 return base.Store(asset); 179 return m_assetService.Store(asset);
159 } 180 }
160 181
161 public override bool Delete(string id) 182 public bool Delete(string id)
162 { 183 {
163 // NOGO 184 // NOGO
164 return false; 185 return false;
165 } 186 }
166 187
188 public AssetBase GetCached(string id)
189 {
190 AssetBase asset = m_assetService.GetCached(id);
191
192 if (asset == null)
193 return null;
194
195 if (!m_AssetPerms.AllowedExport(asset.Type))
196 return null;
197
198 if (asset.Metadata.Type == (sbyte)AssetType.Object)
199 asset.Data = AdjustIdentifiers(asset.Data);
200
201 AdjustIdentifiers(asset.Metadata);
202
203 return asset;
204 }
205
206 public bool Get(string id, object sender, AssetRetrieved handler)
207 {
208 AssetBase asset = Get(id);
209
210 handler?.Invoke(id, sender, asset);
211
212 return true;
213 }
214
215 public bool[] AssetsExist(string[] ids)
216 {
217 return m_assetService.AssetsExist(ids);
218 }
219
220 public bool UpdateContent(string id, byte[] data)
221 {
222 // NO WAY
223 return false;
224 }
225
167 #endregion 226 #endregion
168 227
169 protected void AdjustIdentifiers(AssetMetadata meta) 228 protected void AdjustIdentifiers(AssetMetadata meta)
@@ -187,7 +246,5 @@ namespace OpenSim.Services.HypergridService
187 246
188 return Utils.StringToBytes(ExternalRepresentationUtils.RewriteSOP(xml, "HGAssetService", m_HomeURL, m_Cache, UUID.Zero)); 247 return Utils.StringToBytes(ExternalRepresentationUtils.RewriteSOP(xml, "HGAssetService", m_HomeURL, m_Cache, UUID.Zero));
189 } 248 }
190
191 } 249 }
192
193} 250}