public String save() {
User user = getAuthenticatedUser();
try {
if (!WebloggerConfig.getBooleanProperty("groupblogging.enabled")) {
UserManager mgr = WebloggerFactory.getWeblogger().getUserManager();
List permissions = mgr.getAllPermissions(user);
if (permissions.size() > 0) {
// sneaky user trying to get around 1 blog limit that applies
// only when group blogging is disabled
// TODO: i18n
addError("Sorry, you are only allowed to have 1 weblog.");
return "menu";
}
}
} catch (WebloggerException ex) {
log.error("error checking for existing weblogs count", ex);
}
myValidate();
if(!hasActionErrors()) {
Weblog wd = new Weblog(
getBean().getHandle(),
user,
getBean().getName(),
getBean().getDescription(),
getBean().getEmailAddress(),
getBean().getEmailAddress(),
getBean().getTheme(),
getBean().getLocale(),
getBean().getTimeZone());
// pick a weblog editor for this weblog
String def = WebloggerRuntimeConfig.getProperty("users.editor.pages");
String[] defs = Utilities.stringToStringArray(def,",");
wd.setEditorPage(defs[0]);
try {
// add weblog and flush
UserManager mgr = WebloggerFactory.getWeblogger().getUserManager();
mgr.addWebsite(wd);
WebloggerFactory.getWeblogger().flush();
// tell the user their weblog was created
addMessage("createWebsite.created", getBean().getHandle());