WikiUserDetails user = ServletUtil.currentUserDetails();
if (ServletUtil.isEditable(virtualWiki, topicName, user)) {
return null;
}
if (!user.hasRole(RoleImpl.ROLE_EDIT_EXISTING)) {
WikiMessage messageObject = new WikiMessage("login.message.edit");
return ServletUtil.viewLogin(request, pageInfo, WikiUtil
.getTopicFromURI(request), messageObject);
}
if (!user.hasRole(RoleImpl.ROLE_EDIT_NEW)
&& WikiBase.getDataHandler().lookupTopic(virtualWiki, topicName, false,
null) == null) {
WikiMessage messageObject = new WikiMessage("login.message.editnew");
return ServletUtil.viewLogin(request, pageInfo, WikiUtil
.getTopicFromURI(request), messageObject);
}
Topic topic = WikiBase.getDataHandler().lookupTopic(virtualWiki, topicName,
false, null);
if (topic == null) {
// this should never trigger, but better safe than sorry...
return null;
}
// if (topic.getAdminOnly()) {
// WikiMessage messageObject = new WikiMessage("login.message.editadmin",
// topicName);
// return ServletUtil.viewLogin(request, pageInfo,
// WikiUtil.getTopicFromURI(request), messageObject);
// }
// if (topic.getReadOnly()) {
// throw new WikiException(new WikiMessage("error.readonly"));
// }
// it should be impossible to get here...
throw new WikiException(new WikiMessage("error.unknown",
"Unable to determine topic editing permissions"));
}