use of it.vige.rubia.model.Poster in project rubia-forums by flashboss.
the class NewTopic method execute.
/**
* Execute
*
* @return the navigation state of the application
*/
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String execute() {
String navState = null;
boolean success = false;
try {
// setup the message
Message message = createMessage();
message.setText(this.message);
message.setSubject(subject);
// setup the forum and the corresponding poster
Forum forum = forumsModule.findForumById(forumId);
Poster poster = getPoster(userModule, forumsModule);
// setup the poll related information
Poll poll = createPoll();
if (question != null && question.trim().length() > 0) {
poll.setTitle(question);
poll.setLength(activeDuration);
List<PollOption> pollOptions = new LinkedList<PollOption>();
for (String option : options.keySet()) {
PollOption pollOption = createPollOption(poll);
pollOption.setQuestion((String) options.get(option));
pollOption.setVotes(0);
pollOptions.add(pollOption);
}
poll.setOptions(pollOptions);
validatePoll(poll);
}
poster.incrementPostCount();
// actually create the topic in this forum
// use this method when poll and attachments are actually integrated
// poll
forumsModule.createTopic(// poll
forum, // poll
message, // poll
new Date(), // poll
poster, // poll
poll, // attachments
attachments, topicType);
// setup the navigation state
navState = SUCCESS;
success = true;
} catch (MessageValidationException e) {
// handle proper validation error with a proper message...not just a
// generic message..
// just use generic error page for the proof of concept
// set the custom exception such that e.toString() results in the
// proper message
handleException(e);
} catch (PollValidationException e) {
// handle proper validation error with a proper message...not just a
// generic message..
// just use generic error page for the proof of concept
// set the custom exception such that e.toString() results in the
// proper message
handleException(e);
} catch (Exception e) {
handleException(e);
} finally {
// cleanup if necessary
if (success) {
cleanup();
}
}
return navState;
}
use of it.vige.rubia.model.Poster in project rubia-forums by flashboss.
the class ViewPagePostSearch method getPost.
private static Post getPost(WebDriver driver, WebElement element) {
Post post = new Post();
post.setPoster(new Poster(element.findElement(xpath(POST_POSTER)).getText()));
String createdDate = element.findElement(xpath(POST_CREATED_DATE)).getText().replace(getBundle("ResourceJSF").getString("Posted") + ": ", "");
try {
Date date = dateFormat.parse(createdDate);
post.setCreateDate(date);
} catch (ParseException e) {
}
Message message = new Message();
message.setSubject(element.findElement(xpath(POST_SUBJECT)).getText().replace(getBundle("ResourceJSF").getString("Post_subject") + ": ", ""));
message.setText(element.findElement(xpath(POST_TEXT)).getText());
post.setMessage(message);
List<Attachment> attachments = getAttachmentsOfCurrentPostInPageNoParent(driver, post);
post.setAttachments(attachments);
return post;
}
use of it.vige.rubia.model.Poster in project rubia-forums by flashboss.
the class ViewPageTopicSearch method getPoster.
public static Poster getPoster(WebDriver driver, Topic topic) {
WebElement profileLink = driver.findElement(linkText(topic.getSubject())).findElement(xpath("../../a"));
String userId = profileLink.getText();
profileLink.click();
Poster poster = verifyProfile(driver, userId);
return poster;
}
use of it.vige.rubia.model.Poster in project rubia-forums by flashboss.
the class SearchTopicTest method verifyPostProfileFromTopicPage.
@Test
public void verifyPostProfileFromTopicPage() {
goTo(driver);
SearchCriteria searchForumCriteria = new SearchCriteria();
searchForumCriteria.setAuthor("root");
searchForumCriteria.setCategory(null);
searchForumCriteria.setDisplayAs(TOPICS.name());
searchForumCriteria.setForum(null);
searchForumCriteria.setKeywords("Topic");
searchForumCriteria.setPageNumber(0);
searchForumCriteria.setPageSize(0);
searchForumCriteria.setSearching(null);
searchForumCriteria.setSortBy(null);
searchForumCriteria.setSortOrder(null);
searchForumCriteria.setTimePeriod(null);
List<Topic> topics = searchTopic(driver, searchForumCriteria);
Topic topic = topics.get(2);
Poster poster = getPoster(driver, topic);
assertTrue(poster != null);
assertEquals("root", poster.getUserId());
assertTrue(poster.getPostCount() >= 4);
}
use of it.vige.rubia.model.Poster in project rubia-forums by flashboss.
the class ForumsModuleImpl method findPosterByUserId.
@Override
public Poster findPosterByUserId(String userId) throws ModuleException {
if (userId != null) {
try {
TypedQuery<Poster> query = em.createNamedQuery("findPosterByUserId", Poster.class);
query.setParameter("userId", userId);
Poster user = uniqueElement(query.getResultList());
return user;
} catch (Exception e) {
String message = "Cannot find poster by name " + userId;
throw new ModuleException(message, e);
}
} else {
throw new IllegalArgumentException("user name cannot be null");
}
}
Aggregations