@@ -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