File-based providers no longer throw exception if dir does not exist or is not a dir.
This commit is contained in:
parent
c312b0cf8f
commit
0b95f4662d
@ -24,7 +24,7 @@ class PartFilePartsProvider implements PartsProvider, WithWatchableDir {
|
||||
}
|
||||
|
||||
private PartType getPartType(File file) {
|
||||
partTypes.find {
|
||||
this.partTypes.find {
|
||||
it.ids.contains(new FileNameHandler(file).getExtension())
|
||||
}
|
||||
}
|
||||
@ -32,21 +32,22 @@ class PartFilePartsProvider implements PartsProvider, WithWatchableDir {
|
||||
@Override
|
||||
Collection<Part> provide() {
|
||||
if (!partsDir.isDirectory()) {
|
||||
throw new IllegalArgumentException('partsDir must be a directory')
|
||||
}
|
||||
|
||||
def parts = []
|
||||
partsDir.eachFileRecurse(FileType.FILES) {
|
||||
def type = this.getPartType(it)
|
||||
if (type != null) {
|
||||
def relativePath = this.partsDir.relativePath(it)
|
||||
logger.debug('found part {}', relativePath)
|
||||
parts << new Part(relativePath, type, it.text)
|
||||
} else {
|
||||
logger.warn('ignoring {} since there is no partType for it', it)
|
||||
logger.warn('partsDir {} does not exist or is not a directory; skipping and providing no Parts', this.partsDir)
|
||||
[]
|
||||
} else {
|
||||
def parts = []
|
||||
this.partsDir.eachFileRecurse(FileType.FILES) {
|
||||
def type = this.getPartType(it)
|
||||
if (type != null) {
|
||||
def relativePath = this.partsDir.relativePath(it)
|
||||
logger.debug('found part {}', relativePath)
|
||||
parts << new Part(relativePath, type, it.text)
|
||||
} else {
|
||||
logger.warn('ignoring {} since there is no partType for it', it)
|
||||
}
|
||||
}
|
||||
parts
|
||||
}
|
||||
parts
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -33,22 +33,23 @@ class SpecialPageFileSpecialPagesProvider implements SpecialPagesProvider, WithW
|
||||
@Override
|
||||
Collection<SpecialPage> provide() {
|
||||
if (!this.specialPagesDir.isDirectory()) {
|
||||
throw new IllegalArgumentException('specialPagesDir must be a directory')
|
||||
}
|
||||
|
||||
def specialPages = []
|
||||
this.specialPagesDir.eachFileRecurse(FileType.FILES) {
|
||||
def type = this.getSpecialPageType(it)
|
||||
if (type != null) {
|
||||
def relativePath = this.specialPagesDir.relativePath(it)
|
||||
def path = new RelativePathHandler(relativePath).getWithoutExtension()
|
||||
logger.info('found specialPage {} with type {}', path, type)
|
||||
specialPages << new SpecialPage(it.text, path, type)
|
||||
} else {
|
||||
logger.warn('ignoring {} since there is no specialPageType for it', it)
|
||||
logger.warn('specialPagesDir {} does not exist or is not a directory; skipping and providing no SpecialPages', this.specialPagesDir)
|
||||
[]
|
||||
} else {
|
||||
def specialPages = []
|
||||
this.specialPagesDir.eachFileRecurse(FileType.FILES) {
|
||||
def type = this.getSpecialPageType(it)
|
||||
if (type != null) {
|
||||
def relativePath = this.specialPagesDir.relativePath(it)
|
||||
def path = new RelativePathHandler(relativePath).getWithoutExtension()
|
||||
logger.info('found specialPage {} with type {}', path, type)
|
||||
specialPages << new SpecialPage(it.text, path, type)
|
||||
} else {
|
||||
logger.warn('ignoring {} since there is no specialPageType for it', it)
|
||||
}
|
||||
}
|
||||
specialPages
|
||||
}
|
||||
specialPages
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,20 +32,22 @@ class TemplateFileTemplatesProvider implements TemplatesProvider, WithWatchableD
|
||||
@Override
|
||||
Collection<Template> provide() {
|
||||
if (!this.templatesDir.isDirectory()) {
|
||||
throw new IllegalArgumentException('templatesDir must be a directory')
|
||||
}
|
||||
def templates = []
|
||||
this.templatesDir.eachFileRecurse(FileType.FILES) {
|
||||
def type = this.getType(it)
|
||||
if (type != null) {
|
||||
def relativePath = this.templatesDir.relativePath(it)
|
||||
logger.debug('found template {}', relativePath)
|
||||
templates << new Template(it.text, relativePath, type)
|
||||
} else {
|
||||
logger.warn('ignoring {} because there is no templateType for it', it)
|
||||
logger.warn('templatesDir {} does not exist or is not a directory; skipping and providing no Templates', this.templatesDir)
|
||||
[]
|
||||
} else {
|
||||
def templates = []
|
||||
this.templatesDir.eachFileRecurse(FileType.FILES) {
|
||||
def type = this.getType(it)
|
||||
if (type != null) {
|
||||
def relativePath = this.templatesDir.relativePath(it)
|
||||
logger.debug('found template {}', relativePath)
|
||||
templates << new Template(it.text, relativePath, type)
|
||||
} else {
|
||||
logger.warn('ignoring {} because there is no templateType for it', it)
|
||||
}
|
||||
}
|
||||
templates
|
||||
}
|
||||
templates
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,9 +21,6 @@ class TextFileTextsProvider implements TextsProvider, WithWatchableDir {
|
||||
TextFileTextsProvider(Collection<TextType> textTypes, File textsDir) {
|
||||
this.textTypes = textTypes
|
||||
this.textsDir = textsDir
|
||||
if (!this.textsDir.isDirectory()) {
|
||||
throw new IllegalArgumentException('textsDir must be a directory, given: ' + this.textsDir)
|
||||
}
|
||||
this.watchableDir = this.textsDir
|
||||
}
|
||||
|
||||
@ -35,19 +32,24 @@ class TextFileTextsProvider implements TextsProvider, WithWatchableDir {
|
||||
|
||||
@Override
|
||||
Collection<Text> provide() {
|
||||
def textFiles = []
|
||||
this.textsDir.eachFileRecurse(FileType.FILES) {
|
||||
def type = this.getTextType(it)
|
||||
if (type != null) {
|
||||
def relativePath = this.textsDir.relativePath(it)
|
||||
def path = new RelativePathHandler(relativePath).getWithoutExtension()
|
||||
logger.debug('found textFile {} with type {}', path, type)
|
||||
textFiles << new Text(it.text, path, type)
|
||||
} else {
|
||||
logger.warn('ignoring {} because there is no textType for it', it)
|
||||
if (!this.textsDir.isDirectory()) {
|
||||
logger.warn('textsDir {} does not exist or is not a directory; skipping and providing no Texts', this.textsDir)
|
||||
[]
|
||||
} else {
|
||||
def textFiles = []
|
||||
this.textsDir.eachFileRecurse(FileType.FILES) {
|
||||
def type = this.getTextType(it)
|
||||
if (type != null) {
|
||||
def relativePath = this.textsDir.relativePath(it)
|
||||
def path = new RelativePathHandler(relativePath).getWithoutExtension()
|
||||
logger.debug('found textFile {} with type {}', path, type)
|
||||
textFiles << new Text(it.text, path, type)
|
||||
} else {
|
||||
logger.warn('ignoring {} because there is no textType for it', it)
|
||||
}
|
||||
}
|
||||
textFiles
|
||||
}
|
||||
textFiles
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user