embulk-input-gcs 0.1.11 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a7f7692d41284e6ac5299bb159a47416b4a31b5a
4
- data.tar.gz: c970445b2be3449e3691e63cc139ca3f362333c8
3
+ metadata.gz: 5e7dc0a163123cb7bb2de1738c46d60b70282d12
4
+ data.tar.gz: 10370c8b104b51f6e5ed55297181647a9caa1d82
5
5
  SHA512:
6
- metadata.gz: 9220e5404d2edfd40193813563ce40d487fabab48e78073c256193eac383edd1cae8e84700e97eb47e7513ba0ec8002d19ae7879b63c7a57961852fec0a40348
7
- data.tar.gz: 104febfa4425cac2622d381222c18c3c11033e965731087b7a9fa69f34907cd7f543747b84ffaac83ca4b23b3c2680cf413fc858661c9bd74cbc87d0a6be3342
6
+ metadata.gz: 107ca80b29d9f3a0ea45a5d62326c570e8df3c2efea0a979f51cbcca174e8d67dd8d97183ad7856362699fbd693363ba96e10f9a0513122019a76d6e75dffeab
7
+ data.tar.gz: 39bb76c59dd27373c31280ad20b614d4fa6aab4655eacf9631b29a160838e545d0ec04d3ae7ea140c3897a6020c60f3e4623846bce43edf133708330b4ecd6b4
data/ChangeLog CHANGED
@@ -1,6 +1,13 @@
1
+ Release 0.1.13 - 2016-02-04
2
+ * Upgraded embulk to v0.8.2
3
+ * Updated Google HTTP Client Library from 1.19.0 to 2.1.21.0
4
+ * Updated Google Cloud Storage API Client Library from v1-rev27-1.19.1 to v1-rev59-1.21.0
5
+
1
6
  Release 0.1.11 - 2016-01-25
2
7
  * Added retry logic
3
8
 
9
+ * Added retry logic
10
+
4
11
  Release 0.1.10 - 2015-11-07
5
12
 
6
13
  * Fix resume download logics
data/build.gradle CHANGED
@@ -2,6 +2,7 @@ plugins {
2
2
  id "com.jfrog.bintray" version "1.1"
3
3
  id "com.github.jruby-gradle.base" version "0.1.5"
4
4
  id "java"
5
+ id "checkstyle"
5
6
  id "jacoco"
6
7
  }
7
8
  import com.github.jrubygradle.JRubyExec
