コード例 #1
0
        //tests and sets FS connection params
        private FileSystemSession ctorFS(IFileSystem fileSystem, FileSystemSessionConnectParams fsSessionParams, string rootPath)
        {
            FileSystemSession session = null;

            //Test FS connection
            try
            {
                session = fileSystem.StartSession(fsSessionParams);
                if (fsSessionParams.Version == null)
                {
                    fsSessionParams.Version = session.LatestVersion;
                }
            }
            catch (Exception error)
            {
                throw new MetabaseException(StringConsts.METABASE_FS_CONNECTION_ERROR.Args(fileSystem.GetType().FullName,
                                                                                           fileSystem.Name,
                                                                                           fsSessionParams.ToString(),
                                                                                           error.ToMessageWithType()
                                                                                           ), error);
            }

            m_FS = fileSystem;
            m_FSSessionConnectParams = fsSessionParams;
            m_FSRootPath             = rootPath ?? string.Empty;

            return(session);
        }
コード例 #2
0
        static S3V4FilesystemTests()
        {
            try
            {
                string envVarsStr = System.Environment.GetEnvironmentVariable(NFX_S3);

                var cfg = Configuration.ProviderLoadFromString(envVarsStr, Configuration.CONFIG_LACONIC_FORMAT).Root;

                BUCKET    = cfg.AttrByName(S3V4FileSystemSessionConnectParams.CONFIG_BUCKET_ATTR).Value;
                REGION    = cfg.AttrByName(S3V4FileSystemSessionConnectParams.CONFIG_REGION_ATTR).Value;
                ACCESSKEY = cfg.AttrByName(S3V4FileSystemSessionConnectParams.CONFIG_ACCESSKEY_ATTR).Value;
                SECRETKEY = cfg.AttrByName(S3V4FileSystemSessionConnectParams.CONFIG_SECRETKEY_ATTR).Value;
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format(
                                        "May be environment variable \"{0}\" of format like \"{1}\" isn't present.\nDon't forget to reload VS after variable is added",
                                        NFX_S3,
                                        "s3{ bucket='bucket01' region='us-west-2' access-key='XXXXXXXXXXXXXXXXXXXX' secret-key='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'}"),
                                    ex);
            }

            CONN_PARAMS = FileSystemSessionConnectParams.Make <S3V4FileSystemSessionConnectParams>(
                "s3v3{{ name='s3v4' bucket='{0}' region='{1}' access-key='{2}' secret-key='{3}' }}"
                .Args(BUCKET, REGION, ACCESSKEY, SECRETKEY));
        }
コード例 #3
0
ファイル: DropBoxFileSystem.cs プロジェクト: crasycode/nfx
        public override FileSystemSession StartSession(FileSystemSessionConnectParams connectParams = null)
        {
            if(connectParams != null)
                return new DropBoxFileSystemSession(this, null, connectParams);

            return new DropBoxFileSystemSession(this, null, _authSettings);
        }
コード例 #4
0
ファイル: CMSBank.cs プロジェクト: sergey-msu/azos
        //todo  DObavit cash i vsjy logiku po rabote s filami


        protected override void DoConfigure(IConfigSectionNode node)
        {
            //Make File System
            var fsNode = node[PortalHub.CONFIG_CONTENT_FS_SECTION];

            m_ContentFS = FactoryUtils.MakeAndConfigure <FileSystem>(fsNode,
                                                                     typeof(Azos.IO.FileSystem.Local.LocalFileSystem),
                                                                     args: new object[] { GetType().Name, fsNode });
            var fsPNode = fsNode[PortalHub.CONFIG_FS_CONNECT_PARAMS_SECTION];

            if (fsPNode.Exists)
            {
                m_ContentFSConnect = FileSystemSessionConnectParams.Make <FileSystemSessionConnectParams>(fsPNode);
            }
            else
            {
                m_ContentFSConnect = new FileSystemSessionConnectParams()
                {
                    User = Azos.Security.User.Fake
                };
            }

            m_ContentFSRootPath = fsNode.AttrByName(PortalHub.CONFIG_FS_ROOT_PATH_ATTR).Value;
            if (m_ContentFSRootPath.IsNullOrWhiteSpace())
            {
                throw new WaveException(StringConsts.CONFIG_CMS_BANK_FS_ROOT_PATH_ERROR.Args(PortalHub.CONFIG_CONTENT_FS_SECTION, PortalHub.CONFIG_FS_ROOT_PATH_ATTR));
            }
        }
