Пример #1
0
        public virtual void Configure(IConfigSource config, IRegistryCore registry)
        {
            m_registry = registry;

            m_database = DataManager.RequestPlugin<IAssetDataPlugin>();
            if (m_database == null)
                throw new Exception("Could not find a storage interface in the given module");

            registry.RegisterModuleInterface<IAssetService>(this);

            IConfig handlers = config.Configs["Handlers"];
            if (handlers != null)
                doDatabaseCaching = handlers.GetBoolean("AssetHandlerUseCache", false);

            if (MainConsole.Instance != null)
            {
                MainConsole.Instance.Commands.AddCommand("show digest",
                                                         "show digest <ID>",
                                                         "Show asset digest", HandleShowDigest);

                MainConsole.Instance.Commands.AddCommand("delete asset",
                                                         "delete asset <ID>",
                                                         "Delete asset from database", HandleDeleteAsset);
            }

            MainConsole.Instance.Debug("[ASSET SERVICE]: Local asset service enabled");
        }
Пример #2
0
        public virtual void Configure(IConfigSource config, IRegistryCore registry)
        {
            m_registry = registry;

            m_database = Framework.Utilities.DataManager.RequestPlugin<IAssetDataPlugin>();

            registry.RegisterModuleInterface<IAssetService>(this);

            IConfig handlers = config.Configs["Handlers"];
            if (handlers != null)
                doDatabaseCaching = handlers.GetBoolean("AssetHandlerUseCache", false);

            if (MainConsole.Instance != null && !DoRemoteCalls)
            {
                MainConsole.Instance.Commands.AddCommand(
                    "show digest",
                    "show digest <ID>",
                    "Show asset digest",
                    HandleShowDigest, false, true);

                MainConsole.Instance.Commands.AddCommand(
                    "delete asset",
                    "delete asset <ID>",
                    "Delete asset from database",
                    HandleDeleteAsset, false, true);

                MainConsole.Instance.Commands.AddCommand("get asset",
                    "get asset <ID>",
                    "Gets info about asset from database",
                    HandleGetAsset, false, true);

            }

            MainConsole.Instance.Debug("[ASSET SERVICE]: Local asset service enabled");
        }
Пример #3
0
        public void Initialize(IConfigSource config, IRegistryCore registry)
        {
            string dllName = String.Empty;
            string connString = String.Empty;

            //
            // Try reading the [AssetService] section first, if it exists
            //
            IConfig assetConfig = config.Configs["AssetService"];
            if (assetConfig != null)
            {
                dllName = assetConfig.GetString("StorageProvider", dllName);
                connString = assetConfig.GetString("ConnectionString", connString);
            }

            //
            // Try reading the [DatabaseService] section, if it exists
            //
            IConfig dbConfig = config.Configs["DatabaseService"];
            if (dbConfig != null)
            {
                if (dllName == String.Empty)
                    dllName = dbConfig.GetString("StorageProvider", String.Empty);
                if (connString == String.Empty)
                    connString = dbConfig.GetString("ConnectionString", String.Empty);
            }

            //
            // We tried, but this doesn't exist. We can't proceed.
            //
            if (dllName.Equals(String.Empty))
                throw new Exception("No StorageProvider configured");

            m_Database = AuroraModuleLoader.LoadPlugin<IAssetDataPlugin>(dllName);
            if (m_Database == null)
                throw new Exception("Could not find a storage interface in the given module");

            m_Database.Initialise(connString);

            registry.RegisterModuleInterface<IAssetService>(this);

            MainConsole.Instance.Commands.AddCommand("kfs", false,
                "show digest",
                "show digest <ID>",
                "Show asset digest", HandleShowDigest);

            MainConsole.Instance.Commands.AddCommand("kfs", false,
                    "delete asset",
                    "delete asset <ID>",
                    "Delete asset from database", HandleDeleteAsset);

            m_log.Debug("[ASSET SERVICE]: Local asset service enabled");
        }
