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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.