Skip to content

Commit 9a28ea9

Browse files
authored
Java 8 and kotlin (#504)
* Adding java 8 and kotlin to the build. Updated to the latest version of gradle. Updated the listObjectsForDirectory helper method to be lazy. Updated the start_job commands to fully pass the Iterable along instead of copying it to a List. Added a paginated bucket delete call that minimizes the number of API calls that are used to delete all the objects in a bucket. Fixed an issue in the payload generation of the bulk request body to work around an issue when trying to serialize the payload from an Iterable. Updated the version of Jackson. * Updating dependencies to their latest version. Pulling most of the version information into a single file. Fixed a bug in the network code introduced by reving the http client version. * Updating the shadowjar build to reflect the most recent changes, and to make the service loader work correctly as well. * Updating the shadowjar build more so that all the versions reference the same variable * Working on the last few finishing touches on the shadowJar setup. We're excluding the ds3-interfaces and ds3-utils projects from the metadata build since those classes must be included as apart of the ds3-sdk project, and will already exist. * Updating the shadow build for the metadata module * Removing some unused import. Removing some un-needed type declarations. Performing some minor code cleanup * Adding copyright information * Adding another missing copyright * Updating to use a kotlin built in function instead of our own Guard class * Removing a debug print statement
1 parent b529731 commit 9a28ea9

File tree

40 files changed

+475
-234
lines changed

40 files changed

+475
-234
lines changed

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
language: java
22
jdk:
33
- oraclejdk8
4-
- oraclejdk7
5-
- openjdk7
64
script: ./gradlew -S clean jar ds3-sdk:test ds3-utils:test ds3-metadata:test

build.gradle

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,61 @@
1313
* ****************************************************************************
1414
*/
1515

16+
buildscript {
17+
ext.kotlin_version = '1.1.4-2'
18+
19+
repositories {
20+
mavenCentral()
21+
}
22+
23+
dependencies {
24+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
25+
}
26+
}
27+
28+
1629
allprojects {
1730
group = 'com.spectralogic.ds3'
18-
version = '4.0.0'
31+
version = '4.0.1'
1932
}
2033

2134
subprojects {
2235
apply plugin: 'maven'
2336
apply plugin: 'java'
37+
apply plugin: 'kotlin'
2438
apply plugin: 'findbugs'
2539

26-
sourceCompatibility = JavaVersion.VERSION_1_7
40+
sourceCompatibility = JavaVersion.VERSION_1_8
2741
repositories {
2842
mavenCentral()
2943
mavenLocal()
3044
}
3145

3246
dependencies {
33-
compile 'org.slf4j:slf4j-api:1.7.22'
34-
testCompile ('org.mockito:mockito-core:1.10.19') {
47+
compile "org.slf4j:slf4j-api:$slf4jVersion"
48+
testCompile ("org.mockito:mockito-core:$mockitoVersion") {
3549
exclude group: 'org.hamcrest'
3650
}
3751

38-
testCompile 'junit:junit:4.12'
39-
testCompile 'org.slf4j:slf4j-simple:1.7.22'
52+
testCompile "junit:junit:$junitVersion"
53+
testCompile "org.slf4j:slf4j-simple:$slf4jVersion"
4054
}
4155
}
4256

4357
task wrapper(type: Wrapper) {
44-
gradleVersion = '3.5'
58+
gradleVersion = '4.1'
4559
}
4660

4761
project(':ds3-sdk') {
4862
dependencies {
63+
compile project(':ds3-interfaces')
4964
compile project(':ds3-utils')
5065
}
5166
}
5267

5368
project(':ds3-metadata') {
5469
dependencies {
70+
compile project(':ds3-interfaces')
5571
compile project(':ds3-utils')
5672
}
5773
}

ds3-metadata/build.gradle

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
buildscript {
1717
repositories { jcenter() }
1818
dependencies {
19-
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3'
19+
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.1'
2020
}
2121
}
2222

@@ -26,14 +26,19 @@ shadowJar {
2626
relocate 'org.apache', 'ds3metafatjar.org.apache'
2727
relocate 'com.google', 'ds3metafatjar.com.google'
2828
relocate 'com.sun.jna', 'ds3metafatjar.net.java.dev.jna'
29+
relocate 'org.jetbrains', 'ds3metafatjar.org.jetbrains'
30+
relocate 'org.intellij', 'ds3metafatjar.org.intellij'
31+
relocate 'org.codehaus', 'ds3metafatjar.org.codehaus'
2932

3033
dependencies {
31-
exclude(dependency('org.hamcrest:hamcrest-library:1.3'))
32-
exclude(dependency('org.mockito:mockito-core:1.10.19'))
33-
exclude(dependency('junit:junit:4.12'))
34-
exclude(dependency('org.slf4j:slf4j-api:1.7.22'))
35-
exclude(dependency('org.slf4j:slf4j-simple:1.7.22'))
36-
exclude(dependency('org.apache.commons:commons-lang3:3.0'))
34+
exclude(project(":ds3-interfaces")) // this is being excluded since it must be used with the sdk, which already has this dependency included
35+
exclude(project(":ds3-utils")) // this is being excluded since it must be used with the sdk, which already has this dependency included
36+
exclude(dependency("org.hamcrest:hamcrest-library:$hamcrestVersion"))
37+
exclude(dependency("org.mockito:mockito-core:$mockitoVersion"))
38+
exclude(dependency("junit:junit:$junitVersion"))
39+
exclude(dependency("org.slf4j:slf4j-api:$slf4jVersion"))
40+
exclude(dependency("org.slf4j:slf4j-simple:$slf4jVersion"))
41+
exclude(dependency("org.apache.commons:commons-lang3:$commonslangVersion"))
3742
}
3843
}
3944

@@ -42,10 +47,10 @@ artifacts {
4247
}
4348

4449
dependencies {
45-
compile group: 'net.java.dev.jna', name: 'jna-platform', version: '4.2.2'
46-
compile group: 'net.java.dev.jna', name: 'jna', version: '4.2.2'
47-
compile 'commons-io:commons-io:2.4'
48-
compile 'org.apache.httpcomponents:httpclient:4.5.1'
50+
compile group: 'net.java.dev.jna', name: 'jna-platform', version: "$jnaVersion"
51+
compile group: 'net.java.dev.jna', name: 'jna', version: "$jnaVersion"
52+
compile "commons-io:commons-io:$commonsioVersion"
53+
compile "org.apache.httpcomponents:httpclient:$httpclientVersion"
4954

50-
testCompile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
55+
testCompile group: 'org.apache.commons', name: 'commons-lang3', version: "$commonslangVersion"
5156
}

ds3-sdk-integration/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
*/
1515

1616
dependencies {
17-
compile 'commons-codec:commons-codec:1.10'
18-
compile 'junit:junit:4.12'
19-
testCompile 'org.hamcrest:hamcrest-library:1.3'
20-
testCompile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
17+
compile "commons-codec:commons-codec:$commonscodecVersion"
18+
compile "junit:junit:$junitVersion"
19+
testCompile "org.hamcrest:hamcrest-library:$hamcrestVersion"
20+
testCompile group: 'org.apache.commons', name: 'commons-lang3', version: "$commonslangVersion"
2121
}
2222

ds3-sdk-integration/src/main/java/com/spectralogic/ds3client/integration/Util.java

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.spectralogic.ds3client.commands.DeleteBucketRequest;
2121
import com.spectralogic.ds3client.commands.DeleteObjectRequest;
2222
import com.spectralogic.ds3client.commands.spectrads3.GetSystemInformationSpectraS3Request;
23+
import com.spectralogic.ds3client.helpers.DeleteBucket;
2324
import com.spectralogic.ds3client.helpers.Ds3ClientHelpers;
2425
import com.spectralogic.ds3client.helpers.channelbuilders.PrefixAdderObjectChannelBuilder;
2526
import com.spectralogic.ds3client.models.Contents;
@@ -40,7 +41,7 @@
4041
import static org.junit.Assume.assumeTrue;
4142

4243

43-
public class Util {
44+
public final class Util {
4445
private static final Logger LOG = LoggerFactory.getLogger(Util.class);
4546
public static final String RESOURCE_BASE_NAME = "books/";
4647
public static final String[] BOOKS = {"beowulf.txt", "sherlock_holmes.txt", "tale_of_two_cities.txt", "ulysses.txt"};
@@ -110,22 +111,11 @@ public static void loadBookTestDataWithPrefix(final Ds3Client client, final Stri
110111
}
111112

112113
public static void deleteAllContents(final Ds3Client client, final String bucketName) throws IOException {
113-
final Ds3ClientHelpers helpers = Ds3ClientHelpers.wrap(client);
114-
115-
final Iterable<Contents> objects = helpers.listObjects(bucketName);
116-
for(final Contents contents : objects) {
117-
client.deleteObject(new DeleteObjectRequest(bucketName, contents.getKey()));
118-
}
119-
120-
client.deleteBucket(new DeleteBucketRequest(bucketName));
114+
Ds3ClientHelpers.wrap(client).deleteBucket(bucketName);
121115
}
122116

123117
public static void deleteBucketContents(final Ds3Client client, final String bucketName) throws IOException {
124118
final Ds3ClientHelpers helpers = Ds3ClientHelpers.wrap(client);
125-
126-
final Iterable<Contents> objects = helpers.listObjects(bucketName);
127-
for(final Contents contents : objects) {
128-
client.deleteObject(new DeleteObjectRequest(bucketName, contents.getKey()));
129-
}
119+
DeleteBucket.INSTANCE.deleteBucketContents(helpers, bucketName);
130120
}
131121
}

ds3-sdk-integration/src/test/java/com/spectralogic/ds3client/integration/test/helpers/TempStorageUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* and partition for use in the integration tests to avoid error if the BP does not currently
3131
* have a partition available for running the unit tests.
3232
*/
33-
public class TempStorageUtil {
33+
public final class TempStorageUtil {
3434

3535
private static final String DATA_POLICY_NAME = "_dp";
3636
private static final String STORAGE_DOMAIN_NAME = "_sd";

ds3-sdk-samples/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ apply plugin: 'application'
1818
mainClassName = 'com.spectralogic.ds3client.samples.PartialObjectGetExample'
1919

2020
dependencies {
21-
compile 'org.slf4j:slf4j-simple:1.7.22'
21+
compile "org.slf4j:slf4j-simple:$slf4jVersion"
2222
}

ds3-sdk/build.gradle

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,33 @@ import java.nio.file.Path
1919
buildscript {
2020
repositories { jcenter() }
2121
dependencies {
22-
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3'
22+
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.1'
2323
}
2424
}
2525

2626
apply plugin: 'com.github.johnrengelman.shadow'
2727

2828
shadowJar {
2929
relocate 'com.google', 'ds3fatjar.com.google'
30-
relocate 'org.apache', 'ds3fatjar.org.apache'
30+
relocate 'org.jetbrains', 'ds3fatjar.org.jetbrains'
31+
relocate 'org.intellij', 'ds3fatjar.org.intellij'
3132
relocate 'org.codehaus', 'ds3fatjar.org.codehaus'
33+
relocate 'kotlin', 'ds3fatjar.kotlin'
34+
relocate 'edu.umd', 'ds3fatjar.edu.emd'
35+
relocate 'net.jcip', 'ds3fatjar.net.jcip'
36+
relocate 'com.ctc', 'ds3fatjar.com.ctc'
37+
relocate 'org.apache', 'ds3fatjar.org.apache'
3238
relocate 'com.fasterxml', 'ds3fatjar.com.fasterxml'
3339
dependencies {
34-
exclude(dependency('org.hamcrest:hamcrest-library:1.3'))
35-
exclude(dependency('org.mockito:mockito-core:1.10.19'))
36-
exclude(dependency('junit:junit:4.12'))
37-
exclude(dependency('org.slf4j:slf4j-api:1.7.22'))
38-
exclude(dependency('org.slf4j:slf4j-simple:1.7.22'))
39-
exclude(dependency('org.apache.commons:commons-lang3:3.0'))
40+
exclude(dependency("org.hamcrest:hamcrest-library:$hamcrestVersion"))
41+
exclude(dependency("org.mockito:mockito-core:$mockitoVersion"))
42+
exclude(dependency("junit:junit:$junitVersion"))
43+
exclude(dependency("org.slf4j:slf4j-api:$slf4jVersion"))
44+
exclude(dependency("org.slf4j:slf4j-simple:$slf4jVersion"))
45+
exclude(dependency("org.apache.commons:commons-lang3:$commonslangVersion"))
4046
}
47+
48+
mergeServiceFiles()
4149
}
4250

4351
artifacts {
@@ -78,10 +86,12 @@ jar {
7886
jar.dependsOn genConfigProperties
7987

8088
dependencies {
81-
compile 'org.apache.httpcomponents:httpclient:4.5.1'
89+
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
90+
compile "org.apache.httpcomponents:httpclient:$httpclientVersion"
91+
compile "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:$jacksonVersion"
92+
compile "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:$jacksonVersion"
93+
compile "com.google.guava:guava:$guavaVersion"
8294
compile 'org.codehaus.woodstox:woodstox-core-asl:4.4.1'
83-
compile 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.7.1'
84-
compile 'com.google.guava:guava:20.0'
8595
compile 'com.google.code.findbugs:annotations:3.0.1'
86-
testCompile 'org.hamcrest:hamcrest-library:1.3'
96+
testCompile "org.hamcrest:hamcrest-library:$hamcrestVersion"
8797
}

ds3-sdk/src/main/java/com/spectralogic/ds3client/commands/interfaces/AbstractRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ private static RequestHeaders buildDefaultHeaders() {
3636

3737
@Override
3838
public String getContentType() {
39-
return ContentType.APPLICATION_XML.toString();
39+
return ContentType.APPLICATION_XML.getMimeType();
4040
}
4141

4242
@Override

ds3-sdk/src/main/java/com/spectralogic/ds3client/helpers/Ds3ClientHelpers.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,12 @@ public abstract Iterable<Contents> listObjects(final String bucket, final String
508508
*/
509509
public abstract Iterable<FileSystemKey> remoteListDirectory(final String bucket, final String keyPrefix, final String delimiter, final String nextMarker, final int maxKeys) throws IOException;
510510

511+
/**
512+
*
513+
* @param bucket
514+
*/
515+
public abstract void deleteBucket(final String bucket) throws IOException;
516+
511517
/**
512518
* Returns an Iterable of {@link Ds3Object} that have a prefix added.
513519
*/
@@ -525,20 +531,12 @@ public abstract Iterable<Contents> listObjects(final String bucket, final String
525531
@SafeVarargs
526532
public final Iterable<Ds3Object> toDs3Iterable(final Iterable<Contents> objects, final Predicate<Contents>... filters) {
527533

528-
FluentIterable<Contents> fluentIterable = FluentIterable.from(objects).filter(new com.google.common.base.Predicate<Contents>() {
529-
@Override
530-
public boolean apply(@Nullable final Contents input) {
531-
return input != null;
532-
}
533-
});
534+
FluentIterable<Contents> fluentIterable = FluentIterable.from(objects).filter(input -> input != null);
534535

535536
if (filters != null) {
536537
for (final Predicate<Contents> filter : filters) {
537-
fluentIterable = fluentIterable.filter(new com.google.common.base.Predicate<Contents>() {
538-
@Override
539-
public boolean apply(@Nullable final Contents input) {
540-
return filter == null || filter.test(input); // do not filter anything if filter is null
541-
}
538+
fluentIterable = fluentIterable.filter(input -> {
539+
return filter == null || filter.test(input); // do not filter anything if filter is null
542540
});
543541
}
544542
}
@@ -585,4 +583,9 @@ public abstract ObjectStorageSpaceVerificationResult objectsFromBucketWillFitInD
585583
* Creates a folder in the specified bucket
586584
*/
587585
public abstract void createFolder(final String bucketName, final String folderName) throws IOException;
586+
587+
/**
588+
* Returns the client being wrapped
589+
*/
590+
public abstract Ds3Client getClient();
588591
}

0 commit comments

Comments
 (0)