I am creating new page and immediately after creation of that, creating child page under that. while creation doing operations of the copying permissions and adding labels.
Below is a block of code of page creation and content permissions -
transactionTemplate.execute(() -> {
String pageBodyStr = pageTemplate.getContent().replace("<at:declarations />", "");
createPage.setParentPage(parentPage);
createPage.setTitle(expectedPageName);
createPage.setSpace(parentPage.getSpace());
createPage.setBodyAsString(pageBodyStr);
createPage.setVersion(1);
pageManager.saveContentEntity(createPage, DefaultSaveContext.DEFAULT);
log.info("Created page: " + expectedPageName + " under parent: " + parentPage.getTitle());
return null;
});
// Permissions
try {
ContentPermissionManager contentPermissionManager = ComponentLocator.getComponent(ContentPermissionManager.class);
Page repositoryPage = pageManager.getPage(parentPage.getSpaceKey(), "Repository");
if (repositoryPage != null) {
ContentPermissionSet existingPermissions = createPage.getContentPermissionSet(ContentPermission.EDIT_PERMISSION);
if (existingPermissions == null || existingPermissions.isEmpty()) {
contentPermissionManager.copyContentPermissions(repositoryPage, createPage);
log.info("Copied permissions from Repository.");
} else {
ContentPermission permission = ContentPermission.createGroupPermission(ContentPermission.EDIT_PERMISSION, "confluence-administrators");
contentPermissionManager.addContentPermission(permission, createPage);
log.info("Added fallback Edit permission to new page.");
}
} else {
log.warn("Repository page not found in space: " + parentPage.getSpaceKey());
}
} catch (Exception e) {
log.error("Error while copying page permissions", e);
}
Pages are getting created but transaction is getting rollbacked. whenever I am trying to create a child page under newly created parent page.
Adding few block of error logs:
[confluence.impl.hibernate.ConfluenceHibernateTransactionManager] doRollback Performing rollback. Transactions:\n ->[PluginReadWriteTx]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT (Session #436119910)\n Showing 10 last transactions at this level out of 15 in total:\n [pluginRequires_New_Read_WriteTx]: PROPAGATION_REQUIRES_NEW,ISOLATION_DEFAULT (Session #666079215)\n [pluginRequires_New_Read_WriteTx]: PROPAGATION_REQUIRES_NEW,ISOLATION_DEFAULT (Session #1742749533)\n [pluginRequires_New_Read_WriteTx]: PROPAGATION_REQUIRES_NEW,ISOLATION_DEFAULT (Session #38130456)\n [pluginRequires_New_Read_WriteTx]: PROPAGATION_REQUIRES_NEW,ISOLATION_DEFAULT (Session #1786645634)\n [pluginRequires_New_Read_WriteTx]: PROPAGATION_REQUIRES_NEW,ISOLATION_DEFAULT (Session #956068521)\n [com.atlassian.confluence.core.persistence.hibernate.HibernateVersionHistoryDao.getFinalizedBuildNumber]: PROPAGATION_REQUIRES_NEW,ISOLATION_DEFAULT,readOnly (Session #1479887938)\n [pluginRequires_New_Read_WriteTx]: PROPAGATION_REQUIRES_NEW,ISOLATION_DEFAULT (Session #971053987)\n [pluginRequires_New_Read_WriteTx]: PROPAGATION_REQUIRES_NEW,ISOLATION_DEFAULT (Session #327596168)\n [pluginRequires_New_Read_WriteTx]: PROPAGATION_REQUIRES_NEW,ISOLATION_DEFAULT (Session #417094941)\n [pluginRequires_New_Read_WriteTx]: PROPAGATION_REQUIRES_NEW,ISOLATION_DEFAULT (Session #616823351)
How we can commit the active transaction or wait till it get complete.
Because it looks like parent page is getting created but database related activity is not committed and then it is throwing an error.
This is a few months old, hopefully you've figured it out, but in case you still need help, I have some questions.
This is just the code for the child page creation?
Have you added log entries into the code that creates the parent page?
Is there any log entries prior to the rollback entry?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.