private String processAuthenticationRequiredException(HttpServletRequest request) throws JspException { String key = (String) request .getSession() .getAttribute(JAMWikiAuthenticationConstants.JAMWIKI_AUTHENTICATION_REQUIRED_KEY); String uri = (String) request .getSession() .getAttribute( JAMWikiAuthenticationConstants.JAMWIKI_AUTHENTICATION_REQUIRED_URI_KEY); if (key == null) { return null; } Object[] params = {uri}; String message = Utilities.formatMessage(key, ServletUtil.retrieveUserLocale(request), params); request .getSession() .removeAttribute(JAMWikiAuthenticationConstants.JAMWIKI_AUTHENTICATION_REQUIRED_KEY); request .getSession() .removeAttribute(JAMWikiAuthenticationConstants.JAMWIKI_AUTHENTICATION_REQUIRED_URI_KEY); return formatMessage(message); }
private String processAuthorizationException(HttpServletRequest request) throws JspException { String key = (String) request.getParameter("message"); if (key == null) { return null; } String message = Utilities.formatMessage(key, ServletUtil.retrieveUserLocale(request)); return formatMessage(message); }
private StringBuffer nextPage( Pagination pagination, String baseUrl, int count, boolean previous) { HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest(); StringBuffer output = new StringBuffer(); try { Object[] objects = new Object[1]; objects[0] = new Integer(pagination.getNumResults()); if (pagination.getOffset() == 0 && previous) { output.append( Utilities.formatMessage("common.pagination.previous", request.getLocale(), objects)); return output; } if (pagination.getNumResults() != count && !previous) { output.append( Utilities.formatMessage("common.pagination.next", request.getLocale(), objects)); return output; } output.append("<a href=\""); String virtualWiki = Utilities.getVirtualWikiFromRequest(request); WikiLink wikiLink = LinkUtil.parseWikiLink(baseUrl); int offset = pagination.getOffset() + pagination.getNumResults(); if (previous) { offset = pagination.getOffset() - pagination.getNumResults(); if (offset < 0) offset = 0; } String query = LinkUtil.appendQueryParam( wikiLink.getQuery(), "num", new Integer(pagination.getNumResults()).toString()); query += "&offset=" + offset; wikiLink.setQuery(query); output.append(LinkUtil.buildInternalLinkUrl(request.getContextPath(), virtualWiki, wikiLink)); output.append("\">"); if (previous) { output.append( Utilities.formatMessage("common.pagination.previous", request.getLocale(), objects)); } else { output.append( Utilities.formatMessage("common.pagination.next", request.getLocale(), objects)); } output.append("</a>"); } catch (Exception e) { logger.warning("Failure while building pagination element", e); } return output; }
private String processLegacyLogin(HttpServletRequest request) throws JspException { WikiMessage messageObject = (WikiMessage) request.getAttribute("messageObject"); if (messageObject == null) { return null; } String message = Utilities.formatMessage( messageObject.getKey(), ServletUtil.retrieveUserLocale(request), messageObject.getParams()); return formatMessage(message); }
private String buildSectionEditLink(ParserInput parserInput, int section) throws ParserException { if (!parserInput.getAllowSectionEdit()) { return ""; } if (parserInput.getLocale() == null) { logger.info( "Unable to build section edit links for " + parserInput.getTopicName() + " - locale is empty"); return ""; } // FIXME - template inclusion causes section edits to break, so disable for now Integer inclusion = (Integer) parserInput.getTempParam(TemplateTag.TEMPLATE_INCLUSION); boolean disallowInclusion = (inclusion != null && inclusion > 0); if (disallowInclusion) { return ""; } String url = ""; try { url = LinkUtil.buildEditLinkUrl( parserInput.getContext(), parserInput.getVirtualWiki(), parserInput.getTopicName(), null, section); } catch (DataAccessException e) { logger.error( "Failure while building link for topic " + parserInput.getVirtualWiki() + " / " + parserInput.getTopicName(), e); } // arguments are edit link URL and edit label text Object[] args = new Object[2]; args[0] = url; args[1] = Utilities.formatMessage("common.sectionedit", parserInput.getLocale()); try { return WikiUtil.formatFromTemplate(TEMPLATE_HEADER_EDIT_LINK, args); } catch (IOException e) { throw new ParserException(e); } }
private StringBuffer numResults(Pagination pagination, String baseUrl) { HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest(); StringBuffer output = new StringBuffer(); output .append(Utilities.formatMessage("common.pagination.results", request.getLocale())) .append(": "); output.append(buildOption(10, pagination, baseUrl)); output.append(" | "); output.append(buildOption(25, pagination, baseUrl)); output.append(" | "); output.append(buildOption(50, pagination, baseUrl)); output.append(" | "); output.append(buildOption(100, pagination, baseUrl)); output.append(" | "); output.append(buildOption(250, pagination, baseUrl)); output.append(" | "); output.append(buildOption(500, pagination, baseUrl)); return output; }
@Override public void buildEditLinkUrl(int section) { if (fParserInput.getAllowSectionEdit()) { TagNode divTagNode = new TagNode("div"); divTagNode.addAttribute("style", "font-size:90%;float:right;margin-left:5px;", false); divTagNode.addChild(new ContentToken("[")); append(divTagNode); String url = ""; try { // Use correct section number. // Bliki starts with offset 0 so it must be "section+1" url = LinkUtil.buildEditLinkUrl( fParserInput.getContext(), fParserInput.getVirtualWiki(), fParserInput.getTopicName(), null, section + 1); } catch (Exception e) { logger.error( "Failure while building link for topic " + fParserInput.getVirtualWiki() + " / " + fParserInput.getTopicName(), e); } TagNode aTagNode = new TagNode("a"); aTagNode.addAttribute("href", url, false); aTagNode.addChild( new ContentToken( Utilities.formatMessage("common.sectionedit", fParserInput.getLocale()))); divTagNode.addChild(aTagNode); divTagNode.addChild(new ContentToken("]")); } }