diff --git a/src/main/java/io/cdap/plugin/google/common/GoogleAuthBaseConfig.java b/src/main/java/io/cdap/plugin/google/common/GoogleAuthBaseConfig.java index 6f4443e..710d527 100644 --- a/src/main/java/io/cdap/plugin/google/common/GoogleAuthBaseConfig.java +++ b/src/main/java/io/cdap/plugin/google/common/GoogleAuthBaseConfig.java @@ -177,14 +177,17 @@ & checkPropertyIsSet(collector, clientSecret, CLIENT_SECRET, CLIENT_SECRET_LABEL } private boolean validateServiceAccount(FailureCollector collector) { - if (isServiceAccountFilePath() != null && isServiceAccountFilePath()) { + final Boolean serviceAccountFilePath = isServiceAccountFilePath(); + final Boolean serviceAccountJson = isServiceAccountJson(); + + if (serviceAccountFilePath != null && serviceAccountFilePath) { if (!AUTO_DETECT_VALUE.equals(accountFilePath) && !new File(accountFilePath).exists()) { collector.addFailure("Service Account File Path is not available.", "Please provide path to existing Service Account file.") .withConfigProperty(ACCOUNT_FILE_PATH); } } - if (isServiceAccountJson() != null && isServiceAccountJson()) { + if (serviceAccountJson != null && serviceAccountJson) { if (!Optional.ofNullable(getServiceAccountJson()).isPresent()) { collector.addFailure("Service Account JSON can not be empty.", "Please provide Service Account JSON.") diff --git a/src/main/java/io/cdap/plugin/google/common/GoogleDriveClient.java b/src/main/java/io/cdap/plugin/google/common/GoogleDriveClient.java index 607e18b..11bcd66 100644 --- a/src/main/java/io/cdap/plugin/google/common/GoogleDriveClient.java +++ b/src/main/java/io/cdap/plugin/google/common/GoogleDriveClient.java @@ -105,7 +105,7 @@ protected Credential getCredentials() throws IOException { } protected List getRequiredScopes() { - return Collections.singletonList(DriveScopes.DRIVE); + return Collections.singletonList(DriveScopes.DRIVE_READONLY); } public void checkRootFolder() throws IOException { diff --git a/src/main/java/io/cdap/plugin/google/drive/source/GoogleDriveInputFormat.java b/src/main/java/io/cdap/plugin/google/drive/source/GoogleDriveInputFormat.java index ddcf2d3..fe85fce 100644 --- a/src/main/java/io/cdap/plugin/google/drive/source/GoogleDriveInputFormat.java +++ b/src/main/java/io/cdap/plugin/google/drive/source/GoogleDriveInputFormat.java @@ -18,9 +18,6 @@ import com.github.rholder.retry.RetryException; import com.google.api.services.drive.model.File; -import com.google.gson.JsonObject; -import io.cdap.cdap.api.data.batch.Input; -import io.cdap.plugin.common.SourceInputFormatProvider; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.mapreduce.InputFormat; import org.apache.hadoop.mapreduce.InputSplit; diff --git a/src/main/java/io/cdap/plugin/google/drive/source/SchemaBuilder.java b/src/main/java/io/cdap/plugin/google/drive/source/SchemaBuilder.java index e0ee739..476168e 100644 --- a/src/main/java/io/cdap/plugin/google/drive/source/SchemaBuilder.java +++ b/src/main/java/io/cdap/plugin/google/drive/source/SchemaBuilder.java @@ -27,7 +27,7 @@ * Util class for building pipeline schema. */ public class SchemaBuilder { - public static final String SCHEMA_ROOT_RECORD_NAME = "etlSchemaBody"; + public static final String SCHEMA_ROOT_RECORD_NAME = "FileFromFolder"; public static final String IMAGE_METADATA_FIELD_NAME = "imageMediaMetadata"; public static final String VIDEO_METADATA_FIELD_NAME = "videoMediaMetadata";