@@ -16,18 +17,18 @@ configurations {
16
17
  sourceCompatibility = 1.7
17
18
  targetCompatibility = 1.7
18
19
 
19
- version = "0.1.11"
20
+ version = "0.1.13"
20
21
 
21
22
  dependencies {
22
- compile "org.embulk:embulk-core:0.7.5"
23
- provided "org.embulk:embulk-core:0.7.5"
23
+ compile "org.embulk:embulk-core:0.8.2"
24
+ provided "org.embulk:embulk-core:0.8.2"
24
25
 
25
- compile "com.google.http-client:google-http-client-jackson2:1.19.0"
26
- compile ("com.google.apis:google-api-services-storage:v1-rev27-1.19.1") {exclude module: "guava-jdk5"}
26
+ compile "com.google.http-client:google-http-client-jackson2:1.21.0"
27
+ compile ("com.google.apis:google-api-services-storage:v1-rev59-1.21.0") {exclude module: "guava-jdk5"}
27
28
 
28
29
  testCompile "junit:junit:4.12"
29
- testCompile "org.embulk:embulk-core:0.7.5:tests"
30
- testCompile "org.embulk:embulk-standards:0.7.5"
30
+ testCompile "org.embulk:embulk-core:0.8.2:tests"
31
+ testCompile "org.embulk:embulk-standards:0.8.2"
31
32
  }
32
33
 
33
34
  task classpath(type: Copy, dependsOn: ["jar"]) {
@@ -37,6 +38,23 @@ task classpath(type: Copy, dependsOn: ["jar"]) {
37
38
  }
38
39
  clean { delete 'classpath' }
39
40
 
41
+ checkstyle {
42
+ configFile = file("${project.rootDir}/config/checkstyle/checkstyle.xml")
43
+ toolVersion = '6.14.1'
44
+ }
45
+ checkstyleMain {
46
+ configFile = file("${project.rootDir}/config/checkstyle/default.xml")
47
+ ignoreFailures = true
48
+ }
49
+ checkstyleTest {
50
+ configFile = file("${project.rootDir}/config/checkstyle/default.xml")
51
+ ignoreFailures = true
52
+ }
53
+ task checkstyle(type: Checkstyle) {
54
+ classpath = sourceSets.main.output + sourceSets.test.output
55
+ source = sourceSets.main.allJava + sourceSets.test.allJava
56
+ }
57
+
40
58
  task gem(type: JRubyExec, dependsOn: ["build", "gemspec", "classpath"]) {
41
59
  jrubyArgs "-rrubygems/gem_runner", "-eGem::GemRunner.new.run(ARGV)", "build"
42
60
  script "build/gemspec"
@@ -0,0 +1,130 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE module PUBLIC
3
+ "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
4
+ "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
5
+ <module name="Checker">
6
+ <!-- https://github.com/facebook/presto/blob/master/src/checkstyle/checks.xml -->
7
+ <module name="FileTabCharacter"/>
8
+ <module name="NewlineAtEndOfFile">
9
+ <property name="lineSeparator" value="lf"/>
10
+ </module>
11
+ <module name="RegexpMultiline">
12
+ <property name="format" value="\r"/>
13
+ <property name="message" value="Line contains carriage return"/>
14
+ </module>
15
+ <module name="RegexpMultiline">
16
+ <property name="format" value=" \n"/>
17
+ <property name="message" value="Line has trailing whitespace"/>
18
+ </module>
19
+ <module name="RegexpMultiline">
20
+ <property name="format" value="\{\n\n"/>
21
+ <property name="message" value="Blank line after opening brace"/>
22
+ </module>
23
+ <module name="RegexpMultiline">
24
+ <property name="format" value="\n\n\s*\}"/>
25
+ <property name="message" value="Blank line before closing brace"/>
26
+ </module>
27
+ <module name="RegexpMultiline">
28
+ <property name="format" value="\n\n\n"/>
29
+ <property name="message" value="Multiple consecutive blank lines"/>
30
+ </module>
31
+ <module name="RegexpMultiline">
32
+ <property name="format" value="\n\n\Z"/>
33
+ <property name="message" value="Blank line before end of file"/>
34
+ </module>
35
+ <module name="RegexpMultiline">
36
+ <property name="format" value="Preconditions\.checkNotNull"/>
37
+ <property name="message" value="Use of checkNotNull"/>
38
+ </module>
39
+
40
+ <module name="TreeWalker">
41
+ <module name="EmptyBlock">
42
+ <property name="option" value="text"/>
43
+ <property name="tokens" value="
44
+ LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_IF,
45
+ LITERAL_FOR, LITERAL_TRY, LITERAL_WHILE, INSTANCE_INIT, STATIC_INIT"/>
46
+ </module>
47
+ <module name="EmptyStatement"/>
48
+ <module name="EmptyForInitializerPad"/>
49
+ <module name="EmptyForIteratorPad">
50
+ <property name="option" value="space"/>
51
+ </module>
52
+ <module name="MethodParamPad">
53
+ <property name="allowLineBreaks" value="true"/>
54
+ <property name="option" value="nospace"/>
55
+ </module>
56
+ <module name="ParenPad"/>
57
+ <module name="TypecastParenPad"/>
58
+ <module name="NeedBraces"/>
59
+ <module name="LeftCurly">
60
+ <property name="option" value="nl"/>
61
+ <property name="tokens" value="CLASS_DEF, CTOR_DEF, INTERFACE_DEF, METHOD_DEF"/>
62
+ </module>
63
+ <module name="LeftCurly">
64
+ <property name="option" value="eol"/>
65
+ <property name="tokens" value="
66
+ LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR,
67
+ LITERAL_IF, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE"/>
68
+ </module>
69
+ <module name="RightCurly">
70
+ <property name="option" value="alone"/>
71
+ </module>
72
+ <module name="GenericWhitespace"/>
73
+ <module name="WhitespaceAfter"/>
74
+ <module name="NoWhitespaceBefore"/>
75
+
76
+ <module name="UpperEll"/>
77
+ <module name="DefaultComesLast"/>
78
+ <module name="ArrayTypeStyle"/>
79
+ <module name="MultipleVariableDeclarations"/>
80
+ <module name="ModifierOrder"/>
81
+ <module name="OneStatementPerLine"/>
82
+ <module name="StringLiteralEquality"/>
83
+ <module name="MutableException"/>
84
+ <module name="EqualsHashCode"/>
85
+ <module name="InnerAssignment"/>
86
+ <module name="InterfaceIsType"/>
87
+ <module name="HideUtilityClassConstructor"/>
88
+
89
+ <module name="MemberName"/>
90
+ <module name="LocalVariableName"/>
91
+ <module name="LocalFinalVariableName"/>
92
+ <module name="TypeName"/>
93
+ <module name="PackageName"/>
94
+ <module name="ParameterName"/>
95
+ <module name="StaticVariableName">
96
+ <property name="format" value="^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"/>
97
+ </module>
98
+ <module name="ClassTypeParameterName">
99
+ <property name="format" value="^[A-Z][0-9]?$"/>
100
+ </module>
101
+ <module name="MethodTypeParameterName">
102
+ <property name="format" value="^[A-Z][0-9]?$"/>
103
+ </module>
104
+
105
+ <module name="AvoidStarImport"/>
106
+ <module name="RedundantImport"/>
107
+ <module name="UnusedImports"/>
108
+ <module name="ImportOrder">
109
+ <property name="groups" value="*,javax,java"/>
110
+ <property name="separated" value="true"/>
111
+ <property name="option" value="bottom"/>
112
+ <property name="sortStaticImportsAlphabetically" value="true"/>
113
+ </module>
114
+
115
+ <module name="WhitespaceAround">
116
+ <property name="allowEmptyConstructors" value="true"/>
117
+ <property name="allowEmptyMethods" value="true"/>
118
+ <property name="ignoreEnhancedForColon" value="false"/>
119
+ <property name="tokens" value="
120
+ ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN,
121
+ BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LE,
122
+ LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
123
+ LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
124
+ LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE,
125
+ LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL,
126
+ PLUS, PLUS_ASSIGN, QUESTION, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN,
127
+ STAR, STAR_ASSIGN, TYPE_EXTENSION_AND"/>
128
+ </module>
129
+ </module>
130
+ </module>
@@ -0,0 +1,110 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE module PUBLIC
3
+ "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
4
+ "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
5
+ <!--
6
+ This is a subset of ./checkstyle.xml which allows some loose styles
7
+ -->
8
+ <module name="Checker">
9
+ <module name="FileTabCharacter"/>
10
+ <module name="NewlineAtEndOfFile">
11
+ <property name="lineSeparator" value="lf"/>
12
+ </module>
13
+ <module name="RegexpMultiline">
14
+ <property name="format" value="\r"/>
15
+ <property name="message" value="Line contains carriage return"/>
16
+ </module>
17
+ <module name="RegexpMultiline">
18
+ <property name="format" value=" \n"/>
19
+ <property name="message" value="Line has trailing whitespace"/>
20
+ </module>
21
+ <module name="RegexpMultiline">
22
+ <property name="format" value="\n\n\n"/>
23
+ <property name="message" value="Multiple consecutive blank lines"/>
24
+ </module>
25
+ <module name="RegexpMultiline">
26
+ <property name="format" value="\n\n\Z"/>
27
+ <property name="message" value="Blank line before end of file"/>
28
+ </module>
29
+
30
+ <module name="TreeWalker">
31
+ <module name="EmptyBlock">
32
+ <property name="option" value="text"/>
33
+ <property name="tokens" value="
34
+ LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_IF,
35
+ LITERAL_FOR, LITERAL_TRY, LITERAL_WHILE, INSTANCE_INIT, STATIC_INIT"/>
36
+ </module>
37
+ <module name="EmptyStatement"/>
38
+ <module name="EmptyForInitializerPad"/>
39
+ <module name="EmptyForIteratorPad">
40
+ <property name="option" value="space"/>
41
+ </module>
42
+ <module name="MethodParamPad">
43
+ <property name="allowLineBreaks" value="true"/>
44
+ <property name="option" value="nospace"/>
45
+ </module>
46
+ <module name="ParenPad"/>
47
+ <module name="TypecastParenPad"/>
48
+ <module name="NeedBraces"/>
49
+ <module name="LeftCurly">
50
+ <property name="option" value="nl"/>
51
+ <property name="tokens" value="CLASS_DEF, CTOR_DEF, INTERFACE_DEF, METHOD_DEF"/>
52
+ </module>
53
+ <module name="LeftCurly">
54
+ <property name="option" value="eol"/>
55
+ <property name="tokens" value="
56
+ LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR,
57
+ LITERAL_IF, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE"/>
58
+ </module>
59
+ <module name="RightCurly">
60
+ <property name="option" value="alone"/>
61
+ </module>
62
+ <module name="GenericWhitespace"/>
63
+ <module name="WhitespaceAfter"/>
64
+ <module name="NoWhitespaceBefore"/>
65
+
66
+ <module name="UpperEll"/>
67
+ <module name="DefaultComesLast"/>
68
+ <module name="ArrayTypeStyle"/>
69
+ <module name="MultipleVariableDeclarations"/>
70
+ <module name="ModifierOrder"/>
71
+ <module name="OneStatementPerLine"/>
72
+ <module name="StringLiteralEquality"/>
73
+ <module name="MutableException"/>
74
+ <module name="EqualsHashCode"/>
75
+ <module name="InnerAssignment"/>
76
+ <module name="InterfaceIsType"/>
77
+ <module name="HideUtilityClassConstructor"/>
78
+
79
+ <module name="MemberName"/>
80
+ <module name="LocalVariableName"/>
81
+ <module name="LocalFinalVariableName"/>
82
+ <module name="TypeName"/>
83
+ <module name="PackageName"/>
84
+ <module name="ParameterName"/>
85
+ <module name="StaticVariableName">
86
+ <property name="format" value="^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"/>
87
+ </module>
88
+ <module name="ClassTypeParameterName">
89
+ <property name="format" value="^[A-Z][0-9]?$"/>
90
+ </module>
91
+ <module name="MethodTypeParameterName">
92
+ <property name="format" value="^[A-Z][0-9]?$"/>
93
+ </module>
94
+
95
+ <module name="WhitespaceAround">
96
+ <property name="allowEmptyConstructors" value="true"/>
97
+ <property name="allowEmptyMethods" value="true"/>
98
+ <property name="ignoreEnhancedForColon" value="false"/>
99
+ <property name="tokens" value="
100
+ ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN,
101
+ BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LE,
102
+ LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
103
+ LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
104
+ LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE,
105
+ LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL,
106
+ PLUS, PLUS_ASSIGN, QUESTION, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN,
107
+ STAR, STAR_ASSIGN, TYPE_EXTENSION_AND"/>
108
+ </module>
109
+ </module>
110
+ </module>
Binary file
@@ -1,6 +1,6 @@
1
- #Tue Aug 11 00:26:20 PDT 2015
1
+ #Wed Jan 13 12:41:02 JST 2016
2
2
  distributionBase=GRADLE_USER_HOME
3
3
  distributionPath=wrapper/dists
4
4
  zipStoreBase=GRADLE_USER_HOME
5
5
  zipStorePath=wrapper/dists
6
- distributionUrl=https\://services.gradle.org/distributions/gradle-2.6-bin.zip
6
+ distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-bin.zip
@@ -1,28 +1,28 @@
1
1
  package org.embulk.input.gcs;
2
2
 
3
- import java.io.File;
4
- import java.io.FileInputStream;
5
- import java.io.IOException;
6
-
7
- import com.google.common.base.Optional;
8
- import com.google.common.collect.ImmutableList;
9
- import java.security.GeneralSecurityException;
10
- import java.util.Collections;
11
-
12
3
  import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
13
4
  import com.google.api.client.googleapis.compute.ComputeCredential;
14
5
  import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
6
+ import com.google.api.client.googleapis.json.GoogleJsonResponseException;
7
+ import com.google.api.client.http.HttpRequestInitializer;
15
8
  import com.google.api.client.http.HttpTransport;
16
9
  import com.google.api.client.json.JsonFactory;
17
10
  import com.google.api.client.json.jackson2.JacksonFactory;
18
- import com.google.api.client.http.HttpRequestInitializer;
19
- import com.google.api.client.googleapis.json.GoogleJsonResponseException;
20
11
  import com.google.api.services.storage.Storage;
21
12
  import com.google.api.services.storage.StorageScopes;
22
13
  import com.google.api.services.storage.model.Objects;
14
+ import com.google.common.base.Optional;
15
+ import com.google.common.collect.ImmutableList;
23
16
  import org.embulk.spi.Exec;
24
17
  import org.slf4j.Logger;
25
18
 
19
+ import java.io.File;
20
+ import java.io.FileInputStream;
21
+
22
+ import java.io.IOException;
23
+ import java.security.GeneralSecurityException;
24
+ import java.util.Collections;
25
+
26
26
  public class GcsAuthentication
27
27
  {
28
28
  private final Logger log = Exec.getLogger(GcsAuthentication.class);
@@ -48,9 +48,11 @@ public class GcsAuthentication
48
48
 
49
49
  if (authMethod.equals("compute_engine")) {
50
50
  this.credentials = getComputeCredential();
51
- } else if(authMethod.toLowerCase().equals("json_key")) {
51
+ }
52
+ else if (authMethod.toLowerCase().equals("json_key")) {
52
53
  this.credentials = getServiceAccountCredentialFromJsonFile();
53
- } else {
54
+ }
55
+ else {
54
56
  this.credentials = getServiceAccountCredential();
55
57
  }
56
58
  }
@@ -109,4 +111,4 @@ public class GcsAuthentication
109
111
 
110
112
  return client;
111
113
  }
112
- }
114
+ }
@@ -1,49 +1,46 @@
1
1
  package org.embulk.input.gcs;