コード例 #5
0
        protected override void ValidateConnectParams(FileSystemSessionConnectParams cParams)
        {
            var sftpCParams = cParams as FTPFileSystemSessionConnectParams;

            if (sftpCParams == null)
            {
                throw new NFXIOException(GetType().Name + ".ValidateConnectParams(cParams=null|cParams.Type!=SFTPFileSystemSessionConnectParams)");
            }

            if (sftpCParams.Host.IsNullOrWhiteSpace())
            {
                throw new NFXIOException(GetType().Name + ".ValidateConnectParams($host=null|empty)");
            }

            if (sftpCParams.UserName.IsNullOrWhiteSpace())
            {
                throw new NFXIOException(GetType().Name + ".ValidateConnectParams($user=null|empty)");
            }

            if (!sftpCParams.AcceptAny && sftpCParams.Fingerprint.IsNullOrWhiteSpace())
            {
                throw new NFXIOException(GetType().Name + ".ValidateConnectParams($fingerpring=null|empty)");
            }

            base.ValidateConnectParams(cParams);
        }
コード例 #6
0
 public SkyApplication(IApplication bootApplication,
                       SystemApplicationType sysAppType,
                       IFileSystem metabaseFileSystem,
                       FileSystemSessionConnectParams metabaseFileSystemSessionParams,
                       string metabaseFileSystemRootPath,
                       string thisHostName,
                       bool allowNesting,
                       string[] cmdArgs,
                       ConfigSectionNode rootConfig) : base()
 {
     ctor(allowNesting, cmdArgs, rootConfig);
     m_BootLoader = new BootConfLoader(this, bootApplication,
                                       sysAppType,
                                       metabaseFileSystem,
                                       metabaseFileSystemSessionParams,
                                       metabaseFileSystemRootPath,
                                       thisHostName,
                                       cmdArgs,
                                       rootConfig);
     try
     {
         m_ConfigRoot = m_BootLoader.ApplicationConfiguration.Root;
         InitApplication();
     }
     catch
     {
         Destructor();
         throw;
     }
 }
コード例 #7
0
        void IRunnableHook.Prologue(Runner runner, FID id)
        {
            CONN_PARAMS = FileSystemSessionConnectParams.Make <SVNFileSystemSessionConnectParams>(
                "svn{{ name='aaa' server-url='{0}' user-name='{1}' user-password='******' }}".Args(SVN_ROOT, SVN_UNAME, SVN_UPSW));

            CONN_PARAMS_TIMEOUT = FileSystemSessionConnectParams.Make <SVNFileSystemSessionConnectParams>(
                "svn{{ name='aaa' server-url='{0}' user-name='{1}' user-password='******' timeout-ms=1 }}".Args(SVN_ROOT, SVN_UNAME, SVN_UPSW));
        }
コード例 #8
0
        public void SetUp()
        {
            CONN_PARAMS = FileSystemSessionConnectParams.Make <SVNFileSystemSessionConnectParams>(
                "svn{{ name='aaa' server-url='{0}' user-name='{1}' user-password='******' }}".Args(SVN_ROOT, SVN_UNAME, SVN_UPSW));

            CONN_PARAMS_TIMEOUT = FileSystemSessionConnectParams.Make <SVNFileSystemSessionConnectParams>(
                "svn{{ name='aaa' server-url='{0}' user-name='{1}' user-password='******' timeout-ms=1 }}".Args(SVN_ROOT, SVN_UNAME, SVN_UPSW));
        }
コード例 #9
0
ファイル: LocalFileSystem.cs プロジェクト: mjaric/nfx
 public override FileSystemSession StartSession(FileSystemSessionConnectParams cParams = null)
 {
     if (cParams == null)
     {
         cParams = new FileSystemSessionConnectParams();
     }
     return(new FileSystemSession(this, null, cParams));
 }
コード例 #10
0
        protected override void ValidateConnectParams(FileSystemSessionConnectParams cParams)
        {
            var svnp = (SVNFileSystemSessionConnectParams)cParams;

            if (svnp.ServerURL.IsNullOrWhiteSpace())
            {
                throw new AzosIOException(WSC.FS_SVN_PARAMS_SERVER_URL_ERROR);
            }
        }
コード例 #11
0
        protected override void ValidateConnectParams(FileSystemSessionConnectParams cParams)
        {
            var s3cp = cParams as S3V4FileSystemSessionConnectParams;

            if (s3cp.Bucket.IsNullOrWhiteSpace() || s3cp.Region.IsNullOrWhiteSpace())
            {
                throw new NFXIOException(WSC.FS_S3_PARAMS_SERVER_URL_ERROR);
            }
        }
