KickJava   Java API By Example, From Geeks To Geeks.

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


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.List JavaDoc;
27
28 import org.infoglue.cms.applications.common.actions.InfoGlueAbstractAction;
29 import org.infoglue.cms.controllers.kernel.impl.simple.ContentController;
30 import org.infoglue.cms.controllers.kernel.impl.simple.ContentTypeDefinitionController;
31 import org.infoglue.cms.controllers.kernel.impl.simple.ContentVersionControllerProxy;
32 import org.infoglue.cms.entities.content.ContentVersionVO;
33 import org.infoglue.cms.entities.management.ContentTypeDefinitionVO;
34
35 /**
36  *
37  * @author Mattias Bogeblad
38  *
39  * Present a comparison between two content versions.
40  */

41
42 public class ViewContentVersionDifferenceAction extends InfoGlueAbstractAction
43 {
44     private static final long serialVersionUID = 1L;
45     
46     private Integer JavaDoc contentVersionId1;
47     private Integer JavaDoc contentVersionId2;
48
49     private ContentVersionVO contentVersionVO1;
50     private ContentVersionVO contentVersionVO2;
51     
52     public ContentTypeDefinitionVO contentTypeDefinitionVO;
53
54     public List JavaDoc attributes = null;
55
56     
57     protected String JavaDoc doExecute() throws Exception JavaDoc
58     {
59         this.contentVersionVO1 = ContentVersionControllerProxy.getController().getACContentVersionVOWithId(this.getInfoGluePrincipal(), contentVersionId1);
60         this.contentVersionVO2 = ContentVersionControllerProxy.getController().getACContentVersionVOWithId(this.getInfoGluePrincipal(), contentVersionId2);
61
62         this.contentTypeDefinitionVO = ContentController.getContentController().getContentTypeDefinition(contentVersionVO2.getContentId());
63
64         if(this.contentTypeDefinitionVO != null)
65         {
66             this.attributes = ContentTypeDefinitionController.getController().getContentTypeAttributes(this.contentTypeDefinitionVO.getSchemaValue());
67         }
68
69         return "success";
70     }
71         
72     
73     /**
74      * This method fetches a value from the xml that is the contentVersions Value. If the
75      * contentVersioVO is null the contentVersion has not been created yet and no values are present.
76      */

77      
78     public String JavaDoc getUnescapedAttributeValue(ContentVersionVO contentVersionVO, String JavaDoc key)
79     {
80         String JavaDoc value = "";
81         
82         if(contentVersionVO != null)
83         {
84             try
85             {
86                 String JavaDoc xml = contentVersionVO.getVersionValue();
87                 
88                 int startTagIndex = xml.indexOf("<" + key + ">");
89                 int endTagIndex = xml.indexOf("]]></" + key + ">");
90
91                 if(startTagIndex > 0 && startTagIndex < xml.length() && endTagIndex > startTagIndex && endTagIndex < xml.length())
92                 {
93                     value = xml.substring(startTagIndex + key.length() + 11, endTagIndex);
94                 }
95             }
96             catch(Exception JavaDoc e)
97             {
98                 e.printStackTrace();
99             }
100         }
101         //logger.info("value:" + value);
102
return value;
103     }
104
105     
106     public Integer JavaDoc getContentVersionId1()
107     {
108         return contentVersionId1;
109     }
110     
111     public void setContentVersionId1(Integer JavaDoc contentVersionId1)
112     {
113         this.contentVersionId1 = contentVersionId1;
114     }
115     
116     public Integer JavaDoc getContentVersionId2()
117     {
118         return contentVersionId2;
119     }
120     
121     public void setContentVersionId2(Integer JavaDoc contentVersionId2)
122     {
123         this.contentVersionId2 = contentVersionId2;
124     }
125     
126     public List JavaDoc getAttributes()
127     {
128         return attributes;
129     }
130     
131     public ContentTypeDefinitionVO getContentTypeDefinitionVO()
132     {
133         return contentTypeDefinitionVO;
134     }
135     
136     public ContentVersionVO getContentVersionVO1()
137     {
138         return contentVersionVO1;
139     }
140     
141     public ContentVersionVO getContentVersionVO2()
142     {
143         return contentVersionVO2;
144     }
145 }
146
Popular Tags