Esempio n. 1
0
        public RootFolderModule(IRootFolderService rootFolderService,
                                IBroadcastSignalRMessage signalRBroadcaster,
                                RootFolderValidator rootFolderValidator,
                                PathExistsValidator pathExistsValidator,
                                MappedNetworkDriveValidator mappedNetworkDriveValidator,
                                StartupFolderValidator startupFolderValidator,
                                SystemFolderValidator systemFolderValidator,
                                FolderWritableValidator folderWritableValidator
                                )
            : base(signalRBroadcaster)
        {
            _rootFolderService = rootFolderService;

            GetResourceAll  = GetRootFolders;
            GetResourceById = GetRootFolder;
            CreateResource  = CreateRootFolder;
            DeleteResource  = DeleteFolder;

            SharedValidator.RuleFor(c => c.Path)
            .Cascade(CascadeMode.StopOnFirstFailure)
            .IsValidPath()
            .SetValidator(rootFolderValidator)
            .SetValidator(mappedNetworkDriveValidator)
            .SetValidator(startupFolderValidator)
            .SetValidator(pathExistsValidator)
            .SetValidator(systemFolderValidator)
            .SetValidator(folderWritableValidator);
        }
Esempio n. 2
0
        public MediaManagementConfigController(IConfigService configService,
                                               PathExistsValidator pathExistsValidator,
                                               FolderChmodValidator folderChmodValidator,
                                               FolderWritableValidator folderWritableValidator,
                                               MoviePathValidator moviePathValidator,
                                               StartupFolderValidator startupFolderValidator,
                                               SystemFolderValidator systemFolderValidator,
                                               RootFolderAncestorValidator rootFolderAncestorValidator,
                                               RootFolderValidator rootFolderValidator)
            : base(configService)
        {
            SharedValidator.RuleFor(c => c.RecycleBinCleanupDays).GreaterThanOrEqualTo(0);
            SharedValidator.RuleFor(c => c.ChmodFolder).SetValidator(folderChmodValidator).When(c => !string.IsNullOrEmpty(c.ChmodFolder) && (OsInfo.IsLinux || OsInfo.IsOsx));

            SharedValidator.RuleFor(c => c.RecycleBin).IsValidPath()
            .SetValidator(folderWritableValidator)
            .SetValidator(rootFolderValidator)
            .SetValidator(pathExistsValidator)
            .SetValidator(rootFolderAncestorValidator)
            .SetValidator(startupFolderValidator)
            .SetValidator(systemFolderValidator)
            .SetValidator(moviePathValidator)
            .When(c => !string.IsNullOrWhiteSpace(c.RecycleBin));

            SharedValidator.RuleFor(c => c.MinimumFreeSpaceWhenImporting).GreaterThanOrEqualTo(100);
        }
