use of it.vige.rubia.model.Topic in project rubia-forums by flashboss.
the class ModeratorAction method deleteTopic.
// ui actions supported by this
// bean----------------------------------------------------------------------------------------------------
/**
* UI Action for deleting topic(s) from the forum.
*
* @return the name of the operation
*/
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String deleteTopic() {
try {
for (int topicId : checkboxes.keySet()) {
boolean value = checkboxes.get(topicId);
try {
if (value) {
Topic topic = forumsModule.findTopicById(topicId);
forumsModule.removeTopic(topicId);
topics.remove(topic);
}
} catch (Exception e) {
setWarnBundleMessage("ERR_CANNOT_REMOVE_TOPIC");
return "success";
}
}
setInfoBundleMessage("SUCC_TOPIC_REMOVED");
} catch (Exception e) {
handleException(e);
}
if (!conversation.isTransient())
conversation.end();
return "success";
}
use of it.vige.rubia.model.Topic in project rubia-forums by flashboss.
the class ModeratorAction method execute.
@PostConstruct
public void execute() {
try {
// trying to get forumId from request parameter
int forumId = -1;
String f = getParameter(p_forumId);
if (f != null && f.trim().length() > 0) {
forumId = parseInt(f);
}
checkboxes = new HashMap<Integer, Boolean>();
// grab the data to be displayed for this page
if (forumId != -1) {
// setup the business objects like the forum, topics etc that
// will
// be displayed
forum = forumsModule.findForumById(forumId);
} else {
// trying to get forumId from topicId read from request
String t = getParameter(p_topicId);
if (t != null && t.trim().length() > 0) {
Topic topic = forumsModule.findTopicById(new Integer(t));
forum = topic.getForum();
} else {
String p = getParameter(p_postId);
if (p != null && p.trim().length() > 0) {
Post post = forumsModule.findPostById(new Integer(p));
Topic topic = post.getTopic();
forum = topic.getForum();
}
}
}
if (forum != null) {
topics = forumsModule.findTopics(forum);
topicsDataModel = new ListDataModel<Topic>(topics);
}
} catch (ModuleException e) {
log.error(e);
}
}
use of it.vige.rubia.model.Topic in project rubia-forums by flashboss.
the class ModeratorAction method lockTopic.
/**
* UI Action for locking selected topic(s).
*
* @return the name of the operation
*/
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String lockTopic() {
if (isAnyCheckboxSelected()) {
try {
for (int topicId : checkboxes.keySet()) {
boolean value = checkboxes.get(topicId);
try {
if (value) {
Topic topic = forumsModule.findTopicById(topicId);
updateStatus(topic, TOPIC_LOCKED);
}
} catch (Exception e) {
setWarnBundleMessage("ERR_INTERNAL");
return "";
}
}
setInfoBundleMessage("SUCC_TOPIC_LOCKED");
} catch (Exception e) {
handleException(e);
}
return "";
} else {
setWarnBundleMessage("None_selected");
return "";
}
}
use of it.vige.rubia.model.Topic in project rubia-forums by flashboss.
the class ModeratorAction method unlockTopic.
/**
* UI Action for unlocking selected topic(s).
*
* @return the name of the operation
*/
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String unlockTopic() {
if (isAnyCheckboxSelected()) {
try {
for (int topicId : checkboxes.keySet()) {
boolean value = checkboxes.get(topicId);
try {
if (value) {
Topic topic = forumsModule.findTopicById(topicId);
updateStatus(topic, TOPIC_UNLOCKED);
}
} catch (Exception e) {
setWarnBundleMessage("ERR_INTERNAL");
return "";
}
}
setInfoBundleMessage("SUCC_TOPIC_UNLOCKED");
} catch (Exception e) {
handleException(e);
}
return "";
} else {
setWarnBundleMessage("None_selected");
return "";
}
}
use of it.vige.rubia.model.Topic in project rubia-forums by flashboss.
the class ReplyTopic method start.
public String start() {
String navState = null;
try {
int forumId = -1;
int topicId = -1;
int postId = -1;
String f = getParameter(p_forumId);
String t = getParameter(p_topicId);
String p = getParameter(p_postId);
if (f != null && f.trim().length() > 0) {
forumId = parseInt(f);
}
if (t != null && t.trim().length() > 0) {
topicId = parseInt(t);
}
if (p != null && p.trim().length() > 0) {
postId = parseInt(p);
}
Topic topic = null;
if (topicId == -1 && postId != -1) {
// If topicId was not given and postId is available we get
// topicId from Post
Post post = forumsModule.findPostById((postId));
if (post != null) {
topic = post.getTopic();
topicId = topic.getId().intValue();
}
} else {
topic = forumsModule.findTopicById(topicId);
}
if (forumId == -1 && topic != null) {
forumId = topic.getForum().getId().intValue();
}
// re-initialize this controller to add a reply post in a topic
// to the specified forum
cleanup();
// set the selected forum's id and topic's id
this.forumId = forumId;
this.topicId = topicId;
// set the subject information
subject = RE + topic.getSubject();
navState = START_REPLY;
} catch (Exception e) {
handleException(e);
}
return navState;
}
Aggregations