embulk-input-marketo_extended 0.6.22 → 0.6.28
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 +4 -4
- data/build.gradle +3 -1
- data/src/main/java/org/embulk/input/marketo/CsvTokenizer.java +10 -10
- data/src/main/java/org/embulk/input/marketo/MarketoService.java +1 -1
- data/src/main/java/org/embulk/input/marketo/MarketoServiceImpl.java +75 -11
- data/src/main/java/org/embulk/input/marketo/delegate/ActivityBulkExtractInputPlugin.java +5 -1
- data/src/main/java/org/embulk/input/marketo/delegate/MarketoBaseBulkExtractInputPlugin.java +5 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbd134238def5af6ba480e2c6a504ffd0da4869a
|
4
|
+
data.tar.gz: e396ca6875915874955aef4ea151831f6883d020
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd7084e138f808b034e055ffaccb4b1f9e02b78a24997a68ce03948af5436107c98391e86b8b9b9f124102dbf8054dcc15ebfd2664237e88d3a6c1ab2b553daf
|
7
|
+
data.tar.gz: 4bb8624c8f0786fe7ceaa5f2a1ad581f6af20631962ddef131e4c71814ec2943c6c8b0406f0dcc92f9adbac692a4ecd95adeb3bdb6709cfa7fc6605fd891e8c0
|
data/build.gradle
CHANGED
@@ -16,11 +16,13 @@ repositories {
|
|
16
16
|
configurations {
|
17
17
|
provided
|
18
18
|
}
|
19
|
-
version = "0.6.
|
19
|
+
version = "0.6.28"
|
20
20
|
sourceCompatibility = 1.7
|
21
21
|
targetCompatibility = 1.7
|
22
22
|
|
23
|
+
|
23
24
|
dependencies {
|
25
|
+
|
24
26
|
compile "org.embulk:embulk-core:0.8.+"
|
25
27
|
provided "org.embulk:embulk-core:0.8.+"
|
26
28
|
compile "org.embulk.base.restclient:embulk-base-restclient:0.5.3"
|
@@ -380,7 +380,7 @@ public class CsvTokenizer
|
|
380
380
|
else if (isQuote(c)) {
|
381
381
|
char next = peekNextChar();
|
382
382
|
final char nextNext = peekNextNextChar();
|
383
|
-
Exec.getLogger(CsvTokenizer.class).info("Character is {}. Next: {}, NextNext:{}", c,next,nextNext);
|
383
|
+
// Exec.getLogger(CsvTokenizer.class).info("Character is {}. Next: {}, NextNext:{}", c,next,nextNext);
|
384
384
|
if (isQuote(next)
|
385
385
|
&& (quotesInQuotedFields != "ACCEPT_STRAY_QUOTES_ASSUMING_NO_DELIMITERS_IN_FIELDS"
|
386
386
|
|| (!isDelimiter(nextNext) && !isEndOfLine(nextNext)))) {
|
@@ -399,14 +399,14 @@ public class CsvTokenizer
|
|
399
399
|
}
|
400
400
|
} else {
|
401
401
|
quotedValue.append(line.substring(valueStartPos, linePos - 1));
|
402
|
-
Exec.getLogger(CsvTokenizer.class).info("Current column state is {}. Quoted Value : {}", columnState, quotedValue);
|
402
|
+
// Exec.getLogger(CsvTokenizer.class).info("Current column state is {}. Quoted Value : {}", columnState, quotedValue);
|
403
403
|
columnState = ColumnState.AFTER_QUOTED_VALUE;
|
404
404
|
}
|
405
405
|
}
|
406
406
|
else if (isEscape(c)) { // isQuote must be checked first in case of quote == escape
|
407
407
|
// In RFC 4180, CSV's escape char is '\"'. But '\\' is often used.
|
408
408
|
char next = peekNextChar();
|
409
|
-
Exec.getLogger(CsvTokenizer.class).info("Esc Character is {}. Next: {}, column state{}", c,next, columnState);
|
409
|
+
// Exec.getLogger(CsvTokenizer.class).info("Esc Character is {}. Next: {}, column state{}", c,next, columnState);
|
410
410
|
if (isEndOfLine(c)) {
|
411
411
|
// escape end of line. TODO assuming multi-line quoted value without newline?
|
412
412
|
quotedValue.append(line.substring(valueStartPos, linePos));
|
@@ -416,11 +416,11 @@ public class CsvTokenizer
|
|
416
416
|
}
|
417
417
|
valueStartPos = 0;
|
418
418
|
}
|
419
|
-
else if ( isEscape(next)) { // escaped quote
|
420
|
-
quotedValue.append(line.substring(valueStartPos, linePos - 1));
|
421
|
-
quotedValue.append(next);
|
422
|
-
valueStartPos = ++linePos;
|
423
|
-
}
|
419
|
+
// else if ( isEscape(next)) { // escaped quote
|
420
|
+
// quotedValue.append(line.substring(valueStartPos, linePos - 1));
|
421
|
+
// quotedValue.append(next);
|
422
|
+
// valueStartPos = ++linePos;
|
423
|
+
// }
|
424
424
|
}
|
425
425
|
else {
|
426
426
|
if ((linePos - valueStartPos) + quotedValue.length() > maxQuotedSizeLimit) {
|
@@ -623,7 +623,7 @@ public class CsvTokenizer
|
|
623
623
|
throw new ConfigException("\"quote\" option accepts only 1 character.");
|
624
624
|
}
|
625
625
|
else if (str.isEmpty()) {
|
626
|
-
Exec.getLogger(CsvTokenizer.class).warn("Setting '' (empty string) to \"quote\" option is obsoleted. Currently it becomes '\"' automatically but this behavior will be removed. Please set '\"' explicitly.");
|
626
|
+
// Exec.getLogger(CsvTokenizer.class).warn("Setting '' (empty string) to \"quote\" option is obsoleted. Currently it becomes '\"' automatically but this behavior will be removed. Please set '\"' explicitly.");
|
627
627
|
return new QuoteCharacter('"');
|
628
628
|
}
|
629
629
|
else {
|
@@ -684,7 +684,7 @@ public class CsvTokenizer
|
|
684
684
|
throw new ConfigException("\"escape\" option accepts only 1 character.");
|
685
685
|
}
|
686
686
|
else if (str.isEmpty()) {
|
687
|
-
Exec.getLogger(CsvTokenizer.class).warn("Setting '' (empty string) to \"escape\" option is obsoleted. Currently it becomes null automatically but this behavior will be removed. Please set \"escape: null\" explicitly.");
|
687
|
+
// Exec.getLogger(CsvTokenizer.class).warn("Setting '' (empty string) to \"escape\" option is obsoleted. Currently it becomes null automatically but this behavior will be removed. Please set \"escape: null\" explicitly.");
|
688
688
|
return noEscape();
|
689
689
|
}
|
690
690
|
else {
|
@@ -16,7 +16,7 @@ public interface MarketoService
|
|
16
16
|
|
17
17
|
File extractLead(Date startTime, Date endTime, List<String> extractedFields, String filterField, int pollingTimeIntervalSecond, int bulkJobTimeoutSecond);
|
18
18
|
|
19
|
-
File extractAllActivity(List<Integer> activityTypeIds, Date startTime, Date endTime, int pollingTimeIntervalSecond, int bulkJobTimeoutSecond);
|
19
|
+
File extractAllActivity(List<Integer> activityTypeIds, Date startTime, Date endTime, int pollingTimeIntervalSecond, int bulkJobTimeoutSecond, String landingZone);
|
20
20
|
|
21
21
|
Iterable<ObjectNode> getAllListLead(List<String> extractFields);
|
22
22
|
|
@@ -21,6 +21,11 @@ import java.io.OutputStream;
|
|
21
21
|
import org.apache.commons.io.FileUtils;
|
22
22
|
import java.util.Date;
|
23
23
|
import java.util.List;
|
24
|
+
import java.time.format.DateTimeFormatter;
|
25
|
+
import java.text.DateFormat;
|
26
|
+
import java.text.SimpleDateFormat;
|
27
|
+
|
28
|
+
//import com.amazonaws.services.s3.AmazonS3;
|
24
29
|
|
25
30
|
/**
|
26
31
|
* Created by tai.khuu on 9/6/17.
|
@@ -37,6 +42,12 @@ public class MarketoServiceImpl implements MarketoService
|
|
37
42
|
|
38
43
|
private MarketoRestClient marketoRestClient;
|
39
44
|
|
45
|
+
private static Date startTime;
|
46
|
+
|
47
|
+
private DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
|
48
|
+
|
49
|
+
// private AmazonS3 s3;
|
50
|
+
|
40
51
|
public MarketoServiceImpl(MarketoRestClient marketoRestClient)
|
41
52
|
{
|
42
53
|
this.marketoRestClient = marketoRestClient;
|
@@ -45,6 +56,7 @@ public class MarketoServiceImpl implements MarketoService
|
|
45
56
|
@Override
|
46
57
|
public File extractLead(final Date startTime, Date endTime, List<String> extractedFields, String filterField, int pollingTimeIntervalSecond, final int bulkJobTimeoutSecond)
|
47
58
|
{
|
59
|
+
|
48
60
|
final String exportID = marketoRestClient.createLeadBulkExtract(startTime, endTime, extractedFields, filterField);
|
49
61
|
marketoRestClient.startLeadBulkExtract(exportID);
|
50
62
|
try {
|
@@ -85,9 +97,59 @@ public class MarketoServiceImpl implements MarketoService
|
|
85
97
|
return total;
|
86
98
|
}
|
87
99
|
|
100
|
+
// public boolean exists(String bucketName, String key) {
|
101
|
+
// try {
|
102
|
+
// fullObject = s3Client.getObject(new GetObjectRequest(bucketName, key));
|
103
|
+
// System.out.println("s3 object Content-Type: " + fullObject.getObjectMetadata().getContentType());
|
104
|
+
// return fullObject;
|
105
|
+
// } catch(AmazonServiceException e) {
|
106
|
+
// return false;
|
107
|
+
// }
|
108
|
+
// return true;
|
109
|
+
// }
|
110
|
+
// public String getBucket(String s3_key){
|
111
|
+
// if(s3_key.lenght()) {
|
112
|
+
// return s3_key.split('/')[0];
|
113
|
+
// }
|
114
|
+
// }
|
115
|
+
//
|
116
|
+
// public String getKey(String s3_key){
|
117
|
+
// if(s3_key.lenght()) {
|
118
|
+
// String [] key_parts = s3_key.split('/');
|
119
|
+
// String key = "";
|
120
|
+
// for (String k: key_parts){
|
121
|
+
// key = key + "/" + k ;
|
122
|
+
// }
|
123
|
+
// return s3_key.split('/')[0];
|
124
|
+
// }
|
125
|
+
// }
|
126
|
+
|
88
127
|
@Override
|
89
|
-
public File extractAllActivity(List<Integer> activityTypeIds, Date startTime, Date endTime, int pollingTimeIntervalSecond, int bulkJobTimeoutSecond)
|
128
|
+
public File extractAllActivity(List<Integer> activityTypeIds, Date startTime, Date endTime, int pollingTimeIntervalSecond, int bulkJobTimeoutSecond, String landingZoneFile)
|
90
129
|
{
|
130
|
+
String tempFile = "/tmp/marketo_" + this.dateFormat.format(startTime) +".csv";
|
131
|
+
this.startTime = startTime;
|
132
|
+
|
133
|
+
try{
|
134
|
+
if (landingZoneFile.length()>0){
|
135
|
+
LOGGER.info("Let's check for temp File = {}", tempFile);
|
136
|
+
File f = new File(tempFile);
|
137
|
+
if (f.exists() && f.isFile() && f.canRead()){
|
138
|
+
return f;
|
139
|
+
}
|
140
|
+
// // Lets read and return csv file from s3
|
141
|
+
// s3_object = get_s3_object(getBucket(landingZoneFile), getKey(landingZoneFile));
|
142
|
+
// if(s3_object){
|
143
|
+
// return s3_object.getObjectContent();
|
144
|
+
// }
|
145
|
+
|
146
|
+
}
|
147
|
+
}
|
148
|
+
catch (Exception e){
|
149
|
+
System.out.println("Exception on retrieving from landing zone");
|
150
|
+
System.out.println("Let's continue normal execution.");
|
151
|
+
}
|
152
|
+
|
91
153
|
final String exportID = marketoRestClient.createActivityExtract(activityTypeIds, startTime, endTime);
|
92
154
|
marketoRestClient.startActitvityBulkExtract(exportID);
|
93
155
|
try {
|
@@ -110,10 +172,8 @@ public class MarketoServiceImpl implements MarketoService
|
|
110
172
|
|
111
173
|
private File downloadBulkExtract(Function<BulkExtractRangeHeader, InputStream> getBulkExtractfunction)
|
112
174
|
{
|
113
|
-
final File tempFile = Exec.getTempFileSpace().createTempFile(DEFAULT_FILE_FORMAT);
|
114
|
-
LOGGER.info("Temp File = {}", tempFile.getPath());
|
115
|
-
// File destination = new File("/tmp/example_test.csv");
|
116
175
|
|
176
|
+
final File tempFile = Exec.getTempFileSpace().createTempFile(DEFAULT_FILE_FORMAT);
|
117
177
|
|
118
178
|
long startByte = 0;
|
119
179
|
int resumeTime = 0;
|
@@ -122,13 +182,17 @@ public class MarketoServiceImpl implements MarketoService
|
|
122
182
|
InputStream bulkExtractResult = getBulkExtractfunction.apply(bulkExtractRangeHeader);
|
123
183
|
try {
|
124
184
|
saveExtractedFile(bulkExtractResult, tempFile);
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
185
|
+
if (this.startTime != null){
|
186
|
+
String destinationFileName = "/tmp/marketo_" + this.dateFormat.format(this.startTime) +".csv";
|
187
|
+
final File destination = new File(destinationFileName);
|
188
|
+
try{
|
189
|
+
FileUtils.copyFile(tempFile, destination);
|
190
|
+
LOGGER.info("Save activities in file: "+destinationFileName);
|
191
|
+
}
|
192
|
+
catch (IOException e){
|
193
|
+
LOGGER.error("Exception when copying to file destination {}\nException:{}",destination.getPath(),e );
|
194
|
+
}
|
195
|
+
}
|
132
196
|
return tempFile;
|
133
197
|
}
|
134
198
|
catch (DownloadBulkExtractException e) {
|
@@ -143,7 +143,11 @@ public class ActivityBulkExtractInputPlugin extends MarketoBaseBulkExtractInputP
|
|
143
143
|
protected InputStream getExtractedStream(MarketoService service, PluginTask task, DateTime fromDate, DateTime toDate)
|
144
144
|
{
|
145
145
|
try {
|
146
|
-
|
146
|
+
String landing_path = "";
|
147
|
+
if (task.getLandingPath().isPresent()) {
|
148
|
+
landing_path = task.getLandingPath().get();
|
149
|
+
}
|
150
|
+
return new FileInputStream(service.extractAllActivity(task.getActTypeIds(), fromDate.toDate(), toDate.toDate(), task.getPollingIntervalSecond(), task.getBulkJobTimeoutSecond(), landing_path));
|
147
151
|
}
|
148
152
|
catch (FileNotFoundException e) {
|
149
153
|
throw new RuntimeException("Exception when trying to extract activity", e);
|
@@ -65,6 +65,10 @@ public abstract class MarketoBaseBulkExtractInputPlugin<T extends MarketoBaseBul
|
|
65
65
|
@ConfigDefault("1")
|
66
66
|
Integer getFetchDays();
|
67
67
|
|
68
|
+
@Config("landing_zone")
|
69
|
+
@ConfigDefault("null")
|
70
|
+
Optional<String> getLandingPath();
|
71
|
+
|
68
72
|
@Config("latest_fetch_time")
|
69
73
|
@ConfigDefault("null")
|
70
74
|
Optional<Long> getLatestFetchTime();
|
@@ -444,7 +448,7 @@ public abstract class MarketoBaseBulkExtractInputPlugin<T extends MarketoBaseBul
|
|
444
448
|
int i = 0;
|
445
449
|
while (tokenizer.hasNextColumn()) {
|
446
450
|
if (i == headers.size()){
|
447
|
-
LOGGER.info("We have reached last column. {}", tokenizer.nextColumnOrNull());
|
451
|
+
// LOGGER.info("We have reached last column. {}", tokenizer.nextColumnOrNull());
|
448
452
|
break;
|
449
453
|
}
|
450
454
|
kvMap.put(headers.get(i), tokenizer.nextColumnOrNull());
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embulk-input-marketo_extended
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.28
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- uu59
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2020-11-
|
14
|
+
date: 2020-11-10 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,9 +140,9 @@ files:
|
|
140
140
|
- classpath/jetty-io-9.2.14.v20151106.jar
|
141
141
|
- classpath/commons-io-2.8.0.jar
|
142
142
|
- classpath/jetty-util-9.2.14.v20151106.jar
|
143
|
-
- classpath/embulk-input-marketo_extended-0.6.22.jar
|
144
143
|
- classpath/jetty-http-9.2.14.v20151106.jar
|
145
144
|
- classpath/jetty-client-9.2.14.v20151106.jar
|
145
|
+
- classpath/embulk-input-marketo_extended-0.6.28.jar
|
146
146
|
- classpath/embulk-base-restclient-0.5.3.jar
|
147
147
|
- classpath/embulk-util-retryhelper-jetty92-0.5.3.jar
|
148
148
|
homepage: https://github.com/treasure-data/embulk-input-marketo
|