KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > applications > contenttool > actions > DeleteContentAction


1 /* ===============================================================================
2  *
3  * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4  *
5  * ===============================================================================
6  *
7  * Copyright (C)
8  *
9  * This program is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License version 2, as published by the
11  * Free Software Foundation. See the file LICENSE.html for more information.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19  * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20  *
21  * ===============================================================================
22  */

23
24 package org.infoglue.cms.applications.contenttool.actions;
25
26 import java.util.ArrayList JavaDoc;
27 import java.util.List JavaDoc;
28
29 import org.apache.log4j.Logger;
30 import org.infoglue.cms.applications.common.actions.InfoGlueAbstractAction;
31 import org.infoglue.cms.controllers.kernel.impl.simple.ContentController;
32 import org.infoglue.cms.controllers.kernel.impl.simple.ContentControllerProxy;
33 import org.infoglue.cms.controllers.kernel.impl.simple.RegistryController;
34 import org.infoglue.cms.entities.content.ContentVO;
35
36 /**
37  * This action removes a content from the system.
38  *
39  * @author Mattias Bogeblad
40  */

41
42 public class DeleteContentAction extends InfoGlueAbstractAction
43 {
44     private final static Logger logger = Logger.getLogger(DeleteContentAction.class.getName());
45
46     private static final long serialVersionUID = 1L;
47     
48     private ContentVO contentVO;
49     private Integer JavaDoc parentContentId;
50     private Integer JavaDoc changeTypeId;
51     private String JavaDoc[] registryId;
52     
53     //Used for the relatedPages control
54
private Integer JavaDoc siteNodeId;
55     
56     private List JavaDoc referenceBeanList = new ArrayList JavaDoc();
57     
58     public DeleteContentAction()
59     {
60         this(new ContentVO());
61     }
62
63     public DeleteContentAction(ContentVO contentVO)
64     {
65         this.contentVO = contentVO;
66     }
67     
68     public String JavaDoc doExecute() throws Exception JavaDoc
69     {
70         this.referenceBeanList = RegistryController.getController().getReferencingObjectsForContent(this.contentVO.getContentId());
71         if(this.referenceBeanList != null && this.referenceBeanList.size() > 0)
72         {
73             return "showRelations";
74         }
75         else
76         {
77             try
78             {
79                 this.parentContentId = ContentController.getParentContent(this.contentVO.getContentId()).getContentId();
80             }
81             catch(Exception JavaDoc e)
82             {
83                 logger.info("The content must have been a root-content because we could not find a parent.");
84             }
85
86             ContentControllerProxy.getController().acDelete(this.getInfoGluePrincipal(), this.contentVO);
87             
88             return "success";
89         }
90     }
91     
92     public String JavaDoc doStandalone() throws Exception JavaDoc
93     {
94         this.referenceBeanList = RegistryController.getController().getReferencingObjectsForContent(this.contentVO.getContentId());
95         if(this.referenceBeanList != null && this.referenceBeanList.size() > 0)
96         {
97             return "showRelations";
98         }
99         else
100         {
101             try
102             {
103                 this.parentContentId = ContentController.getParentContent(this.contentVO.getContentId()).getContentId();
104             }
105             catch(Exception JavaDoc e)
106             {
107                 logger.info("The content must have been a root-content because we could not find a parent.");
108             }
109
110             ContentControllerProxy.getController().acDelete(this.getInfoGluePrincipal(), this.contentVO);
111             
112             return "successStandalone";
113         }
114     }
115
116     public String JavaDoc doDeleteReference() throws Exception JavaDoc
117     {
118         for(int i=0; i<registryId.length; i++)
119             RegistryController.getController().delete(new Integer JavaDoc(registryId[i]));
120         
121         return doExecute();
122     }
123     
124     public String JavaDoc doFixPage() throws Exception JavaDoc
125     {
126         return "fixPage";
127     }
128
129     public String JavaDoc doFixPageHeader() throws Exception JavaDoc
130     {
131         return "fixPageHeader";
132     }
133
134     public void setContentId(Integer JavaDoc contentId)
135     {
136         this.contentVO.setContentId(contentId);
137     }
138
139     public void setParentContentId(Integer JavaDoc parentContentId)
140     {
141         this.parentContentId = parentContentId;
142     }
143
144     public void setChangeTypeId(Integer JavaDoc changeTypeId)
145     {
146         this.changeTypeId = changeTypeId;
147     }
148
149     public Integer JavaDoc getContentId()
150     {
151         return this.parentContentId;
152     }
153     
154     public Integer JavaDoc getOriginalContentId()
155     {
156         return this.contentVO.getContentId();
157     }
158     
159     public Integer JavaDoc getUnrefreshedContentId()
160     {
161         return this.parentContentId;
162     }
163     
164     public Integer JavaDoc getChangeTypeId()
165     {
166         return this.changeTypeId;
167     }
168         
169     public String JavaDoc getErrorKey()
170     {
171         return "ContentVersion.stateId";
172     }
173     
174     public String JavaDoc getReturnAddress()
175     {
176         return "ViewContent.action?contentId=" + this.contentVO.getId() + "&repositoryId=" + this.contentVO.getRepositoryId();
177     }
178
179     public List JavaDoc getReferenceBeanList()
180     {
181         return referenceBeanList;
182     }
183     
184     public Integer JavaDoc getSiteNodeId()
185     {
186         return siteNodeId;
187     }
188     
189     public void setSiteNodeId(Integer JavaDoc siteNodeId)
190     {
191         this.siteNodeId = siteNodeId;
192     }
193     
194     public String JavaDoc[] getRegistryId()
195     {
196         return registryId;
197     }
198     
199     public void setRegistryId(String JavaDoc[] registryId)
200     {
201         this.registryId = registryId;
202     }
203 }
204
Popular Tags