2
2
 
3
- import java.util.List;
4
- import java.util.ArrayList;
5
- import java.util.Collections;
6
- import java.io.IOException;
7
- import java.io.InterruptedIOException;
8
- import java.io.InputStream;
9
- import java.math.BigInteger;
10
-
11
3
  import com.google.api.client.http.HttpResponseException;
12
- import com.google.common.collect.ImmutableList;
13
- import com.google.common.base.Optional;
4
+ import com.google.api.services.storage.Storage;
5
+ import com.google.api.services.storage.model.Bucket;
6
+ import com.google.api.services.storage.model.Objects;
7
+ import com.google.api.services.storage.model.StorageObject;
8
+ import com.google.common.annotations.VisibleForTesting;
9
+ import com.google.common.base.Charsets;
14
10
  import com.google.common.base.Function;
11
+ import com.google.common.base.Optional;
15
12
  import com.google.common.base.Throwables;
16
- import com.google.common.base.Charsets;
13
+ import com.google.common.collect.ImmutableList;
17
14
  import com.google.common.io.BaseEncoding;
18
- import com.google.common.annotations.VisibleForTesting;
19
- import java.security.GeneralSecurityException;
20
-
21
- import org.embulk.config.TaskReport;
22
15
  import org.embulk.config.Config;
