mirror of
https://github.com/google/nomulus
synced 2026-01-06 05:27:13 +00:00
Upgrade dependencies (#2468)
This commit is contained in:
@@ -135,14 +135,12 @@ dependencies {
|
||||
implementation deps['com.google.api.grpc:proto-google-common-protos']
|
||||
implementation deps['com.google.api.grpc:proto-google-cloud-secretmanager-v1']
|
||||
implementation deps['com.google.api-client:google-api-client']
|
||||
implementation deps['com.google.api-client:google-api-client-appengine']
|
||||
implementation deps['com.google.api-client:google-api-client-servlet']
|
||||
implementation deps['com.google.monitoring-client:metrics']
|
||||
implementation deps['com.google.monitoring-client:stackdriver']
|
||||
implementation deps['com.google.api-client:google-api-client-java6']
|
||||
implementation deps['com.google.api.grpc:proto-google-cloud-tasks-v2']
|
||||
implementation deps['com.google.apis:google-api-services-admin-directory']
|
||||
implementation deps['com.google.apis:google-api-services-appengine']
|
||||
implementation deps['com.google.apis:google-api-services-bigquery']
|
||||
implementation deps['com.google.apis:google-api-services-dataflow']
|
||||
implementation deps['com.google.apis:google-api-services-dns']
|
||||
@@ -176,12 +174,10 @@ dependencies {
|
||||
implementation deps['com.google.cloud:google-cloud-storage']
|
||||
implementation deps['com.google.cloud:google-cloud-tasks']
|
||||
implementation deps['com.google.http-client:google-http-client']
|
||||
implementation deps['com.google.http-client:google-http-client-appengine']
|
||||
implementation deps['com.google.http-client:google-http-client-jackson2']
|
||||
implementation deps['com.google.oauth-client:google-oauth-client']
|
||||
implementation deps['com.google.oauth-client:google-oauth-client-java6']
|
||||
implementation deps['com.google.oauth-client:google-oauth-client-jetty']
|
||||
implementation deps['com.google.oauth-client:google-oauth-client-appengine']
|
||||
implementation deps['com.google.oauth-client:google-oauth-client-servlet']
|
||||
implementation deps['com.google.protobuf:protobuf-java']
|
||||
implementation deps['com.google.re2j:re2j']
|
||||
|
||||
@@ -40,11 +40,10 @@ com.github.jnr:jnr-unixsocket:0.38.22=compileClasspath,deploy_jar,nonprodCompile
|
||||
com.github.jnr:jnr-x86asm:1.0.2=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.github.kevinstern:software-and-algorithms:1.0=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
|
||||
com.google.android:annotations:4.1.1.4=deploy_jar,nonprodRuntimeClasspath,runtimeClasspath,testRuntimeClasspath
|
||||
com.google.api-client:google-api-client-appengine:2.6.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.api-client:google-api-client-jackson2:2.0.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.api-client:google-api-client-java6:2.1.4=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.api-client:google-api-client-servlet:2.6.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.api-client:google-api-client:1.35.2=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.api-client:google-api-client:2.6.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.api.grpc:gapic-google-cloud-storage-v2:2.32.1-alpha=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath
|
||||
com.google.api.grpc:gapic-google-cloud-storage-v2:2.39.0-alpha=testCompileClasspath,testRuntimeClasspath
|
||||
com.google.api.grpc:grpc-google-cloud-bigquerystorage-v1:3.4.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
@@ -88,12 +87,11 @@ com.google.api:gax-grpc:2.48.1=compileClasspath,deploy_jar,nonprodCompileClasspa
|
||||
com.google.api:gax-httpjson:2.48.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.api:gax:2.48.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.apis:google-api-services-admin-directory:directory_v1-rev20240509-2.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.apis:google-api-services-appengine:v1-rev20240415-2.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.apis:google-api-services-bigquery:v2-rev20240229-2.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.apis:google-api-services-bigquery:v2-rev20240423-2.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.apis:google-api-services-cloudresourcemanager:v1-rev20240310-2.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.apis:google-api-services-dataflow:v1b3-rev20240218-2.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.apis:google-api-services-dns:v2beta1-rev99-1.25.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.apis:google-api-services-drive:v2-rev393-1.25.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.apis:google-api-services-dataflow:v1b3-rev20240430-2.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.apis:google-api-services-dns:v1-rev20240419-2.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.apis:google-api-services-drive:v3-rev20240521-2.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.apis:google-api-services-gmail:v1-rev20240520-2.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.apis:google-api-services-groupssettings:v1-rev20210624-2.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.apis:google-api-services-healthcare:v1-rev20240130-2.0.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
@@ -112,7 +110,8 @@ com.google.auto.service:auto-service-annotations:1.1.1=annotationProcessor,compi
|
||||
com.google.auto.service:auto-service:1.1.1=annotationProcessor
|
||||
com.google.auto.value:auto-value-annotations:1.10.4=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.auto.value:auto-value-annotations:1.9=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
|
||||
com.google.auto.value:auto-value:1.10.4=annotationProcessor,compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.auto.value:auto-value:1.10.4=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.auto.value:auto-value:1.11.0=annotationProcessor,testAnnotationProcessor
|
||||
com.google.auto:auto-common:1.2.1=annotationProcessor,errorprone,nonprodAnnotationProcessor,testAnnotationProcessor
|
||||
com.google.closure-stylesheets:closure-stylesheets:1.5.0=css
|
||||
com.google.cloud.bigdataoss:gcsio:2.2.16=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
@@ -170,19 +169,19 @@ com.google.googlejavaformat:google-java-format:1.5=annotationProcessor,testAnnot
|
||||
com.google.guava:failureaccess:1.0.1=checkstyle,errorprone,nonprodAnnotationProcessor,soy
|
||||
com.google.guava:failureaccess:1.0.2=annotationProcessor,compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.guava:guava-parent:32.1.1-jre=errorprone,nonprodAnnotationProcessor
|
||||
com.google.guava:guava-testlib:33.2.0-jre=testCompileClasspath,testRuntimeClasspath
|
||||
com.google.guava:guava-testlib:33.2.1-jre=testCompileClasspath,testRuntimeClasspath
|
||||
com.google.guava:guava:20.0=css
|
||||
com.google.guava:guava:31.0.1-jre=checkstyle,soy
|
||||
com.google.guava:guava:32.1.1-jre=errorprone,nonprodAnnotationProcessor
|
||||
com.google.guava:guava:33.0.0-jre=annotationProcessor,testAnnotationProcessor
|
||||
com.google.guava:guava:33.2.0-android=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath
|
||||
com.google.guava:guava:33.2.0-jre=testCompileClasspath,testRuntimeClasspath
|
||||
com.google.guava:guava:33.2.1-jre=testCompileClasspath,testRuntimeClasspath
|
||||
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,soy,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.gwt:gwt-user:2.10.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.http-client:google-http-client-apache-v2:1.43.3=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath
|
||||
com.google.http-client:google-http-client-apache-v2:1.44.1=testCompileClasspath,testRuntimeClasspath
|
||||
com.google.http-client:google-http-client-appengine:1.44.2=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.http-client:google-http-client-gson:1.44.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.http-client:google-http-client-apache-v2:1.44.2=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.http-client:google-http-client-appengine:1.43.3=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath
|
||||
com.google.http-client:google-http-client-appengine:1.44.1=testCompileClasspath,testRuntimeClasspath
|
||||
com.google.http-client:google-http-client-gson:1.44.2=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.http-client:google-http-client-jackson2:1.44.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.http-client:google-http-client-protobuf:1.44.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.http-client:google-http-client:1.44.2=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
@@ -200,7 +199,6 @@ com.google.jsinterop:jsinterop-annotations:2.0.0=compileClasspath,deploy_jar,non
|
||||
com.google.monitoring-client:contrib:1.0.7=testCompileClasspath,testRuntimeClasspath
|
||||
com.google.monitoring-client:metrics:1.0.7=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.monitoring-client:stackdriver:1.0.7=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.oauth-client:google-oauth-client-appengine:1.36.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.oauth-client:google-oauth-client-java6:1.36.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.oauth-client:google-oauth-client-jetty:1.36.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
com.google.oauth-client:google-oauth-client-servlet:1.36.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
@@ -400,18 +398,18 @@ org.conscrypt:conscrypt-openjdk-uber:2.5.2=compileClasspath,deploy_jar,nonprodCo
|
||||
org.easymock:easymock:3.0=css
|
||||
org.eclipse.collections:eclipse-collections-api:11.1.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.eclipse.collections:eclipse-collections:11.1.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.eclipse.jetty.ee10:jetty-ee10-servlet:12.0.9=testCompileClasspath,testRuntimeClasspath
|
||||
org.eclipse.jetty.ee10:jetty-ee10-webapp:12.0.9=testCompileClasspath,testRuntimeClasspath
|
||||
org.eclipse.jetty:jetty-ee:12.0.9=testCompileClasspath,testRuntimeClasspath
|
||||
org.eclipse.jetty:jetty-http:12.0.9=testCompileClasspath,testRuntimeClasspath
|
||||
org.eclipse.jetty:jetty-io:12.0.9=testCompileClasspath,testRuntimeClasspath
|
||||
org.eclipse.jetty:jetty-security:12.0.9=testCompileClasspath,testRuntimeClasspath
|
||||
org.eclipse.jetty:jetty-server:12.0.9=testCompileClasspath,testRuntimeClasspath
|
||||
org.eclipse.jetty:jetty-session:12.0.9=testCompileClasspath,testRuntimeClasspath
|
||||
org.eclipse.jetty:jetty-util:12.0.9=testCompileClasspath,testRuntimeClasspath
|
||||
org.eclipse.jetty:jetty-xml:12.0.9=testCompileClasspath,testRuntimeClasspath
|
||||
org.flywaydb:flyway-core:10.13.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.flywaydb:flyway-database-postgresql:10.13.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.eclipse.jetty.ee10:jetty-ee10-servlet:12.0.10=testCompileClasspath,testRuntimeClasspath
|
||||
org.eclipse.jetty.ee10:jetty-ee10-webapp:12.0.10=testCompileClasspath,testRuntimeClasspath
|
||||
org.eclipse.jetty:jetty-ee:12.0.10=testCompileClasspath,testRuntimeClasspath
|
||||
org.eclipse.jetty:jetty-http:12.0.10=testCompileClasspath,testRuntimeClasspath
|
||||
org.eclipse.jetty:jetty-io:12.0.10=testCompileClasspath,testRuntimeClasspath
|
||||
org.eclipse.jetty:jetty-security:12.0.10=testCompileClasspath,testRuntimeClasspath
|
||||
org.eclipse.jetty:jetty-server:12.0.10=testCompileClasspath,testRuntimeClasspath
|
||||
org.eclipse.jetty:jetty-session:12.0.10=testCompileClasspath,testRuntimeClasspath
|
||||
org.eclipse.jetty:jetty-util:12.0.10=testCompileClasspath,testRuntimeClasspath
|
||||
org.eclipse.jetty:jetty-xml:12.0.10=testCompileClasspath,testRuntimeClasspath
|
||||
org.flywaydb:flyway-core:10.14.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.flywaydb:flyway-database-postgresql:10.14.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.glassfish.jaxb:jaxb-runtime:2.3.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.glassfish.jaxb:txw2:2.3.1=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
org.gwtproject:gwt-user:2.10.0=compileClasspath,deploy_jar,nonprodCompileClasspath,nonprodRuntimeClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
|
||||
|
||||
@@ -401,7 +401,7 @@ public class CloudDnsWriter extends BaseDnsWriter {
|
||||
if (err == null || err.getErrors().size() > 1) {
|
||||
throw e;
|
||||
}
|
||||
String errorReason = err.getErrors().get(0).getReason();
|
||||
String errorReason = err.getErrors().getFirst().getReason();
|
||||
|
||||
if (RETRYABLE_EXCEPTION_REASONS.contains(errorReason)) {
|
||||
throw new ZoneStateException(errorReason);
|
||||
|
||||
@@ -16,11 +16,9 @@ package google.registry.storage.drive;
|
||||
|
||||
import com.google.api.client.http.ByteArrayContent;
|
||||
import com.google.api.services.drive.Drive;
|
||||
import com.google.api.services.drive.Drive.Children;
|
||||
import com.google.api.services.drive.model.ChildList;
|
||||
import com.google.api.services.drive.model.ChildReference;
|
||||
import com.google.api.services.drive.Drive.Files;
|
||||
import com.google.api.services.drive.model.File;
|
||||
import com.google.api.services.drive.model.ParentReference;
|
||||
import com.google.api.services.drive.model.FileList;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.net.MediaType;
|
||||
@@ -37,16 +35,19 @@ public class DriveConnection {
|
||||
|
||||
/** Drive client instance wrapped by this class. */
|
||||
@Inject Drive drive;
|
||||
@Inject public DriveConnection() {}
|
||||
|
||||
@Inject
|
||||
public DriveConnection() {}
|
||||
|
||||
/**
|
||||
* Creates a folder with the given parent.
|
||||
*
|
||||
* @return the folder id.
|
||||
*/
|
||||
public String createFolder(String title, String parentFolderId) throws IOException {
|
||||
return drive.files()
|
||||
.insert(createFileReference(title, GOOGLE_FOLDER, parentFolderId))
|
||||
public String createFolder(String name, @Nullable String parentFolderId) throws IOException {
|
||||
return drive
|
||||
.files()
|
||||
.create(createFileReference(name, GOOGLE_FOLDER, parentFolderId))
|
||||
.execute()
|
||||
.getId();
|
||||
}
|
||||
@@ -60,11 +61,12 @@ public class DriveConnection {
|
||||
*
|
||||
* @return the file id.
|
||||
*/
|
||||
public String createFile(String title, MediaType mimeType, String parentFolderId, byte[] bytes)
|
||||
public String createFile(String name, MediaType mimeType, String parentFolderId, byte[] bytes)
|
||||
throws IOException {
|
||||
return drive.files()
|
||||
.insert(
|
||||
createFileReference(title, mimeType, parentFolderId),
|
||||
return drive
|
||||
.files()
|
||||
.create(
|
||||
createFileReference(name, mimeType, parentFolderId),
|
||||
new ByteArrayContent(mimeType.toString(), bytes))
|
||||
.execute()
|
||||
.getId();
|
||||
@@ -72,79 +74,79 @@ public class DriveConnection {
|
||||
|
||||
/**
|
||||
* Creates a file with the given parent or updates the existing one if a file already exists with
|
||||
* that same title and parent.
|
||||
* that same name and parent.
|
||||
*
|
||||
* @throws IllegalStateException if multiple files with that name exist in the given folder.
|
||||
* @throws IOException if communication with Google Drive fails for any reason.
|
||||
* @return the file id.
|
||||
*/
|
||||
public String createOrUpdateFile(
|
||||
String title, MediaType mimeType, String parentFolderId, byte[] bytes) throws IOException {
|
||||
List<String> existingFiles = listFiles(parentFolderId, String.format("title = '%s'", title));
|
||||
String name, MediaType mimeType, String parentFolderId, byte[] bytes) throws IOException {
|
||||
List<String> existingFiles = listFiles(parentFolderId, String.format("name = '%s'", name));
|
||||
if (existingFiles.size() > 1) {
|
||||
throw new IllegalStateException(String.format(
|
||||
"Could not update file '%s' in Drive folder id '%s' because multiple files with that "
|
||||
+ "name already exist.",
|
||||
title,
|
||||
parentFolderId));
|
||||
throw new IllegalStateException(
|
||||
String.format(
|
||||
"Could not update file '%s' in Drive folder id '%s' because multiple files with that "
|
||||
+ "name already exist.",
|
||||
name, parentFolderId));
|
||||
}
|
||||
return existingFiles.isEmpty()
|
||||
? createFile(title, mimeType, parentFolderId, bytes)
|
||||
: updateFile(existingFiles.get(0), title, mimeType, bytes);
|
||||
? createFile(name, mimeType, parentFolderId, bytes)
|
||||
: updateFile(existingFiles.getFirst(), name, mimeType, bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the file with the given id in place, setting the title, content, and mime type to the
|
||||
* Updates the file with the given id in place, setting the name, content, and mime type to the
|
||||
* newly specified values.
|
||||
*
|
||||
* @return the file id.
|
||||
*/
|
||||
public String updateFile(String fileId, String title, MediaType mimeType, byte[] bytes)
|
||||
public String updateFile(String fileId, String name, MediaType mimeType, byte[] bytes)
|
||||
throws IOException {
|
||||
File file = new File().setTitle(title);
|
||||
return drive.files()
|
||||
File file = new File().setName(name);
|
||||
return drive
|
||||
.files()
|
||||
.update(fileId, file, new ByteArrayContent(mimeType.toString(), bytes))
|
||||
.execute()
|
||||
.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of Drive file ids for all files in Google Drive in the folder with the
|
||||
* specified id.
|
||||
* Returns a list of Drive file ids for all files in Google Drive in the folder with the specified
|
||||
* id.
|
||||
*/
|
||||
public List<String> listFiles(String parentFolderId) throws IOException {
|
||||
return listFiles(parentFolderId, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of Drive file ids for all files in Google Drive in the folder with the
|
||||
* specified id and matching the given Drive query.
|
||||
* Returns a list of Drive file ids for all files in Google Drive in the folder with the specified
|
||||
* id and matching the given Drive query.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/drive/web/search-parameters">The query format</a>
|
||||
*/
|
||||
public List<String> listFiles(String parentFolderId, String query) throws IOException {
|
||||
ImmutableList.Builder<String> result = new ImmutableList.Builder<>();
|
||||
Children.List req = drive.children().list(parentFolderId);
|
||||
Files.List req = drive.files().list();
|
||||
StringBuilder q = new StringBuilder(String.format("'%s' in parents", parentFolderId));
|
||||
if (!Strings.isNullOrEmpty(query)) {
|
||||
req.setQ(query);
|
||||
q.append(String.format(" and %s", query));
|
||||
}
|
||||
req.setQ(q.toString());
|
||||
do {
|
||||
ChildList files = req.execute();
|
||||
for (ChildReference child : files.getItems()) {
|
||||
result.add(child.getId());
|
||||
}
|
||||
FileList files = req.execute();
|
||||
files.getFiles().forEach(file -> result.add(file.getId()));
|
||||
req.setPageToken(files.getNextPageToken());
|
||||
} while (!Strings.isNullOrEmpty(req.getPageToken()));
|
||||
return result.build();
|
||||
}
|
||||
|
||||
/** Constructs an object representing a file (or folder) with a given title and parent. */
|
||||
/** Constructs an object representing a file (or folder) with a given name and parent. */
|
||||
private File createFileReference(
|
||||
String title, MediaType mimeType, @Nullable String parentFolderId) {
|
||||
String name, MediaType mimeType, @Nullable String parentFolderId) {
|
||||
return new File()
|
||||
.setTitle(title)
|
||||
.setName(name)
|
||||
.setMimeType(mimeType.toString())
|
||||
.setParents(parentFolderId == null
|
||||
? null
|
||||
: ImmutableList.of(new ParentReference().setId(parentFolderId)));
|
||||
.setParents(parentFolderId == null ? null : ImmutableList.of(parentFolderId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import static com.google.common.io.ByteStreams.toByteArray;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.argThat;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -28,12 +27,9 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import com.google.api.client.http.ByteArrayContent;
|
||||
import com.google.api.services.drive.Drive;
|
||||
import com.google.api.services.drive.Drive.Children;
|
||||
import com.google.api.services.drive.Drive.Files;
|
||||
import com.google.api.services.drive.model.ChildList;
|
||||
import com.google.api.services.drive.model.ChildReference;
|
||||
import com.google.api.services.drive.model.File;
|
||||
import com.google.api.services.drive.model.ParentReference;
|
||||
import com.google.api.services.drive.model.FileList;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.net.MediaType;
|
||||
import java.util.Arrays;
|
||||
@@ -47,15 +43,13 @@ class DriveConnectionTest {
|
||||
|
||||
private final Drive drive = mock(Drive.class);
|
||||
private final Files files = mock(Files.class);
|
||||
private final Children children = mock(Children.class);
|
||||
private final Files.Insert insert = mock(Files.Insert.class);
|
||||
private final Files.Create create = mock(Files.Create.class);
|
||||
private final Files.Update update = mock(Files.Update.class);
|
||||
private final Children.List childrenList = mock(Children.List.class);
|
||||
private final Files.List filesList = mock(Files.List.class);
|
||||
|
||||
private static final byte[] DATA = {1, 2, 3};
|
||||
ChildList childList;
|
||||
private DriveConnection driveConnection;
|
||||
private List<String> allChildren;
|
||||
private List<String> allFiles;
|
||||
|
||||
private ArgumentMatcher<ByteArrayContent> hasByteArrayContent(final byte[] data) {
|
||||
return arg -> {
|
||||
@@ -72,154 +66,143 @@ class DriveConnectionTest {
|
||||
driveConnection = new DriveConnection();
|
||||
driveConnection.drive = drive;
|
||||
when(drive.files()).thenReturn(files);
|
||||
when(drive.children()).thenReturn(children);
|
||||
when(insert.execute()).thenReturn(new File().setId("id"));
|
||||
when(create.execute()).thenReturn(new File().setId("id"));
|
||||
when(update.execute()).thenReturn(new File().setId("id"));
|
||||
|
||||
// Mocking required for listFiles.
|
||||
ChildReference child1 = new ChildReference().setId("child1");
|
||||
ChildReference child2 = new ChildReference().setId("child2");
|
||||
ChildReference child3 = new ChildReference().setId("child3");
|
||||
ChildReference child4 = new ChildReference().setId("child4");
|
||||
List<ChildReference> children1 = ImmutableList.of(child1, child2);
|
||||
List<ChildReference> children2 = ImmutableList.of(child3, child4);
|
||||
allChildren = ImmutableList.of(child1.getId(), child2.getId(), child3.getId(), child4.getId());
|
||||
ChildList childList1 = new ChildList();
|
||||
childList1.setItems(children1);
|
||||
childList1.setNextPageToken("page2");
|
||||
ChildList childList2 = new ChildList();
|
||||
childList2.setItems(children2);
|
||||
childList2.setNextPageToken(null);
|
||||
when(childrenList.execute()).thenReturn(childList1, childList2);
|
||||
when(childrenList.setQ(anyString())).thenReturn(childrenList);
|
||||
when(childrenList.getPageToken()).thenCallRealMethod();
|
||||
when(childrenList.setPageToken(any())).thenCallRealMethod();
|
||||
when(children.list("driveFolderId")).thenReturn(childrenList);
|
||||
File file1 = new File().setId("file1");
|
||||
File file2 = new File().setId("file2");
|
||||
File file3 = new File().setId("file2");
|
||||
File file4 = new File().setId("file4");
|
||||
List<File> files1 = ImmutableList.of(file1, file2);
|
||||
List<File> files2 = ImmutableList.of(file3, file4);
|
||||
allFiles = ImmutableList.of(file1.getId(), file2.getId(), file3.getId(), file4.getId());
|
||||
FileList fileList1 = new FileList();
|
||||
fileList1.setFiles(files1);
|
||||
fileList1.setNextPageToken("page2");
|
||||
FileList fileList2 = new FileList();
|
||||
fileList2.setFiles(files2);
|
||||
fileList2.setNextPageToken(null);
|
||||
when(filesList.execute()).thenReturn(fileList1, fileList2);
|
||||
when(filesList.getPageToken()).thenCallRealMethod();
|
||||
when(filesList.setPageToken(any())).thenCallRealMethod();
|
||||
when(files.list()).thenReturn(filesList);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCreateFileAtRoot() throws Exception {
|
||||
when(files.insert(
|
||||
eq(new File().setTitle("title").setMimeType("image/gif")),
|
||||
when(files.create(
|
||||
eq(new File().setName("name").setMimeType("image/gif")),
|
||||
argThat(hasByteArrayContent(DATA))))
|
||||
.thenReturn(insert);
|
||||
assertThat(driveConnection.createFile("title", MediaType.GIF, null, DATA)).isEqualTo("id");
|
||||
.thenReturn(create);
|
||||
assertThat(driveConnection.createFile("name", MediaType.GIF, null, DATA)).isEqualTo("id");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCreateFileInFolder() throws Exception {
|
||||
when(files.insert(
|
||||
when(files.create(
|
||||
eq(
|
||||
new File()
|
||||
.setTitle("title")
|
||||
.setName("name")
|
||||
.setMimeType("image/gif")
|
||||
.setParents(ImmutableList.of(new ParentReference().setId("parent")))),
|
||||
.setParents(ImmutableList.of("parent"))),
|
||||
argThat(hasByteArrayContent(DATA))))
|
||||
.thenReturn(insert);
|
||||
assertThat(driveConnection.createFile("title", MediaType.GIF, "parent", DATA)).isEqualTo("id");
|
||||
.thenReturn(create);
|
||||
assertThat(driveConnection.createFile("name", MediaType.GIF, "parent", DATA)).isEqualTo("id");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCreateFolderAtRoot() throws Exception {
|
||||
when(files.insert(
|
||||
new File().setTitle("title").setMimeType("application/vnd.google-apps.folder")))
|
||||
.thenReturn(insert);
|
||||
assertThat(driveConnection.createFolder("title", null)).isEqualTo("id");
|
||||
when(files.create(new File().setName("name").setMimeType("application/vnd.google-apps.folder")))
|
||||
.thenReturn(create);
|
||||
assertThat(driveConnection.createFolder("name", null)).isEqualTo("id");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCreateFolderInFolder() throws Exception {
|
||||
when(files.insert(
|
||||
when(files.create(
|
||||
new File()
|
||||
.setTitle("title")
|
||||
.setName("name")
|
||||
.setMimeType("application/vnd.google-apps.folder")
|
||||
.setParents(ImmutableList.of(new ParentReference().setId("parent")))))
|
||||
.thenReturn(insert);
|
||||
assertThat(driveConnection.createFolder("title", "parent")).isEqualTo("id");
|
||||
.setParents(ImmutableList.of("parent"))))
|
||||
.thenReturn(create);
|
||||
assertThat(driveConnection.createFolder("name", "parent")).isEqualTo("id");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testListFiles_noQueryWithPagination() throws Exception {
|
||||
assertThat(driveConnection.listFiles("driveFolderId")).containsExactlyElementsIn(allChildren);
|
||||
verify(childrenList).setPageToken("page2");
|
||||
verify(childrenList).setPageToken(null);
|
||||
verify(childrenList, times(0)).setQ(anyString());
|
||||
verify(childrenList, times(2)).getPageToken();
|
||||
assertThat(driveConnection.listFiles("driveFolderId")).containsExactlyElementsIn(allFiles);
|
||||
verify(filesList).setPageToken("page2");
|
||||
verify(filesList).setPageToken(null);
|
||||
verify(filesList, times(1)).setQ("'driveFolderId' in parents");
|
||||
verify(filesList, times(2)).getPageToken();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testListFiles_withQueryAndPagination() throws Exception {
|
||||
assertThat(driveConnection.listFiles("driveFolderId", "sampleQuery"))
|
||||
.containsExactlyElementsIn(allChildren);
|
||||
verify(childrenList).setPageToken("page2");
|
||||
verify(childrenList).setPageToken(null);
|
||||
verify(childrenList, times(1)).setQ("sampleQuery");
|
||||
verify(childrenList, times(2)).getPageToken();
|
||||
.containsExactlyElementsIn(allFiles);
|
||||
verify(filesList).setPageToken("page2");
|
||||
verify(filesList).setPageToken(null);
|
||||
verify(filesList, times(1)).setQ("'driveFolderId' in parents and sampleQuery");
|
||||
verify(filesList, times(2)).getPageToken();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCreateOrUpdateFile_succeedsForNewFile() throws Exception {
|
||||
when(files.insert(
|
||||
when(files.create(
|
||||
eq(
|
||||
new File()
|
||||
.setTitle("title")
|
||||
.setName("name")
|
||||
.setMimeType("video/webm")
|
||||
.setParents(ImmutableList.of(new ParentReference().setId("driveFolderId")))),
|
||||
.setParents(ImmutableList.of("driveFolderId"))),
|
||||
argThat(hasByteArrayContent(DATA))))
|
||||
.thenReturn(insert);
|
||||
ChildList emptyChildList = new ChildList().setItems(ImmutableList.of()).setNextPageToken(null);
|
||||
when(childrenList.execute()).thenReturn(emptyChildList);
|
||||
.thenReturn(create);
|
||||
FileList emptyFileList = new FileList().setFiles(ImmutableList.of()).setNextPageToken(null);
|
||||
when(filesList.execute()).thenReturn(emptyFileList);
|
||||
assertThat(
|
||||
driveConnection.createOrUpdateFile(
|
||||
"title", MediaType.WEBM_VIDEO, "driveFolderId", DATA))
|
||||
driveConnection.createOrUpdateFile("name", MediaType.WEBM_VIDEO, "driveFolderId", DATA))
|
||||
.isEqualTo("id");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCreateOrUpdateFile_succeedsForUpdatingFile() throws Exception {
|
||||
when(files.update(
|
||||
eq("id"), eq(new File().setTitle("title")), argThat(hasByteArrayContent(DATA))))
|
||||
when(files.update(eq("id"), eq(new File().setName("name")), argThat(hasByteArrayContent(DATA))))
|
||||
.thenReturn(update);
|
||||
ChildList childList =
|
||||
new ChildList()
|
||||
.setItems(ImmutableList.of(new ChildReference().setId("id")))
|
||||
.setNextPageToken(null);
|
||||
when(childrenList.execute()).thenReturn(childList);
|
||||
FileList fileList =
|
||||
new FileList().setFiles(ImmutableList.of(new File().setId("id"))).setNextPageToken(null);
|
||||
when(filesList.execute()).thenReturn(fileList);
|
||||
assertThat(
|
||||
driveConnection.createOrUpdateFile(
|
||||
"title", MediaType.WEBM_VIDEO, "driveFolderId", DATA))
|
||||
driveConnection.createOrUpdateFile("name", MediaType.WEBM_VIDEO, "driveFolderId", DATA))
|
||||
.isEqualTo("id");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCreateOrUpdateFile_throwsExceptionWhenMultipleFilesWithNameAlreadyExist()
|
||||
throws Exception {
|
||||
ChildList childList =
|
||||
new ChildList()
|
||||
.setItems(
|
||||
ImmutableList.of(
|
||||
new ChildReference().setId("id1"), new ChildReference().setId("id2")))
|
||||
FileList fileList =
|
||||
new FileList()
|
||||
.setFiles(ImmutableList.of(new File().setId("id1"), new File().setId("id2")))
|
||||
.setNextPageToken(null);
|
||||
when(childrenList.execute()).thenReturn(childList);
|
||||
when(filesList.execute()).thenReturn(fileList);
|
||||
IllegalStateException thrown =
|
||||
assertThrows(
|
||||
IllegalStateException.class,
|
||||
() ->
|
||||
driveConnection.createOrUpdateFile(
|
||||
"title", MediaType.WEBM_VIDEO, "driveFolderId", DATA));
|
||||
"name", MediaType.WEBM_VIDEO, "driveFolderId", DATA));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains(
|
||||
"Could not update file 'title' in Drive folder id 'driveFolderId' "
|
||||
"Could not update file 'name' in Drive folder id 'driveFolderId' "
|
||||
+ "because multiple files with that name already exist.");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUpdateFile_succeeds() throws Exception {
|
||||
when(files.update(
|
||||
eq("id"), eq(new File().setTitle("title")), argThat(hasByteArrayContent(DATA))))
|
||||
when(files.update(eq("id"), eq(new File().setName("name")), argThat(hasByteArrayContent(DATA))))
|
||||
.thenReturn(update);
|
||||
assertThat(driveConnection.updateFile("id", "title", MediaType.WEBM_VIDEO, DATA))
|
||||
assertThat(driveConnection.updateFile("id", "name", MediaType.WEBM_VIDEO, DATA))
|
||||
.isEqualTo("id");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ class ConsoleUpdateRegistrarActionTest {
|
||||
new JpaTestExtensions.Builder().buildIntegrationTestExtension();
|
||||
|
||||
@Test
|
||||
void testSuccess__updatesRegistrar() throws IOException {
|
||||
void testSuccess_updatesRegistrar() throws IOException {
|
||||
var action = createAction(String.format(registrarPostData, "TheRegistrar", "app, dev", false));
|
||||
action.run();
|
||||
Registrar newRegistrar = Registrar.loadByRegistrarId("TheRegistrar").get();
|
||||
@@ -109,7 +109,7 @@ class ConsoleUpdateRegistrarActionTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFails__missingWhoisContact() throws IOException {
|
||||
void testFails_missingWhoisContact() throws IOException {
|
||||
RegistryEnvironment.PRODUCTION.setup(systemPropertyExtension);
|
||||
var action = createAction(String.format(registrarPostData, "TheRegistrar", "app, dev", false));
|
||||
action.run();
|
||||
@@ -119,7 +119,7 @@ class ConsoleUpdateRegistrarActionTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess__presentWhoisContact() throws IOException {
|
||||
void testSuccess_presentWhoisContact() throws IOException {
|
||||
RegistryEnvironment.PRODUCTION.setup(systemPropertyExtension);
|
||||
RegistrarPoc contact =
|
||||
new RegistrarPoc.Builder()
|
||||
@@ -143,7 +143,7 @@ class ConsoleUpdateRegistrarActionTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess__sendsEmail() throws AddressException, IOException {
|
||||
void testSuccess_sendsEmail() throws AddressException, IOException {
|
||||
var action = createAction(String.format(registrarPostData, "TheRegistrar", "app, dev", false));
|
||||
action.run();
|
||||
verify(consoleApiParams.sendEmailUtils().gmailClient, times(1))
|
||||
|
||||
Reference in New Issue
Block a user