Пример #4
0
        public AssetServiceBase(IConfigSource config, string configName) : base(config)
        {
            if (configName != string.Empty)
                m_ConfigName = configName;

            string dllName = String.Empty;
            string connString = String.Empty;

            //
            // Try reading the [AssetService] section, if it exists
            //
            IConfig assetConfig = config.Configs[m_ConfigName];
            if (assetConfig != null)
            {
                dllName = assetConfig.GetString("StorageProvider", dllName);
                connString = assetConfig.GetString("ConnectionString", connString);
            }

            //
            // Try reading the [DatabaseService] section, if it exists
            //
            IConfig dbConfig = config.Configs["DatabaseService"];
            if (dbConfig != null)
            {
                if (dllName == String.Empty)
                    dllName = dbConfig.GetString("StorageProvider", String.Empty);
                if (connString == String.Empty)
                    connString = dbConfig.GetString("ConnectionString", String.Empty);
            }

            //
            // We tried, but this doesn't exist. We can't proceed.
            //
            if (dllName.Equals(String.Empty))
                throw new Exception("No StorageProvider configured");

            m_Database = LoadPlugin<IAssetDataPlugin>(dllName);
            if (m_Database == null)
                throw new Exception(string.Format("Could not find a storage interface in the module {0}", dllName));

            m_Database.Initialise(connString);

            string loaderName = assetConfig.GetString("DefaultAssetLoader",
                    String.Empty);

            if (loaderName != String.Empty)
            {
                m_AssetLoader = LoadPlugin<IAssetLoader>(loaderName);

                if (m_AssetLoader == null)
                    throw new Exception(string.Format("Asset loader could not be loaded from {0}", loaderName));
            }
        }
        public AuthorizationServiceBase(IConfigSource config) : base(config)
        {
            string dllName = String.Empty;
            string connString = String.Empty;

            //
            // Try reading the [AuthorizationService] section first, if it exists
            //
            IConfig assetConfig = config.Configs["AuthorizationService"];
            if (assetConfig != null)
            {
                dllName = assetConfig.GetString("StorageProvider", dllName);
                connString = assetConfig.GetString("ConnectionString", connString);
            }

            //
            // Try reading the [DatabaseService] section, if it exists
            //
            IConfig dbConfig = config.Configs["DatabaseService"];
            if (dbConfig != null)
            {
                if (dllName == String.Empty)
                    dllName = dbConfig.GetString("StorageProvider", String.Empty);
                if (connString == String.Empty)
                    connString = dbConfig.GetString("ConnectionString", String.Empty);
            }

            //
            // We tried, but this doesn't exist. We can't proceed.
            //
            if (dllName.Equals(String.Empty))
                throw new Exception("No StorageProvider configured");

            m_Database = LoadPlugin<IAssetDataPlugin>(dllName);
            if (m_Database == null)
                throw new Exception("Could not find a storage interface in the given module");

            m_Database.Initialise(connString);

        }
Пример #6
0
 public virtual void Start(IConfigSource config, IRegistryCore registry)
 {
     if (m_doConversion)
         m_assetService = Aurora.DataManager.DataManager.RequestPlugin<IAssetDataPlugin>();
 }
 public PostAssetStreamHandler(IAssetDataPlugin assetProvider)
     : base("POST", "/assets")
 {
     // m_assetManager = assetManager;
     m_assetProvider = assetProvider;
 }
 public virtual void Start(IConfigSource config, IRegistryCore registry)
 {
     if (!m_enabled)
         return;
     if (m_doConversion)
         m_assetService = Framework.Utilities.DataManager.RequestPlugin<IAssetDataPlugin>();
 }
