Ejemplo n.º 1
0
        public bool Delete(string id)
        {
            m_log.DebugFormat("[ASSET SERVICE]: Deleting asset {0}", id);
            UUID assetID;

            if (!UUID.TryParse(id, out assetID))
            {
                return(false);
            }

            if (assetID == UUID.Zero)
            {
                return(false);
            }

            AssetBase asset = m_Database.GetAsset(assetID);

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

            if ((int)(asset.Flags & AssetFlags.Maptile) != 0 || //Depriated, use Deletable instead
                (int)(asset.Flags & AssetFlags.Deletable) != 0)
            {
                return(m_Database.Delete(id));
            }
            else
            {
                m_log.DebugFormat("[ASSET SERVICE]: Request to delete asset {0}, but flags are not Maptile", id);
            }

            return(false);
        }
Ejemplo n.º 2
0
        public virtual bool Delete(UUID id)
        {
            if (m_doRemoteOnly)
            {
                object remoteValue = DoRemoteByURL("AssetServerURI", id);
                return(remoteValue != null ? (bool)remoteValue : false);
            }

            return(m_database.Delete(id));
        }
Ejemplo n.º 3
0
        public virtual bool Delete(UUID id)
        {
            object remoteValue = DoRemote(id);

            if (remoteValue != null || m_doRemoteOnly)
            {
                return(remoteValue == null ? false : (bool)remoteValue);
            }

            return(m_database.Delete(id));
        }
        /// <summary>
        ///     Load an asset
        /// </summary>
        /// <param name="assetPath"> </param>
        /// <param name="data"></param>
        /// <returns>true if asset was successfully loaded, false otherwise</returns>
        private bool LoadAsset(string assetPath, byte[] data)
        {
            //IRegionSerialiser serialiser = scene.RequestModuleInterface<IRegionSerialiser>();
            // Right now we're nastily obtaining the UUID from the filename
            string filename = assetPath.Remove(0, ArchiveConstants.ASSETS_PATH.Length);

            int i = filename.LastIndexOf(ArchiveConstants.ASSET_EXTENSION_SEPARATOR);

            if (i == -1)
            {
                MainConsole.Instance.ErrorFormat(
                    "[INVENTORY ARCHIVER]: Could not find extension information in asset path {0} since it's missing the separator {1}.  Skipping",
                    assetPath, ArchiveConstants.ASSET_EXTENSION_SEPARATOR);

                return(false);
            }

            string extension = filename.Substring(i);
            string uuid      = filename.Remove(filename.Length - extension.Length);

            if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension))
            {
                AssetType assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension];

                if (assetType == AssetType.Unknown)
                {
                    MainConsole.Instance.WarnFormat(
                        "[INVENTORY ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length,
                        uuid);
                }
                else if (assetType == AssetType.Object)
                {
                    string       xmlData     = Utils.BytesToString(data);
                    ISceneEntity sceneObject = SceneEntitySerializer.SceneObjectSerializer.FromOriginalXmlFormat(
                        xmlData, m_registry);
                    if (sceneObject != null)
                    {
                        if (m_creatorIdForAssetId.ContainsKey(UUID.Parse(uuid)))
                        {
                            foreach (
                                ISceneChildEntity sop in
                                from sop in sceneObject.ChildrenEntities()
                                where string.IsNullOrEmpty(sop.CreatorData)
                                select sop)
                            {
                                sop.CreatorID = m_creatorIdForAssetId[UUID.Parse(uuid)];
                            }
                        }
                        foreach (ISceneChildEntity sop in sceneObject.ChildrenEntities())
                        {
                            //Fix ownerIDs and perms
                            sop.Inventory.ApplyGodPermissions((uint)PermissionMask.All);
                            sceneObject.ApplyPermissions((uint)PermissionMask.All);
                            foreach (TaskInventoryItem item in sop.Inventory.GetInventoryItems())
                            {
                                item.OwnerID = m_userInfo.PrincipalID;
                            }
                            sop.OwnerID = m_userInfo.PrincipalID;
                        }
                        data =
                            Utils.StringToBytes(
                                SceneEntitySerializer.SceneObjectSerializer.ToOriginalXmlFormat(sceneObject));
                    }
                }
                //MainConsole.Instance.DebugFormat("[INVENTORY ARCHIVER]: Importing asset {0}, type {1}", uuid, assetType);

                AssetBase asset = new AssetBase(UUID.Parse(uuid), "RandomName", assetType, m_overridecreator)
                {
                    Data =
                        data,
                    Flags
                        =
                            AssetFlags
                            .Normal
                };
                IAssetService    assetService = m_registry.RequestModuleInterface <IAssetService>();
                IAssetDataPlugin assetData    = Framework.Utilities.DataManager.RequestPlugin <IAssetDataPlugin>();
                if (assetData != null && ReplaceAssets)
                {
                    assetData.Delete(asset.ID, true);
                }

                assetService.Store(asset);
                return(true);
            }
            MainConsole.Instance.ErrorFormat(
                "[INVENTORY ARCHIVER]: Tried to dearchive data with path {0} with an unknown type extension {1}",
                assetPath, extension);

            return(false);
        }
