use of javax.interceptor.Interceptors in project rubia-forums by flashboss.
the class DeletePost method confirmDelete.
// actions---------------------------------------------------------------------------------------------------------------------------------
/**
* @return the navigation state of the application
*/
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String confirmDelete() {
String navState = null;
try {
// setup the business objects/data of interest
Post post = forumsModule.findPostById(postId);
Topic topic = post.getTopic();
// 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));
}
boolean isFirstPost = false;
boolean isLastPost = false;
List<Post> posts = forumsModule.findPostsByTopicId(topic);
if (posts.get(0).getId() == post.getId().intValue()) {
isFirstPost = true;
}
if (posts.get(posts.size() - 1).getId().intValue() == post.getId().intValue()) {
isLastPost = true;
}
// now perform the actual delete operation.........................
if (isLastPost && isFirstPost) {
// cascade delete will take care of removing
// the post
// the watches
// the poll
// the links
forumsModule.removeTopic(post.getTopic().getId());
// set the proper navigation state
navState = TOPIC_DELETED;
} else {
forumsModule.removePost(post.getId(), isLastPost);
// set the proper navigation state
navState = SUCCESS;
}
} catch (Exception e) {
handleException(e);
}
return navState;
}
use of javax.interceptor.Interceptors in project rubia-forums by flashboss.
the class ForumWatchController method activateWatch.
/**
* @return the navigation state of the application
*/
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String activateWatch() {
String navState = null;
try {
int forumId = selectedForum;
try {
String wt = getRequestParameter(p_notified_watch_type);
if (wt != null && wt.trim().length() > 0) {
watchMode = parseInt(wt);
} else {
watchMode = -1;
}
} catch (NumberFormatException e) {
handleException(e);
watchMode = -1;
}
if (forumId == -1 || watchMode == -1) {
return null;
}
// make sure a watch for this forum is not already issued for this
// user
boolean isDuplicate = isDuplicateWatch(forumId);
if (isDuplicate) {
return "success";
}
// get the forum that must be activated for watching
Forum forum = forumsModule.findForumById(forumId);
// activate the watch for the selected forum
forumsModule.createWatch(getPoster(userModule, forumsModule), forum, watchMode);
navState = "success";
} catch (Exception e) {
handleException(e);
}
return navState;
}
use of javax.interceptor.Interceptors in project rubia-forums by flashboss.
the class ForumWatchController method deActivateWatch.
/**
* @return the navigation state of the application
*/
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String deActivateWatch() {
String navState = null;
try {
int watchId = -1;
String w = getRequestParameter(p_watchId);
if (w != null && w.trim().length() > 0) {
watchId = parseInt(w);
}
if (watchId == -1) {
String f = getRequestParameter(p_forumId);
if (f != null && f.trim().length() > 0) {
int forumId = parseInt(f);
ForumWatch forumWatch = forumsModule.findForumWatchByUserAndForum(getUser(userModule), forumId);
watchId = forumWatch != null ? forumWatch.getId().intValue() : -1;
}
}
if (watchId != -1) {
forumsModule.removeWatch(forumsModule.findForumWatchById(watchId));
}
} catch (Exception e) {
handleException(e);
}
return navState;
}
use of javax.interceptor.Interceptors 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 javax.interceptor.Interceptors 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 "";
}
}
Aggregations