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