Пример #9
0
        public AssetServiceBase(IConfigSource config, string configName) : base(config)
        {
            if (!String.IsNullOrEmpty(configName))
            {
                m_ConfigName = configName;
            }

            string dllName    = String.Empty;
            string connString = String.Empty;

            // Try reading the [AssetService] section, if it exists
            IConfig assetConfig = config.Configs[m_ConfigName];

            if (assetConfig != null)
            {
                dllName    = assetConfig.GetString("StorageProvider", dllName);
                connString = assetConfig.GetString("ConnectionString", connString);
            }

            // Try reading the [DatabaseService] section, if it exists
            IConfig dbConfig = config.Configs["DatabaseService"];

            if (dbConfig != null)
            {
                if (String.IsNullOrEmpty(dllName))
                {
                    dllName = dbConfig.GetString("StorageProvider", String.Empty);
                }
                if (String.IsNullOrEmpty(connString))
                {
                    connString = dbConfig.GetString("ConnectionString", String.Empty);
                }
            }

            // We tried, but this doesn't exist. We can't proceed.
            if (String.IsNullOrEmpty(dllName))
            {
                throw new Exception("No StorageProvider configured");
            }

            m_Database = LoadPlugin <IAssetDataPlugin>(dllName);
            if (m_Database == null)
            {
                throw new Exception("Could not find a storage interface in the given module");
            }

            m_Database.Initialize(connString);

            string loaderName = assetConfig.GetString("DefaultAssetLoader",
                                                      String.Empty);

            if (!String.IsNullOrEmpty(loaderName))
            {
                m_AssetLoader = LoadPlugin <IAssetLoader>(loaderName);

                if (m_AssetLoader == null)
                {
                    throw new Exception("Asset loader could not be loaded");
                }
            }
        }
 public virtual void Start (IConfigSource config, IRegistryCore registry)
 {
     if (m_migrateSQL)
         m_assetService = Framework.Utilities.DataManager.RequestPlugin<IAssetDataPlugin> ();
 }
Пример #11
0
        public virtual void Configure (IConfigSource config, IRegistryCore registry)
        {
            m_registry = registry;
            string dllName = String.Empty;
            string connString = String.Empty;

            //
            // Try reading the [AssetService] section first, if it exists
            //
            IConfig assetConfig = config.Configs["AssetService"];
            if (assetConfig != null)
            {
                dllName = assetConfig.GetString("StorageProvider", dllName);
                connString = assetConfig.GetString("ConnectionString", connString);
            }

            //
            // Try reading the [DatabaseService] section, if it exists
            //
            IConfig dbConfig = config.Configs["DatabaseService"];
            if (dbConfig != null)
            {
                if (dllName == String.Empty)
                    dllName = dbConfig.GetString("StorageProvider", String.Empty);
                if (connString == String.Empty)
                    connString = dbConfig.GetString("ConnectionString", String.Empty);
            }

            //
            // We tried, but this doesn't exist. We can't proceed.
            //
            if (dllName.Equals(String.Empty))
                throw new Exception("No StorageProvider configured");

            m_Database = AuroraModuleLoader.LoadPlugin<IAssetDataPlugin>(Util.BasePathCombine(dllName));
            if (m_Database == null)
                throw new Exception("Could not find a storage interface in the given module");

            m_Database.Initialise(connString);

            if (MainConsole.Instance != null)
            {
                MainConsole.Instance.Commands.AddCommand ("show digest",
                        "show digest <ID>",
                        "Show asset digest", HandleShowDigest);

                MainConsole.Instance.Commands.AddCommand ("delete asset",
                        "delete asset <ID>",
                        "Delete asset from database", HandleDeleteAsset);
            }

            IHttpServer server = registry.RequestModuleInterface<ISimulationBase> ().GetHttpServer (0);
            string ExternalName = server.HostName + ":" + server.Port + "/";
            Uri m_Uri = new Uri (ExternalName);
            m_externalIP = Util.GetHostFromDNS (m_Uri.Host);

            m_log.Debug("[ASSET SERVICE]: Local asset service enabled");
        }
