KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > applications > managementtool > actions > CreateLanguageAction


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.managementtool.actions;
25
26 import org.infoglue.cms.applications.common.actions.InfoGlueAbstractAction;
27 import org.infoglue.cms.controllers.kernel.impl.simple.LanguageController;
28 import org.infoglue.cms.entities.management.LanguageVO;
29 import org.infoglue.cms.exception.ConstraintException;
30 import org.infoglue.cms.util.ConstraintExceptionBuffer;
31
32 /**
33  * This action represents the CreateLanguage Usecase.
34  */

35
36 public class CreateLanguageAction extends InfoGlueAbstractAction
37 {
38
39     private Integer JavaDoc languageId;
40     private String JavaDoc name;
41     private String JavaDoc languageCode;
42     private String JavaDoc charset;
43     private ConstraintExceptionBuffer ceb;
44     private LanguageVO languageVO;
45   
46   
47     public CreateLanguageAction()
48     {
49         this(new LanguageVO());
50     }
51     
52     public CreateLanguageAction(LanguageVO languageVO)
53     {
54         this.languageVO = languageVO;
55         this.ceb = new ConstraintExceptionBuffer();
56             
57     }
58     
59     public java.lang.String JavaDoc getName()
60     {
61         if(this.name != null)
62             return this.name;
63             
64         return this.languageVO.getName();
65     }
66         
67     public void setName(java.lang.String JavaDoc name)
68     {
69         try
70         {
71             this.languageVO.setName(name);
72         }
73         catch(ConstraintException ce)
74         {
75             this.name = name;
76             this.ceb.add(new ConstraintExceptionBuffer(ce));
77         }
78     }
79      
80     public java.lang.String JavaDoc getLanguageCode()
81     {
82         if(this.languageCode != null)
83             return this.languageCode;
84             
85         return this.languageVO.getLanguageCode();
86     }
87         
88     public void setLanguageCode(java.lang.String JavaDoc languageCode)
89     {
90         try
91         {
92             this.languageVO.setLanguageCode(languageCode);
93         }
94         catch(ConstraintException ce)
95         {
96             this.languageCode = languageCode;
97             this.ceb.add(new ConstraintExceptionBuffer(ce));
98         }
99     }
100
101     public java.lang.String JavaDoc getCharset()
102     {
103         return this.languageVO.getCharset();
104     }
105         
106     public void setCharset(java.lang.String JavaDoc charset)
107     {
108         this.languageVO.setCharset(charset);
109     }
110       
111     public String JavaDoc doExecute() throws Exception JavaDoc
112     {
113         ceb.add(this.languageVO.validate());
114         ceb.throwIfNotEmpty();
115         
116         LanguageVO languageVO = LanguageController.getController().create(this.languageVO);
117         
118         return "success";
119     }
120
121     public String JavaDoc doInput() throws Exception JavaDoc
122     {
123         return "input";
124     }
125         
126 }
127
Popular Tags