Esempio n. 1
0
        public AssetBase Get(string id)
        {
            //m_log.DebugFormat("[HG ASSET CONNECTOR]: Get {0}", id);
            AssetBase asset = null;

            if (IsHG(id))
            {
                asset = GetForeign(id);
                if (asset != null)
                {
                    // Now store it locally, if allowed
                    if (m_AssetPerms != null && !m_AssetPerms.AllowedImport(asset.Type))
                    {
                        return(null);
                    }
                    Store(asset);
                }
            }
            else
            {
                if (m_Cache != null)
                {
                    if (!m_Cache.Get(id, out asset))
                    {
                        return(null);
                    }
                    if (asset != null)
                    {
                        return(asset);
                    }
                }
                asset = GetFromLocal(id);
                if (m_Cache != null)
                {
                    if (asset == null)
                    {
                        m_Cache.CacheNegative(id);
                    }
                    else
                    {
                        m_Cache.Cache(asset);
                    }
                }
            }
            return(asset);
        }
        //public virtual bool Get(string id, Object sender, AssetRetrieved handler)

        public override string Store(AssetBase asset)
        {
            if (!m_AssetPerms.AllowedImport(asset.Type))
            {
                return(string.Empty);
            }

            return(base.Store(asset));
        }
        //public virtual bool Get(string id, Object sender, AssetRetrieved handler)

        public string Store(AssetBase asset)
        {
            if (!m_AssetPerms.AllowedImport(asset.Type))
                return string.Empty;

            // Deal with bug introduced in Oct. 20 (1eb3e6cc43e2a7b4053bc1185c7c88e22356c5e8)
            // Fix bad assets before storing on this server
            if (asset.Type == (int)AssetType.Object && asset.Data != null)
            {
                string xml = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(asset.Data));
                asset.Data = Utils.StringToBytes(xml);
            }

            return m_assetService.Store(asset);
        }
Esempio n. 4
0
        public AssetBase Get(string id)
        {
            //m_log.DebugFormat("[HG ASSET CONNECTOR]: Get {0}", id);
            AssetBase asset = null;

            if (m_Cache != null)
            {
                if (!m_Cache.Get(id, out asset))
                {
                    return(null);
                }

                if (asset != null)
                {
                    return(asset);
                }
            }

            if (IsHG(id))
            {
                asset = m_HGService.Get(id);
                if (asset != null)
                {
                    // Now store it locally, if allowed
                    if (m_AssetPerms.AllowedImport(asset.Type))
                    {
                        m_GridService.Store(asset);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            else
            {
                asset = m_GridService.Get(id);
            }

            if (m_Cache != null)
            {
                m_Cache.Cache(asset);
            }

            return(asset);
        }