use of com.willshex.blogwt.shared.api.datatype.Post in project blogwt by billy1380.
the class EditPagePage method getPageSuccess.
/* (non-Javadoc)
*
* @see com.willshex.blogwt.shared.api.page.call.event.GetPageEventHandler#
* getPageSuccess(com.willshex.blogwt.shared.api.page.call.GetPageRequest,
* com.willshex.blogwt.shared.api.page.call.GetPageResponse) */
@Override
public void getPageSuccess(GetPageRequest input, GetPageResponse output) {
if (output.status == StatusType.StatusTypeSuccess) {
PagePlanBuilder builder = new PagePlanBuilder();
EditPageWizardPage ewp = new EditPageWizardPage();
ewp.setData(output.page);
builder.addPage(ewp);
SelectPostWizardPage spwp = new SelectPostWizardPage();
for (Post post : output.page.posts) {
spwp = new SelectPostWizardPage();
spwp.setData(post);
builder.addPage(spwp, post != output.page.posts.get(0));
}
setPlan(builder.setName("Edit " + output.page.title).addFinishedHandler(this).build());
}
}
use of com.willshex.blogwt.shared.api.datatype.Post in project blogwt by billy1380.
the class PageDetailPage method show.
private void show(Page page) {
pnlContent.clear();
SectionPart section;
for (Post post : page.posts) {
section = new SectionPart();
section.setContent(page.slug, post);
pnlContent.add(section);
}
lnkEditPage.setTargetHistoryToken(PageType.EditPagePageType.asTargetHistoryToken(page.slug));
pnlLoading.setVisible(false);
FooterPart.get().scrollToTop();
refreshTitle();
}
use of com.willshex.blogwt.shared.api.datatype.Post in project blogwt by billy1380.
the class FeedServlet method getFeed.
protected SyndFeed getFeed(HttpServletRequest request) throws IOException, FeedException {
SyndFeed feed = new SyndFeedImpl();
String url = ServletHelper.constructBaseUrl(request);
feed.setTitle(PropertyServiceProvider.provide().getNamedProperty(PropertyHelper.TITLE).value);
feed.setLink(url + "/feed");
feed.setDescription(PropertyServiceProvider.provide().getNamedProperty(PropertyHelper.EXTENDED_TITLE).value);
List<Post> posts;
Pager pager = PagerHelper.createDefaultPager();
List<SyndEntry> entries = new ArrayList<SyndEntry>();
SyndEntry entry;
SyndContent description;
MarkdownProcessor processor = new MarkdownProcessor();
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) {
entry = new SyndEntryImpl();
entry.setTitle(post.title);
entry.setLink(url + "/#" + PageType.PostDetailPageType.asTargetHistoryToken(post.slug));
entry.setPublishedDate(post.published);
description = new SyndContentImpl();
description.setType("text/HTML");
description.setValue(processor.process(post.summary));
entry.setDescription(description);
entries.add(entry);
}
}
} while (posts != null && posts.size() >= pager.count.intValue());
feed.setEntries(entries);
return feed;
}
use of com.willshex.blogwt.shared.api.datatype.Post in project blogwt by billy1380.
the class UpdatePostActionHandler method handle.
/* (non-Javadoc)
*
* @see
* com.willshex.gson.web.service.server.ActionHandler#handle(com.willshex.
* gson.web.service.shared.Request,
* com.willshex.gson.web.service.shared.Response) */
@Override
protected void handle(UpdatePostRequest input, UpdatePostResponse output) throws Exception {
ApiValidator.request(input, UpdatePostRequest.class);
ApiValidator.accessCode(input.accessCode, "input.accessCode");
output.session = input.session = SessionValidator.lookupCheckAndExtend(input.session, "input.session");
UserValidator.authorisation(input.session.user, Arrays.asList(PermissionServiceProvider.provide().getCodePermission(PermissionHelper.MANAGE_POSTS)), "input.session.user");
Post updatedPost = input.post;
input.post = PostValidator.lookup(input.post, "input.post");
input.post.content = PostServiceProvider.provide().getPostContent(input.post);
updatedPost = PostValidator.validate(updatedPost, "input.post");
input.post.commentsEnabled = updatedPost.commentsEnabled;
input.post.content.body = updatedPost.content.body;
input.post.listed = updatedPost.listed;
input.post.summary = updatedPost.summary;
List<String> removedTags = null;
if (updatedPost.tags == null) {
removedTags = input.post.tags;
} else {
if (input.post.tags != null) {
removedTags = new ArrayList<String>();
for (String tag : input.post.tags) {
if (!updatedPost.tags.contains(tag)) {
removedTags.add(tag);
}
}
}
}
input.post.tags = updatedPost.tags;
input.post.title = updatedPost.title;
// don't change the original publish date
if (Boolean.TRUE.equals(input.publish) && input.post.published == null) {
input.post.published = new Date();
}
output.post = PostServiceProvider.provide().updatePost(input.post, removedTags);
}
use of com.willshex.blogwt.shared.api.datatype.Post in project blogwt by billy1380.
the class SearchAllActionHandler method handle.
/* (non-Javadoc)
*
* @see
* com.willshex.gson.web.service.server.ActionHandler#handle(com.willshex.
* gson.web.service.shared.Request,
* com.willshex.gson.web.service.shared.Response) */
@SuppressWarnings("unchecked")
@Override
protected void handle(SearchAllRequest input, SearchAllResponse output) throws Exception {
ApiValidator.request(input, SearchAllRequest.class);
ApiValidator.accessCode(input.accessCode, "input.accessCode");
try {
output.session = input.session = SessionValidator.lookupCheckAndExtend(input.session, "input.session");
} catch (InputValidationException ex) {
output.session = input.session = null;
}
if (input.query == null)
ApiValidator.throwServiceError(InputValidationException.class, ApiError.InvalidValueNull, "String: input.query");
output.posts = ((ISearch<Post>) PostServiceProvider.provide()).search(input.query, Integer.valueOf(0), SearchHelper.SHORT_SEARCH_LIMIT, null, null);
Map<Key<User>, User> users = new HashMap<Key<User>, User>();
if (output.posts != null) {
for (Post post : output.posts) {
if (users.get(post.authorKey) == null) {
users.put(post.authorKey, UserServiceProvider.provide().getUser(keyToId(post.authorKey)));
}
post.author = users.get(post.authorKey);
}
}
output.pages = ((ISearch<Page>) PageServiceProvider.provide()).search(input.query, Integer.valueOf(0), SearchHelper.SHORT_SEARCH_LIMIT, null, null);
if (output.pages != null) {
for (Page page : output.pages) {
if (users.get(page.ownerKey) == null) {
users.put(page.ownerKey, UserServiceProvider.provide().getUser(keyToId(page.ownerKey)));
}
page.owner = users.get(page.ownerKey);
}
}
output.users = ((ISearch<User>) UserServiceProvider.provide()).search(input.query, Integer.valueOf(0), SearchHelper.SHORT_SEARCH_LIMIT, null, null);
}
Aggregations