aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Handlers/Asset
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Server/Handlers/Asset')
-rw-r--r--OpenSim/Server/Handlers/Asset/AssetServerConnector.cs11
-rw-r--r--OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs7
-rw-r--r--OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs28
-rw-r--r--OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs7
-rw-r--r--OpenSim/Server/Handlers/Asset/AssetsExistHandler.cs7
5 files changed, 54 insertions, 6 deletions
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs
index 9b86986..ab81dd6 100644
--- a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs
+++ b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs
@@ -30,6 +30,7 @@ using System.IO;
30using Nini.Config; 30using Nini.Config;
31using OpenMetaverse; 31using OpenMetaverse;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.ServiceAuth;
33using OpenSim.Framework.Console; 34using OpenSim.Framework.Console;
34using OpenSim.Server.Base; 35using OpenSim.Server.Base;
35using OpenSim.Services.Interfaces; 36using OpenSim.Services.Interfaces;
@@ -69,6 +70,8 @@ namespace OpenSim.Server.Handlers.Asset
69 bool allowDelete = serverConfig.GetBoolean("AllowRemoteDelete", false); 70 bool allowDelete = serverConfig.GetBoolean("AllowRemoteDelete", false);
70 bool allowDeleteAllTypes = serverConfig.GetBoolean("AllowRemoteDeleteAllTypes", false); 71 bool allowDeleteAllTypes = serverConfig.GetBoolean("AllowRemoteDeleteAllTypes", false);
71 72
73 string redirectURL = serverConfig.GetString("RedirectURL", string.Empty);
74
72 AllowedRemoteDeleteTypes allowedRemoteDeleteTypes; 75 AllowedRemoteDeleteTypes allowedRemoteDeleteTypes;
73 76
74 if (!allowDelete) 77 if (!allowDelete)
@@ -83,9 +86,11 @@ namespace OpenSim.Server.Handlers.Asset
83 allowedRemoteDeleteTypes = AllowedRemoteDeleteTypes.MapTile; 86 allowedRemoteDeleteTypes = AllowedRemoteDeleteTypes.MapTile;
84 } 87 }
85 88
86 server.AddStreamHandler(new AssetServerGetHandler(m_AssetService)); 89 IServiceAuth auth = ServiceAuth.Create(config, m_ConfigName);
87 server.AddStreamHandler(new AssetServerPostHandler(m_AssetService)); 90
88 server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowedRemoteDeleteTypes)); 91 server.AddStreamHandler(new AssetServerGetHandler(m_AssetService, auth, redirectURL));
92 server.AddStreamHandler(new AssetServerPostHandler(m_AssetService, auth));
93 server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowedRemoteDeleteTypes, auth));
89 server.AddStreamHandler(new AssetsExistHandler(m_AssetService)); 94 server.AddStreamHandler(new AssetsExistHandler(m_AssetService));
90 95
91 MainConsole.Instance.Commands.AddCommand("Assets", false, 96 MainConsole.Instance.Commands.AddCommand("Assets", false,
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs
index 941b97d..d85d471 100644
--- a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs
+++ b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs
@@ -38,6 +38,7 @@ using System.Xml.Serialization;
38using OpenSim.Server.Base; 38using OpenSim.Server.Base;
39using OpenSim.Services.Interfaces; 39using OpenSim.Services.Interfaces;
40using OpenSim.Framework; 40using OpenSim.Framework;
41using OpenSim.Framework.ServiceAuth;
41using OpenSim.Framework.Servers.HttpServer; 42using OpenSim.Framework.Servers.HttpServer;
42 43
43namespace OpenSim.Server.Handlers.Asset 44namespace OpenSim.Server.Handlers.Asset
@@ -70,6 +71,12 @@ namespace OpenSim.Server.Handlers.Asset
70 m_allowedTypes = allowedTypes; 71 m_allowedTypes = allowedTypes;
71 } 72 }
72 73
74 public AssetServerDeleteHandler(IAssetService service, AllowedRemoteDeleteTypes allowedTypes, IServiceAuth auth) :
75 base("DELETE", "/assets", auth)
76 {
77 m_AssetService = service;
78 m_allowedTypes = allowedTypes;
79 }
73 protected override byte[] ProcessRequest(string path, Stream request, 80 protected override byte[] ProcessRequest(string path, Stream request,
74 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 81 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
75 { 82 {
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs
index ed3b4af..91c5c54 100644
--- a/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs
+++ b/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs
@@ -38,20 +38,31 @@ using System.Xml.Serialization;
38using OpenSim.Server.Base; 38using OpenSim.Server.Base;
39using OpenSim.Services.Interfaces; 39using OpenSim.Services.Interfaces;
40using OpenSim.Framework; 40using OpenSim.Framework;
41using OpenSim.Framework.ServiceAuth;
41using OpenSim.Framework.Servers.HttpServer; 42using OpenSim.Framework.Servers.HttpServer;
42 43
43namespace OpenSim.Server.Handlers.Asset 44namespace OpenSim.Server.Handlers.Asset
44{ 45{
45 public class AssetServerGetHandler : BaseStreamHandler 46 public class AssetServerGetHandler : BaseStreamHandler
46 { 47 {
47 // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 49
49 private IAssetService m_AssetService; 50 private IAssetService m_AssetService;
51 private string m_RedirectURL;
50 52
51 public AssetServerGetHandler(IAssetService service) : 53 public AssetServerGetHandler(IAssetService service) :
52 base("GET", "/assets") 54 base("GET", "/assets")
53 { 55 {
56 m_AssetService = service;
57 }
58
59 public AssetServerGetHandler(IAssetService service, IServiceAuth auth, string redirectURL) :
60 base("GET", "/assets", auth)
61 {
54 m_AssetService = service; 62 m_AssetService = service;
63 m_RedirectURL = redirectURL;
64 if (!m_RedirectURL.EndsWith("/"))
65 m_RedirectURL = m_RedirectURL.TrimEnd('/');
55 } 66 }
56 67
57 protected override byte[] ProcessRequest(string path, Stream request, 68 protected override byte[] ProcessRequest(string path, Stream request,
@@ -64,9 +75,10 @@ namespace OpenSim.Server.Handlers.Asset
64 if (p.Length == 0) 75 if (p.Length == 0)
65 return result; 76 return result;
66 77
78 string id = string.Empty;
67 if (p.Length > 1) 79 if (p.Length > 1)
68 { 80 {
69 string id = p[0]; 81 id = p[0];
70 string cmd = p[1]; 82 string cmd = p[1];
71 83
72 if (cmd == "data") 84 if (cmd == "data")
@@ -117,7 +129,7 @@ namespace OpenSim.Server.Handlers.Asset
117 { 129 {
118 // Get the entire asset (metadata + data) 130 // Get the entire asset (metadata + data)
119 131
120 string id = p[0]; 132 id = p[0];
121 AssetBase asset = m_AssetService.Get(id); 133 AssetBase asset = m_AssetService.Get(id);
122 134
123 if (asset != null) 135 if (asset != null)
@@ -144,6 +156,16 @@ namespace OpenSim.Server.Handlers.Asset
144 result = new byte[0]; 156 result = new byte[0];
145 } 157 }
146 158
159 if (httpResponse.StatusCode == (int)HttpStatusCode.NotFound && !string.IsNullOrEmpty(m_RedirectURL) && !string.IsNullOrEmpty(id))
160 {
161 httpResponse.StatusCode = (int)HttpStatusCode.Redirect;
162 string rurl = m_RedirectURL;
163 if (!path.StartsWith("/"))
164 rurl += "/";
165 rurl += path;
166 httpResponse.AddHeader("Location", rurl);
167 m_log.DebugFormat("[ASSET GET HANDLER]: Asset not found, redirecting to {0} ({1})", rurl, httpResponse.StatusCode);
168 }
147 return result; 169 return result;
148 } 170 }
149 } 171 }
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs
index a77e67d..1c706a7 100644
--- a/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs
@@ -38,6 +38,7 @@ using System.Xml.Serialization;
38using OpenSim.Server.Base; 38using OpenSim.Server.Base;
39using OpenSim.Services.Interfaces; 39using OpenSim.Services.Interfaces;
40using OpenSim.Framework; 40using OpenSim.Framework;
41using OpenSim.Framework.ServiceAuth;
41using OpenSim.Framework.Servers.HttpServer; 42using OpenSim.Framework.Servers.HttpServer;
42 43
43namespace OpenSim.Server.Handlers.Asset 44namespace OpenSim.Server.Handlers.Asset
@@ -54,6 +55,12 @@ namespace OpenSim.Server.Handlers.Asset
54 m_AssetService = service; 55 m_AssetService = service;
55 } 56 }
56 57
58 public AssetServerPostHandler(IAssetService service, IServiceAuth auth) :
59 base("POST", "/assets", auth)
60 {
61 m_AssetService = service;
62 }
63
57 protected override byte[] ProcessRequest(string path, Stream request, 64 protected override byte[] ProcessRequest(string path, Stream request,
58 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 65 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
59 { 66 {
diff --git a/OpenSim/Server/Handlers/Asset/AssetsExistHandler.cs b/OpenSim/Server/Handlers/Asset/AssetsExistHandler.cs
index 6d01f86..32901b3 100644
--- a/OpenSim/Server/Handlers/Asset/AssetsExistHandler.cs
+++ b/OpenSim/Server/Handlers/Asset/AssetsExistHandler.cs
@@ -38,6 +38,7 @@ using System.Xml.Serialization;
38using OpenSim.Server.Base; 38using OpenSim.Server.Base;
39using OpenSim.Services.Interfaces; 39using OpenSim.Services.Interfaces;
40using OpenSim.Framework; 40using OpenSim.Framework;
41using OpenSim.Framework.ServiceAuth;
41using OpenSim.Framework.Servers.HttpServer; 42using OpenSim.Framework.Servers.HttpServer;
42using OpenMetaverse; 43using OpenMetaverse;
43 44
@@ -55,6 +56,12 @@ namespace OpenSim.Server.Handlers.Asset
55 m_AssetService = service; 56 m_AssetService = service;
56 } 57 }
57 58
59 public AssetsExistHandler(IAssetService service, IServiceAuth auth) :
60 base("POST", "/get_assets_exist", auth)
61 {
62 m_AssetService = service;
63 }
64
58 protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 65 protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
59 { 66 {
60 XmlSerializer xs; 67 XmlSerializer xs;