-
Notifications
You must be signed in to change notification settings - Fork 43
Twitter Modificaitons #8
Changes from all commits
741a454
544a0c9
651be79
4f30bd2
1a03d5f
361d122
d1018e9
ae27541
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!-- | ||
| ~ Licensed to the Apache Software Foundation (ASF) under one | ||
| ~ or more contributor license agreements. See the NOTICE file | ||
| ~ distributed with this work for additional information | ||
| ~ regarding copyright ownership. The ASF licenses this file | ||
| ~ to you under the Apache License, Version 2.0 (the | ||
| ~ "License"); you may not use this file except in compliance | ||
| ~ | ||
| ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
| ~ | ||
| ~ Unless required by applicable law or agreed to in writing, | ||
| ~ software distributed under the License is distributed on an | ||
| ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| ~ KIND, either express or implied. See the License for the | ||
| ~ specific language governing permissions and limitations | ||
| ~ under the License. | ||
| --> | ||
|
|
||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <parent> | ||
| <artifactId>streams-contrib</artifactId> | ||
| <groupId>org.apache.streams</groupId> | ||
| <version>0.1-SNAPSHOT</version> | ||
| </parent> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <artifactId>streams-amazon-aws</artifactId> | ||
|
|
||
| <packaging>pom</packaging> | ||
| <name>streams-amazon-aws</name> | ||
|
|
||
| <properties> | ||
|
|
||
| </properties> | ||
|
|
||
| <modules> | ||
| <module>streams-persist-s3</module> | ||
| </modules> | ||
|
|
||
| <dependencyManagement> | ||
| <dependencies> | ||
| <dependency> | ||
| <groupId>com.amazonaws</groupId> | ||
| <artifactId>aws-java-sdk</artifactId> | ||
| <version>1.7.5</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.apache.streams</groupId> | ||
| <artifactId>streams-config</artifactId> | ||
| <version>${project.version}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.apache.streams</groupId> | ||
| <artifactId>streams-core</artifactId> | ||
| <version>${project.version}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.apache.streams</groupId> | ||
| <artifactId>streams-pojo</artifactId> | ||
| <version>${project.version}</version> | ||
| </dependency> | ||
| </dependencies> | ||
| </dependencyManagement> | ||
| </project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!-- | ||
| ~ Licensed to the Apache Software Foundation (ASF) under one | ||
| ~ or more contributor license agreements. See the NOTICE file | ||
| ~ distributed with this work for additional information | ||
| ~ regarding copyright ownership. The ASF licenses this file | ||
| ~ to you under the Apache License, Version 2.0 (the | ||
| ~ "License"); you may not use this file except in compliance | ||
| ~ | ||
| ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
| ~ | ||
| ~ Unless required by applicable law or agreed to in writing, | ||
| ~ software distributed under the License is distributed on an | ||
| ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| ~ KIND, either express or implied. See the License for the | ||
| ~ specific language governing permissions and limitations | ||
| ~ under the License. | ||
| --> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <parent> | ||
| <artifactId>streams-amazon-aws</artifactId> | ||
| <groupId>org.apache.streams</groupId> | ||
| <version>0.1-SNAPSHOT</version> | ||
| </parent> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <artifactId>streams-persist-s3</artifactId> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.apache.streams</groupId> | ||
| <artifactId>streams-config</artifactId> | ||
| <version>${project.version}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.apache.streams</groupId> | ||
| <artifactId>streams-core</artifactId> | ||
| <version>${project.version}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.apache.streams</groupId> | ||
| <artifactId>streams-pojo</artifactId> | ||
| <version>${project.version}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.amazonaws</groupId> | ||
| <artifactId>aws-java-sdk</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.apache.streams</groupId> | ||
| <artifactId>streams-util</artifactId> | ||
| <version>${project.version}</version> | ||
| </dependency> | ||
| </dependencies> | ||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.codehaus.mojo</groupId> | ||
| <artifactId>build-helper-maven-plugin</artifactId> | ||
| <version>1.8</version> | ||
| <executions> | ||
| <execution> | ||
| <id>add-source</id> | ||
| <phase>generate-sources</phase> | ||
| <goals> | ||
| <goal>add-source</goal> | ||
| </goals> | ||
| <configuration> | ||
| <sources> | ||
| <source>target/generated-sources/jsonschema2pojo</source> | ||
| </sources> | ||
| </configuration> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>org.jsonschema2pojo</groupId> | ||
| <artifactId>jsonschema2pojo-maven-plugin</artifactId> | ||
| <configuration> | ||
| <addCompileSourceRoot>true</addCompileSourceRoot> | ||
| <generateBuilders>true</generateBuilders> | ||
| <sourcePaths> | ||
| <sourcePath>src/main/jsonschema/org/apache/streams/s3/S3Configuration.json</sourcePath> | ||
| <sourcePath>src/main/jsonschema/org/apache/streams/s3/S3WriterConfiguration.json</sourcePath> | ||
| <sourcePath>src/main/jsonschema/org/apache/streams/s3/S3ReaderConfiguration.json</sourcePath> | ||
| </sourcePaths> | ||
| <outputDirectory>target/generated-sources/jsonschema2pojo</outputDirectory> | ||
| <targetPackage>org.apache.streams.s3.pojo</targetPackage> | ||
| <useLongIntegers>true</useLongIntegers> | ||
| <useJodaDates>true</useJodaDates> | ||
| </configuration> | ||
| <executions> | ||
| <execution> | ||
| <goals> | ||
| <goal>generate</goal> | ||
| </goals> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </project> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.apache.streams.s3; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. License
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where do I get a license?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import com.typesafe.config.Config; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| public class S3Configurator { | ||
|
|
||
| private final static Logger LOGGER = LoggerFactory.getLogger(S3Configurator.class); | ||
|
|
||
| private final static ObjectMapper mapper = new ObjectMapper(); | ||
|
|
||
| public static S3Configuration detectConfiguration(Config s3) { | ||
|
|
||
| S3Configuration s3Configuration = new S3Configuration(); | ||
|
|
||
| s3Configuration.setBucket(s3.getString("bucket")); | ||
| s3Configuration.setKey(s3.getString("key")); | ||
| s3Configuration.setSecretKey(s3.getString("secretKey")); | ||
|
|
||
| // The Amazon S3 Library defaults to HTTPS | ||
| String protocol = (!s3.hasPath("protocol") ? "https": s3.getString("protocol")).toLowerCase(); | ||
|
|
||
| if(!(protocol.equals("https") || protocol.equals("http"))) { | ||
| // you must specify either HTTP or HTTPS | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you mean to do something here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, another commit coming with a RUN-TIME exception. |
||
| throw new RuntimeException("You must specify either HTTP or HTTPS as a protocol"); | ||
| } | ||
|
|
||
| s3Configuration.setProtocol(protocol.toLowerCase()); | ||
|
|
||
| return s3Configuration; | ||
| } | ||
|
|
||
| public static S3ReaderConfiguration detectReaderConfiguration(Config s3) { | ||
|
|
||
| S3Configuration S3Configuration = detectConfiguration(s3); | ||
| S3ReaderConfiguration s3ReaderConfiguration = mapper.convertValue(S3Configuration, S3ReaderConfiguration.class); | ||
|
|
||
| s3ReaderConfiguration.setReaderPath(s3.getString("readerPath")); | ||
|
|
||
| return s3ReaderConfiguration; | ||
| } | ||
|
|
||
| public static S3WriterConfiguration detectWriterConfiguration(Config s3) { | ||
|
|
||
| S3Configuration s3Configuration = detectConfiguration(s3); | ||
| S3WriterConfiguration s3WriterConfiguration = mapper.convertValue(s3Configuration, S3WriterConfiguration.class); | ||
|
|
||
| String rootPath = s3.getString("writerPath"); | ||
|
|
||
| // if the root path doesn't end in a '/' then we need to force the '/' at the end of the path. | ||
| s3WriterConfiguration.setWriterPath(rootPath + (rootPath.endsWith("/") ? "" : "/")); | ||
|
|
||
| s3WriterConfiguration.setWriterFilePrefix(s3.hasPath("writerFilePrefix") ? s3.getString("writerFilePrefix") : "default"); | ||
|
|
||
| if(s3.hasPath("maxFileSize")) | ||
| s3WriterConfiguration.setMaxFileSize((long)s3.getInt("maxFileSize")); | ||
| if(s3.hasPath("chunk")) | ||
| s3WriterConfiguration.setChunk(s3.getBoolean("chunk")); | ||
|
|
||
| return s3WriterConfiguration; | ||
| } | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need license