コード例 #12
0
ファイル: Metabank.cs プロジェクト: rstonkus/azos
        /// <summary>
        /// Opens metabase from the specified file system instance at the specified metabase root path
        /// </summary>
        /// <param name="bootApplication">IApplication chassis which this metabank boots from</param>
        /// <param name="skyApplication">ISkyApplication chassis which this metabank installs in</param>
        /// <param name="fileSystem">
        /// An instance of a file system that stores the metabase files
        /// Note: This file system is typically a component of Boot application, not the sky app which is being mounted.
        /// Metabank does NOT dispose the FS, as it is an external resource relative to metabank
        /// </param>
        /// <param name="fsSessionParams">File system connection parameter</param>
        /// <param name="rootPath">A path to the directory within the file system that contains metabase root data</param>
        internal Metabank(IApplication bootApplication,
                          ISkyApplication skyApplication,
                          IFileSystem fileSystem,
                          FileSystemSessionConnectParams fsSessionParams,
                          string rootPath) : base(bootApplication.NonNull(nameof(bootApplication)))
        {
            this.m_SkyApplication = skyApplication.NonNull(nameof(skyApplication));

            if (fileSystem is LocalFileSystem && fsSessionParams == null)
            {
                fsSessionParams = new FileSystemSessionConnectParams();
            }

            if (fileSystem == null || fsSessionParams == null)
            {
                throw new MetabaseException(StringConsts.ARGUMENT_ERROR + "Metabank.ctor(fileSystem|fsSessionParams==null)");
            }

            using (var session = ctorFS(fileSystem, fsSessionParams, rootPath))
            {
                m_CommonLevelConfig = getConfigFromFile(session, CONFIG_COMMON_FILE).Root;

                m_RootConfig = getConfigFromFile(session, CONFIG_SECTION_LEVEL_FILE).Root;
                includeCommonConfig(m_RootConfig);
                m_RootConfig.ResetModified();

                m_RootAppConfig  = getConfigFromFile(session, CONFIG_SECTION_LEVEL_ANY_APP_FILE).Root;
                m_PlatformConfig = getConfigFromFile(session, CONFIG_PLATFORMS_FILE).Root;
                m_NetworkConfig  = getConfigFromFile(session, CONFIG_NETWORKS_FILE).Root;
                m_ContractConfig = getConfigFromFile(session, CONFIG_CONTRACTS_FILE).Root;
            }
            m_Catalogs = new Registry <Catalog>();
            var cacheStore = new CacheStore(this, "AC.Metabank");

            //No app available - nowhere to configure: //cacheStore.Configure(null);

            /*
             * cacheStore.TableOptions.Register( new TableOptions(APP_CATALOG, 37, 3) );
             * cacheStore.TableOptions.Register( new TableOptions(BIN_CATALOG, 37, 7) );
             * cacheStore.TableOptions.Register( new TableOptions(REG_CATALOG, 37, 17) );
             * superseded by the cacheStore.DefaultTableOptions below:
             */
            cacheStore.DefaultTableOptions = new TableOptions("*", 37, 17);
            //reg catalog needs more space
            cacheStore.TableOptions.Register(new TableOptions(REG_CATALOG, 571, 37));

            cacheStore.InstrumentationEnabled = false;

            m_Cache = new ComplexKeyHashingStrategy(cacheStore);

            new AppCatalog(this);
            new BinCatalog(this);
            new SecCatalog(this);
            new RegCatalog(this);

            ConfigAttribute.Apply(this, m_RootConfig);
        }
