Skip to content

Commit 6cf442d

Browse files
authored
Merge pull request #66 from embulk/add_validation
add validator into ConfigMapperFactory
2 parents 71eb637 + 53928aa commit 6cf442d

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

NOTICE_GEM

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ They are licensed under the Apache Software License, Version 2.0.
1414
The gem distribution of this product includes JARs of the Jakarta Bean Validation API 1.1 (https://beanvalidation.org/1.1/), as-is.
1515
It is licensed under the Apache Software License, Version 2.0.
1616

17-
The gem distribution of this product includes JARs of Apache Commons IO, Commons Logging, Commons Virtual File System, as-is.
17+
The gem distribution of this product includes JARs of Apache Commons IO, Commons Logging, Commons Virtual File System, Commons BeanUtils, Commons Lang, BVal, as-is.
1818
They are licensed under the Apache Software License, Version 2.0.
1919

2020
The gem distribution of this product includes JARs of JSch - Java Secure Channel (http://www.jcraft.com/jsch/), as-is.

build.gradle

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ repositories {
1313
}
1414

1515
group = "org.embulk"
16-
version = "0.3.0-SNAPSHOT"
16+
version = "0.3.1-SNAPSHOT"
1717
description = "Stores files on SFTP server."
1818

1919
sourceCompatibility = 1.8
@@ -50,6 +50,12 @@ dependencies {
5050
compile "com.fasterxml.jackson.core:jackson-databind:2.6.7"
5151
compile "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.6.7"
5252
compile "javax.validation:validation-api:1.1.0.Final"
53+
compile "org.apache.bval:bval-jsr303:0.5"
54+
// Necessary for bval from Java 9+
55+
compile 'javax.xml.bind:jaxb-api:2.2.11'
56+
compile 'com.sun.xml.bind:jaxb-core:2.2.11'
57+
compile 'com.sun.xml.bind:jaxb-impl:2.2.11'
58+
compile 'javax.activation:activation:1.1.1'
5359

5460
compile "org.embulk:embulk-util-retryhelper:0.8.2"
5561

gradle/dependency-locks/embulkPluginRuntime.lockfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,17 @@ com.fasterxml.jackson.core:jackson-core:2.6.7
66
com.fasterxml.jackson.core:jackson-databind:2.6.7
77
com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.6.7
88
com.jcraft:jsch:0.1.55
9+
com.sun.xml.bind:jaxb-core:2.2.11
10+
com.sun.xml.bind:jaxb-impl:2.2.11
11+
commons-beanutils:commons-beanutils-core:1.8.3
912
commons-io:commons-io:2.6
1013
commons-logging:commons-logging:1.2
14+
javax.activation:activation:1.1.1
1115
javax.validation:validation-api:1.1.0.Final
16+
javax.xml.bind:jaxb-api:2.2.11
17+
org.apache.bval:bval-core:0.5
18+
org.apache.bval:bval-jsr303:0.5
19+
org.apache.commons:commons-lang3:3.1
1220
org.apache.commons:commons-vfs2:2.2
1321
org.embulk:embulk-util-config:0.3.1
1422
org.embulk:embulk-util-retryhelper:0.8.2

src/main/java/org/embulk/output/sftp/SftpFileOutputPlugin.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.embulk.output.sftp;
1818

19+
import org.apache.bval.jsr303.ApacheValidationProvider;
1920
import org.embulk.config.ConfigDiff;
2021
import org.embulk.config.ConfigSource;
2122
import org.embulk.config.TaskReport;
@@ -31,6 +32,8 @@
3132
import org.embulk.util.config.TaskMapper;
3233
import org.embulk.util.config.units.LocalFile;
3334

35+
import javax.validation.Validation;
36+
import javax.validation.Validator;
3437
import javax.validation.constraints.Max;
3538
import javax.validation.constraints.Min;
3639

@@ -180,7 +183,9 @@ public TransactionalFileOutput open(TaskSource taskSource, final int taskIndex)
180183
return new SftpRemoteFileOutput(task, taskIndex, Exec.getTempFileSpace());
181184
}
182185

183-
static final ConfigMapperFactory CONFIG_MAPPER_FACTORY = ConfigMapperFactory.builder().addDefaultModules().build();
186+
private static final Validator VALIDATOR =
187+
Validation.byProvider(ApacheValidationProvider.class).configure().buildValidatorFactory().getValidator();
188+
static final ConfigMapperFactory CONFIG_MAPPER_FACTORY = ConfigMapperFactory.builder().addDefaultModules().withValidator(VALIDATOR).build();
184189
static final ConfigMapper CONFIG_MAPPER = CONFIG_MAPPER_FACTORY.createConfigMapper();
185190
static final TaskMapper TASK_MAPPER = CONFIG_MAPPER_FACTORY.createTaskMapper();
186191
}

0 commit comments

Comments
 (0)