Exemple #1
0
        public void Post(UUID assetID, UUID ownerID, string userAssetURL)
        {
            // Post the item from the local AssetCache onto the remote asset server
            // and place an entry in m_assetMap

            m_log.Debug("[HG ASSET MAPPER]: Posting object " + assetID + " to asset server " + userAssetURL);
            AssetBase asset = m_scene.AssetService.Get(assetID.ToString());

            if (asset != null)
            {
                Dictionary <UUID, AssetType> ids = new Dictionary <UUID, AssetType>();
                HGUuidGatherer uuidGatherer      = new HGUuidGatherer(this, m_scene.AssetService, string.Empty);
                uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
                foreach (UUID uuid in ids.Keys)
                {
                    asset = m_scene.AssetService.Get(uuid.ToString());
                    if (asset == null)
                    {
                        m_log.DebugFormat("[HG ASSET MAPPER]: Could not find asset {0}", uuid);
                    }
                    else
                    {
                        PostAsset(userAssetURL, asset);
                    }
                }

                // maybe all pieces got there...
                m_log.DebugFormat("[HG ASSET MAPPER]: Successfully posted item {0} to asset server {1}", assetID, userAssetURL);
            }
            else
            {
                m_log.DebugFormat("[HG ASSET MAPPER]: Something wrong with asset {0}, it could not be found", assetID);
            }
        }
Exemple #2
0
        // TODO: unused
        // private void Dump(Dictionary<UUID, bool> lst)
        // {
        //     m_log.Debug("XXX -------- UUID DUMP ------- XXX");
        //     foreach (KeyValuePair<UUID, bool> kvp in lst)
        //         m_log.Debug(" >> " + kvp.Key + " (texture? " + kvp.Value + ")");
        //     m_log.Debug("XXX -------- UUID DUMP ------- XXX");
        // }

        #endregion


        #region Public interface

        public void Get(UUID assetID, UUID ownerID, string userAssetURL)
        {
            // Get the item from the remote asset server onto the local AssetCache
            // and place an entry in m_assetMap

            m_log.Debug("[HG ASSET MAPPER]: Fetching object " + assetID + " from asset server " + userAssetURL);
            AssetBase asset = FetchAsset(userAssetURL, assetID);

            if (asset != null)
            {
                // OK, now fetch the inside.
                Dictionary <UUID, AssetType> ids = new Dictionary <UUID, AssetType>();
                HGUuidGatherer uuidGatherer      = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL);
                uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
                if (ids.ContainsKey(assetID))
                {
                    ids.Remove(assetID);
                }
                foreach (UUID uuid in ids.Keys)
                {
                    FetchAsset(userAssetURL, uuid);
                }

                m_log.DebugFormat("[HG ASSET MAPPER]: Successfully fetched asset {0} from asset server {1}", asset.ID, userAssetURL);
            }
            else
            {
                m_log.Warn("[HG ASSET MAPPER]: Could not fetch asset from remote asset server " + userAssetURL);
            }
        }
Exemple #3
0
        // TODO: unused
        // private void Dump(Dictionary<UUID, bool> lst)
        // {
        //     m_log.Debug("XXX -------- UUID DUMP ------- XXX");
        //     foreach (KeyValuePair<UUID, bool> kvp in lst)
        //         m_log.Debug(" >> " + kvp.Key + " (texture? " + kvp.Value + ")");
        //     m_log.Debug("XXX -------- UUID DUMP ------- XXX");
        // }

        #endregion


        #region Public interface

        public void Get(UUID assetID, UUID ownerID, string userAssetURL)
        {
            // Get the item from the remote asset server onto the local AssetService

            AssetMetadata meta = FetchMetadata(userAssetURL, assetID);

            if (meta == null)
            {
                return;
            }

            // The act of gathering UUIDs downloads the assets from the remote server
            Dictionary <UUID, AssetType> ids = new Dictionary <UUID, AssetType>();
            HGUuidGatherer uuidGatherer      = new HGUuidGatherer(m_scene.AssetService, userAssetURL);

            uuidGatherer.GatherAssetUuids(assetID, (AssetType)meta.Type, ids);
        }