23
- import org.embulk.config.ConfigInject;
24
- import org.embulk.config.ConfigDiff;
25
16
  import org.embulk.config.ConfigDefault;
17
+ import org.embulk.config.ConfigDiff;
26
18
  import org.embulk.config.ConfigException;
19
+ import org.embulk.config.ConfigInject;
27
20
  import org.embulk.config.ConfigSource;
28
21
  import org.embulk.config.Task;
22
+ import org.embulk.config.TaskReport;
29
23
  import org.embulk.config.TaskSource;
30
- import org.embulk.spi.Exec;
31
24
  import org.embulk.spi.BufferAllocator;
25
+ import org.embulk.spi.Exec;
32
26
  import org.embulk.spi.FileInputPlugin;
33
27
  import org.embulk.spi.TransactionalFileInput;
34
28
  import org.embulk.spi.unit.LocalFile;
35
29
  import org.embulk.spi.util.InputStreamFileInput;
36
30
  import org.embulk.spi.util.ResumableInputStream;
37
- import org.embulk.spi.util.RetryExecutor.Retryable;
38
31
  import org.embulk.spi.util.RetryExecutor.RetryGiveupException;
39
- import static org.embulk.spi.util.RetryExecutor.retryExecutor;
40
-
32
+ import org.embulk.spi.util.RetryExecutor.Retryable;
41
33
  import org.slf4j.Logger;
