예제 #1
0
        public IEnumerable <DirectoryModel> GetDirectories(string applicationName, string directoryName)
        {
            var application = GetApplicationsData(applicationName).SingleOrDefault();
            var directories = GetDirectories(application, directoryName);

            if (!string.IsNullOrWhiteSpace(directoryName) && directories != null && directories.Count() == 0)
            {
                throw new SettingsNotFoundException(directoryName);
            }

            if (!Auth.AllowReadDirectories(applicationName))
            {
                throw new SettingsAuthorizationException(AuthorizationScope.Application, AuthorizationLevel.Read, applicationName, Auth.CurrentIdentity.Id);
            }

            if (!string.IsNullOrWhiteSpace(directoryName))
            {
                if (!Auth.AllowReadDirectory(applicationName, directoryName))
                {
                    throw new SettingsAuthorizationException(AuthorizationScope.Application, AuthorizationLevel.Read, applicationName, Auth.CurrentIdentity.Id);
                }
            }

            return(directories);
        }
예제 #2
0
        private IEnumerable <SettingData> GetSettingsFromStore(SettingStore store)
        {
            if (store == null || string.IsNullOrWhiteSpace(store.ApplicationName) || string.IsNullOrWhiteSpace(store.DirectoryName))
            {
                throw new SettingsStoreException("Invalid path");
            }

            if (!Auth.AllowReadDirectory(store.ApplicationName, store.DirectoryName))
            {
                throw new SettingsAuthorizationException(AuthorizationScope.Directory, AuthorizationLevel.Read, store.DirectoryName, Auth.CurrentIdentity.Id);
            }
            var version = Store.GetVersion(store.ApplicationName, store.Version);

            if (version == null)
            {
                throw new SettingsNotFoundException(store.Version.ToString());
            }

            var directory = Store.GetDirectory(store.ApplicationName, store.DirectoryName);

            if (version == null)
            {
                throw new SettingsNotFoundException(store.DirectoryName);
            }

            return(Store.Context.Settings.Where(s =>
                                                s.VersionId == version.Id &&
                                                s.DirectoryId == directory.Id));
        }