File Source: WeblogRemove.java
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. The ASF licenses this file to You
4 * under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License. For additional information regarding
15 * copyright in this work, please see the NOTICE file in the top level
16 * directory of this distribution.
17 */
18
19 package org.apache.roller.weblogger.ui.struts2.editor;
20
21 import org.apache.commons.logging.Log;
22 import org.apache.commons.logging.LogFactory;
23 import org.apache.roller.weblogger.business.WebloggerFactory;
24 import org.apache.roller.weblogger.business.UserManager;
25 import org.apache.roller.weblogger.pojos.WeblogPermission;
26 import org.apache.roller.weblogger.ui.struts2.util.UIAction;
27 import org.apache.roller.weblogger.util.cache.CacheManager;
28
29
30 /**
31 * Action for removing a weblog.
32 */
33 public class WeblogRemove extends UIAction {
34
/*
P/P * Method: org.apache.roller.weblogger.ui.struts2.editor.WeblogRemove__static_init
*
* Postconditions:
* init'ed(log)
*/
35 private static Log log = LogFactory.getLog(WeblogRemove.class);
36
37
/*
P/P * Method: void org.apache.roller.weblogger.ui.struts2.editor.WeblogRemove()
*
* Postconditions:
* this.actionName == &"weblogRemove"
* this.actionWeblog == null
* this.authenticatedUser == null
* this.weblog == null
* this.desiredMenu == &"editor"
* this.pageTitle == &"websiteRemove.title"
*/
38 public WeblogRemove() {
39 this.actionName = "weblogRemove";
40 this.desiredMenu = "editor";
41 this.pageTitle = "websiteRemove.title";
42 }
43
44
45 // admin perms required
46 public short requiredWeblogPermissions() {
/*
P/P * Method: short requiredWeblogPermissions()
*
* Presumptions:
* init'ed(org.apache.roller.weblogger.pojos.WeblogPermission.ADMIN)
*
* Postconditions:
* return_value == org.apache.roller.weblogger.pojos.WeblogPermission.ADMIN
* (soft) init'ed(return_value)
*/
47 return WeblogPermission.ADMIN;
48 }
49
50
51 /**
52 * Show weblog remove confirmation.
53 */
54 public String execute() {
/*
P/P * Method: String execute()
*
* Postconditions:
* return_value == &"confirm"
*/
55 return "confirm";
56 }
57
58
59 /**
60 * Remove a weblog.
61 */
62 public String remove() {
63
64 try {
/*
P/P * Method: String remove()
*
* Preconditions:
* this.actionWeblog != null
* (soft) log != null
*
* Presumptions:
* org.apache.roller.weblogger.business.Weblogger:getUserManager(...)@65 != null
* org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger(...)@65 != null
* org.apache.roller.weblogger.business.WebloggerFactory:getWeblogger(...)@69 != null
*
* Postconditions:
* return_value in Addr_Set{&"success",&"confirm"}
*/
65 UserManager umgr = WebloggerFactory.getWeblogger().getUserManager();
66
67 // remove website
68 umgr.removeWebsite(getActionWeblog());
69 WebloggerFactory.getWeblogger().flush();
70
71 CacheManager.invalidate(getActionWeblog());
72
73 // TODO: i18n
74 addMessage("Successfully removed weblog - "+getActionWeblog().getName());
75
76 return SUCCESS;
77
78 } catch (Exception ex) {
79 log.error("Error removing weblog - "+getActionWeblog().getHandle(), ex);
80 // TODO: i18n
81 addError("Error removing weblog");
82 }
83
84 return "confirm";
85
86 }
87
88 }
SofCheck Inspector Build Version : 2.18479
| WeblogRemove.java |
2009-Jan-02 14:25:26 |
| WeblogRemove.class |
2009-Sep-04 03:12:45 |