Skip to content

Commit 4d5c0dd

Browse files
committed
Fixed ParentDocumentId is null
1 parent 96df739 commit 4d5c0dd

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

dynamodb-documents/src/main/java/com/formkiq/stacks/dynamodb/FolderIndexProcessorImpl.java

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ public FolderIndexProcessorImpl(final DynamoDbConnectionBuilder connection,
125125
this.dynamoDb = new DynamoDbServiceImpl(connection, documentsTable);
126126
}
127127

128+
private void checkParentId(final FolderIndexRecord record, final String parentId) {
129+
if (record.parentDocumentId() == null) {
130+
record.parentDocumentId(parentId);
131+
}
132+
}
133+
128134
/**
129135
* Create Folder.
130136
*
@@ -391,6 +397,8 @@ record = record.getFromAttributes(siteId, attrs);
391397

392398
list.add(new FolderIndexRecordExtended(record, isRecordChanged));
393399

400+
checkParentId(record, parentId);
401+
394402
if (record.documentId() != null) {
395403
parentId = record.documentId();
396404
}
@@ -419,20 +427,6 @@ public FolderIndexRecord getFolderByDocumentId(final String siteId, final String
419427
return map.containsKey(documentId) ? map.get(documentId) : null;
420428
}
421429

422-
/**
423-
* Query GSI1 for Folder by DocumentId.
424-
*
425-
* @param siteId {@link String}
426-
* @param documentId {@link String}
427-
* @return {@link QueryResponse}
428-
*/
429-
private QueryResponse queryForFolderByDocumentId(final String siteId, final String documentId) {
430-
FolderIndexRecord record = new FolderIndexRecord().documentId(documentId);
431-
String pk = record.pkGsi1(siteId);
432-
QueryResponse response = this.dynamoDb.queryIndex(GSI1, AttributeValue.fromS(pk), null, 1);
433-
return response;
434-
}
435-
436430
@Override
437431
public Map<String, FolderIndexRecord> getFolderByDocumentIds(final String siteId,
438432
final List<String> documentIds) {
@@ -726,6 +720,20 @@ public void moveIndex(final String siteId, final String sourcePath, final String
726720
}
727721
}
728722

723+
/**
724+
* Query GSI1 for Folder by DocumentId.
725+
*
726+
* @param siteId {@link String}
727+
* @param documentId {@link String}
728+
* @return {@link QueryResponse}
729+
*/
730+
private QueryResponse queryForFolderByDocumentId(final String siteId, final String documentId) {
731+
FolderIndexRecord record = new FolderIndexRecord().documentId(documentId);
732+
String pk = record.pkGsi1(siteId);
733+
QueryResponse response = this.dynamoDb.queryIndex(GSI1, AttributeValue.fromS(pk), null, 1);
734+
return response;
735+
}
736+
729737
/**
730738
* Validate Path exists.
731739
*

0 commit comments

Comments
 (0)