Пример #12
0
        public void Configure(IConfigSource config, IRegistryCore registry)
        {
            string dllName    = String.Empty;
            string connString = String.Empty;

            //
            // Try reading the [AssetService] section first, if it exists
            //
            IConfig assetConfig = config.Configs["AssetService"];

            if (assetConfig != null)
            {
                dllName    = assetConfig.GetString("StorageProvider", dllName);
                connString = assetConfig.GetString("ConnectionString", connString);
            }

            //
            // Try reading the [DatabaseService] section, if it exists
            //
            IConfig dbConfig = config.Configs["DatabaseService"];

            if (dbConfig != null)
            {
                if (dllName == String.Empty)
                {
                    dllName = dbConfig.GetString("StorageProvider", String.Empty);
                }
                if (connString == String.Empty)
                {
                    connString = dbConfig.GetString("ConnectionString", String.Empty);
                }
            }

            //
            // We tried, but this doesn't exist. We can't proceed.
            //
            if (dllName.Equals(String.Empty))
            {
                throw new Exception("No StorageProvider configured");
            }

            m_Database = AuroraModuleLoader.LoadPlugin <IAssetDataPlugin>(Util.BasePathCombine(dllName));
            if (m_Database == null)
            {
                throw new Exception("Could not find a storage interface in the given module");
            }

            m_Database.Initialise(connString);

            registry.RegisterModuleInterface <IAssetService>(this);

            MainConsole.Instance.Commands.AddCommand("kfs", false,
                                                     "show digest",
                                                     "show digest <ID>",
                                                     "Show asset digest", HandleShowDigest);

            MainConsole.Instance.Commands.AddCommand("kfs", false,
                                                     "delete asset",
                                                     "delete asset <ID>",
                                                     "Delete asset from database", HandleDeleteAsset);

            m_log.Debug("[ASSET SERVICE]: Local asset service enabled");
        }
 public GetAssetStreamHandler(IAssetDataPlugin assetProvider)
     : base("GET", "/assets")
 {
     m_assetProvider = assetProvider;
 }
Пример #14
0
        public void Initialise(AssetInventoryServer server)
        {
            m_server = server;
            m_openSimConfig = server.ConfigFile.Configs["OpenSim"];

            try
            {
                m_assetProvider = DataPluginFactory.LoadDataPlugin<IAssetDataPlugin>(m_openSimConfig.GetString("asset_database_provider"),
                                                                                     m_openSimConfig.GetString("asset_database_connect"));
                if (m_assetProvider == null)
                {
                    m_log.Error("[OPENSIMASSETSTORAGE]: Failed to load a database plugin, server halting.");
                    Environment.Exit(-1);
                }
                else
                    m_log.InfoFormat("[OPENSIMASSETSTORAGE]: Loaded storage backend: {0}", Version);
            }
            catch (Exception e)
            {
                m_log.WarnFormat("[OPENSIMASSETSTORAGE]: Failure loading data plugin: {0}", e.ToString());
                throw new PluginNotInitialisedException(Name);
            }
        }
        /// <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);
        }
Пример #16
0
        public override void Initialise(IPlugin plugin)
        {
            IAssetDataPlugin p = plugin as IAssetDataPlugin;

            p.Initialise(connect);
        }
 public PostAssetStreamHandler(IAssetDataPlugin assetProvider)
     : base("POST", "/assets")
 {
     // m_assetManager = assetManager;
     m_assetProvider = assetProvider;
 }
        public InventoryArchiveReadRequest(
            IRegistryCore registry, UserAccount userInfo, string invPath, string loadPath, bool merge,
            UUID overwriteCreator)
        {
            Stream str = ArchiveHelpers.GetStream(loadPath);
            if (str == null)
                return;

            m_registry = registry;
            m_merge = merge;
            m_userInfo = userInfo;
            m_invPath = invPath.StartsWith("/") ? invPath.Remove(0, 1) : invPath;
            m_loadStream = new GZipStream(str, CompressionMode.Decompress);
            m_overridecreator = overwriteCreator;

            // we will need these at some time
            m_assetService = m_registry.RequestModuleInterface<IAssetService>();
            m_assetData = Framework.Utilities.DataManager.RequestPlugin<IAssetDataPlugin>();
            m_inventoryService = m_registry.RequestModuleInterface<IInventoryService> ();
            m_accountService = m_registry.RequestModuleInterface<IUserAccountService> ();
        }
Пример #19
0
 public void setupDB(AssetConfig config)
 {
     try
     {
         m_assetProvider = DataPluginFactory.LoadDataPlugin<IAssetDataPlugin>(config.DatabaseProvider, config.DatabaseConnect);
         if (m_assetProvider == null)
         {
             m_log.Error("[ASSET]: Failed to load a database plugin, server halting");
             Environment.Exit(-1);
         }
     }
     catch (Exception e)
     {
         m_log.Warn("[ASSET]: setupDB() - Exception occured");
         m_log.Warn("[ASSET]: " + e.ToString());
     }
 }