@Override public Map<String, ?> getBlogPost(String authenticationToken, String id) { Map<String, Object> postStructure = null; BlogPost post = getPageManager().getBlogPost(Long.parseLong(id)); if (null != post && permissionManager.hasPermission(AuthenticatedUserThreadLocal.getUser(), Permission.VIEW, post)) { postStructure = new Hashtable<String, Object>(); postStructure.put("id", post.getIdAsString()); postStructure.put("spaceKey", post.getSpaceKey()); postStructure.put("title", post.getTitle()); postStructure.put("version", post.getVersion()); postStructure.put("content", post.getBodyAsString()); if (StringUtils.isNotBlank(post.getCreatorName())) postStructure.put("creator", post.getCreatorName()); postStructure.put("created", post.getCreationDate()); } return postStructure; } }
protected byte[] getTextContentAsBytes(String encoding) throws UnsupportedEncodingException { return getBlogPost().getBodyContent().getBody().getBytes(encoding); }
private StringBuilder getContentEntityWikiLink( ContentEntityObject content, PageContext ctx ) { StringBuilder buff = new StringBuilder(); if ( content instanceof SpaceContentEntityObject ) { SpaceContentEntityObject spaceContent = (SpaceContentEntityObject) content; if ( !StringUtils.equals( spaceContent.getSpaceKey(), ctx.getSpaceKey() ) ) buff.append( spaceContent.getSpaceKey() ).append( ":" ); if ( content instanceof Page ) { Page page = (Page) content; buff.append( page.getTitle() ); } else if ( content instanceof BlogPost ) { BlogPost blogPost = (BlogPost) content; buff.append( blogPost.getDatePath() ).append( "/" ).append( blogPost.getTitle() ); } else { buff.append( "$" ).append( content.getIdAsString() ); } } else if ( content instanceof PersonalInformation ) { buff.append( "~" ).append( ( (PersonalInformation) content ).getUsername() ); } else { buff.append( "$" ).append( content.getIdAsString() ); } return buff; } }
.append('/').append(blogPost.getPostingDayOfMonth()) .append('/').append(blogPost.getTitle()).append(DISPLAY_NAME_SUFFIX);
@SuppressWarnings("unused") public Message getFormattedDate() { return friendlyDateFormatter.getFormatMessage(post.getCreationDate()); }
public String getDisplayName() { return getBlogPost().getTitle() + DISPLAY_NAME_SUFFIX; } }
@Override public Document buildHtml(BlogPost blogPost) throws ImportExportException { List<String> pageHtml = ImmutableList.of(renderToHtml(blogPost, null)); LinkFixer linkFixer = new LinkFixer(blogPost.getSpace().getKey(), settingsManager.getGlobalSettings().getBaseUrl(), ANCHOR); return buildHtml(pageHtml, blogPost.getSpace(), DecorationPolicy.none(), new TocBuilder(), new BookmarksBuilder(), linkFixer); }
/** * Returns the content for a particular BlogPost, based on what content setting the user has specified (titles, excerpts or entire) * * @param post the BlogPost * @param contentType the content type to be returned * @return the content of the BlogPost */ private String getContent(BlogPost post, String contentType) { String excerpt; if (CONTENT_EXCERPTS.equals(contentType)) { excerpt = excerptHelper.getExcerpt(post); // If page does not have an excerpt macro declared than calculate one manually from the whole body if (StringUtils.isBlank(excerpt)) { excerpt = excerptHelper.getText(post.getBodyAsString()); // CONFDEV-3633 // the excerptHelper returns element contents. If the element contained a CDATA with further markup // (e.g. in the case of a code macro showing XML code) then the excerpt will appear to contain // markup. Encode it. if (excerpt.length() > EXCERPT_LENGTH) { excerpt = GeneralUtil.htmlEncode(TextUtils.trimToEndingChar(excerpt, EXCERPT_LENGTH)) + "…"; } else { excerpt = GeneralUtil.htmlEncode(excerpt); } return excerpt; } } else { excerpt = post.getBodyAsString(); } return excerpt; }
public String getBlogPostId( final String authenticationToken, final String spaceKey, final String title, final Date day) throws RemoteException { final Calendar _day; final BlogPost blogPost; if (StringUtils.isBlank(spaceKey)) throw new RemoteException("Space key not specified."); if (StringUtils.isBlank(title)) throw new RemoteException("Blog post title not specified."); if (null == day) throw new RemoteException("Blog post publish date not specified."); _day = Calendar.getInstance(getUserTimeZone()); _day.setTime(day); blogPost = getPageManager().getBlogPost(spaceKey, title, _day); return (null != blogPost && getPermissionManager().hasPermission(AuthenticatedUserThreadLocal.getUser(), Permission.VIEW, blogPost)) ? blogPost.getIdAsString() : null; }
getText( "blogposts.error.already-included-page", StringEscapeUtils.escapeHtml4(blogPost.getDisplayTitle())
protected long getCreationtTime() { return getBlogPost().getCreationDate().getTime(); }
eventSpace = ((BlogPostEvent) e).getBlogPost().getSpace();