use of it.vige.rubia.ModuleException in project rubia-forums by flashboss.
the class ViewForum method execute.
/**
*/
@PostConstruct
public void execute() {
// parse the input parameters
int forumId = -1;
String f = getParameter(p_forumId);
if (f != null && f.trim().length() > 0) {
forumId = parseInt(f);
}
// ForumsModule is stored as a final variable so that anonymous
// class
// could use it.
final ForumsModule fm = forumsModule;
// grab the data to be displayed for this page
if (forumId != -1) {
// be displayed
try {
forum = fm.findForumById(forumId);
// Getting sticky topics for this page
Collection<Topic> stickies = getStickyThreads();
// Getting announcements
Collection<Topic> announcements = getAnnouncements();
normalThreads = fm.findTopicsDesc(forum, NORMAL, 0, MAX_VALUE);
normalThreadsDataModel = new ListDataModel<Topic>(normalThreads);
Collection<Topic> listOfTopics = new LinkedList<Topic>();
listOfTopics.addAll(stickies);
listOfTopics.addAll(announcements);
listOfTopics.addAll(normalThreads);
// Getting sticky topics for this page
topicLastPosts = fm.findLastPostsOfTopics(listOfTopics);
// topic minipaging
for (Topic cour : listOfTopics) {
if (cour.getReplies() > 0) {
PageNavigator topicNav = new PageNavigator(cour.getReplies() + 1, // this
userPreferences.getPostsPerTopic(), // current page of the navigator
0) {
/**
*/
private static final long serialVersionUID = 6277599446838264687L;
protected Collection<Integer> initializePage() {
return null;
}
};
topicNavigator.put(cour.getId(), topicNav);
}
}
} catch (ModuleException e) {
log.error(e);
}
}
}
use of it.vige.rubia.ModuleException in project rubia-forums by flashboss.
the class FeedsServlet method doGet.
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
String[] uri = request.getRequestURI().split("/");
if (uri.length < 5 || (uri[4].equals(GLOBAL) && uri.length != 5) || (!uri[4].equals(GLOBAL) && uri.length != 6)) {
response.sendError(SC_BAD_REQUEST, WRONG_FEED_REQ);
return;
}
String type = uri[3];
String what = uri[4];
Integer id = null;
if (!what.equals(GLOBAL))
id = valueOf(uri[5]);
SyndFeed feed = new SyndFeedImpl();
if (!setFeedType(feed, type)) {
response.sendError(SC_BAD_REQUEST, WRONG_FEED_TYPE + type);
return;
}
String url = null;
String urlType = null;
String urlRequestParam = request.getParameter("url");
String urlTypeRequestParam = request.getParameter("urlType");
if (urlRequestParam != null && urlRequestParam.trim().length() != 0 && urlTypeRequestParam != null && urlTypeRequestParam.trim().length() != 0 && (urlTypeRequestParam.compareTo("p") == 0 || urlTypeRequestParam.compareTo("s") == 0)) {
url = request.getParameter("url");
urlType = urlTypeRequestParam;
}
String urlInitParam = getServletContext().getInitParameter(URL_INIT_PARAM_NAME);
String urlTypeInitParam = getServletContext().getInitParameter(URL_TYPE_INIT_PARAM_NAME);
if (urlInitParam != null && urlInitParam.trim().length() != 0 && urlTypeInitParam != null && urlTypeInitParam.trim().length() != 0) {
url = urlInitParam;
urlType = urlTypeInitParam;
}
if (url == null || urlType == null) {
response.sendError(SC_BAD_REQUEST, WRONG_FEED_REQ);
return;
}
try {
if (what.equals(CATEGORY)) {
createCategoryFeed(feed, id, url, urlType);
} else if (what.equals(FORUM)) {
createForumFeed(feed, id, url, urlType);
} else if (what.equals(TOPIC)) {
createTopicFeed(feed, id, url, urlType);
} else if (what.equals(GLOBAL)) {
createGlobalFeed(feed, id, url, urlType);
} else {
response.sendError(SC_BAD_REQUEST, WRONG_FEED_SHOW_TYPE + what);
return;
}
} catch (ModuleException e) {
response.sendError(SC_INTERNAL_SERVER_ERROR, e.getMessage());
return;
}
response.setContentType("text/xml");
Writer writer = response.getWriter();
SyndFeedOutput output = new SyndFeedOutput();
output.output(feed, writer);
writer.flush();
} catch (Exception e) {
throw new ServletException(e);
}
}
use of it.vige.rubia.ModuleException 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);
}
}
Aggregations