Exemple #4
0
        // TODO: unused
        // private void Dump(Dictionary<UUID, bool> lst)
        // {
        //     m_log.Debug("XXX -------- UUID DUMP ------- XXX");
        //     foreach (KeyValuePair<UUID, bool> kvp in lst)
        //         m_log.Debug(" >> " + kvp.Key + " (texture? " + kvp.Value + ")");
        //     m_log.Debug("XXX -------- UUID DUMP ------- XXX");
        // }

        #endregion Internal functions

        #region Public interface

        public void Get(UUID assetID, UUID ownerID, string userAssetURL)
        {
            // Get the item from the remote asset server onto the local AssetService

            AssetMetadata meta = FetchMetadata(userAssetURL, assetID);

            if (meta == null)
            {
                return;
            }

            // The act of gathering UUIDs downloads some assets from the remote server
            // but not all...
            Dictionary <UUID, sbyte> ids          = new Dictionary <UUID, sbyte>();
            HGUuidGatherer           uuidGatherer = new HGUuidGatherer(m_scene.AssetService, userAssetURL);

            uuidGatherer.GatherAssetUuids(assetID, meta.Type, ids);
            m_log.DebugFormat("[HG ASSET MAPPER]: Preparing to get {0} assets", ids.Count);
            bool success = true;

            foreach (UUID uuid in ids.Keys)
            {
                if (FetchAsset(userAssetURL, uuid) == null)
                {
                    success = false;
                }
            }

            // maybe all pieces got here...
            if (!success)
            {
                m_log.DebugFormat("[HG ASSET MAPPER]: Problems getting item {0} from asset server {1}", assetID, userAssetURL);
            }
            else
            {
                m_log.DebugFormat("[HG ASSET MAPPER]: Successfully got item {0} from asset server {1}", assetID, userAssetURL);
            }
        }
Exemple #5
0
        public void Post(UUID assetID, UUID ownerID, string userAssetURL)
        {
            m_log.DebugFormat("[HG ASSET MAPPER]: Starting to send asset {0} with children to asset server {1}", assetID, userAssetURL);

            // Find all the embedded assets

            AssetBase asset = m_scene.AssetService.Get(assetID.ToString());

            if (asset == null)
            {
                m_log.DebugFormat("[HG ASSET MAPPER]: Something wrong with asset {0}, it could not be found", assetID);
                return;
            }

            Dictionary <UUID, sbyte> ids          = new Dictionary <UUID, sbyte>();
            HGUuidGatherer           uuidGatherer = new HGUuidGatherer(m_scene.AssetService, string.Empty);

            uuidGatherer.GatherAssetUuids(asset.FullID, asset.Type, ids);

            // Check which assets already exist in the destination server

            string url = userAssetURL;

            if (!url.EndsWith("/") && !url.EndsWith("="))
            {
                url = url + "/";
            }

            string[] remoteAssetIDs = new string[ids.Count];
            int      i = 0;

            foreach (UUID id in ids.Keys)
            {
                remoteAssetIDs[i++] = url + id.ToString();
            }

            bool[] exist = m_scene.AssetService.AssetsExist(remoteAssetIDs);

            var existSet = new HashSet <string>();

            i = 0;
            foreach (UUID id in ids.Keys)
            {
                if (exist[i])
                {
                    existSet.Add(id.ToString());
                }
                ++i;
            }

            // Send only those assets which don't already exist in the destination server

            bool success = true;

            foreach (UUID uuid in ids.Keys)
            {
                if (!existSet.Contains(uuid.ToString()))
                {
                    asset = m_scene.AssetService.Get(uuid.ToString());
                    if (asset == null)
                    {
                        m_log.DebugFormat("[HG ASSET MAPPER]: Could not find asset {0}", uuid);
                    }
                    else
                    {
                        success &= PostAsset(userAssetURL, asset);
                    }
                }
                else
                {
                    m_log.DebugFormat("[HG ASSET MAPPER]: Didn't post asset {0} because it already exists in asset server {1}", uuid, userAssetURL);
                }
            }

            if (!success)
            {
                m_log.DebugFormat("[HG ASSET MAPPER]: Problems sending asset {0} with children to asset server {1}", assetID, userAssetURL);
            }
            else
            {
                m_log.DebugFormat("[HG ASSET MAPPER]: Successfully sent asset {0} with children to asset server {1}", assetID, userAssetURL);
            }
        }