use of com.willshex.blogwt.shared.api.datatype.Post in project blogwt by billy1380.
the class PostService method updatePost.
/* (non-Javadoc)
*
* @see com.willshex.blogwt.server.service.post.IPostService#updatePost(com.
* willshex.blogwt.shared.api.datatype.Post, java.util.Collection) */
@Override
public Post updatePost(Post post, Collection<String> removedTags) {
post.slug = PostHelper.slugify(post.title);
if (post.content != null) {
if (post.content.created == null) {
post.content.created = post.created;
}
if (post.content.postKey == null) {
post.content.postKey = Key.create(post);
}
provide().save().entity(post.content).now();
}
String previousSlug = null, nextSlug = null;
Post previousPost = null, nextPost = null;
if (Boolean.TRUE.equals(post.listed) && post.published != null) {
if (post.previousSlug == null && post.nextSlug == null) {
previousPost = getPreviousPost(post);
nextPost = getNextPost(post);
if (previousPost != null) {
post.previousSlug = previousPost.slug;
previousPost.nextSlug = post.slug;
}
if (nextPost != null) {
post.nextSlug = nextPost.slug;
nextPost.previousSlug = post.slug;
}
}
} else {
previousSlug = post.previousSlug;
nextSlug = post.nextSlug;
post.previousSlug = null;
post.nextSlug = null;
}
provide().save().entity(post).now();
updateTags(post);
if (removedTags != null) {
deleteFromTags(post, removedTags);
}
if (Boolean.TRUE.equals(post.listed)) {
ArchiveEntryServiceProvider.provide().archivePost(post);
} else {
deleteFromArchive(post);
if (previousSlug != null && nextSlug != null) {
previousPost = getSlugPost(previousSlug);
nextPost = getSlugPost(nextSlug);
previousPost.nextSlug = nextPost.slug;
nextPost.previousSlug = previousPost.slug;
updatePost(previousPost, null);
updatePost(nextPost, null);
} else if (previousSlug != null) {
previousPost = getSlugPost(previousSlug);
previousPost.nextSlug = null;
updatePost(previousPost, null);
} else if (nextSlug != null) {
nextPost = getSlugPost(nextSlug);
nextPost.previousSlug = null;
updatePost(nextPost, null);
}
}
SearchHelper.queueToIndex(getName(), post.id);
if (previousPost != null) {
updatePost(previousPost, null);
}
return post;
}
use of com.willshex.blogwt.shared.api.datatype.Post in project blogwt by billy1380.
the class TagService method addTagBatch.
/* (non-Javadoc)
*
* @see com.willshex.blogwt.server.service.tag.ITagService#addTagBatch(java.
* util.Collection) */
@Override
public void addTagBatch(Collection<Tag> tags) {
for (Tag tag : tags) {
if (tag.created == null) {
tag.created = new Date();
}
tag.name = tag.name.toLowerCase();
tag.slug = PostHelper.slugify(tag.name);
if (tag.posts != null) {
for (Post post : tag.posts) {
if (tag.postKeys == null) {
tag.postKeys = new ArrayList<Key<Post>>();
}
tag.postKeys.add(Key.create(post));
}
}
}
provide().save().entities(tags).now();
}
use of com.willshex.blogwt.shared.api.datatype.Post in project blogwt by billy1380.
the class CreatePostRequest method fromJson.
@Override
public void fromJson(JsonObject jsonObject) {
super.fromJson(jsonObject);
if (jsonObject.has("post")) {
JsonElement jsonPost = jsonObject.get("post");
if (jsonPost != null) {
post = new Post();
post.fromJson(jsonPost.getAsJsonObject());
}
}
if (jsonObject.has("publish")) {
JsonElement jsonPublish = jsonObject.get("publish");
if (jsonPublish != null) {
publish = Boolean.valueOf(jsonPublish.getAsBoolean());
}
}
}
use of com.willshex.blogwt.shared.api.datatype.Post in project blogwt by billy1380.
the class GetPostResponse method fromJson.
@Override
public void fromJson(JsonObject jsonObject) {
super.fromJson(jsonObject);
if (jsonObject.has("post")) {
JsonElement jsonPost = jsonObject.get("post");
if (jsonPost != null) {
post = new Post();
post.fromJson(jsonPost.getAsJsonObject());
}
}
}
use of com.willshex.blogwt.shared.api.datatype.Post in project blogwt by billy1380.
the class GetRelatedPostsResponse method fromJson.
@Override
public void fromJson(JsonObject jsonObject) {
super.fromJson(jsonObject);
if (jsonObject.has("posts")) {
JsonElement jsonPosts = jsonObject.get("posts");
if (jsonPosts != null) {
posts = new Post();
posts.fromJson(jsonPosts.getAsJsonObject());
}
}
if (jsonObject.has("pager")) {
JsonElement jsonPager = jsonObject.get("pager");
if (jsonPager != null) {
pager = new Pager();
pager.fromJson(jsonPager.getAsJsonObject());
}
}
}
Aggregations