This is an automated email from the ASF dual-hosted git repository.
tpalfy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new 64a4d2b48f NIFI-14388 Added More Metadata Attributes to Google Drive
Processors (part 2)
64a4d2b48f is described below
commit 64a4d2b48f8cde10759f22c7f03e7f0ccd7f84a4
Author: Peter Turcsanyi <[email protected]>
AuthorDate: Tue Mar 25 12:01:39 2025 +0100
NIFI-14388 Added More Metadata Attributes to Google Drive Processors (part
2)
Added drive.parent.folder.id, drive.parent.folder.name,
drive.listed.folder.id, drive.listed.folder.name in ListGoogleDrive.
Added drive.owner, drive.last.modifying.user, drive.web.view.link,
drive.web.content.link in FetchGoogleDrive.
This closes #9820.
Signed-off-by: Tamas Palfy <[email protected]>
---
.../processors/gcp/drive/FetchGoogleDrive.java | 25 ++++++++-
.../gcp/drive/GoogleDriveAttributes.java | 12 +++++
.../processors/gcp/drive/GoogleDriveFileInfo.java | 61 ++++++++++++++++++++++
.../nifi/processors/gcp/drive/ListGoogleDrive.java | 32 +++++++++---
.../processors/gcp/drive/FetchGoogleDriveTest.java | 4 +-
.../gcp/drive/ListGoogleDriveSimpleTest.java | 14 +++--
.../gcp/drive/ListGoogleDriveTestRunnerTest.java | 17 +++++-
7 files changed, 150 insertions(+), 15 deletions(-)
diff --git
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/FetchGoogleDrive.java
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/FetchGoogleDrive.java
index aabcb6e955..1039f692e4 100644
---
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/FetchGoogleDrive.java
+++
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/FetchGoogleDrive.java
@@ -29,8 +29,11 @@ import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.Set;
import java.util.concurrent.TimeUnit;
+
+import com.google.api.services.drive.model.User;
import org.apache.nifi.annotation.behavior.InputRequirement;
import org.apache.nifi.annotation.behavior.ReadsAttribute;
import org.apache.nifi.annotation.behavior.WritesAttribute;
@@ -65,15 +68,23 @@ import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.ERROR_M
import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.FILENAME_DESC;
import static org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.ID;
import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.ID_DESC;
+import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.LAST_MODIFYING_USER;
+import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.LAST_MODIFYING_USER_DESC;
import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.MIME_TYPE_DESC;
import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.MODIFIED_TIME;
import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.MODIFIED_TIME_DESC;
+import static org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.OWNER;
+import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.OWNER_DESC;
import static org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SIZE;
import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SIZE_AVAILABLE;
import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SIZE_AVAILABLE_DESC;
import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SIZE_DESC;
import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.TIMESTAMP;
import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.TIMESTAMP_DESC;
+import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.WEB_CONTENT_LINK;
+import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.WEB_CONTENT_LINK_DESC;
+import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.WEB_VIEW_LINK;
+import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.WEB_VIEW_LINK_DESC;
@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED)
@Tags({"google", "drive", "storage", "fetch"})
@@ -90,6 +101,10 @@ import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.TIMESTA
@WritesAttribute(attribute = TIMESTAMP, description = TIMESTAMP_DESC),
@WritesAttribute(attribute = CREATED_TIME, description =
CREATED_TIME_DESC),
@WritesAttribute(attribute = MODIFIED_TIME, description =
MODIFIED_TIME_DESC),
+ @WritesAttribute(attribute = OWNER, description = OWNER_DESC),
+ @WritesAttribute(attribute = LAST_MODIFYING_USER, description =
LAST_MODIFYING_USER_DESC),
+ @WritesAttribute(attribute = WEB_VIEW_LINK, description =
WEB_VIEW_LINK_DESC),
+ @WritesAttribute(attribute = WEB_CONTENT_LINK, description =
WEB_CONTENT_LINK_DESC),
@WritesAttribute(attribute = ERROR_CODE, description =
ERROR_CODE_DESC),
@WritesAttribute(attribute = ERROR_MESSAGE, description =
ERROR_MESSAGE_DESC)
})
@@ -291,7 +306,13 @@ public class FetchGoogleDrive extends AbstractProcessor
implements GoogleDriveTr
final long startNanos = System.nanoTime();
try {
final File fileMetadata = fetchFileMetadata(fileId);
- final Map<String, String> attributeMap =
createGoogleDriveFileInfoBuilder(fileMetadata).build().toAttributeMap();
+ final Map<String, String> attributeMap =
createGoogleDriveFileInfoBuilder(fileMetadata)
+
.owner(Optional.ofNullable(fileMetadata.getOwners()).filter(owners ->
!owners.isEmpty()).map(List::getFirst).map(User::getDisplayName).orElse(null))
+
.lastModifyingUser(Optional.ofNullable(fileMetadata.getLastModifyingUser()).map(User::getDisplayName).orElse(null))
+ .webViewLink(fileMetadata.getWebViewLink())
+ .webContentLink(fileMetadata.getWebContentLink())
+ .build()
+ .toAttributeMap();
flowFile = fetchFile(fileMetadata, session, context, flowFile,
attributeMap);
@@ -407,7 +428,7 @@ public class FetchGoogleDrive extends AbstractProcessor
implements GoogleDriveTr
.files()
.get(fileId)
.setSupportsAllDrives(true)
- .setFields("id, name, createdTime, modifiedTime, mimeType,
size, exportLinks")
+ .setFields("id, name, createdTime, modifiedTime, mimeType,
size, exportLinks, owners, lastModifyingUser, webViewLink, webContentLink")
.execute();
}
diff --git
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/GoogleDriveAttributes.java
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/GoogleDriveAttributes.java
index 361615e415..740ab9e353 100644
---
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/GoogleDriveAttributes.java
+++
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/GoogleDriveAttributes.java
@@ -63,6 +63,18 @@ public class GoogleDriveAttributes {
public static final String WEB_CONTENT_LINK = "drive.web.content.link";
public static final String WEB_CONTENT_LINK_DESC = "Web content link to
the file";
+ public static final String PARENT_FOLDER_ID = "drive.parent.folder.id";
+ public static final String PARENT_FOLDER_ID_DESC = "The id of the file's
parent folder";
+
+ public static final String PARENT_FOLDER_NAME = "drive.parent.folder.name";
+ public static final String PARENT_FOLDER_NAME_DESC = "The name of the
file's parent folder";
+
+ public static final String LISTED_FOLDER_ID = "drive.listed.folder.id";
+ public static final String LISTED_FOLDER_ID_DESC = "The id of the base
folder that was listed";
+
+ public static final String LISTED_FOLDER_NAME = "drive.listed.folder.name";
+ public static final String LISTED_FOLDER_NAME_DESC = "The name of the base
folder that was listed";
+
public static final String ERROR_MESSAGE = "error.message";
public static final String ERROR_MESSAGE_DESC = "The error message
returned by Google Drive";
diff --git
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/GoogleDriveFileInfo.java
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/GoogleDriveFileInfo.java
index 7b84807dbd..846ef07226 100644
---
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/GoogleDriveFileInfo.java
+++
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/GoogleDriveFileInfo.java
@@ -35,9 +35,13 @@ import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.CREATED
import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.FILENAME;
import static org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.ID;
import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.LAST_MODIFYING_USER;
+import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.LISTED_FOLDER_ID;
+import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.LISTED_FOLDER_NAME;
import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.MIME_TYPE;
import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.MODIFIED_TIME;
import static org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.OWNER;
+import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.PARENT_FOLDER_ID;
+import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.PARENT_FOLDER_NAME;
import static org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.PATH;
import static org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SIZE;
import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SIZE_AVAILABLE;
@@ -64,6 +68,10 @@ public class GoogleDriveFileInfo implements ListableEntity {
recordFields.add(new RecordField(LAST_MODIFYING_USER,
RecordFieldType.STRING.getDataType(), true));
recordFields.add(new RecordField(WEB_VIEW_LINK,
RecordFieldType.STRING.getDataType(), true));
recordFields.add(new RecordField(WEB_CONTENT_LINK,
RecordFieldType.STRING.getDataType(), true));
+ recordFields.add(new RecordField(PARENT_FOLDER_ID,
RecordFieldType.STRING.getDataType(), true));
+ recordFields.add(new RecordField(PARENT_FOLDER_NAME,
RecordFieldType.STRING.getDataType(), true));
+ recordFields.add(new RecordField(LISTED_FOLDER_ID,
RecordFieldType.STRING.getDataType(), true));
+ recordFields.add(new RecordField(LISTED_FOLDER_NAME,
RecordFieldType.STRING.getDataType(), true));
SCHEMA = new SimpleRecordSchema(recordFields);
}
@@ -82,6 +90,11 @@ public class GoogleDriveFileInfo implements ListableEntity {
private final String webViewLink;
private final String webContentLink;
+ private final String parentFolderId;
+ private final String parentFolderName;
+ private final String listedFolderId;
+ private final String listedFolderName;
+
public String getId() {
return id;
}
@@ -126,6 +139,22 @@ public class GoogleDriveFileInfo implements ListableEntity
{
return webContentLink;
}
+ public String getParentFolderId() {
+ return parentFolderId;
+ }
+
+ public String getParentFolderName() {
+ return parentFolderName;
+ }
+
+ public String getListedFolderId() {
+ return listedFolderId;
+ }
+
+ public String getListedFolderName() {
+ return listedFolderName;
+ }
+
@Override
public Record toRecord() {
return new MapRecord(SCHEMA, toMap());
@@ -147,6 +176,10 @@ public class GoogleDriveFileInfo implements ListableEntity
{
values.put(LAST_MODIFYING_USER, getLastModifyingUser());
values.put(WEB_VIEW_LINK, getWebViewLink());
values.put(WEB_CONTENT_LINK, getWebContentLink());
+ values.put(PARENT_FOLDER_ID, getParentFolderId());
+ values.put(PARENT_FOLDER_NAME, getParentFolderName());
+ values.put(LISTED_FOLDER_ID, getListedFolderId());
+ values.put(LISTED_FOLDER_NAME, getListedFolderName());
return values;
}
@@ -177,6 +210,10 @@ public class GoogleDriveFileInfo implements ListableEntity
{
private String lastModifyingUser;
private String webViewLink;
private String webContentLink;
+ private String parentFolderId;
+ private String parentFolderName;
+ private String listedFolderId;
+ private String listedFolderName;
public Builder id(String id) {
this.id = id;
@@ -238,6 +275,26 @@ public class GoogleDriveFileInfo implements ListableEntity
{
return this;
}
+ public Builder parentFolderId(String parentFolderId) {
+ this.parentFolderId = parentFolderId;
+ return this;
+ }
+
+ public Builder parentFolderName(String parentFolderName) {
+ this.parentFolderName = parentFolderName;
+ return this;
+ }
+
+ public Builder listedFolderId(String listedFolderId) {
+ this.listedFolderId = listedFolderId;
+ return this;
+ }
+
+ public Builder listedFolderName(String listedFolderName) {
+ this.listedFolderName = listedFolderName;
+ return this;
+ }
+
public GoogleDriveFileInfo build() {
return new GoogleDriveFileInfo(this);
}
@@ -287,6 +344,10 @@ public class GoogleDriveFileInfo implements ListableEntity
{
this.lastModifyingUser = builder.lastModifyingUser;
this.webViewLink = builder.webViewLink;
this.webContentLink = builder.webContentLink;
+ this.parentFolderId = builder.parentFolderId;
+ this.parentFolderName = builder.parentFolderName;
+ this.listedFolderId = builder.listedFolderId;
+ this.listedFolderName = builder.listedFolderName;
}
@Override
diff --git
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/ListGoogleDrive.java
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/ListGoogleDrive.java
index 8211f4e6ec..fb6563fde3 100644
---
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/ListGoogleDrive.java
+++
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/ListGoogleDrive.java
@@ -71,11 +71,17 @@ import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.ID;
import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.ID_DESC;
import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.LAST_MODIFYING_USER;
import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.LAST_MODIFYING_USER_DESC;
+import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.LISTED_FOLDER_ID;
+import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.LISTED_FOLDER_NAME;
import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.MIME_TYPE_DESC;
import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.MODIFIED_TIME;
import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.MODIFIED_TIME_DESC;
import static org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.OWNER;
import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.OWNER_DESC;
+import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.PARENT_FOLDER_ID;
+import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.PARENT_FOLDER_ID_DESC;
+import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.PARENT_FOLDER_NAME;
+import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.PARENT_FOLDER_NAME_DESC;
import static org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.PATH;
import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.PATH_DESC;
import static org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SIZE;
@@ -113,7 +119,11 @@ import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.WEB_VIE
@WritesAttribute(attribute = OWNER, description = OWNER_DESC),
@WritesAttribute(attribute = LAST_MODIFYING_USER, description =
LAST_MODIFYING_USER_DESC),
@WritesAttribute(attribute = WEB_VIEW_LINK, description =
WEB_VIEW_LINK_DESC),
- @WritesAttribute(attribute = WEB_CONTENT_LINK, description =
WEB_CONTENT_LINK_DESC)})
+ @WritesAttribute(attribute = WEB_CONTENT_LINK, description =
WEB_CONTENT_LINK_DESC),
+ @WritesAttribute(attribute = PARENT_FOLDER_ID, description =
PARENT_FOLDER_ID_DESC),
+ @WritesAttribute(attribute = PARENT_FOLDER_NAME, description =
PARENT_FOLDER_NAME_DESC),
+ @WritesAttribute(attribute = LISTED_FOLDER_ID, description =
WEB_CONTENT_LINK_DESC),
+ @WritesAttribute(attribute = LISTED_FOLDER_NAME, description =
WEB_CONTENT_LINK_DESC)})
@Stateful(scopes = {Scope.CLUSTER}, description = "The processor stores
necessary data to be able to keep track what files have been listed already." +
" What exactly needs to be stored depends on the 'Listing Strategy'." +
" State is stored across the cluster so that this Processor can be run
on Primary Node only and if a new Primary Node is selected, the new node can
pick up" +
@@ -189,6 +199,9 @@ public class ListGoogleDrive extends
AbstractListProcessor<GoogleDriveFileInfo>
private volatile Drive driveService;
+ private volatile String listedFolderId;
+ private volatile String listedFolderName;
+
@Override
protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
return PROPERTY_DESCRIPTORS;
@@ -213,6 +226,9 @@ public class ListGoogleDrive extends
AbstractListProcessor<GoogleDriveFileInfo>
HttpTransport httpTransport = new
ProxyAwareTransportFactory(proxyConfiguration).create();
driveService = createDriveService(context, httpTransport,
DriveScopes.DRIVE, DriveScopes.DRIVE_METADATA_READONLY);
+
+ listedFolderId =
context.getProperty(FOLDER_ID).evaluateAttributeExpressions().getValue();
+ listedFolderName = getFolderName(listedFolderId);
}
@Override
@@ -255,7 +271,6 @@ public class ListGoogleDrive extends
AbstractListProcessor<GoogleDriveFileInfo>
) throws IOException {
final List<GoogleDriveFileInfo> listing = new ArrayList<>();
- final String folderId =
context.getProperty(FOLDER_ID).evaluateAttributeExpressions().getValue();
final Boolean recursive =
context.getProperty(RECURSIVE_SEARCH).asBoolean();
final Long minAge =
context.getProperty(MIN_AGE).asTimePeriod(TimeUnit.MILLISECONDS);
@@ -283,9 +298,9 @@ public class ListGoogleDrive extends
AbstractListProcessor<GoogleDriveFileInfo>
final String queryTemplate = queryTemplateBuilder.toString();
- final String folderPath = urlEncode(getFolderName(folderId));
+ final String listedFolderPath = urlEncode(listedFolderName);
- queryFolder(folderId, folderPath, queryTemplate, recursive, listing);
+ queryFolder(listedFolderId, listedFolderName, listedFolderPath,
queryTemplate, recursive, listing);
return listing;
}
@@ -318,6 +333,7 @@ public class ListGoogleDrive extends
AbstractListProcessor<GoogleDriveFileInfo>
private void queryFolder(
final String folderId,
+ final String folderName,
final String folderPath,
final String queryTemplate,
final boolean recursive,
@@ -347,7 +363,11 @@ public class ListGoogleDrive extends
AbstractListProcessor<GoogleDriveFileInfo>
.owner(Optional.ofNullable(file.getOwners()).filter(owners ->
!owners.isEmpty()).map(List::getFirst).map(User::getDisplayName).orElse(null))
.lastModifyingUser(Optional.ofNullable(file.getLastModifyingUser()).map(User::getDisplayName).orElse(null))
.webViewLink(file.getWebViewLink())
- .webContentLink(file.getWebContentLink());
+ .webContentLink(file.getWebContentLink())
+ .parentFolderId(folderId)
+ .parentFolderName(folderName)
+ .listedFolderId(listedFolderId)
+ .listedFolderName(listedFolderName);
listing.add(builder.build());
}
@@ -358,7 +378,7 @@ public class ListGoogleDrive extends
AbstractListProcessor<GoogleDriveFileInfo>
for (final File subfolder : subfolders) {
final String subfolderPath = folderPath + "/" +
urlEncode(subfolder.getName());
- queryFolder(subfolder.getId(), subfolderPath, queryTemplate, true,
listing);
+ queryFolder(subfolder.getId(), subfolder.getName(), subfolderPath,
queryTemplate, true, listing);
}
}
diff --git
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/drive/FetchGoogleDriveTest.java
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/drive/FetchGoogleDriveTest.java
index 48257d4882..a41d102166 100644
---
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/drive/FetchGoogleDriveTest.java
+++
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/drive/FetchGoogleDriveTest.java
@@ -104,7 +104,7 @@ public class FetchGoogleDriveTest extends
AbstractGoogleDriveTest {
when(mockDriverService.files()
.get(fileId)
.setSupportsAllDrives(true)
- .setFields("id, name, createdTime, modifiedTime, mimeType,
size, exportLinks")
+ .setFields("id, name, createdTime, modifiedTime, mimeType,
size, exportLinks, owners, lastModifyingUser, webViewLink, webContentLink")
.execute()).thenReturn(createFile());
}
@@ -118,7 +118,7 @@ public class FetchGoogleDriveTest extends
AbstractGoogleDriveTest {
when(mockDriverService.files()
.get(fileId)
.setSupportsAllDrives(true)
- .setFields("id, name, createdTime, modifiedTime, mimeType,
size, exportLinks")
+ .setFields("id, name, createdTime, modifiedTime, mimeType,
size, exportLinks, owners, lastModifyingUser, webViewLink, webContentLink")
.execute()).thenReturn(createFile());
}
diff --git
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/drive/ListGoogleDriveSimpleTest.java
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/drive/ListGoogleDriveSimpleTest.java
index 29d785f1a6..dae9e0425f 100644
---
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/drive/ListGoogleDriveSimpleTest.java
+++
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/drive/ListGoogleDriveSimpleTest.java
@@ -63,8 +63,6 @@ public class ListGoogleDriveSimpleTest {
return mockDriverService;
}
};
-
- testSubject.onScheduled(mockProcessContext);
}
@Test
@@ -139,9 +137,15 @@ public class ListGoogleDriveSimpleTest {
.lastModifyingUser(lastModifyingUser)
.webViewLink(webViewLink)
.webContentLink(webContentLink)
+ .parentFolderId(folderId)
+ .parentFolderName(folderName)
+ .listedFolderId(folderId)
+ .listedFolderName(folderName)
.build()
);
+ testSubject.onScheduled(mockProcessContext);
+
// WHEN
List<GoogleDriveFileInfo> actual =
testSubject.performListing(mockProcessContext, minTimestamp, null);
@@ -160,7 +164,11 @@ public class ListGoogleDriveSimpleTest {
GoogleDriveFileInfo::getOwner,
GoogleDriveFileInfo::getLastModifyingUser,
GoogleDriveFileInfo::getWebViewLink,
- GoogleDriveFileInfo::getWebContentLink
+ GoogleDriveFileInfo::getWebContentLink,
+ GoogleDriveFileInfo::getParentFolderId,
+ GoogleDriveFileInfo::getParentFolderName,
+ GoogleDriveFileInfo::getListedFolderId,
+ GoogleDriveFileInfo::getListedFolderName
);
List<EqualsWrapper<GoogleDriveFileInfo>> expectedWrapper =
wrapList(expected, propertyProviders);
diff --git
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/drive/ListGoogleDriveTestRunnerTest.java
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/drive/ListGoogleDriveTestRunnerTest.java
index b827358278..71a9a8ddea 100644
---
a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/drive/ListGoogleDriveTestRunnerTest.java
+++
b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/test/java/org/apache/nifi/processors/gcp/drive/ListGoogleDriveTestRunnerTest.java
@@ -22,9 +22,13 @@ import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.CREATED
import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.FILENAME;
import static org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.ID;
import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.LAST_MODIFYING_USER;
+import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.LISTED_FOLDER_ID;
+import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.LISTED_FOLDER_NAME;
import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.MIME_TYPE;
import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.MODIFIED_TIME;
import static org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.OWNER;
+import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.PARENT_FOLDER_ID;
+import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.PARENT_FOLDER_NAME;
import static org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.PATH;
import static org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SIZE;
import static
org.apache.nifi.processors.gcp.drive.GoogleDriveAttributes.SIZE_AVAILABLE;
@@ -189,7 +193,11 @@ public class ListGoogleDriveTestRunnerTest implements
OutputChecker {
"\"drive.owner\":\"" + owner + "\"," +
"\"drive.last.modifying.user\":\"" + lastModifyingUser
+ "\"," +
"\"drive.web.view.link\":\"" + webViewLink + "\"," +
- "\"drive.web.content.link\":\"" + webContentLink +
"\"" +
+ "\"drive.web.content.link\":\"" + webContentLink +
"\"," +
+ "\"drive.parent.folder.id\":\"" + folderId + "\"," +
+ "\"drive.parent.folder.name\":\"" + folderName + "\","
+
+ "\"drive.listed.folder.id\":\"" + folderId + "\"," +
+ "\"drive.listed.folder.name\":\"" + folderName + "\"" +
"}" +
"]");
@@ -250,6 +258,10 @@ public class ListGoogleDriveTestRunnerTest implements
OutputChecker {
inputFlowFileAttributes.put(GoogleDriveAttributes.LAST_MODIFYING_USER,
lastModifyingUser);
inputFlowFileAttributes.put(GoogleDriveAttributes.WEB_VIEW_LINK,
webViewLink);
inputFlowFileAttributes.put(GoogleDriveAttributes.WEB_CONTENT_LINK,
webContentLink);
+ inputFlowFileAttributes.put(GoogleDriveAttributes.PARENT_FOLDER_ID,
folderId);
+ inputFlowFileAttributes.put(GoogleDriveAttributes.PARENT_FOLDER_NAME,
folderName);
+ inputFlowFileAttributes.put(GoogleDriveAttributes.LISTED_FOLDER_ID,
folderId);
+ inputFlowFileAttributes.put(GoogleDriveAttributes.LISTED_FOLDER_NAME,
folderName);
HashSet<Map<String, String>> expectedAttributes = new
HashSet<>(singletonList(inputFlowFileAttributes));
@@ -294,6 +306,7 @@ public class ListGoogleDriveTestRunnerTest implements
OutputChecker {
@Override
public Set<String> getCheckedAttributeNames() {
- return Set.of(ID, FILENAME, SIZE, SIZE_AVAILABLE, TIMESTAMP,
CREATED_TIME, MODIFIED_TIME, MIME_TYPE, PATH, OWNER, LAST_MODIFYING_USER,
WEB_VIEW_LINK, WEB_CONTENT_LINK);
+ return Set.of(ID, FILENAME, SIZE, SIZE_AVAILABLE, TIMESTAMP,
CREATED_TIME, MODIFIED_TIME, MIME_TYPE, PATH, OWNER, LAST_MODIFYING_USER,
WEB_VIEW_LINK, WEB_CONTENT_LINK,
+ PARENT_FOLDER_ID, PARENT_FOLDER_NAME, LISTED_FOLDER_ID,
LISTED_FOLDER_NAME);
}
}