コード例 #13
0
ファイル: PortalHub.cs プロジェクト: sergey-msu/azos
        protected override void DoConfigure(IConfigSectionNode node)
        {
            if (node == null || !node.Exists)
            {
                throw new WaveException(StringConsts.CONFIG_PORTAL_HUB_NODE_ERROR);
            }

            foreach (var cn in node.Children.Where(cn => cn.IsSameName(CONFIG_PORTAL_SECTION)))
            {
                var portal = FactoryUtils.MakeDirectedComponent <Portal>(this, cn, extraArgs: new [] { cn });
                if (!m_Portals.Register(portal))
                {
                    throw new WaveException(StringConsts.PORTAL_HUB_MODULE_ALREADY_CONTAINS_PORTAL_ERROR.Args(portal.Name));
                }
            }


            //Make File System
            var fsNode = node[CONFIG_CONTENT_FS_SECTION];

            m_ContentFS = FactoryUtils.MakeAndConfigureDirectedComponent <FileSystem>(this, fsNode, typeof(IO.FileSystem.Local.LocalFileSystem));
            var fsPNode = fsNode[CONFIG_FS_CONNECT_PARAMS_SECTION];

            if (fsPNode.Exists)
            {
                m_ContentFSConnect = FileSystemSessionConnectParams.Make <FileSystemSessionConnectParams>(fsPNode);
            }
            else
            {
                m_ContentFSConnect = new FileSystemSessionConnectParams()
                {
                    User = Azos.Security.User.Fake
                };
            }

            m_ContentFSRootPath = fsNode.AttrByName(CONFIG_FS_ROOT_PATH_ATTR).Value;
            if (m_ContentFSRootPath.IsNullOrWhiteSpace())
            {
                throw new WaveException(StringConsts.CONFIG_PORTAL_HUB_FS_ROOT_PATH_ERROR.Args(CONFIG_CONTENT_FS_SECTION, CONFIG_FS_ROOT_PATH_ATTR));
            }

            //todo temporary - uncomment after done
            //var cmsNode = node[CONFIG_CMS_BANK_SECTION];
            //if (cmsNode.Exists)
            //{
            //  m_CMSBank = FactoryUtils.MakeAndConfigure<CMS.ICMSBankImplementation>(cmsNode, typeof(CMS.CMSBank));
            //  var svc = m_CMSBank as ServiceModel.Service;
            //  if (svc!=null)
            //    svc.Start();
            //}
            //else
            m_CMSBank = CMS.NOPCMSBank.Instance;
        }
コード例 #14
0
ファイル: BootConfLoader.cs プロジェクト: saleyn/agni
        private static IFileSystem getFileSystem(ServiceBaseApplication bootApp,
                                                 IConfigSectionNode mNode,
                                                 out FileSystemSessionConnectParams cParams)
        {
            IFileSystem result = null;

            bootApp.writeLog(NFX.Log.MessageType.Info, "Making metabase FS instance...");

            var fsNode = mNode[CONFIG_FS_SECTION];

            var fsFallbackTypeName = Environment.GetEnvironmentVariable(ENV_VAR_METABASE_FS_TYPE);
            var fsFallbackType     = typeof(NFX.IO.FileSystem.Local.LocalFileSystem);

            if (fsFallbackTypeName.IsNotNullOrWhiteSpace())
            {
                fsFallbackType = Type.GetType(fsFallbackTypeName, true);
            }

            result = FactoryUtils.MakeAndConfigure <FileSystem>(fsNode,
                                                                fsFallbackType,
                                                                args: new object[] { CONFIG_METABASE_SECTION, fsNode });

            var paramsNode = fsNode[CONFIG_SESSION_CONNECT_PARAMS_SECTION];

            if (paramsNode.Exists)
            {
                cParams = FileSystemSessionConnectParams.Make <FileSystemSessionConnectParams>(paramsNode);
            }
            else
            {
                var fsFallbackCString = Environment.GetEnvironmentVariable(ENV_VAR_METABASE_FS_CSTRING);
                if (fsFallbackCString.IsNotNullOrWhiteSpace())
                {
                    cParams = FileSystemSessionConnectParams.Make <FileSystemSessionConnectParams>(fsFallbackCString);
                }
                else
                {
                    cParams = new FileSystemSessionConnectParams()
                    {
                        User = User.Fake
                    }
                };
            }

            bootApp.writeLog(NFX.Log.MessageType.Info, "...Metabase FS FileSystemSessionConnectParams instance of '{0}' made".Args(cParams.GetType().FullName));
            bootApp.writeLog(NFX.Log.MessageType.Info, "...Metabase FS instance of '{0}' made".Args(result.GetType().FullName));

            return(result);
        }

        #endregion
    }
コード例 #15
0
        public void SetUp()
        {
            CONN_PARAMS = FileSystemSessionConnectParams.Make <S3V4FileSystemSessionConnectParams>(
                "s3 {{ name='s3v4' bucket='{0}' region='{1}' access-key='{2}' secret-key='{3}' }}"
                .Args(S3_BUCKET, S3_REGION, S3_ACCESSKEY, S3_SECRETKEY));

            CONN_PARAMS_TIMEOUT = FileSystemSessionConnectParams.Make <S3V4FileSystemSessionConnectParams>(
                "s3 {{ name='s3v4' bucket='{0}' region='{1}' access-key='{2}' secret-key='{3}' timeout-ms=1 }}"
                .Args(S3_BUCKET, S3_REGION, S3_ACCESSKEY, S3_SECRETKEY));

            cleanUp();
            initialize();
        }
