use of org.apache.wiki.WikiEngine in project jspwiki by apache.
the class BugReportHandler method findNextPage.
/**
* Finds a free page name for adding the bug report. Tries to construct a page,
* and if it's found, adds a number to it and tries again.
*/
private synchronized String findNextPage(WikiContext context, String title, String baseName) {
String basicPageName = ((baseName != null) ? baseName : "Bug") + MarkupParser.cleanLink(title);
WikiEngine engine = context.getEngine();
String pageName = basicPageName;
long lastbug = 2;
while (engine.pageExists(pageName)) {
pageName = basicPageName + lastbug++;
}
return pageName;
}
use of org.apache.wiki.WikiEngine in project jspwiki by apache.
the class UserNameTag method doWikiStartTag.
public final int doWikiStartTag() throws IOException {
WikiEngine engine = this.m_wikiContext.getEngine();
WikiSession wikiSession = WikiSession.getWikiSession(engine, (HttpServletRequest) pageContext.getRequest());
Principal user = wikiSession.getUserPrincipal();
if (user != null) {
if (VALID_USER_NAME_PATTERN.matcher(user.getName()).matches()) {
pageContext.getOut().print(TextUtil.replaceEntities(user.getName()));
} else {
pageContext.getOut().print(Preferences.getBundle(m_wikiContext, InternationalizationManager.CORE_BUNDLE).getString("security.user.fullname.invalid"));
}
}
return SKIP_BODY;
}
use of org.apache.wiki.WikiEngine in project jspwiki by apache.
the class UserProfileTag method doWikiStartTag.
public final int doWikiStartTag() throws IOException, WikiSecurityException {
UserManager manager = m_wikiContext.getEngine().getUserManager();
UserProfile profile = manager.getUserProfile(m_wikiContext.getWikiSession());
String result = null;
if (EXISTS.equals(m_prop) || NOT_NEW.equals(m_prop)) {
return profile.isNew() ? SKIP_BODY : EVAL_BODY_INCLUDE;
} else if (NEW.equals(m_prop) || NOT_EXISTS.equals(m_prop)) {
return profile.isNew() ? EVAL_BODY_INCLUDE : SKIP_BODY;
} else if (CREATED.equals(m_prop) && profile.getCreated() != null) {
result = profile.getCreated().toString();
} else if (EMAIL.equals(m_prop)) {
result = profile.getEmail();
} else if (FULLNAME.equals(m_prop)) {
result = profile.getFullname();
} else if (GROUPS.equals(m_prop)) {
result = printGroups(m_wikiContext);
} else if (LOGINNAME.equals(m_prop)) {
result = profile.getLoginName();
} else if (MODIFIED.equals(m_prop) && profile.getLastModified() != null) {
result = profile.getLastModified().toString();
} else if (ROLES.equals(m_prop)) {
result = printRoles(m_wikiContext);
} else if (WIKINAME.equals(m_prop)) {
result = profile.getWikiName();
if (result == null) {
//
// Default back to the declared user name
//
WikiEngine engine = this.m_wikiContext.getEngine();
WikiSession wikiSession = WikiSession.getWikiSession(engine, (HttpServletRequest) pageContext.getRequest());
Principal user = wikiSession.getUserPrincipal();
if (user != null) {
result = user.getName();
}
}
} else if (CHANGE_PASSWORD.equals(m_prop) || CHANGE_LOGIN_NAME.equals(m_prop)) {
AuthenticationManager authMgr = m_wikiContext.getEngine().getAuthenticationManager();
if (!authMgr.isContainerAuthenticated()) {
return EVAL_BODY_INCLUDE;
}
} else if (NOT_CHANGE_PASSWORD.equals(m_prop) || NOT_CHANGE_LOGIN_NAME.equals(m_prop)) {
AuthenticationManager authMgr = m_wikiContext.getEngine().getAuthenticationManager();
if (authMgr.isContainerAuthenticated()) {
return EVAL_BODY_INCLUDE;
}
}
if (result != null) {
pageContext.getOut().print(TextUtil.replaceEntities(result));
}
return SKIP_BODY;
}
use of org.apache.wiki.WikiEngine in project jspwiki by apache.
the class VariableTag method doWikiStartTag.
public final int doWikiStartTag() throws JspException, IOException {
WikiEngine engine = m_wikiContext.getEngine();
JspWriter out = pageContext.getOut();
String msg = null;
String value = null;
try {
value = engine.getVariableManager().getValue(m_wikiContext, getVar());
} catch (NoSuchVariableException e) {
msg = "No such variable: " + e.getMessage();
} catch (IllegalArgumentException e) {
msg = "Incorrect variable name: " + e.getMessage();
}
if (value == null) {
value = m_default;
}
if (value == null) {
value = msg;
}
out.write(TextUtil.replaceEntities(value));
return SKIP_BODY;
}
use of org.apache.wiki.WikiEngine in project jspwiki by apache.
the class ParentPageNameTag method doWikiStartTag.
/**
* {@inheritDoc}
*/
@Override
public final int doWikiStartTag() throws IOException {
WikiEngine engine = m_wikiContext.getEngine();
WikiPage page = m_wikiContext.getPage();
if (page != null) {
if (page instanceof Attachment) {
pageContext.getOut().print(engine.beautifyTitle(((Attachment) page).getParentName()));
} else {
String name = page.getName();
int entrystart = name.indexOf("_blogentry_");
if (entrystart != -1) {
name = name.substring(0, entrystart);
}
int commentstart = name.indexOf("_comments_");
if (commentstart != -1) {
name = name.substring(0, commentstart);
}
pageContext.getOut().print(engine.beautifyTitle(name));
}
}
return SKIP_BODY;
}
Aggregations