embulk-input-marketo_extended 0.6.22 → 0.6.23

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: a6efba1be34ca3cd08c0883805641173eb6259c0
4
- data.tar.gz: d65d6decb9c9c8fb7b135d60a42488c8ddb7f5de
3
+ metadata.gz: 5b0c3ee50cdeedfe6defe0a8a9897d72215b2cf2
4
+ data.tar.gz: 1f5d6cc8b29e54d620a77e1e914669188b846b91
5
5
  SHA512:
6
- metadata.gz: 0d3558a194417bec40a6943482d8e082c1ada38acb323c410f81672ab46f8ce59445334c0b89df6cc5ff7ab4279a6e9346f2c42119b8020460605530ea8a9068
7
- data.tar.gz: 7210c0fcc06ad5df7d18285e18300973d249950df83641744acd72d5492d6b1aba2852500407893a127e48508241040537ace24edd47b2aa607bd420102f13e3
6
+ metadata.gz: c9a329a13abe4324ac2c662a1ed97d7bc9adda3b4e37da4d8d4428ba9d9d3d32600334093b38e4068b07e69918d1056e98468a293328ac89eab8c9ee88e5d0c5
7
+ data.tar.gz: a0f0fbf7645cf7915145f8f648f644b9a1f1fa2c1f57f87bb10404936020fdd18dd066103831134c381738d5822bbb618746141469def4b27d94de5c1faa7f91
@@ -16,11 +16,13 @@ repositories {
16
16
  configurations {
17
17
  provided
18
18
  }
19
- version = "0.6.22"
19
+ version = "0.6.23"
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"
@@ -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
- // try{
126
- // FileUtils.copyFile(tempFile, destination);
127
- // }
128
- // catch (IOException e){
129
- // LOGGER.error("Exception when copying to file destination {}\nException:{}",destination.getPath(),e );
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,7 @@ public class ActivityBulkExtractInputPlugin extends MarketoBaseBulkExtractInputP
143
143
  protected InputStream getExtractedStream(MarketoService service, PluginTask task, DateTime fromDate, DateTime toDate)
144
144
  {
145
145
  try {
146
- return new FileInputStream(service.extractAllActivity(task.getActTypeIds(), fromDate.toDate(), toDate.toDate(), task.getPollingIntervalSecond(), task.getBulkJobTimeoutSecond()));
146
+ return new FileInputStream(service.extractAllActivity(task.getActTypeIds(), fromDate.toDate(), toDate.toDate(), task.getPollingIntervalSecond(), task.getBulkJobTimeoutSecond(), task.getLandingPath()));
147
147
  }
148
148
  catch (FileNotFoundException e) {
149
149
  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
+ String getLandingPath();
71
+
68
72
  @Config("latest_fetch_time")
69
73
  @ConfigDefault("null")
70
74
  Optional<Long> getLatestFetchTime();
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.22
4
+ version: 0.6.23
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-06 00:00:00.000000000 Z
14
+ date: 2020-11-09 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  requirement: !ruby/object:Gem::Requirement
@@ -140,7 +140,7 @@ 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
143
+ - classpath/embulk-input-marketo_extended-0.6.23.jar
144
144
  - classpath/jetty-http-9.2.14.v20151106.jar
145
145
  - classpath/jetty-client-9.2.14.v20151106.jar
146
146
  - classpath/embulk-base-restclient-0.5.3.jar