コード例 #16
0
        internal BootConfLoader(ISkyApplication application,
                                IApplication bootApplication,
                                SystemApplicationType appType,
                                IFileSystem metabaseFileSystem,
                                FileSystemSessionConnectParams metabaseFileSystemSessionParams,
                                string metabaseFileSystemRootPath,
                                string thisHostName,
                                string[] cmdArgs,
                                ConfigSectionNode rootConfig,
                                string dynamicHostNameSuffix = null)
        {
            Platform.Abstraction.PlatformAbstractionLayer.SetProcessInvariantCulture();
            SystemVarResolver.Bind();//todo: Refactor to use ~App. app var resolver instead
            Configuration.ProcesswideConfigNodeProviderType = typeof(MetabankFileConfigNodeProvider);

            m_SystemApplicationType = appType;

            m_Application = application.NonNull(nameof(application));

            //1. Init boot app container
            m_BootApplication = bootApplication;

            if (m_BootApplication == null)
            {
                m_BootApplication        = new AzosApplication(allowNesting: true, cmdArgs: cmdArgs, rootConfig: rootConfig);
                m_IsBootApplicationOwner = true;
            }

            writeLog(MessageType.Trace, "Entering Sky app bootloader...");

            //2. what host is this?
            m_HostName = determineHostName(thisHostName);

            //Sets cluster host name in all log messages
            if (m_HostName.IsNotNullOrWhiteSpace())
            {
                Message.DefaultHostName = m_HostName;
            }

            //3. Mount metabank
            var mNode = m_BootApplication.ConfigRoot[CONFIG_SKY_SECTION][CONFIG_METABASE_SECTION];

            ensureMetabaseAppName(mNode);

            m_Metabase          = new Metabank(m_BootApplication, m_Application, metabaseFileSystem, metabaseFileSystemSessionParams, metabaseFileSystemRootPath);
            m_IsMetabaseFSOwner = false;//externally supplied

            writeLog(MessageType.Trace, "...exiting Sky app bootloader");
        }
コード例 #17
0
ファイル: GoogleDriveTests.cs プロジェクト: uzbekdev1/nfx
        public void SetUp()
        {
            var csDefault = "google-drive{{ email='{0}' cert-path=$'{1}' }}"
                            .Args(GOOGLE_DRIVE_EMAIL, GOOGLE_DRIVE_CERT_PATH);

            CONN_PARAMS = FileSystemSessionConnectParams.Make <GoogleDriveParameters>(csDefault);

            var csTimeout = "google-drive{{ email='{0}' cert-path=$'{1}' timeout-ms=1 }}"
                            .Args(GOOGLE_DRIVE_EMAIL, GOOGLE_DRIVE_CERT_PATH);

            CONN_PARAMS_TIMEOUT = FileSystemSessionConnectParams.Make <GoogleDriveParameters>(csTimeout);

            cleanUp();
            initialize();
        }
コード例 #18
0
ファイル: DeleteFilesJob.cs プロジェクト: itadapter/nfx
 public DeleteFilesJob(
     IEventTimer timer,
     string name = null,
     TimeSpan? interval = null,
     IConfigSectionNode config = null,
     FileSystem fs = null,
     FileSystemSessionConnectParams fsConnectParams = null,
     string fsRootPath = null
     )
     : base(timer, name, null, interval, config, EventBodyAsyncModel.LongRunningAsyncTask)
 {
     if (fs!=null) m_FS = fs;
       if (fsConnectParams!=null) m_FSConnectParams = fsConnectParams;
       if (fsRootPath.IsNotNullOrWhiteSpace()) m_FSRootPath  = fsRootPath;
 }
コード例 #19
0
        protected internal DropBoxFileSystemSession(NFX.IO.FileSystem.FileSystem fs, IFileSystemHandle handle,
                                                    FileSystemSessionConnectParams cParams) : base(fs, handle, cParams)
        {
            if(fs == null)
                throw new ArgumentNullException("fs");

            if (cParams == null)
                throw new ArgumentNullException("cParams");

            DropBoxFileSystemSessionConnectParams pr = cParams as DropBoxFileSystemSessionConnectParams;
            if (pr == null)
                throw new NFXException(StringConsts.FS_SESSION_BAD_PARAMS_ERROR + GetType() + ".ctor_DropBoxFileSystemSession");

            ConnectParameters = pr;
        }
