KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > applications > structuretool > actions > DeleteSiteNodeAction


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.structuretool.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.RegistryController;
32 import org.infoglue.cms.controllers.kernel.impl.simple.SiteNodeController;
33 import org.infoglue.cms.controllers.kernel.impl.simple.SiteNodeControllerProxy;
34 import org.infoglue.cms.entities.structure.SiteNodeVO;
35
36
37 /**
38  * This action removes a siteNode from the system.
39  *
40  * @author Mattias Bogeblad
41  */

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