use of it.vige.rubia.model.Poster in project rubia-forums by flashboss.
the class ReplyTopic method execute.
/**
* Execute
*
* @return the navigation state of the application
*/
public String execute() {
String navState = null;
boolean success = false;
try {
Message message = createMessage();
message.setText(this.message);
message.setSubject(subject);
// setup the forum and the corresponding poster
Forum forum = forumsModule.findForumById(forumId);
topic = forumsModule.findTopicById(topicId);
Poster poster = getPoster(forumsModule, userModule);
// make sure this topic is not locked
if (topic.getStatus() == TOPIC_LOCKED) {
// should not allow posting a reply since the topic is locked
throw new Exception(getBundleMessage(BUNDLE_NAME, TOPIC_LOCKED_ERR_KEY));
}
// actually post a reply to this topic in the forum
poster.incrementPostCount();
// attachments
forumsModule.createPost(// attachments
topic, // attachments
forum, // attachments
message, // attachments
new Date(), // attachments
poster, // attachments
attachments);
currentTopicPage.setPage(viewTopic.getLastPageNumber());
// 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 VerifyTopic method getPoster.
public static Poster getPoster(WebDriver driver, Forum forum) {
WebElement profileLink = driver.findElement(linkText(forum.getName())).findElement(xpath("../../../td[5]/a[2]"));
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 VerifyTopic method getPosterLastPost.
public static Poster getPosterLastPost(WebDriver driver, Topic topic) {
WebElement profileLink = driver.findElements(className(PROFILE_LINK)).get(0).findElement(xpath("../tr/td/a[contains(text(),'" + topic.getSubject() + "')]")).findElement(xpath("../a[2]"));
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 ViewRSSLink method getPage.
public static Forum getPage(WebDriver driver, Forum forum) {
VerifyForum.goTo(driver, forum);
goTo(driver);
Forum result = new Forum();
result.setName(driver.findElement(id(FEED_TITLE_TEXT)).getText().split(": ")[1]);
result.setCategory(new Category(driver.findElement(id(FEED_SUBTITLE_TEXT)).getText().split(" in category ")[1]));
Map<String, Topic> topics = new HashMap<String, Topic>();
List<WebElement> entries = driver.findElements(className(ENTRY_LINK));
DateFormat dateFormat = new SimpleDateFormat("d MMM yyyy, HH:mm");
for (WebElement entry : entries) {
String[] entryText = entry.getText().split(BY);
String lastUpdated = entry.findElement(className(LAST_UPDATED)).getText();
String topicTitle = entryText[0].replace(RE, "");
Topic topic = topics.get(topicTitle);
if (topic == null) {
topic = new Topic(topicTitle);
topics.put(topicTitle, topic);
}
Post post = new Post(entry.findElement(className(FEED_ENTRY_CONTENT)).getText());
post.setPoster(new Poster(entryText[1].split("\n")[0]));
try {
post.setCreateDate(dateFormat.parse(lastUpdated));
} catch (ParseException e) {
}
post.getMessage().setSubject(entryText[0]);
topic.getPosts().add(post);
}
result.setTopics(new ArrayList<Topic>(topics.values()));
returnToHome(driver);
return result;
}
use of it.vige.rubia.model.Poster in project rubia-forums by flashboss.
the class JSFUtil method getPoster.
/**
* @param userModule
* the user module of the application
* @param forumsModule
* the forums module of the application
*
* @return the current poster
* @throws Exception
* the error exception
*/
public static Poster getPoster(UserModule userModule, ForumsModule forumsModule) throws Exception {
Poster poster = null;
if (!isAnonymous()) {
User user = getUser(userModule);
Object userId = user.getId();
poster = forumsModule.findPosterByUserId(userId.toString());
if (poster == null) {
poster = new Poster(userId.toString());
}
} else {
poster = getGuestPoster(userModule, forumsModule);
}
return poster;
}
Aggregations