page.setOwnerType(ownerType);
page.setOwnerId(ownerId);
page.setName(getUIStringInput("name").getValue());
// Check if the page exists
PageService pageService = getApplicationComponent(PageService.class);
PageKey pageKey = new SiteKey(ownerType, ownerId).page(page.getName());
if (pageService.loadPage(pageKey) == null) {
// Set defaults only on new pages
UserPortalConfigService configService = getApplicationComponent(UserPortalConfigService.class);
configService.setDefaultPermissions(page);
}