Ejemplo n.º 5
0
 public virtual bool Delete(UUID id)
 {
     MainConsole.Instance.DebugFormat("[ASSET SERVICE]: Deleting asset {0}", id);
     return(m_database.Delete(id));
 }
        /// <summary>
        ///     Load an asset
        /// </summary>
        /// <param name="assetPath"> </param>
        /// <param name="data"></param>
        /// <returns>true if asset was successfully loaded, false otherwise</returns>
        bool LoadAsset(string assetPath, byte [] data)
        {
            //IRegionSerializer serializer = scene.RequestModuleInterface<IRegionSerializer>();
            // Right now we're nastily obtaining the UUID from the filename
            string filename = assetPath.Remove(0, ArchiveConstants.ASSETS_PATH.Length);

            int i = filename.LastIndexOf(ArchiveConstants.ASSET_EXTENSION_SEPARATOR, StringComparison.Ordinal);

            if (i == -1)
            {
                MainConsole.Instance.ErrorFormat(
                    "[Inventory Archiver]: Could not find extension information in asset path {0} since it's missing the separator {1}.  Skipping",
                    assetPath, ArchiveConstants.ASSET_EXTENSION_SEPARATOR);

                return(false);
            }

            string extension = filename.Substring(i);
            string uuid      = filename.Remove(filename.Length - extension.Length);
            UUID   assetID   = UUID.Parse(uuid);

            if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension))
            {
                AssetType assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE [extension];

                if (assetType == AssetType.Unknown)
                {
                    MainConsole.Instance.WarnFormat(
                        "[Inventory Archiver]: Importing {0} byte asset {1} with unknown type", data.Length,
                        uuid);
                }
                else if (assetType == AssetType.Object)
                {
                    string       xmlData     = Utils.BytesToString(data);
                    ISceneEntity sceneObject = SceneEntitySerializer.SceneObjectSerializer.FromOriginalXmlFormat(
                        xmlData, m_registry);
                    if (sceneObject != null)
                    {
                        if (m_creatorIdForAssetId.ContainsKey(assetID))
                        {
                            foreach (
                                ISceneChildEntity sop in
                                from sop in sceneObject.ChildrenEntities()
                                where string.IsNullOrEmpty(sop.CreatorData)
                                select sop)
                            {
                                sop.CreatorID = m_creatorIdForAssetId [assetID];
                            }
                        }

                        foreach (ISceneChildEntity sop in sceneObject.ChildrenEntities())
                        {
                            //Fix ownerIDs and perms
                            sop.Inventory.ApplyGodPermissions((uint)PermissionMask.All);
                            sceneObject.ApplyPermissions((uint)PermissionMask.All);
                            foreach (TaskInventoryItem item in sop.Inventory.GetInventoryItems())
                            {
                                item.OwnerID = m_userInfo.PrincipalID;
                            }
                            sop.OwnerID = m_userInfo.PrincipalID;
                        }

                        data =
                            Utils.StringToBytes(
                                SceneEntitySerializer.SceneObjectSerializer.ToOriginalXmlFormat(sceneObject));
                    }
                }
                //MainConsole.Instance.DebugFormat("[Inventory Archiver]: Importing asset {0}, type {1}", uuid, assetType);

                AssetBase asset = new AssetBase(assetID, m_invName, assetType, m_overridecreator)
                {
                    Data  = data,
                    Flags = AssetFlags.Normal
                };

                if (m_assetData != null && ReplaceAssets)
                {
                    m_assetData.Delete(asset.ID, true);
                }

                // check if this asset already exists in the database
                try {
                    if (!m_assetService.GetExists(asset.ID.ToString()))
                    {
                        m_assetService.Store(asset);
                    }
                } catch {
                    MainConsole.Instance.Error(
                        "[Inventory Archiver]: Error checking if asset exists. Possibly 'Path too long' for file based asset storage");
                }
                asset.Dispose();
                return(true);
            }
            MainConsole.Instance.ErrorFormat(
                "[Inventory Archiver]: Tried to dearchive data with path {0} with an unknown type extension {1}",
                assetPath, extension);

            return(false);
        }