コード例 #20
0
        static GoogleDriveFileSystemTests()
        {
            try
            {
                var env = System.Environment.GetEnvironmentVariable(NFX_GOOGLE_DRIVE);

                var cfg = Configuration.ProviderLoadFromString(env, Configuration.CONFIG_LACONIC_FORMAT).Root;
                CONN_PARAMS = FileSystemSessionConnectParams.Make <GoogleDriveParameters>(env);
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format(
                                        "May be environment variable \"{0}\" of format like \"{1}\" isn't present.\nDon't forget to reload VS after variable is added",
                                        NFX_GOOGLE_DRIVE,
                                        "google-drive{ client-id='<value>' client-secret='<value>' access-token='<value>' refresh-token='<value>' }"
                                        ),
                                    ex
                                    );
            }
        }
コード例 #21
0
ファイル: PortalHub.cs プロジェクト: wangchengqun/azos
        protected override void DoConfigure(IConfigSectionNode node)
        {
            if (node == null || !node.Exists)
            {
                throw new WaveException(StringConsts.CONFIG_PORTAL_HUB_NODE_ERROR);
            }

            foreach (var cn in node.Children.Where(cn => cn.IsSameName(CONFIG_PORTAL_SECTION)))
            {
                var portal = FactoryUtils.MakeDirectedComponent <Portal>(this, cn, extraArgs: new [] { cn });
                if (!m_Portals.Register(portal))
                {
                    throw new WaveException(StringConsts.PORTAL_HUB_MODULE_ALREADY_CONTAINS_PORTAL_ERROR.Args(portal.Name));
                }
            }


            //Make File System
            var fsNode = node[CONFIG_CONTENT_FS_SECTION];

            m_ContentFS = FactoryUtils.MakeAndConfigureDirectedComponent <FileSystem>(this, fsNode, typeof(IO.FileSystem.Local.LocalFileSystem));
            var fsPNode = fsNode[CONFIG_FS_CONNECT_PARAMS_SECTION];

            if (fsPNode.Exists)
            {
                m_ContentFSConnect = FileSystemSessionConnectParams.Make <FileSystemSessionConnectParams>(fsPNode);
            }
            else
            {
                m_ContentFSConnect = new FileSystemSessionConnectParams()
                {
                    User = Azos.Security.User.Fake
                };
            }

            m_ContentFSRootPath = fsNode.AttrByName(CONFIG_FS_ROOT_PATH_ATTR).Value;
            if (m_ContentFSRootPath.IsNullOrWhiteSpace())
            {
                throw new WaveException(StringConsts.CONFIG_PORTAL_HUB_FS_ROOT_PATH_ERROR.Args(CONFIG_CONTENT_FS_SECTION, CONFIG_FS_ROOT_PATH_ATTR));
            }
        }
コード例 #22
0
        public SecDBFileReader(FileSystem fs, FileSystemSessionConnectParams conParams, string fileName)
        {
            if (fs == null ||
                conParams == null ||
                fileName.IsNullOrWhiteSpace())
            {
                throw new FinancialException(StringConsts.ARGUMENT_ERROR + "SecDBFileReader.ctor(fs==null | conParams==null | fileName==null)");
            }


            if (!fs.InstanceCapabilities.SupportsStreamSeek)
            {
                throw new FinancialException(StringConsts.SECDB_FS_SEEK_STREAM_ERROR.Args("{0}('{1}')".Args(fs.GetType().FullName, fs.Name)));
            }


            m_FS        = fs;
            m_FSConnect = conParams;
            m_FileName  = fileName;

            workWithFile <bool, bool>((_, file) => { parseHeadersAndMetadata(file); return(true); }, true);
        }
コード例 #23
0
        void IConfigurable.Configure(IConfigSectionNode node)
        {
            if (node == null || !node.Exists)
            {
                throw new WaveException(StringConsts.CONFIG_PORTAL_HUB_NODE_ERROR);
            }

            foreach (var cn in node.Children.Where(cn => cn.IsSameName(CONFIG_PORTAL_SECTION)))
            {
                m_Portals.Register(FactoryUtils.Make <Portal>(cn, typeof(Portal), args: new object[] { cn }));
            }

            //Make File System
            var fsNode = node[CONFIG_CONTENT_FS_SECTION];

            m_ContentFS = FactoryUtils.MakeAndConfigure <FileSystem>(fsNode,
                                                                     typeof(NFX.IO.FileSystem.Local.LocalFileSystem),
                                                                     args: new object[] { GetType().Name, fsNode });
            var fsPNode = fsNode[CONFIG_FS_CONNECT_PARAMS_SECTION];

            if (fsPNode.Exists)
            {
                m_ContentFSConnect = FileSystemSessionConnectParams.Make <FileSystemSessionConnectParams>(fsPNode);
            }
            else
            {
                m_ContentFSConnect = new FileSystemSessionConnectParams()
                {
                    User = NFX.Security.User.Fake
                };
            }

            m_ContentFSRootPath = fsNode.AttrByName(CONFIG_FS_ROOT_PATH_ATTR).Value;
            if (m_ContentFSRootPath.IsNullOrWhiteSpace())
            {
                throw new WaveException(StringConsts.CONFIG_PORTAL_HUB_FS_ROOT_PATH_ERROR.Args(CONFIG_CONTENT_FS_SECTION, CONFIG_FS_ROOT_PATH_ATTR));
            }
        }
