ActionForm actionForm,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
CreateWebsiteForm form = (CreateWebsiteForm)actionForm;
ActionMessages msgs = new ActionMessages();
ActionMessages errors = validate(form, new ActionErrors());
ActionForward forward = mapping.findForward("yourWebsites");
Roller roller = RollerFactory.getRoller();
WebsiteData website = null;
if (!errors.isEmpty()) {
saveErrors(request, errors);
forward = mapping.findForward("createWebsite.page");
} else try {
RollerContext rollerContext = RollerContext.getRollerContext();
UserData user =
RollerSession.getRollerSession(request).getAuthenticatedUser();
UserManager mgr = roller.getUserManager();
if (!RollerConfig.getBooleanProperty("groupblogging.enabled")) {
List permissions = roller.getUserManager().getAllPermissions(user);
if (permissions.size() > 0) {
// sneaky user trying to get around 1 blog limit that applies
// only when group blogging is disabled
return mapping.findForward("access-denied");
}
}
WebsiteData wd = new WebsiteData(
form.getHandle(),
user,
form.getName(),
form.getDescription(),
form.getEmailAddress(),
form.getEmailAddress(),
form.getTheme(),
form.getLocale(),
form.getTimeZone());
try {
String def = RollerRuntimeConfig.getProperty("users.editor.pages");
String[] defs = Utilities.stringToStringArray(def,",");
wd.setEditorPage(defs[0]);
} catch (Exception ex) {
log.error("ERROR setting default editor page for weblog", ex);
}
mgr.addWebsite(wd);
RollerFactory.getRoller().flush();
request.setAttribute("model",
new CreateWebsitePageModel(request, response, mapping, website));
msgs.add(ActionMessages.GLOBAL_MESSAGE,
new ActionMessage("createWebsite.created", form.getHandle()));
saveMessages(request, msgs);
} catch (RollerException e) {
errors.add(ActionErrors.GLOBAL_ERROR,
new ActionError(e.getMessage()));
saveErrors(request, errors);