001: /**
002: * Copyright (c) 2003-2007, David A. Czarnecki
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms, with or without
006: * modification, are permitted provided that the following conditions are met:
007: *
008: * Redistributions of source code must retain the above copyright notice, this list of conditions and the
009: * following disclaimer.
010: * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
011: * following disclaimer in the documentation and/or other materials provided with the distribution.
012: * Neither the name of "David A. Czarnecki" and "blojsom" nor the names of its contributors may be used to
013: * endorse or promote products derived from this software without specific prior written permission.
014: * Products derived from this software may not be called "blojsom", nor may "blojsom" appear in their name,
015: * without prior written permission of David A. Czarnecki.
016: *
017: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
018: * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
019: * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
020: * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
021: * EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
022: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
023: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
024: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
025: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
026: * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
027: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
028: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
029: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
030: */package org.blojsom.plugin.admin;
031:
032: import org.apache.commons.logging.Log;
033: import org.apache.commons.logging.LogFactory;
034: import org.blojsom.blog.Blog;
035: import org.blojsom.blog.Entry;
036: import org.blojsom.blog.User;
037: import org.blojsom.fetcher.Fetcher;
038: import org.blojsom.fetcher.FetcherException;
039: import org.blojsom.plugin.PluginException;
040: import org.blojsom.util.BlojsomConstants;
041: import org.blojsom.util.BlojsomUtils;
042:
043: import javax.servlet.http.HttpServletRequest;
044: import javax.servlet.http.HttpServletResponse;
045: import java.io.File;
046: import java.io.IOException;
047: import java.util.Date;
048: import java.util.HashMap;
049: import java.util.Map;
050: import java.util.Properties;
051:
052: /**
053: * EditBlogsPlugin
054: *
055: * @author David Czarnecki
056: * @version $Id: EditBlogsPlugin.java,v 1.8 2007/01/17 02:35:05 czarneckid Exp $
057: * @since blojsom 3.0
058: */
059: public class EditBlogsPlugin extends BaseAdminPlugin {
060:
061: private Log _logger = LogFactory.getLog(EditBlogsPlugin.class);
062:
063: // Pages
064: private static final String EDIT_BLOG_USERS_PAGE = "/org/blojsom/plugin/admin/templates/admin-edit-blogs";
065:
066: // Localization constants
067: private static final String FAILED_DELETE_BLOGS_PERMISSION_KEY = "failed.delete.blogs.permission.text";
068: private static final String FAILED_REMOVE_BLOG_CONFIGURATION_KEY = "failed.remove.blog.configuration.text";
069: private static final String FAILED_REMOVE_BLOG_DIRECTORY_KEY = "failed.remove.blog.directory.text";
070: private static final String FAILED_REMOVE_BLOG_RESOURCES_DIRECTORY_KEY = "failed.remove.blog.resources.text";
071: private static final String DELETED_BLOG_KEY = "deleted.blog.text";
072:
073: private static final String FAILED_DELETE_PROTECTED_BLOG_KEY = "failed.delete.protected.blog.text";
074: private static final String FAILED_ADD_BLOGS_PERMISSION_KEY = "failed.add.blogs.permission.text";
075: private static final String MISSING_WEBLOG_ID_KEY = "missing.weblog.id.text";
076: private static final String WEBLOG_ID_EXISTS_KEY = "weblog.id.exists.text";
077: private static final String WEBLOG_DIRECTORY_EXISTS_KEY = "weblog.directory.exists.text";
078: private static final String PASSWORDS_NOT_MATCHED_KEY = "passwords.not.matched.text";
079: private static final String FAILED_BOOTSTRAP_DIRECTORY_COPY_KEY = "failed.bootstrap.directory.copy.text";
080: private static final String FAILED_BLOG_DIRECTORY_CREATE_KEY = "failed.blog.directory.create.text";
081: private static final String ADDED_NEW_WEBLOG_KEY = "added.new.blog.text";
082:
083: private static final String BLOJSOM_PLUGIN_EDIT_BLOGS = "BLOJSOM_PLUGIN_EDIT_BLOGS";
084:
085: // Actions
086: private static final String DELETE_BLOG_USER_ACTION = "delete-blog-user";
087: private static final String ADD_BLOG_USER_ACTION = "add-blog-user";
088:
089: // Form elements
090: private static final String BLOG_ID = "blog-id";
091: private static final String BLOG_LOGIN_ID = "blog-login-id";
092: private static final String BLOG_USER_EMAIL = "blog-user-email";
093: private static final String BLOG_USER_NAME = "blog-user-name";
094: private static final String BLOG_USER_PASSWORD = "blog-user-password";
095: private static final String BLOG_USER_PASSWORD_CHECK = "blog-user-password-check";
096:
097: // Permissions
098: private static final String ADD_BLOG_PERMISSION = "add_blog";
099: private static final String DELETE_BLOG_PERMISSION = "delete_blog";
100:
101: private Fetcher _fetcher;
102: private Map _defaultBlogProperties;
103: private Map _defaultTemplateProperties;
104: private Map _defaultPluginProperties;
105: private Properties _blojsomProperties;
106: private Map _protectedBlogs;
107:
108: /**
109: * Default constructor.
110: */
111: public EditBlogsPlugin() {
112: }
113:
114: /**
115: * Set the {@link Fetcher}
116: *
117: * @param fetcher {@link Fetcher}
118: */
119: public void setFetcher(Fetcher fetcher) {
120: _fetcher = fetcher;
121: }
122:
123: /**
124: * Set the default blog properties
125: *
126: * @param defaultBlogProperties Default blog properties
127: */
128: public void setDefaultBlogProperties(Map defaultBlogProperties) {
129: _defaultBlogProperties = defaultBlogProperties;
130: }
131:
132: /**
133: * Set the default template properties
134: *
135: * @param defaultTemplateProperties Default template properties
136: */
137: public void setDefaultTemplateProperties(
138: Map defaultTemplateProperties) {
139: _defaultTemplateProperties = defaultTemplateProperties;
140: }
141:
142: /**
143: * Set the default plugin properties
144: *
145: * @param defaultPluginProperties Default plugin properties
146: */
147: public void setDefaultPluginProperties(Map defaultPluginProperties) {
148: _defaultPluginProperties = defaultPluginProperties;
149: }
150:
151: /**
152: * Set the default blojsom properties
153: *
154: * @param blojsomProperties Default blojsom properties
155: */
156: public void setBlojsomProperties(Properties blojsomProperties) {
157: _blojsomProperties = blojsomProperties;
158: }
159:
160: /**
161: * Set the protected blogs (cannot be deleted)
162: *
163: * @param protectedBlogs Map of protected blogs
164: */
165: public void setProtectedBlogs(Map protectedBlogs) {
166: _protectedBlogs = protectedBlogs;
167: }
168:
169: /**
170: * Process the blog entries
171: *
172: * @param httpServletRequest Request
173: * @param httpServletResponse Response
174: * @param blog {@link Blog} instance
175: * @param context Context
176: * @param entries Blog entries retrieved for the particular request
177: * @return Modified set of blog entries
178: * @throws PluginException If there is an error processing the blog entries
179: */
180: public Entry[] process(HttpServletRequest httpServletRequest,
181: HttpServletResponse httpServletResponse, Blog blog,
182: Map context, Entry[] entries) throws PluginException {
183: if (!authenticateUser(httpServletRequest, httpServletResponse,
184: context, blog)) {
185: httpServletRequest.setAttribute(
186: BlojsomConstants.PAGE_PARAM, ADMIN_LOGIN_PAGE);
187:
188: return entries;
189: }
190:
191: String username = getUsernameFromSession(httpServletRequest,
192: blog);
193:
194: try {
195: context.put(BLOJSOM_PLUGIN_EDIT_BLOGS, _fetcher
196: .loadBlogIDs());
197: } catch (FetcherException e) {
198: _logger.error(e);
199: }
200:
201: String action = BlojsomUtils.getRequestValue(ACTION_PARAM,
202: httpServletRequest);
203: if (BlojsomUtils.checkNullOrBlank(action)) {
204: if (_logger.isDebugEnabled()) {
205: _logger.debug("User did not request edit action");
206: }
207:
208: httpServletRequest.setAttribute(
209: BlojsomConstants.PAGE_PARAM,
210: ADMIN_ADMINISTRATION_PAGE);
211: } else if (PAGE_ACTION.equals(action)) {
212: if (_logger.isDebugEnabled()) {
213: _logger.debug("User requested edit blogs page");
214: }
215:
216: httpServletRequest.setAttribute(
217: BlojsomConstants.PAGE_PARAM, EDIT_BLOG_USERS_PAGE);
218: } else if (DELETE_BLOG_USER_ACTION.equals(action)) {
219: if (_logger.isDebugEnabled()) {
220: _logger.debug("User requested delete blog action");
221: }
222:
223: // Check user is allowed to delete blogs
224: if (!checkPermission(blog, null, username,
225: DELETE_BLOG_PERMISSION)) {
226: httpServletRequest.setAttribute(
227: BlojsomConstants.PAGE_PARAM,
228: EDIT_BLOG_USERS_PAGE);
229: addOperationResultMessage(context, getAdminResource(
230: FAILED_DELETE_BLOGS_PERMISSION_KEY,
231: FAILED_DELETE_BLOGS_PERMISSION_KEY, blog
232: .getBlogAdministrationLocale()));
233:
234: return entries;
235: }
236:
237: String blogID = BlojsomUtils.getRequestValue(BLOG_ID,
238: httpServletRequest);
239:
240: if (BlojsomUtils.checkNullOrBlank(blogID)) {
241: httpServletRequest.setAttribute(
242: BlojsomConstants.PAGE_PARAM,
243: EDIT_BLOG_USERS_PAGE);
244: return entries;
245: } else if (_protectedBlogs.containsKey(blogID)) {
246: httpServletRequest.setAttribute(
247: BlojsomConstants.PAGE_PARAM,
248: EDIT_BLOG_USERS_PAGE);
249: addOperationResultMessage(context, formatAdminResource(
250: FAILED_DELETE_PROTECTED_BLOG_KEY,
251: FAILED_DELETE_PROTECTED_BLOG_KEY, blog
252: .getBlogAdministrationLocale(),
253: new Object[] { blogID }));
254:
255: return entries;
256: } else {
257: if (_logger.isDebugEnabled()) {
258: _logger.debug("Deleting blog: " + blogID);
259: }
260:
261: try {
262: Blog blogToDelete = _fetcher.loadBlog(blogID);
263: _fetcher.deleteBlog(blogToDelete);
264: } catch (FetcherException e) {
265: if (_logger.isErrorEnabled()) {
266: _logger.error(e);
267: }
268:
269: addOperationResultMessage(
270: context,
271: formatAdminResource(
272: FAILED_REMOVE_BLOG_CONFIGURATION_KEY,
273: FAILED_REMOVE_BLOG_CONFIGURATION_KEY,
274: blog.getBlogAdministrationLocale(),
275: new Object[] { blogID }));
276:
277: return entries;
278: }
279:
280: String blogsDirectoryPath = _blojsomProperties
281: .getProperty(
282: BlojsomConstants.BLOGS_DIRECTORY_IP,
283: BlojsomConstants.DEFAULT_BLOGS_DIRECTORY);
284: String resourcesDirectoryPath = _blojsomProperties
285: .getProperty(
286: BlojsomConstants.RESOURCES_DIRECTORY_IP,
287: BlojsomConstants.DEFAULT_RESOURCES_DIRECTORY);
288:
289: File blogDirectory = new File(
290: _servletConfig
291: .getServletContext()
292: .getRealPath(
293: BlojsomConstants.DEFAULT_CONFIGURATION_BASE_DIRECTORY)
294: + blogsDirectoryPath + blogID + "/");
295: if (!BlojsomUtils.deleteDirectory(blogDirectory)) {
296: if (_logger.isErrorEnabled()) {
297: _logger
298: .error("Unable to remove blog directory: "
299: + blogDirectory.toString());
300: }
301:
302: addOperationResultMessage(context,
303: formatAdminResource(
304: FAILED_REMOVE_BLOG_DIRECTORY_KEY,
305: FAILED_REMOVE_BLOG_DIRECTORY_KEY,
306: blog.getBlogAdministrationLocale(),
307: new Object[] { blogID }));
308: } else {
309: if (_logger.isDebugEnabled()) {
310: _logger.debug("Removed blog directory: "
311: + blogDirectory.toString());
312: }
313: }
314:
315: File blogResourcesDirectory = new File(_servletConfig
316: .getServletContext().getRealPath("/")
317: + resourcesDirectoryPath + blogID + "/");
318: if (!BlojsomUtils
319: .deleteDirectory(blogResourcesDirectory)) {
320: if (_logger.isErrorEnabled()) {
321: _logger
322: .error("Unable to remove blog resource directory: "
323: + blogResourcesDirectory
324: .toString());
325: }
326:
327: addOperationResultMessage(
328: context,
329: formatAdminResource(
330: FAILED_REMOVE_BLOG_RESOURCES_DIRECTORY_KEY,
331: FAILED_REMOVE_BLOG_RESOURCES_DIRECTORY_KEY,
332: blog.getBlogAdministrationLocale(),
333: new Object[] { blogID }));
334: } else {
335: if (_logger.isDebugEnabled()) {
336: _logger
337: .debug("Removed blog resource directory: "
338: + blogResourcesDirectory
339: .toString());
340: }
341: }
342:
343: if (_logger.isDebugEnabled()) {
344: _logger
345: .debug("Wrote new blojsom configuration after deleting blog: "
346: + blogID);
347: }
348:
349: try {
350: context.put(BLOJSOM_PLUGIN_EDIT_BLOGS, _fetcher
351: .loadBlogIDs());
352: } catch (FetcherException e) {
353: _logger.error(e);
354: }
355:
356: addOperationResultMessage(context, formatAdminResource(
357: DELETED_BLOG_KEY, DELETED_BLOG_KEY, blog
358: .getBlogAdministrationLocale(),
359: new Object[] { blogID }));
360: }
361:
362: httpServletRequest.setAttribute(
363: BlojsomConstants.PAGE_PARAM, EDIT_BLOG_USERS_PAGE);
364: } else if (ADD_BLOG_USER_ACTION.equals(action)) {
365: if (_logger.isDebugEnabled()) {
366: _logger.debug("User requested add blog action");
367: }
368:
369: // Check user is allowed to add blogs
370: if (!checkPermission(blog, null, username,
371: ADD_BLOG_PERMISSION)) {
372: httpServletRequest.setAttribute(
373: BlojsomConstants.PAGE_PARAM,
374: EDIT_BLOG_USERS_PAGE);
375: addOperationResultMessage(context, getAdminResource(
376: FAILED_ADD_BLOGS_PERMISSION_KEY,
377: FAILED_ADD_BLOGS_PERMISSION_KEY, blog
378: .getBlogAdministrationLocale()));
379:
380: return entries;
381: }
382:
383: String blogID = BlojsomUtils.getRequestValue(BLOG_ID,
384: httpServletRequest);
385:
386: if (BlojsomUtils.checkNullOrBlank(blogID)) { // Check that we got a blog user ID
387: addOperationResultMessage(context, getAdminResource(
388: MISSING_WEBLOG_ID_KEY, MISSING_WEBLOG_ID_KEY,
389: blog.getBlogAdministrationLocale()));
390: httpServletRequest.setAttribute(
391: BlojsomConstants.PAGE_PARAM,
392: EDIT_BLOG_USERS_PAGE);
393:
394: return entries;
395: } else { // Begin the process of adding a new user
396: if (_logger.isDebugEnabled()) {
397: _logger.debug("Adding new blog id: " + blogID);
398: }
399:
400: try {
401: _fetcher.loadBlog(blogID);
402:
403: addOperationResultMessage(context,
404: formatAdminResource(WEBLOG_ID_EXISTS_KEY,
405: WEBLOG_ID_EXISTS_KEY,
406: blog.getBlogAdministrationLocale(),
407: new Object[] { blogID }));
408: httpServletRequest.setAttribute(
409: BlojsomConstants.PAGE_PARAM,
410: EDIT_BLOG_USERS_PAGE);
411:
412: return entries;
413: } catch (FetcherException e) {
414: }
415:
416: Blog blogToAdd = _fetcher.newBlog();
417: blogToAdd.setBlogId(blogID);
418:
419: File blogDirectory = new File(
420: _servletConfig.getServletContext().getRealPath(
421: "/")
422: + BlojsomConstants.DEFAULT_CONFIGURATION_BASE_DIRECTORY
423: + blogID);
424: if (blogDirectory.exists()) { // Make sure that the blog user ID does not conflict with a directory underneath the installation directory
425: if (_logger.isDebugEnabled()) {
426: _logger
427: .debug("Blog directory already exists for blog ID: "
428: + blogID);
429: }
430:
431: addOperationResultMessage(context,
432: formatAdminResource(
433: WEBLOG_DIRECTORY_EXISTS_KEY,
434: WEBLOG_DIRECTORY_EXISTS_KEY,
435: blog.getBlogAdministrationLocale(),
436: new Object[] { blogID }));
437: httpServletRequest.setAttribute(
438: BlojsomConstants.PAGE_PARAM,
439: EDIT_BLOG_USERS_PAGE);
440:
441: return entries;
442: } else { // Otherwise, check the authorization passwords match
443: String blogUserPassword = BlojsomUtils
444: .getRequestValue(BLOG_USER_PASSWORD,
445: httpServletRequest);
446: String blogUserPasswordCheck = BlojsomUtils
447: .getRequestValue(BLOG_USER_PASSWORD_CHECK,
448: httpServletRequest);
449:
450: // Check to see that the password and password check are equal
451: if (!blogUserPassword.equals(blogUserPasswordCheck)) {
452: if (_logger.isDebugEnabled()) {
453: _logger
454: .debug("User password does not equal password check");
455: }
456:
457: addOperationResultMessage(
458: context,
459: getAdminResource(
460: PASSWORDS_NOT_MATCHED_KEY,
461: PASSWORDS_NOT_MATCHED_KEY,
462: blog
463: .getBlogAdministrationLocale()));
464: httpServletRequest.setAttribute(
465: BlojsomConstants.PAGE_PARAM,
466: EDIT_BLOG_USERS_PAGE);
467:
468: return entries;
469: } else { // And if they do, initialize the blog and user
470: String blogLoginID = BlojsomUtils
471: .getRequestValue(BLOG_LOGIN_ID,
472: httpServletRequest);
473: String blogUserEmail = BlojsomUtils
474: .getRequestValue(BLOG_USER_EMAIL,
475: httpServletRequest);
476: String blogUserName = BlojsomUtils
477: .getRequestValue(BLOG_USER_NAME,
478: httpServletRequest);
479:
480: if (!BlojsomUtils.checkNullOrBlank(blogLoginID)
481: && !BlojsomUtils
482: .checkNullOrBlank(blogUserEmail)) {
483: // Setup the blog
484: blogToAdd
485: .setProperties(_defaultBlogProperties);
486:
487: if (!BlojsomUtils
488: .checkNullOrBlank(blogUserName)) {
489: blogToAdd.setBlogOwner(blogUserName);
490: } else {
491: blogToAdd.setBlogOwner(blogLoginID);
492: }
493:
494: if (!BlojsomUtils
495: .checkNullOrBlank(blogUserEmail)) {
496: blogToAdd
497: .setBlogOwnerEmail(blogUserEmail);
498: }
499:
500: blogToAdd
501: .setTemplates(_defaultTemplateProperties);
502: blogToAdd
503: .setPlugins(_defaultPluginProperties);
504:
505: BlojsomUtils.resolveDynamicBaseAndBlogURL(
506: httpServletRequest, blogToAdd,
507: blogID);
508:
509: try {
510: _fetcher.saveBlog(blogToAdd);
511: } catch (FetcherException e) {
512: if (_logger.isErrorEnabled()) {
513: _logger.error(e);
514: }
515:
516: return entries;
517: }
518:
519: User user = _fetcher.newUser();
520: user.setBlogId(blogToAdd.getId());
521: user.setUserEmail(blogUserEmail);
522: Map userMetaData = new HashMap();
523: userMetaData.put(
524: "all_permissions_permission",
525: "true");
526: user.setMetaData(userMetaData);
527: user.setUserLogin(blogLoginID);
528: if (!BlojsomUtils
529: .checkNullOrBlank(blogUserName)) {
530: user.setUserName(blogUserName);
531: } else {
532: user.setUserName(blogLoginID);
533: }
534: user.setUserPassword(blogUserPassword);
535: user.setUserRegistered(new Date());
536: user.setUserStatus("new");
537:
538: try {
539: _fetcher.saveUser(blogToAdd, user);
540: } catch (FetcherException e) {
541: if (_logger.isErrorEnabled()) {
542: _logger.error(e);
543: }
544: }
545:
546: String blogsDirectoryPath = _blojsomProperties
547: .getProperty(
548: BlojsomConstants.BLOGS_DIRECTORY_IP,
549: BlojsomConstants.DEFAULT_BLOGS_DIRECTORY);
550: String bootstrapDirectoryPath = _blojsomProperties
551: .getProperty(
552: BlojsomConstants.BOOTSTRAP_DIRECTORY_IP,
553: BlojsomConstants.DEFAULT_BOOTSTRAP_DIRECTORY);
554: String templatesDirectoryPath = _blojsomProperties
555: .getProperty(
556: BlojsomConstants.TEMPLATES_DIRECTORY_IP,
557: BlojsomConstants.DEFAULT_TEMPLATES_DIRECTORY);
558: String resourcesDirectoryPath = _blojsomProperties
559: .getProperty(
560: BlojsomConstants.RESOURCES_DIRECTORY_IP,
561: BlojsomConstants.DEFAULT_RESOURCES_DIRECTORY);
562:
563: File bootstrapResourcesDirectory = new File(
564: _servletConfig
565: .getServletContext()
566: .getRealPath(
567: BlojsomConstants.DEFAULT_CONFIGURATION_BASE_DIRECTORY)
568: + blogsDirectoryPath
569: + bootstrapDirectoryPath
570: + resourcesDirectoryPath);
571: File newBlogResourcesDirectory = new File(
572: _servletConfig
573: .getServletContext()
574: .getRealPath(
575: resourcesDirectoryPath)
576: + "/" + blogID);
577: File bootstrapTemplatesDirectory = new File(
578: _servletConfig
579: .getServletContext()
580: .getRealPath(
581: BlojsomConstants.DEFAULT_CONFIGURATION_BASE_DIRECTORY)
582: + blogsDirectoryPath
583: + bootstrapDirectoryPath
584: + templatesDirectoryPath);
585: File newBlogTemplatesDirectory = new File(
586: _servletConfig
587: .getServletContext()
588: .getRealPath(
589: BlojsomConstants.DEFAULT_CONFIGURATION_BASE_DIRECTORY)
590: + blogsDirectoryPath
591: + blogID
592: + templatesDirectoryPath);
593:
594: try {
595: newBlogResourcesDirectory.mkdirs();
596: BlojsomUtils.copyDirectory(
597: bootstrapResourcesDirectory,
598: newBlogResourcesDirectory);
599: } catch (IOException e) {
600: if (_logger.isErrorEnabled()) {
601: _logger.error(e);
602: }
603:
604: addOperationResultMessage(
605: context,
606: getAdminResource(
607: FAILED_BOOTSTRAP_DIRECTORY_COPY_KEY,
608: FAILED_BOOTSTRAP_DIRECTORY_COPY_KEY,
609: blog
610: .getBlogAdministrationLocale()));
611: httpServletRequest.setAttribute(
612: BlojsomConstants.PAGE_PARAM,
613: EDIT_BLOG_USERS_PAGE);
614:
615: return entries;
616: }
617:
618: try {
619: newBlogTemplatesDirectory.mkdirs();
620: BlojsomUtils.copyDirectory(
621: bootstrapTemplatesDirectory,
622: newBlogTemplatesDirectory);
623: } catch (IOException e) {
624: if (_logger.isErrorEnabled()) {
625: _logger.error(e);
626: }
627:
628: addOperationResultMessage(
629: context,
630: getAdminResource(
631: FAILED_BLOG_DIRECTORY_CREATE_KEY,
632: FAILED_BLOG_DIRECTORY_CREATE_KEY,
633: blog
634: .getBlogAdministrationLocale()));
635: httpServletRequest.setAttribute(
636: BlojsomConstants.PAGE_PARAM,
637: EDIT_BLOG_USERS_PAGE);
638:
639: return entries;
640: }
641:
642: try {
643: context.put(BLOJSOM_PLUGIN_EDIT_BLOGS,
644: _fetcher.loadBlogIDs());
645: } catch (FetcherException e) {
646: _logger.error(e);
647: }
648:
649: addOperationResultMessage(
650: context,
651: formatAdminResource(
652: ADDED_NEW_WEBLOG_KEY,
653: ADDED_NEW_WEBLOG_KEY,
654: blog
655: .getBlogAdministrationLocale(),
656: new Object[] { blogID }));
657: httpServletRequest.setAttribute(
658: BlojsomConstants.PAGE_PARAM,
659: EDIT_BLOG_USERS_PAGE);
660: } else {
661: // User login ID or user e-mail is null or blank
662: }
663: }
664: }
665: }
666: }
667:
668: return entries;
669: }
670: }
|