コード例 #24
0
ファイル: VfsSink.cs プロジェクト: erxdkh/azos
        protected override void DoConfigure(IConfigSectionNode node)
        {
            base.DoConfigure(node);

            if (node == null || !node.Exists)
            {
                return;
            }

            //Make File System
            var fsNode = node[CONFIG_CONTENT_FS_SECTION];

            DisposeAndNull(ref m_Session);
            DisposeAndNull(ref m_Fs);

            m_Fs = FactoryUtils.MakeAndConfigureComponent <FileSystem>(App, fsNode, typeof(IO.FileSystem.Local.LocalFileSystem));

            var pnode = fsNode[CONFIG_FS_CONNECT_PARAMS_SECTION];

            DisposeIfDisposableAndNull(ref m_FsConnectParams);

            if (pnode.Exists)
            {
                m_FsConnectParams = FileSystemSessionConnectParams.Make <FileSystemSessionConnectParams>(pnode);
            }
            else
            {
                m_FsConnectParams = new FileSystemSessionConnectParams()
                {
                    User = Security.User.Fake
                }
            };


            m_Session = m_Fs.StartSession(m_FsConnectParams);
        }
    }
コード例 #25
0
        public void Configure(IConfigSectionNode node)
        {
            if (node == null || !node.Exists)
            {
                return;
            }

            //making FileSystem instance along with connect parameters
            var fsNode = node[CONFIG_FILE_SYSTEM_SECTION];

            DisposeAndNull(ref m_FS);//dispose existing

            //make new virtual FS instance
            m_FS = FactoryUtils.MakeAndConfigureDirectedComponent <FileSystem>(this, fsNode, typeof(Azos.IO.FileSystem.Local.LocalFileSystem));

            var paramsNode = fsNode[CONFIG_SESSION_CONNECT_PARAMS_SECTION];

            if (paramsNode.Exists)
            {
                m_FSConnectParams = FileSystemSessionConnectParams.Make <FileSystemSessionConnectParams>(paramsNode);
            }
            else
            {
                m_FSConnectParams = new FileSystemSessionConnectParams()
                {
                    User = User.Fake
                }
            };

            m_FSRootPath = fsNode.AttrByName(CONFIG_ROOT_PATH_ATTR)
                           .ValueAsString()
                           .NonBlank(CONFIG_ROOT_PATH_ATTR);

            WriteLog(MessageType.Trace,
                     nameof(FileSystemCmsSource),
                     $"Configured FS: '{m_FS.GetType().FullName}' type, using '{m_FSConnectParams.GetType().Name}' connect parameters. Root path: '{m_FSRootPath}'");
        }
コード例 #26
0
ファイル: SVNFileSystemSession.cs プロジェクト: itadapter/nfx
        protected override void ValidateConnectParams(FileSystemSessionConnectParams cParams)
        {
            var svnp = (SVNFileSystemSessionConnectParams)cParams;

              if (svnp.ServerURL.IsNullOrWhiteSpace())
              throw new NFXIOException(WSC.FS_SVN_PARAMS_SERVER_URL_ERROR);
        }