Esempio n. 3
0
        public RootFolderModule(IRootFolderService rootFolderService,
                                ICalibreProxy calibreProxy,
                                IBroadcastSignalRMessage signalRBroadcaster,
                                RootFolderValidator rootFolderValidator,
                                PathExistsValidator pathExistsValidator,
                                MappedNetworkDriveValidator mappedNetworkDriveValidator,
                                StartupFolderValidator startupFolderValidator,
                                SystemFolderValidator systemFolderValidator,
                                FolderWritableValidator folderWritableValidator,
                                QualityProfileExistsValidator qualityProfileExistsValidator,
                                MetadataProfileExistsValidator metadataProfileExistsValidator)
            : base(signalRBroadcaster)
        {
            _rootFolderService = rootFolderService;
            _calibreProxy      = calibreProxy;

            GetResourceAll  = GetRootFolders;
            GetResourceById = GetRootFolder;
            CreateResource  = CreateRootFolder;
            UpdateResource  = UpdateRootFolder;
            DeleteResource  = DeleteFolder;

            SharedValidator.RuleFor(c => c.Path)
            .Cascade(CascadeMode.StopOnFirstFailure)
            .IsValidPath()
            .SetValidator(mappedNetworkDriveValidator)
            .SetValidator(startupFolderValidator)
            .SetValidator(pathExistsValidator)
            .SetValidator(systemFolderValidator)
            .SetValidator(folderWritableValidator);

            PostValidator.RuleFor(c => c.Path)
            .SetValidator(rootFolderValidator);

            SharedValidator.RuleFor(c => c)
            .Must(x => CalibreLibraryOnlyUsedOnce(x))
            .When(x => x.IsCalibreLibrary)
            .WithMessage("Calibre library is already configured as a root folder");

            SharedValidator.RuleFor(c => c.Name)
            .NotEmpty();

            SharedValidator.RuleFor(c => c.DefaultMetadataProfileId)
            .SetValidator(metadataProfileExistsValidator);

            SharedValidator.RuleFor(c => c.DefaultQualityProfileId)
            .SetValidator(qualityProfileExistsValidator);

            SharedValidator.RuleFor(c => c.Host).ValidHost().When(x => x.IsCalibreLibrary);
            SharedValidator.RuleFor(c => c.Port).InclusiveBetween(1, 65535).When(x => x.IsCalibreLibrary);
            SharedValidator.RuleFor(c => c.UrlBase).ValidUrlBase().When(c => c.UrlBase.IsNotNullOrWhiteSpace());
            SharedValidator.RuleFor(c => c.Username).NotEmpty().When(c => !string.IsNullOrWhiteSpace(c.Password));
            SharedValidator.RuleFor(c => c.Password).NotEmpty().When(c => !string.IsNullOrWhiteSpace(c.Username));

            SharedValidator.RuleFor(c => c.OutputFormat).Must(x => x.Split(',').All(y => Enum.TryParse <CalibreFormat>(y, true, out _))).When(x => x.OutputFormat.IsNotNullOrWhiteSpace()).WithMessage("Invalid output formats");
            SharedValidator.RuleFor(c => c.OutputProfile).IsEnumName(typeof(CalibreProfile));
        }
Esempio n. 4
0
 public MediaManagementConfigModule(IConfigService configService,
                                    PathExistsValidator pathExistsValidator,
                                    FolderChmodValidator folderChmodValidator,
                                    FolderWritableValidator folderWritableValidator,
                                    MoviePathValidator moviePathValidator,
                                    StartupFolderValidator startupFolderValidator,
                                    SystemFolderValidator systemFolderValidator,
                                    RootFolderAncestorValidator rootFolderAncestorValidator,
                                    RootFolderValidator rootFolderValidator)
     : base(configService)
 {
     SharedValidator.RuleFor(c => c.ChmodFolder).SetValidator(folderChmodValidator).When(c => !string.IsNullOrEmpty(c.ChmodFolder) && PlatformInfo.IsMono);
     SharedValidator.RuleFor(c => c.RecycleBin).IsValidPath()
     .SetValidator(folderWritableValidator)
     .SetValidator(rootFolderValidator)
     .SetValidator(pathExistsValidator)
     .SetValidator(moviePathValidator)
     .SetValidator(rootFolderAncestorValidator)
     .SetValidator(startupFolderValidator)
     .SetValidator(systemFolderValidator)
     .When(c => !string.IsNullOrWhiteSpace(c.RecycleBin));
 }
Esempio n. 5
0
        public RootFolderController(IRootFolderService rootFolderService,
                                    IBroadcastSignalRMessage signalRBroadcaster,
                                    RootFolderValidator rootFolderValidator,
                                    PathExistsValidator pathExistsValidator,
                                    MappedNetworkDriveValidator mappedNetworkDriveValidator,
                                    RecycleBinValidator recycleBinValidator,
                                    StartupFolderValidator startupFolderValidator,
                                    SystemFolderValidator systemFolderValidator,
                                    FolderWritableValidator folderWritableValidator)
            : base(signalRBroadcaster)
        {
            _rootFolderService = rootFolderService;

            SharedValidator.RuleFor(c => c.Path)
            .Cascade(CascadeMode.StopOnFirstFailure)
            .IsValidPath()
            .SetValidator(rootFolderValidator)
            .SetValidator(mappedNetworkDriveValidator)
            .SetValidator(startupFolderValidator)
            .SetValidator(recycleBinValidator)
            .SetValidator(pathExistsValidator)
            .SetValidator(systemFolderValidator)
            .SetValidator(folderWritableValidator);
        }