Example #1
0
        public Aurora.Framework.AssetBase Get(string id)
        {
            Aurora.Framework.AssetBase asset = null;
            AssetBase rasset = null;

            if (m_Cache != null)
            {
                asset = m_Cache.Get(id);
                if ((asset != null) && ((asset.Data != null) && (asset.Data.Length != 0)))
                {
                    return(asset);
                }
            }

            List <string> serverURIs = m_registry == null
                                          ? null
                                          : m_registry.RequestModuleInterface <IConfigurationService>().FindValueOf(
                "AssetServerURI");

            if (m_serverURL != string.Empty)
            {
                serverURIs = new List <string>(new string[1] {
                    m_serverURL
                });
            }
            if (serverURIs != null)
            {
                foreach (string mServerUri in serverURIs)
                {
                    string uri = mServerUri + "/" + id;
                    rasset = SynchronousRestObjectRequester.MakeRequest <int, AssetBase>("GET", uri, 0);
                    asset  = TearDown(rasset);
                    if (m_Cache != null && asset != null)
                    {
                        m_Cache.Cache(asset.IDString, asset);
                    }
                    if (asset != null)
                    {
                        return(asset);
                    }
                }
            }
            return(null);
        }
Example #2
0
        public UUID UpdateContent(UUID id, byte[] data)
        {
            Aurora.Framework.AssetBase asset = null;

            if (m_Cache != null)
            {
                asset = m_Cache.Get(id.ToString());
            }

            if (asset == null)
            {
                asset = Get(id.ToString());
                if (asset == null)
                {
                    return(UUID.Zero);
                }
            }
            asset.Data = data;

            List <string> serverURIs = m_registry.RequestModuleInterface <IConfigurationService>().FindValueOf("AssetServerURI");

            if (m_serverURL != string.Empty)
            {
                serverURIs = new List <string>(new string[1] {
                    m_serverURL
                });
            }
            foreach (string m_ServerURI in serverURIs)
            {
                string uri = m_ServerURI + "/" + id;

                if (SynchronousRestObjectRequester.
                    MakeRequest <AssetBase, bool>("POST", uri, Build(asset)))
                {
                    if (m_Cache != null)
                    {
                        m_Cache.Cache(asset.IDString, asset);
                    }

                    return(asset.ID);
                }
            }
            return(UUID.Zero);
        }