use of com.willshex.blogwt.shared.api.datatype.Post in project blogwt by billy1380.
the class UpdatePostRequest 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 SearchAllResponse 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 ArrayList<Post>();
Post item = null;
for (int i = 0; i < jsonPosts.getAsJsonArray().size(); i++) {
if (jsonPosts.getAsJsonArray().get(i) != null) {
(item = new Post()).fromJson(jsonPosts.getAsJsonArray().get(i).getAsJsonObject());
posts.add(item);
}
}
}
}
if (jsonObject.has("pages")) {
JsonElement jsonPages = jsonObject.get("pages");
if (jsonPages != null) {
pages = new ArrayList<Page>();
Page item = null;
for (int i = 0; i < jsonPages.getAsJsonArray().size(); i++) {
if (jsonPages.getAsJsonArray().get(i) != null) {
(item = new Page()).fromJson(jsonPages.getAsJsonArray().get(i).getAsJsonObject());
pages.add(item);
}
}
}
}
if (jsonObject.has("users")) {
JsonElement jsonUsers = jsonObject.get("users");
if (jsonUsers != null) {
users = new ArrayList<User>();
User item = null;
for (int i = 0; i < jsonUsers.getAsJsonArray().size(); i++) {
if (jsonUsers.getAsJsonArray().get(i) != null) {
(item = new User()).fromJson(jsonUsers.getAsJsonArray().get(i).getAsJsonObject());
users.add(item);
}
}
}
}
}
use of com.willshex.blogwt.shared.api.datatype.Post in project blogwt by billy1380.
the class PostHelper method nextPostSlug.
/**
* @param posts
* @param slug
* @return
*/
public static String nextPostSlug(List<Post> posts, String slug) {
String nextSlug = slug;
if (posts != null) {
String strippedSlug;
int largestSuffix = 0, suffix;
for (Post post : posts) {
strippedSlug = post.slug.replace(slug, "");
if (!strippedSlug.isEmpty()) {
suffix = Integer.parseInt(strippedSlug);
if (suffix > largestSuffix) {
largestSuffix = suffix;
}
}
}
if (posts.size() > 0 && largestSuffix >= 0) {
nextSlug += Integer.toString(largestSuffix + 1);
}
}
return nextSlug;
}
use of com.willshex.blogwt.shared.api.datatype.Post in project blogwt by billy1380.
the class EditPagePage method onfinished.
/* (non-Javadoc)
*
* @see com.willshex.blogwt.client.wizard.PagePlanFinishedHandler#onfinished
* (java.util.List) */
@Override
public void onfinished(List<WizardPage<?>> pages) {
Page page = null;
Post post = null;
for (WizardPage<?> wizardPage : pages) {
if (wizardPage instanceof EditPageWizardPage) {
page = ((EditPageWizardPage) wizardPage).getData();
if (page.posts != null) {
page.posts.clear();
}
} else if (wizardPage instanceof SelectPostWizardPage) {
if (page.posts == null) {
page.posts = new ArrayList<Post>();
}
post = ((SelectPostWizardPage) wizardPage).getData();
page.posts.add(post);
}
}
if (page.id == null) {
PageController.get().createPage(page);
} else {
PageController.get().updatePage(page);
}
}
use of com.willshex.blogwt.shared.api.datatype.Post in project blogwt by billy1380.
the class SiteMapServlet method printPosts.
private void printPosts(PrintWriter p, String url) {
List<Post> posts;
Pager pager = PagerHelper.createDefaultPager();
do {
posts = PostServiceProvider.provide().getPosts(Boolean.FALSE, Boolean.FALSE, pager.start, pager.count, PostSortType.PostSortTypePublished, SortDirectionType.SortDirectionTypeDescending);
if (posts != null) {
PagerHelper.moveForward(pager);
for (Post post : posts) {
p.println(String.format(LOC_FORMAT, url, "#" + PageType.PostDetailPageType.asTargetHistoryToken(post.slug)));
}
}
} while (posts != null && posts.size() >= pager.count.intValue());
}
Aggregations