Source:
<code>public Page createPage(Wiki wiki, String parentPageName, Page page) throws WikiException { String pageName = TitleResolver.getId(page.getTitle(), false); page.setName(pageName); if (isExisting(wiki.getType(), wiki.getOwner(), pageName)) { throw new WikiException("Page " + wiki.getType() + ":" + wiki.getOwner() + ":" + pageName + " already exists, cannot create it."); } Page parentPage = getPageOfWikiByName(wiki.getType(), wiki.getOwner(), parentPageName); List<PermissionEntry> permissions = page.getPermissions(); if(permissions == null) { permissions = this.getWikiDefaultPermissions(wiki.getType(), wiki.getOwner()); page.setPermissions(permissions); } String currentUser = org.exoplatform.wiki.utils.Utils.getCurrentUser(); PermissionEntry currentUserPermEnty = null; outerloop: for (PermissionEntry permEntry : page.getPermissions()) { if (permEntry.getId().equals(currentUser)) { currentUserPermEnty = permEntry; for (Permission permission : permEntry.getPermissions()) { if (permission.getPermissionType().equals(PermissionType.ADMINPAGE)) { if (permission.isAllowed()) { break outerloop; } else { <START> permission.setAllowed(true); <END> } } } List<Permission> userPermissions = Arrays.asList(permEntry.getPermissions()); userPermissions.add(new Permission(PermissionType.ADMINPAGE, true)); permEntry.setPermissions((Permission[]) userPermissions.toArray()); } } if (currentUserPermEnty == null) { currentUserPermEnty = new PermissionEntry(currentUser, "", IDType.USER, new Permission[] { new Permission(PermissionType.VIEWPAGE, true), new Permission(PermissionType.EDITPAGE, true), new Permission(PermissionType.ADMINPAGE, true) }); page.getPermissions().add(currentUserPermEnty); } Page createdPage = dataStorage.createPage(wiki, parentPage, page); invalidateCache(parentPage); invalidateCache(page); postAddPage(wiki.getType(), wiki.getOwner(), page.getName(), createdPage); return createdPage; }</code><technical_language>break loop in this case, need : if (!permission.isAllowed()) { // Update permEntry } break;</technical_language>

Target:
public Page createPage(Wiki wiki, String parentPageName, Page page) throws WikiException { String pageName = TitleResolver.getId(page.getTitle(), false); page.setName(pageName); if (isExisting(wiki.getType(), wiki.getOwner(), pageName)) { throw new WikiException("Page " + wiki.getType() + ":" + wiki.getOwner() + ":" + pageName + " already exists, cannot create it."); } Page parentPage = getPageOfWikiByName(wiki.getType(), wiki.getOwner(), parentPageName); List<PermissionEntry> permissions = page.getPermissions(); if(permissions == null) { permissions = this.getWikiDefaultPermissions(wiki.getType(), wiki.getOwner()); page.setPermissions(permissions); } String currentUser = org.exoplatform.wiki.utils.Utils.getCurrentUser(); PermissionEntry currentUserPermEnty = null; for (PermissionEntry permEntry : page.getPermissions()) { if (permEntry.getId().equals(currentUser)) { currentUserPermEnty = permEntry; Boolean hasAdminPerm = false; for (Permission permission : permEntry.getPermissions()) { if (permission.getPermissionType().equals(PermissionType.ADMINPAGE)) { if (!permission.isAllowed()) { permission.setAllowed(true); } hasAdminPerm = true; break; } } if (!hasAdminPerm) { List<Permission> userPermissions = Arrays.asList(permEntry.getPermissions()); userPermissions.add(new Permission(PermissionType.ADMINPAGE, true)); permEntry.setPermissions((Permission[]) userPermissions.toArray()); } break; } } if (currentUserPermEnty == null) { currentUserPermEnty = new PermissionEntry(currentUser, "", IDType.USER, new Permission[] { new Permission(PermissionType.VIEWPAGE, true), new Permission(PermissionType.EDITPAGE, true), new Permission(PermissionType.ADMINPAGE, true) }); page.getPermissions().add(currentUserPermEnty); } Page createdPage = dataStorage.createPage(wiki, parentPage, page); invalidateCache(parentPage); invalidateCache(page); postAddPage(wiki.getType(), wiki.getOwner(), page.getName(), createdPage); return createdPage; }