@Override public Map<String, ?> getPage(String authenticationToken, String pageId) { Page page = pageManager.getPage(Long.parseLong(pageId)); Map<String, Object> pageStruct = null; if (null != page && permissionManager.hasPermission(AuthenticatedUserThreadLocal.getUser(), Permission.VIEW, page)) { pageStruct = new Hashtable<String, Object>(); pageStruct.put("id", page.getIdAsString()); pageStruct.put("spaceKey", page.getSpaceKey()); Page parentPage = page.getParent(); if (null != parentPage) pageStruct.put("parentId", page.getParent().getIdAsString()); pageStruct.put("title", page.getTitle()); pageStruct.put("version", page.getVersion()); pageStruct.put("content", page.getBodyAsString()); if (StringUtils.isNotBlank(page.getCreatorName())) pageStruct.put("creator", page.getCreatorName()); pageStruct.put("created", page.getCreationDate()); if (StringUtils.isNotBlank(page.getLastModifierName())) pageStruct.put("lastModifier", page.getLastModifierName()); pageStruct.put("lastModified", page.getLastModificationDate()); } return pageStruct; }
setSpaceKey(bookmarkPage.getSpaceKey()); setDescription(bookmark.getDescription());
private void createPage(String newPageTitle) throws DavException { Space thisSpace = getSpace(); Page newPage = new Page(); newPage.setSpace(thisSpace); /* Check for invalid page title */ if (PageResourceImpl.isPageTitleValid(newPageTitle)) { /* Check for (A Document Being Saved By Text Edit) created by TextEdit and stop the page creation */ ConfluenceDavSession confluenceDavSession = (ConfluenceDavSession) getSession(); if (isTextEditCreatingTempFolder(newPageTitle, confluenceDavSession)) throw new DavException(HttpServletResponse.SC_FORBIDDEN, "This plugin does not allow creation of page with the title \"" + TEXTEDIT_TEMP_FOLDER_NAME + "\". See http://developer.atlassian.com/jira/browse/WBDV-143 for more information."); newPage.setTitle(newPageTitle); /* Check for duplicate page creation. */ if (null == pageManager.getPage(newPage.getSpaceKey(), newPage.getTitle())) { newPage.setCreatorName(AuthenticatedUserThreadLocal.getUser().getName()); pageManager.saveContentEntity(newPage, null); } else { throw new DavException(HttpServletResponse.SC_BAD_REQUEST, "Page creation denied. Page " + newPageTitle + " is not unique in space " + newPage.getSpaceKey()); } } else { throw new DavException(HttpServletResponse.SC_FORBIDDEN, "Page creation denied. New page name has invalid characters in the title: " + newPageTitle); } }
private void createPage(String newPageTitle) throws DavException { Page thisPage = getPage(); Page newPage = new Page(); newPage.setSpace(thisPage.getSpace()); /* Check for invalid page title */ if (isPageTitleValid(newPageTitle)) { /* Check for (A Document Being Saved By Text Edit) created by TextEdit and stop the page creation */ ConfluenceDavSession confluenceDavSession = (ConfluenceDavSession) getSession(); if (isTextEditCreatingTempFolder(newPageTitle, confluenceDavSession)) throw new DavException(HttpServletResponse.SC_FORBIDDEN, "This plugin does not allow creation of page with the title \"" + TEXTEDIT_TEMP_FOLDER_NAME + "\". See http://developer.atlassian.com/jira/browse/WBDV-143 for more information."); newPage.setTitle(newPageTitle); /* Check for duplicate page creation. */ if (null == pageManager.getPage(newPage.getSpaceKey(), newPage.getTitle())) { newPage.setParentPage(thisPage); newPage.setCreatorName(AuthenticatedUserThreadLocal.getUser().getName()); thisPage.addChild(newPage); pageManager.saveContentEntity(newPage, null); } else { throw new DavException(HttpServletResponse.SC_FORBIDDEN, "Page creation denied. Page " + newPageTitle + " is not unique in space " + newPage.getSpaceKey()); } } else { throw new DavException(HttpServletResponse.SC_FORBIDDEN, "Page creation denied. New page name has invalid characters in the title: " + newPageTitle); } }
newChildPage.setTitle(generateUniquePageTitle(childPage.getSpaceKey(), childPage.getTitle())); newChildPage.setSpace(childPage.getSpace()); newChildPage.setBodyContent(childPage.getBodyContent());
uniqueName = generateUniquePageTitle(getPage().getSpaceKey(), getPage().getTitle());