34
+ import static org.embulk.spi.util.RetryExecutor.retryExecutor;
42
35
 
43
- import com.google.api.services.storage.Storage;
44
- import com.google.api.services.storage.model.Bucket;
45
- import com.google.api.services.storage.model.Objects;
46
- import com.google.api.services.storage.model.StorageObject;
36
+ import java.io.IOException;
37
+ import java.io.InputStream;
38
+ import java.io.InterruptedIOException;
39
+ import java.math.BigInteger;
40
+ import java.security.GeneralSecurityException;
41
+ import java.util.ArrayList;
42
+ import java.util.Collections;
43
+ import java.util.List;
47
44
 
48
45
  public class GcsFileInputPlugin
49
46
  implements FileInputPlugin
@@ -108,7 +105,8 @@ public class GcsFileInputPlugin
108
105
  }
109
106
  try {
110
107
  task.setP12Keyfile(Optional.of(LocalFile.of(task.getP12KeyfileFullpath().get())));
111
- } catch (IOException ex) {
108
+ }
109
+ catch (IOException ex) {
112
110
  throw Throwables.propagate(ex);
113
111
  }
114
112
  }
@@ -117,7 +115,8 @@ public class GcsFileInputPlugin
117
115
  if (!task.getJsonKeyfile().isPresent()) {
118
116
  throw new ConfigException("If auth_method is json_key, you have to set json_keyfile");
119
117
  }
120
- } else if (task.getAuthMethod().getString().equals("private_key")) {
118
+ }
119
+ else if (task.getAuthMethod().getString().equals("private_key")) {
121
120
  if (!task.getP12Keyfile().isPresent() || !task.getServiceAccountEmail().isPresent()) {
122
121
  throw new ConfigException("If auth_method is private_key, you have to set both service_account_email and p12_keyfile");
123
122
  }
@@ -148,7 +147,8 @@ public class GcsFileInputPlugin
148
147
  task.getJsonKeyfile().transform(localFileToPathString()),
149
148
  task.getApplicationName()
150
149
  );
151
- } catch (GeneralSecurityException | IOException ex) {
150
+ }
151
+ catch (GeneralSecurityException | IOException ex) {
152
152
  throw new ConfigException(ex);
153
153
  }
154
154
  }
@@ -170,7 +170,8 @@ public class GcsFileInputPlugin
170
170
  if (task.getLastPath().isPresent()) {
171
171
  configDiff.set("last_path", task.getLastPath().get());
172
172
  }
173
- } else {
173
+ }
174
+ else {
174
175
  Collections.sort(files);
175
176
  configDiff.set("last_path", files.get(files.size() - 1));
176
177
  }
@@ -190,7 +191,8 @@ public class GcsFileInputPlugin
190
191
  Storage client = null;
191
192
  try {
192
193
  client = auth.getGcsClient(task.getBucket());
193
- } catch (IOException ex) {
194
+ }
195
+ catch (IOException ex) {
194
196
  throw new ConfigException(ex);
195
197
  }
196
198
 
