aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Util.cs
diff options
context:
space:
mode:
authorOren Hurvitz2014-03-31 11:53:12 +0300
committerOren Hurvitz2014-04-02 06:30:57 +0100
commitd1c3f8eef58b29eb8760eeb1ac03852a2387f927 (patch)
treeb8686f4ea01b6dac3740b9685734686e2178dd2d /OpenSim/Framework/Util.cs
parentfix orphaned code in sun module per mantis 7068 (diff)
downloadopensim-SC_OLD-d1c3f8eef58b29eb8760eeb1ac03852a2387f927.zip
opensim-SC_OLD-d1c3f8eef58b29eb8760eeb1ac03852a2387f927.tar.gz
opensim-SC_OLD-d1c3f8eef58b29eb8760eeb1ac03852a2387f927.tar.bz2
opensim-SC_OLD-d1c3f8eef58b29eb8760eeb1ac03852a2387f927.tar.xz
Added assets service method AssetsExist(), which returns whether the given list of assets exist.
This method is used to optimize sending assets with embedded assets: e.g., when a Hypergrid visitor takes an item into the inventory.
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Util.cs50
1 files changed, 50 insertions, 0 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index c7a7341..b133ff3 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -52,6 +52,8 @@ using OpenMetaverse;
52using OpenMetaverse.StructuredData; 52using OpenMetaverse.StructuredData;
53using Amib.Threading; 53using Amib.Threading;
54using System.Collections.Concurrent; 54using System.Collections.Concurrent;
55using System.Collections.Specialized;
56using System.Web;
55 57
56namespace OpenSim.Framework 58namespace OpenSim.Framework
57{ 59{
@@ -866,6 +868,54 @@ namespace OpenSim.Framework
866 } 868 }
867 869
868 /// <summary> 870 /// <summary>
871 /// Parses a foreign asset ID.
872 /// </summary>
873 /// <param name="id">A possibly-foreign asset ID: http://grid.example.com:8002/00000000-0000-0000-0000-000000000000 </param>
874 /// <param name="url">The URL: http://grid.example.com:8002</param>
875 /// <param name="assetID">The asset ID: 00000000-0000-0000-0000-000000000000. Returned even if 'id' isn't foreign.</param>
876 /// <returns>True: this is a foreign asset ID; False: it isn't</returns>
877 public static bool ParseForeignAssetID(string id, out string url, out string assetID)
878 {
879 url = String.Empty;
880 assetID = String.Empty;
881
882 UUID uuid;
883 if (UUID.TryParse(id, out uuid))
884 {
885 assetID = uuid.ToString();
886 return false;
887 }
888
889 if ((id.Length == 0) || (id[0] != 'h' && id[0] != 'H'))
890 return false;
891
892 Uri assetUri;
893 if (!Uri.TryCreate(id, UriKind.Absolute, out assetUri) || assetUri.Scheme != Uri.UriSchemeHttp)
894 return false;
895
896 // Simian
897 if (assetUri.Query != string.Empty)
898 {
899 NameValueCollection qscoll = HttpUtility.ParseQueryString(assetUri.Query);
900 assetID = qscoll["id"];
901 if (assetID != null)
902 url = id.Replace(assetID, ""); // Malformed again, as simian expects
903 else
904 url = id; // !!! best effort
905 }
906 else // robust
907 {
908 url = "http://" + assetUri.Authority;
909 assetID = assetUri.LocalPath.Trim(new char[] { '/' });
910 }
911
912 if (!UUID.TryParse(assetID, out uuid))
913 return false;
914
915 return true;
916 }
917
918 /// <summary>
869 /// Removes all invalid path chars (OS dependent) 919 /// Removes all invalid path chars (OS dependent)
870 /// </summary> 920 /// </summary>
871 /// <param name="path">path</param> 921 /// <param name="path">path</param>