Skip to content

Commit

Permalink
Fixed ParentDocumentId is null
Browse files Browse the repository at this point in the history
  • Loading branch information
mfriesen committed Sep 25, 2023
1 parent 96df739 commit 4d5c0dd
Showing 1 changed file with 22 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ public FolderIndexProcessorImpl(final DynamoDbConnectionBuilder connection,
this.dynamoDb = new DynamoDbServiceImpl(connection, documentsTable);
}

private void checkParentId(final FolderIndexRecord record, final String parentId) {
if (record.parentDocumentId() == null) {
record.parentDocumentId(parentId);
}
}

/**
* Create Folder.
*
Expand Down Expand Up @@ -391,6 +397,8 @@ record = record.getFromAttributes(siteId, attrs);

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

checkParentId(record, parentId);

if (record.documentId() != null) {
parentId = record.documentId();
}
Expand Down Expand Up @@ -419,20 +427,6 @@ public FolderIndexRecord getFolderByDocumentId(final String siteId, final String
return map.containsKey(documentId) ? map.get(documentId) : null;
}

/**
* Query GSI1 for Folder by DocumentId.
*
* @param siteId {@link String}
* @param documentId {@link String}
* @return {@link QueryResponse}
*/
private QueryResponse queryForFolderByDocumentId(final String siteId, final String documentId) {
FolderIndexRecord record = new FolderIndexRecord().documentId(documentId);
String pk = record.pkGsi1(siteId);
QueryResponse response = this.dynamoDb.queryIndex(GSI1, AttributeValue.fromS(pk), null, 1);
return response;
}

@Override
public Map<String, FolderIndexRecord> getFolderByDocumentIds(final String siteId,
final List<String> documentIds) {
Expand Down Expand Up @@ -726,6 +720,20 @@ public void moveIndex(final String siteId, final String sourcePath, final String
}
}

/**
* Query GSI1 for Folder by DocumentId.
*
* @param siteId {@link String}
* @param documentId {@link String}
* @return {@link QueryResponse}
*/
private QueryResponse queryForFolderByDocumentId(final String siteId, final String documentId) {
FolderIndexRecord record = new FolderIndexRecord().documentId(documentId);
String pk = record.pkGsi1(siteId);
QueryResponse response = this.dynamoDb.queryIndex(GSI1, AttributeValue.fromS(pk), null, 1);
return response;
}

/**
* Validate Path exists.
*
Expand Down

0 comments on commit 4d5c0dd

Please sign in to comment.