@@ -237,12 +239,12 @@ public class GcsFileInputPlugin
237
239
  log.debug("bucket location: " + bk.getLocation());
238
240
  log.debug("bucket timeCreated: " + bk.getTimeCreated());
239
241
  log.debug("bucket owner: " + bk.getOwner());
240
- } catch (IOException e) {
242
+ }
243
+ catch (IOException e) {
241
244
  log.warn("Could not access to bucket:" + bucket);
242
245
  log.warn(e.getMessage());
243
246
  }
244
247
 
245
-
246
248
  try {
247
249
  // @see https://cloud.google.com/storage/docs/json_api/v1/objects/list
248
250
  Storage.Objects.List listObjects = client.objects().list(bucket);
@@ -265,7 +267,8 @@ public class GcsFileInputPlugin
265
267
  lastKey = objects.getNextPageToken();
266
268
  listObjects.setPageToken(lastKey);
267
269
  } while (lastKey != null);
268
- } catch (IOException e) {
270
+ }
271
+ catch (IOException e) {
269
272
  if ((e instanceof HttpResponseException) && ((HttpResponseException) e).getStatusCode() == 400) {
270
273
  throw new ConfigException(String.format("Files listing failed: bucket:%s, prefix:%s, last_path:%s", bucket, prefix, lastKey), e);
271
274
  }
@@ -328,10 +331,11 @@ public class GcsFileInputPlugin
328
331
  throws RetryGiveupException
329
332
  {
330
333
  String message = String.format("GCS GET request failed. Retrying %d/%d after %d seconds. Message: %s",
331
- retryCount, retryLimit, retryWait/1000, exception.getMessage());
334
+ retryCount, retryLimit, retryWait / 1000, exception.getMessage());
332
335
  if (retryCount % 3 == 0) {
333
336
  log.warn(message, exception);
334
- } else {
337
+ }
338
+ else {
335
339
  log.warn(message);
336
340
  }
337
341
  }
@@ -342,10 +346,12 @@ public class GcsFileInputPlugin
342
346
  {
343
347
  }
344
348
  });
345
- } catch (RetryGiveupException ex) {
349
+ }
350
+ catch (RetryGiveupException ex) {
346
351
  Throwables.propagateIfInstanceOf(ex.getCause(), IOException.class);
347
352
  throw Throwables.propagate(ex.getCause());
348
- } catch (InterruptedException ex) {
353
+ }
354
+ catch (InterruptedException ex) {
349
355
  throw new InterruptedIOException();
350
356
  }
351
357
  }
@@ -360,7 +366,9 @@ public class GcsFileInputPlugin
360
366
  super(task.getBufferAllocator(), new SingleFileProvider(task, taskIndex));
361
367
  }
362
368
 
363
- public void abort() { }
369
+ public void abort()
370
+ {
371
+ }
364
372
 
365
373
  public TaskReport commit()
366
374
  {
@@ -368,7 +376,9 @@ public class GcsFileInputPlugin
368
376
  }
369
377
 
370
378
  @Override
371
- public void close() { }
379
+ public void close()
380
+ {
381
+ }
372
382
  }
373
383
 
374
384
  private class SingleFileProvider
@@ -399,7 +409,9 @@ public class GcsFileInputPlugin
399
409
  }
400
410
 
401
411
  @Override
402
- public void close() { }
412
+ public void close()
413
+ {
414
+ }
403
415
  }
404
416
 
405
417
  // String nextToken = base64Encode(0x0a + 0x01~0x27 + filePath);
@@ -415,11 +427,10 @@ public class GcsFileInputPlugin
415
427
  System.arraycopy(utf8, 0, encoding, 2, utf8.length);
416
428
 
417
429
  String s = BaseEncoding.base64().encode(encoding);
418
- log.debug(String.format("last_path(base64 encoded): %s" ,s));
430
+ log.debug(String.format("last_path(base64 encoded): %s", s));
419
431
  return s;
420
432
  }
421
433
 
422
-
423
434
  public enum AuthMethod
