KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > applications > publishingtool > actions > CreateEditionAction


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.publishingtool.actions;
25
26 import java.util.ArrayList JavaDoc;
27 import java.util.List JavaDoc;
28
29 import org.infoglue.cms.controllers.kernel.impl.simple.EventController;
30 import org.infoglue.cms.controllers.kernel.impl.simple.PublicationController;
31 import org.infoglue.cms.entities.publishing.PublicationVO;
32 import org.infoglue.cms.entities.workflow.EventVO;
33 import org.infoglue.cms.exception.SystemException;
34 import org.infoglue.cms.util.ConstraintExceptionBuffer;
35 import org.infoglue.cms.util.validators.ConstraintRule;
36
37 public class CreateEditionAction extends ViewPublicationsAction
38 {
39
40     private PublicationVO publicationVO;
41     private ConstraintExceptionBuffer ceb;
42     private String JavaDoc name;
43     private String JavaDoc description;
44     private List JavaDoc events;
45
46     public CreateEditionAction()
47     {
48         this(new PublicationVO());
49     }
50     
51     public CreateEditionAction(PublicationVO publicationVO)
52     {
53         this.publicationVO = publicationVO;
54         this.ceb = new ConstraintExceptionBuffer();
55             
56     }
57
58     public ConstraintRule getRule(String JavaDoc fieldName)
59     {
60         return publicationVO.getRule(fieldName);
61     }
62             
63     public java.lang.String JavaDoc getName()
64     {
65         if(this.name != null)
66             return this.name;
67             
68         return this.publicationVO.getName();
69     }
70         
71     public void setName(java.lang.String JavaDoc name)
72     {
73         this.publicationVO.setName(name);
74     }
75       
76
77     public String JavaDoc getDescription()
78     {
79         if(this.description != null)
80             return this.description;
81             
82         return this.publicationVO.getDescription();
83     }
84         
85     public void setDescription(String JavaDoc description)
86     {
87             this.publicationVO.setDescription(description);
88     }
89
90     public List JavaDoc getEvents()
91     {
92         return this.events;
93     }
94
95     public String JavaDoc doExecute() throws Exception JavaDoc
96     {
97         this.publicationVO.setRepositoryId(getRepositoryId());
98         
99         ceb = this.publicationVO.validate();
100
101         // Content versions to publish
102
setEvents(getRequest().getParameterValues("sel"));
103         
104         //String[] contents = getRequest().getParameterValues("sel");
105
//String[] siteNodes = getRequest().getParameterValues("sit");
106
//setContentToPublish(PublicationController.getContentVersionVOToPublish(contents));
107
//setSiteNodeToPublish(PublicationController.getSiteNodeVersionVOToPublish(siteNodes));
108

109         ceb.throwIfNotEmpty();
110
111         this.publicationVO = PublicationController.getController().createAndPublish(this.publicationVO, events, false, this.getInfoGluePrincipal());
112         
113         return "success";
114     }
115         
116     public String JavaDoc doInput() throws Exception JavaDoc
117     {
118         this.publicationVO.PrepareValidation();
119         setEvents(getRequest().getParameterValues("sel"));
120         //String[] events = getRequest().getParameterValues("sel");
121
//String[] siteNodes = getRequest().getParameterValues("sit");
122
//setContentToPublish(PublicationController.getContentVersionVOToPublish(contents));
123
//setSiteNodeToPublish(PublicationController.getSiteNodeVersionVOToPublish(siteNodes));
124
return "input";
125     }
126
127
128     private void setEvents(String JavaDoc[] eventArguments) throws SystemException, Exception JavaDoc
129     {
130         List JavaDoc events = new ArrayList JavaDoc();
131         
132         for(int i=0; i < eventArguments.length; i++)
133         {
134             EventVO eventVO = EventController.getEventVOWithId(new Integer JavaDoc(eventArguments[i]));
135             events.add(eventVO);
136         }
137         
138         this.events = events;
139     }
140
141 }
142
Popular Tags