KickJava   Java API By Example, From Geeks To Geeks.

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


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.List JavaDoc;
27
28 import org.apache.log4j.Logger;
29 import org.infoglue.cms.applications.common.actions.InfoGlueAbstractAction;
30 import org.infoglue.cms.controllers.kernel.impl.simple.ContentController;
31 import org.infoglue.cms.controllers.kernel.impl.simple.RepositoryController;
32 import org.infoglue.cms.controllers.kernel.impl.simple.SiteNodeController;
33 import org.infoglue.cms.entities.content.ContentVO;
34 import org.infoglue.cms.entities.structure.SiteNodeVO;
35 import org.infoglue.cms.util.ConstraintExceptionBuffer;
36
37 /**
38  * This action shows the Content-tree when binding stuff.
39  */

40
41 public class ViewStructureTreeForInlineLinkAction extends InfoGlueAbstractAction
42 {
43     private final static Logger logger = Logger.getLogger(ViewStructureTreeForInlineLinkAction.class.getName());
44
45     private static final long serialVersionUID = 1L;
46
47     private Integer JavaDoc repositoryId;
48     private ConstraintExceptionBuffer ceb;
49     private String JavaDoc tree;
50     private List JavaDoc repositories;
51     private String JavaDoc textAreaId = "";
52     private Integer JavaDoc oldSiteNodeId;
53     private Integer JavaDoc oldContentId;
54     
55     
56     public ViewStructureTreeForInlineLinkAction()
57     {
58         this.ceb = new ConstraintExceptionBuffer();
59     }
60
61     public void setRepositoryId(Integer JavaDoc repositoryId)
62     {
63         this.repositoryId = repositoryId;
64     }
65
66     public Integer JavaDoc getRepositoryId()
67     {
68         return this.repositoryId;
69     }
70    
71     public String JavaDoc getTree()
72     {
73         return tree;
74     }
75
76     public void setTree(String JavaDoc string)
77     {
78         tree = string;
79     }
80     
81     public String JavaDoc getCurrentAction()
82     {
83         return "ViewStructureTreeForInlineLink.action";
84     }
85     
86     public String JavaDoc doExecute() throws Exception JavaDoc
87     {
88         this.repositories = RepositoryController.getController().getAuthorizedRepositoryVOList(this.getInfoGluePrincipal(), true);
89
90         if(this.repositoryId == null)
91         {
92             this.repositoryId = (Integer JavaDoc)getHttpSession().getAttribute("repositoryId");
93             if(this.repositoryId == null)
94                 this.repositoryId = RepositoryController.getController().getFirstRepositoryVO().getRepositoryId();
95         }
96         
97         return "success";
98     }
99
100     public String JavaDoc doUseFCKEditor() throws Exception JavaDoc
101     {
102         doExecute();
103         
104         return "successFCKEditor";
105     }
106
107     public List JavaDoc getRepositories()
108     {
109         return repositories;
110     }
111     
112     public String JavaDoc getTextAreaId()
113     {
114         return textAreaId;
115     }
116
117     public void setTextAreaId(String JavaDoc string)
118     {
119         textAreaId = string;
120     }
121
122     public Integer JavaDoc getOldSiteNodeId()
123     {
124         return oldSiteNodeId;
125     }
126     
127     public void setOldSiteNodeId(Integer JavaDoc oldSiteNodeId)
128     {
129         this.oldSiteNodeId = oldSiteNodeId;
130     }
131     
132     public String JavaDoc getExpansion(Integer JavaDoc oldSiteNodeId)
133     {
134         String JavaDoc expansion = "/";
135         
136         if(oldSiteNodeId == null)
137             return "";
138         
139         try
140         {
141             SiteNodeVO parentSiteNodeVO = SiteNodeController.getController().getParentSiteNode(oldSiteNodeId);
142             while(parentSiteNodeVO != null)
143             {
144                 expansion += parentSiteNodeVO.getId() + "/";
145                 parentSiteNodeVO = SiteNodeController.getController().getParentSiteNode(parentSiteNodeVO.getId());
146             }
147         }
148         catch(Exception JavaDoc e)
149         {
150             logger.warn("Expansion not possible:" + e.getMessage(), e);
151         }
152         
153         return expansion;
154     }
155
156     public String JavaDoc getContentExpansion(Integer JavaDoc oldContentId)
157     {
158         String JavaDoc expansion = "/";
159         
160         if(oldContentId == null)
161             return "";
162         
163         try
164         {
165             ContentVO parentContentVO = ContentController.getContentController().getParentContent(oldContentId);
166             while(parentContentVO != null)
167             {
168                 expansion += parentContentVO.getId() + "/";
169                 parentContentVO = ContentController.getContentController().getParentContent(parentContentVO.getId());
170             }
171         }
172         catch(Exception JavaDoc e)
173         {
174             logger.warn("Expansion not possible:" + e.getMessage(), e);
175         }
176         
177         return expansion;
178     }
179
180     public Integer JavaDoc getOldContentId()
181     {
182         return oldContentId;
183     }
184     
185     public void setOldContentId(Integer JavaDoc oldContentId)
186     {
187         this.oldContentId = oldContentId;
188     }
189 }
190
Popular Tags