424
435
  {
425
436
  private_key("private_key"),
@@ -1,19 +1,20 @@
1
1
  package org.embulk.input.gcs;
2
2
 
3
+ import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
4
+ import com.google.api.client.googleapis.json.GoogleJsonResponseException;
5
+ import com.google.api.services.storage.Storage;
3
6
  import com.google.common.base.Optional;
4
7
  import org.embulk.EmbulkTestRuntime;
5
- import com.google.api.services.storage.Storage;
6
- import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
8
+ import org.junit.BeforeClass;
9
+ import org.junit.Rule;
10
+ import org.junit.Test;
7
11
 
8
- import java.io.IOException;
9
12
  import java.io.FileNotFoundException;
10
- import java.security.GeneralSecurityException;
11
- import com.google.api.client.googleapis.json.GoogleJsonResponseException;
12
13
 
14
+ import java.io.IOException;
13
15
  import java.lang.reflect.Field;
14
- import org.junit.BeforeClass;
15
- import org.junit.Rule;
16
- import org.junit.Test;
16
+ import java.security.GeneralSecurityException;
17
+
17
18
  import static org.junit.Assert.assertEquals;
18
19
  import static org.junit.Assume.assumeNotNull;
19
20
 
@@ -35,12 +36,18 @@ public class TestGcsAuthentication
35
36
  @BeforeClass
36
37
  public static void initializeConstant()
37
38
  {
38
- GCP_EMAIL = Optional.of(System.getenv("GCP_EMAIL"));
39
- GCP_P12_KEYFILE = Optional.of(System.getenv("GCP_P12_KEYFILE"));
40
- GCP_JSON_KEYFILE = Optional.of(System.getenv("GCP_JSON_KEYFILE"));
41
- GCP_BUCKET = System.getenv("GCP_BUCKET");
39
+ String gcpEmail = System.getenv("GCP_EMAIL");
40
+ String gcpP12KeyFile = System.getenv("GCP_P12_KEYFILE");
41
+ String gcpJsonKeyFile = System.getenv("GCP_JSON_KEYFILE");
42
+ String gcpBucket = System.getenv("GCP_BUCKET");
43
+
42
44
  // skip test cases, if environment variables are not set.
43
- assumeNotNull(GCP_EMAIL, GCP_P12_KEYFILE, GCP_JSON_KEYFILE, GCP_BUCKET);
45
+ assumeNotNull(gcpEmail, gcpP12KeyFile, gcpJsonKeyFile, gcpBucket);
46
+
47
+ GCP_EMAIL = Optional.of(gcpEmail);
48
+ GCP_P12_KEYFILE = Optional.of(gcpP12KeyFile);
49
+ GCP_JSON_KEYFILE = Optional.of(gcpJsonKeyFile);
50
+ GCP_BUCKET = gcpBucket;
44
51
  }
45
52
 
46
53
  @Rule
@@ -1,45 +1,47 @@
1
1
  package org.embulk.input.gcs;
2
2
 
3
- import java.util.ArrayList;
4
- import java.util.Arrays;
5
- import java.util.List;
6
- import com.google.common.collect.ImmutableMap;
3
+ import com.google.api.services.storage.Storage;
7
4
  import com.google.common.base.Optional;
8
5
  import com.google.common.collect.ImmutableList;
6
+ import com.google.common.collect.ImmutableMap;
9
7
  import com.google.common.collect.Lists;
10
- import java.io.BufferedReader;
11
- import java.io.InputStream;
12
- import java.io.InputStreamReader;
13
- import java.io.IOException;
14
- import java.security.GeneralSecurityException;
15
-
16
8
  import org.embulk.EmbulkTestRuntime;
17
- import org.embulk.config.TaskReport;
18
- import org.embulk.config.TaskSource;
19
9
  import org.embulk.config.ConfigDiff;
20
- import org.embulk.config.ConfigSource;
21
10
  import org.embulk.config.ConfigException;
11
+ import org.embulk.config.ConfigSource;
12
+ import org.embulk.config.TaskReport;
13
+ import org.embulk.config.TaskSource;
14
+ import org.embulk.input.gcs.GcsFileInputPlugin.PluginTask;
22
15
  import org.embulk.spi.Exec;
23
16
  import org.embulk.spi.FileInputPlugin;
24
17
  import org.embulk.spi.FileInputRunner;
25
18
  import org.embulk.spi.InputPlugin;
26
- import org.embulk.spi.util.Pages;
27
19
  import org.embulk.spi.Schema;
28
20
  import org.embulk.spi.TestPageBuilderReader.MockPageOutput;
29
- import org.embulk.input.gcs.GcsFileInputPlugin.PluginTask;
21
+ import org.embulk.spi.util.Pages;
30
22
  import org.embulk.standards.CsvParserPlugin;
31
-
32
- import com.google.api.services.storage.Storage;
33
-
34
- import org.junit.BeforeClass;
35
23
  import org.junit.Before;
24
+ import org.junit.BeforeClass;
36
25
  import org.junit.Rule;
37
26
  import org.junit.Test;
27
+
28
+ import java.io.BufferedReader;
29
+
30
+ import java.io.IOException;
31
+ import java.io.InputStream;
32
+ import java.io.InputStreamReader;
33
+ import java.security.GeneralSecurityException;
34
+ import java.util.ArrayList;
35
+ import java.util.Arrays;
36
+ import java.util.List;
37
+
38
38
  import static org.junit.Assert.assertEquals;
39
39
  import static org.junit.Assume.assumeNotNull;
40
- import java.lang.reflect.Method;
40
+
41
41
  import java.lang.reflect.InvocationTargetException;
42
42
 
43
+ import java.lang.reflect.Method;
44
+
43
45
  public class TestGcsFileInputPlugin
44
46
  {
45
47
  private static Optional<String> GCP_EMAIL;
@@ -48,7 +50,7 @@ public class TestGcsFileInputPlugin
48
50
  private static String GCP_BUCKET;
49
51
  private static String GCP_BUCKET_DIRECTORY;
50
52
  private static String GCP_PATH_PREFIX;
51
- private final String GCP_APPLICATION_NAME = "embulk-input-gcs";
53
+ private static String GCP_APPLICATION_NAME;
52
54
  private FileInputRunner runner;
53
55
  private MockPageOutput output;
54
56
 
@@ -62,12 +64,18 @@ public class TestGcsFileInputPlugin
62
64
  @BeforeClass
63
65
  public static void initializeConstant()
64
66
  {
65
- GCP_EMAIL = Optional.of(System.getenv("GCP_EMAIL"));
66
- GCP_P12_KEYFILE = Optional.of(System.getenv("GCP_P12_KEYFILE"));
67
- GCP_JSON_KEYFILE = Optional.of(System.getenv("GCP_JSON_KEYFILE"));
68
- GCP_BUCKET = System.getenv("GCP_BUCKET");
67
+ String gcpEmail = System.getenv("GCP_EMAIL");
68
+ String gcpP12KeyFile = System.getenv("GCP_P12_KEYFILE");
69
+ String gcpJsonKeyFile = System.getenv("GCP_JSON_KEYFILE");
70
+ String gcpBucket = System.getenv("GCP_BUCKET");
71
+
69
72
  // skip test cases, if environment variables are not set.
70
- assumeNotNull(GCP_EMAIL, GCP_P12_KEYFILE, GCP_JSON_KEYFILE, GCP_BUCKET);
73
+ assumeNotNull(gcpEmail, gcpP12KeyFile, gcpJsonKeyFile, gcpBucket);
74
+
75
+ GCP_EMAIL = Optional.of(gcpEmail);
76
+ GCP_P12_KEYFILE = Optional.of(gcpP12KeyFile);
77
+ GCP_JSON_KEYFILE = Optional.of(gcpJsonKeyFile);
78
+ GCP_BUCKET = gcpBucket;
71
79
 
72
80
  GCP_BUCKET_DIRECTORY = System.getenv("GCP_BUCKET_DIRECTORY") != null ? getDirectory(System.getenv("GCP_BUCKET_DIRECTORY")) : getDirectory("");
73
81
  GCP_PATH_PREFIX = GCP_BUCKET_DIRECTORY + "sample_";
@@ -245,7 +253,8 @@ public class TestGcsFileInputPlugin
245
253
  PluginTask task = config.loadConfig(PluginTask.class);
246
254
  ConfigDiff configDiff = plugin.transaction(config, new FileInputPlugin.Control() {
247
255
  @Override
248
- public List<TaskReport> run(TaskSource taskSource, int taskCount) {
256
+ public List<TaskReport> run(TaskSource taskSource, int taskCount)
257
+ {
249
258
  assertEquals(2, taskCount);
250
259
  return emptyTaskReports(taskCount);
251
260
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-input-gcs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Satoshi Akama
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-25 00:00:00.000000000 Z
11
+ date: 2016-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -49,6 +49,8 @@ files:
49
49
  - ChangeLog
50
50
  - README.md
51
51
  - build.gradle
52
+ - config/checkstyle/checkstyle.xml
53
+ - config/checkstyle/default.xml
52
54
  - gradle/wrapper/gradle-wrapper.jar
53
55
  - gradle/wrapper/gradle-wrapper.properties
54
56
  - gradlew
@@ -63,12 +65,12 @@ files:
63
65
  - src/test/resources/sample_02.csv
64
66
  - classpath/commons-codec-1.3.jar
65
67
  - classpath/commons-logging-1.1.1.jar
66
- - classpath/embulk-input-gcs-0.1.11.jar
67
- - classpath/google-api-client-1.19.1.jar
68
- - classpath/google-api-services-storage-v1-rev27-1.19.1.jar
69
- - classpath/google-http-client-1.19.0.jar
70
- - classpath/google-http-client-jackson2-1.19.0.jar
71
- - classpath/google-oauth-client-1.19.0.jar
68
+ - classpath/embulk-input-gcs-0.1.13.jar
69
+ - classpath/google-api-client-1.21.0.jar
70
+ - classpath/google-api-services-storage-v1-rev59-1.21.0.jar
71
+ - classpath/google-http-client-1.21.0.jar
72
+ - classpath/google-http-client-jackson2-1.21.0.jar
73
+ - classpath/google-oauth-client-1.21.0.jar
72
74
  - classpath/httpclient-4.0.1.jar
73
75
  - classpath/httpcore-4.0.1.jar
74
76
  - classpath/jsr305-1.3.9.jar
Binary file