KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > controllers > kernel > impl > simple > SiteNodeControllerProxy


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.controllers.kernel.impl.simple;
25
26 import java.util.ArrayList JavaDoc;
27 import java.util.HashMap JavaDoc;
28 import java.util.List JavaDoc;
29 import java.util.Map JavaDoc;
30
31 import org.exolab.castor.jdo.Database;
32 import org.infoglue.cms.entities.structure.SiteNode;
33 import org.infoglue.cms.entities.structure.SiteNodeVO;
34 import org.infoglue.cms.exception.Bug;
35 import org.infoglue.cms.exception.ConstraintException;
36 import org.infoglue.cms.exception.SystemException;
37 import org.infoglue.cms.security.InfoGluePrincipal;
38
39
40 /**
41  * @author Mattias Bogeblad
42  */

43
44 public class SiteNodeControllerProxy extends SiteNodeController
45 {
46     protected static final Integer JavaDoc NO = new Integer JavaDoc(0);
47     protected static final Integer JavaDoc YES = new Integer JavaDoc(1);
48     protected static final Integer JavaDoc INHERITED = new Integer JavaDoc(2);
49
50     private static List JavaDoc interceptors = new ArrayList JavaDoc();
51
52     public static SiteNodeControllerProxy getSiteNodeControllerProxy()
53     {
54         return new SiteNodeControllerProxy();
55     }
56     
57     /*
58     private void intercept(Map hashMap, String InterceptionPointName, InfoGluePrincipal infogluePrincipal) throws ConstraintException, SystemException, Bug, Exception
59     {
60         InterceptionPointVO interceptionPointVO = InterceptionPointController.getController().getInterceptionPointVOWithName(InterceptionPointName);
61         
62         if(interceptionPointVO == null)
63             throw new SystemException("The InterceptionPoint " + InterceptionPointName + " was not found. The system will not work unless you restore it.");
64             
65         List interceptors = InterceptionPointController.getController().getInterceptorsVOList(interceptionPointVO.getInterceptionPointId());
66         Iterator interceptorsIterator = interceptors.iterator();
67         while(interceptorsIterator.hasNext())
68         {
69             InterceptorVO interceptorVO = (InterceptorVO)interceptorsIterator.next();
70             logger.info("Adding interceptorVO:" + interceptorVO.getName());
71             try
72             {
73                 InfoGlueInterceptor infoGlueInterceptor = (InfoGlueInterceptor)Class.forName(interceptorVO.getClassName()).newInstance();
74                 infoGlueInterceptor.intercept(infogluePrincipal, interceptionPointVO, hashMap);
75             }
76             catch(ClassNotFoundException e)
77             {
78                 logger.warn("The interceptor " + interceptorVO.getClassName() + "was not found: " + e.getMessage(), e);
79             }
80         }
81
82     }
83     */

84     /*
85     private void intercept(Map hashMap, String InterceptionPointName, InfoGluePrincipal infogluePrincipal, Database db) throws ConstraintException, SystemException, Bug, Exception
86     {
87         InterceptionPoint interceptionPoint = InterceptionPointController.getController().getInterceptionPointWithName(InterceptionPointName, db);
88         
89         List interceptors = InterceptionPointController.getController().getInterceptorsVOList(interceptionPoint.getInterceptionPointId(), db);
90         Iterator interceptorsIterator = interceptors.iterator();
91         while(interceptorsIterator.hasNext())
92         {
93             InterceptorVO interceptorVO = (InterceptorVO)interceptorsIterator.next();
94             logger.info("Adding interceptorVO:" + interceptorVO.getName());
95             try
96             {
97                 InfoGlueInterceptor infoGlueInterceptor = (InfoGlueInterceptor)Class.forName(interceptorVO.getClassName()).newInstance();
98                 infoGlueInterceptor.intercept(infogluePrincipal, interceptionPoint.getValueObject(), hashMap, db);
99             }
100             catch(ClassNotFoundException e)
101             {
102                 logger.warn("The interceptor " + interceptorVO.getClassName() + "was not found: " + e.getMessage(), e);
103             }
104         }
105
106     }
107     */

108     
109     /**
110      * This method creates a siteNode after first checking that the user has rights to create it.
111      */

112
113     public SiteNodeVO acCreate(InfoGluePrincipal infogluePrincipal, Integer JavaDoc parentSiteNodeId, Integer JavaDoc siteNodeTypeDefinitionId, Integer JavaDoc repositoryId, SiteNodeVO siteNodeVO) throws ConstraintException, SystemException, Bug, Exception JavaDoc
114     {
115         Map JavaDoc hashMap = new HashMap JavaDoc();
116         hashMap.put("siteNodeId", parentSiteNodeId);
117         
118         intercept(hashMap, "SiteNodeVersion.CreateSiteNode", infogluePrincipal);
119
120         return SiteNodeController.getController().create(parentSiteNodeId, siteNodeTypeDefinitionId, infogluePrincipal, repositoryId, siteNodeVO);
121     }
122
123     /**
124      * This method creates a siteNode after first checking that the user has rights to create it.
125      */

126
127     public SiteNode acCreate(InfoGluePrincipal infogluePrincipal, Integer JavaDoc parentSiteNodeId, Integer JavaDoc siteNodeTypeDefinitionId, Integer JavaDoc repositoryId, SiteNodeVO siteNodeVO, Database db) throws ConstraintException, SystemException, Bug, Exception JavaDoc
128     {
129         Map JavaDoc hashMap = new HashMap JavaDoc();
130         hashMap.put("siteNodeId", parentSiteNodeId);
131         
132         intercept(hashMap, "SiteNodeVersion.CreateSiteNode", infogluePrincipal, db);
133
134         return SiteNodeController.getController().create(db, parentSiteNodeId, siteNodeTypeDefinitionId, infogluePrincipal, repositoryId, siteNodeVO);
135     }
136     
137     /**
138      * This method updates a content after first checking that the user has rights to edit it.
139      */

140     /*
141     public SiteNodeVersionVO acUpdate(InfoGluePrincipal infogluePrincipal, SiteNodeVersionVO siteNodeVersionVO) throws ConstraintException, SystemException, Bug, Exception
142     {
143         Map hashMap = new HashMap();
144         hashMap.put("siteNodeVersionId", siteNodeVersionVO.getId());
145         
146         intercept(hashMap, "SiteNodeVersion.Write", infogluePrincipal);
147
148         return update(siteNodeVersionVO);
149     }
150     */

151     
152     /**
153      * This method updates a content after first checking that the user has rights to edit it.
154      */

155     /*
156     public SiteNodeVersionVO acUpdate(InfoGluePrincipal infogluePrincipal, SiteNodeVersionVO siteNodeVersionVO, Database db) throws ConstraintException, SystemException, Bug, Exception
157     {
158         Map hashMap = new HashMap();
159         hashMap.put("siteNodeVersionId", siteNodeVersionVO.getId());
160         
161         intercept(hashMap, "SiteNodeVersion.Write", infogluePrincipal, db);
162
163         return update(siteNodeVersionVO, db);
164     }
165     */

166     /**
167      * This method deletes a sitenode after first checking that the user has rights to delete it.
168      */

169     
170     public void acDelete(InfoGluePrincipal infogluePrincipal, SiteNodeVO siteNodeVO) throws ConstraintException, SystemException, Bug, Exception JavaDoc
171     {
172         Map JavaDoc hashMap = new HashMap JavaDoc();
173         hashMap.put("siteNodeId", siteNodeVO.getId());
174         
175         intercept(hashMap, "SiteNodeVersion.DeleteSiteNode", infogluePrincipal);
176
177         delete(siteNodeVO);
178     }
179     
180     
181     /**
182      * This method moves a content after first checking that the user has rights to edit it.
183      */

184
185     public void acMoveSiteNode(InfoGluePrincipal infogluePrincipal, SiteNodeVO siteNodeVO, Integer JavaDoc newParentSiteNodeId) throws ConstraintException, SystemException, Bug, Exception JavaDoc
186     {
187         Map JavaDoc hashMap = new HashMap JavaDoc();
188         hashMap.put("siteNodeId", siteNodeVO.getId());
189         
190         intercept(hashMap, "SiteNodeVersion.MoveSiteNode", infogluePrincipal);
191         
192         hashMap = new HashMap JavaDoc();
193         hashMap.put("siteNodeId", newParentSiteNodeId);
194
195         intercept(hashMap, "SiteNodeVersion.CreateSiteNode", infogluePrincipal);
196
197         moveSiteNode(siteNodeVO, newParentSiteNodeId);
198     }
199     
200
201 }
202
Popular Tags