コード例 #27
0
ファイル: PortalHub.cs プロジェクト: vlapchenko/nfx
    void IConfigurable.Configure(IConfigSectionNode node)
    { 
      if (node==null || !node.Exists) 
        throw new WaveException(StringConsts.CONFIG_PORTAL_HUB_NODE_ERROR);

      foreach(var cn in node.Children.Where(cn=>cn.IsSameName(CONFIG_PORTAL_SECTION)))
        m_Portals.Register( FactoryUtils.Make<Portal>(cn, typeof(Portal), args: new object[]{ cn }));

      //Make File System
      var fsNode =  node[CONFIG_CONTENT_FS_SECTION];
      
      m_ContentFS = FactoryUtils.MakeAndConfigure<FileSystem>(fsNode, 
                                                       typeof(NFX.IO.FileSystem.Local.LocalFileSystem),
                                                       args: new object[]{GetType().Name, fsNode});
      var fsPNode = fsNode[CONFIG_FS_CONNECT_PARAMS_SECTION];
      
      if (fsPNode.Exists)
      {
        m_ContentFSConnect = FileSystemSessionConnectParams.Make<FileSystemSessionConnectParams>(fsPNode);
      }
      else
      {
        m_ContentFSConnect = new FileSystemSessionConnectParams(){ User = NFX.Security.User.Fake}; 
      }

      m_ContentFSRootPath = fsNode.AttrByName(CONFIG_FS_ROOT_PATH_ATTR).Value;
      if (m_ContentFSRootPath.IsNullOrWhiteSpace())
       throw new WaveException(StringConsts.CONFIG_PORTAL_HUB_FS_ROOT_PATH_ERROR.Args(CONFIG_CONTENT_FS_SECTION, CONFIG_FS_ROOT_PATH_ATTR));
    }
コード例 #28
0
ファイル: SVNFileSystem.cs プロジェクト: cole2295/nfx
 public override FileSystemSession StartSession(FileSystemSessionConnectParams cParams = null)
 {
     return this.StartSession(cParams as SVNFileSystemSessionConnectParams);
 }
コード例 #29
0
ファイル: DeleteFilesJob.cs プロジェクト: itadapter/nfx
        public override void Configure(IConfigSectionNode config)
        {
            base.Configure(config);

            if (config==null || !config.Exists) return;

            //Make File System
            var fsNode =  config[CONFIG_CONTENT_FS_SECTION];

            var fs = FactoryUtils.MakeAndConfigure<FileSystem>(fsNode,
                                                         typeof(NFX.IO.FileSystem.Local.LocalFileSystem),
                                                         args: new object[]{GetType().Name, fsNode});
            var fsPNode = fsNode[CONFIG_FS_CONNECT_PARAMS_SECTION];

            FileSystemSessionConnectParams fsc;

            if (fsPNode.Exists)
            {
              fsc = FileSystemSessionConnectParams.Make<FileSystemSessionConnectParams>(fsPNode);
            }
            else
            {
              fsc = new FileSystemSessionConnectParams(){ User = NFX.Security.User.Fake};
            }

            var fsp = fsNode.AttrByName(CONFIG_FS_ROOT_PATH_ATTR).Value;

            BindFS(fs, fsc, fsp);
        }
コード例 #30
0
ファイル: SVNFileSystem.cs プロジェクト: dotnetchris/nfx
 protected override FileSystemSessionConnectParams MakeSessionConfigParams(IConfigSectionNode node)
 {
     return(FileSystemSessionConnectParams.Make <SVNFileSystemSessionConnectParams>(node));
 }
コード例 #31
0
ファイル: LocalFileSystem.cs プロジェクト: itadapter/nfx
 public override FileSystemSession StartSession(FileSystemSessionConnectParams cParams = null)
 {
     if (cParams==null) cParams = new FileSystemSessionConnectParams();
     return new FileSystemSession(this, null, cParams);
 }
コード例 #32
0
 public override FileSystemSession StartSession(FileSystemSessionConnectParams cParams = null)
 {
     return(this.StartSession(cParams as GoogleDriveParameters));
 }
コード例 #33
0
        protected override void ValidateConnectParams(FileSystemSessionConnectParams cParams)
        {
            var s3cp = cParams as S3V4FileSystemSessionConnectParams;

              if (s3cp.Bucket.IsNullOrWhiteSpace() || s3cp.Region.IsNullOrWhiteSpace())
            throw new NFXIOException(WSC.FS_S3_PARAMS_SERVER_URL_ERROR);
        }
コード例 #34
0
 public override FileSystemSession StartSession(FileSystemSessionConnectParams cParams = null)
 {
   return this.StartSession(cParams as GoogleDriveParameters);
 }
コード例 #35
0
ファイル: SVNFileSystem.cs プロジェクト: dotnetchris/nfx
 public override FileSystemSession StartSession(FileSystemSessionConnectParams cParams = null)
 {
     return(this.StartSession(cParams as SVNFileSystemSessionConnectParams));
 }
コード例 #36
0
ファイル: DeleteFilesJob.cs プロジェクト: itadapter/nfx
 public void BindFS(FileSystem fs, FileSystemSessionConnectParams fsConnectParams, string fsRootPath)
 {
     lock(m_FSLock)
     {
       m_FS = fs;
       m_FSConnectParams = fsConnectParams;
       m_FSRootPath      = fsRootPath;
     }
 }