KickJava   Java API By Example, From Geeks To Geeks.

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


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.apache.log4j.Logger;
27 import org.infoglue.cms.applications.common.actions.InfoGlueAbstractAction;
28 import org.infoglue.cms.applications.contenttool.wizards.actions.CreateContentWizardInputAssetsAction;
29 import org.infoglue.cms.controllers.kernel.impl.simple.ContentTypeDefinitionController;
30 import org.infoglue.cms.entities.management.ContentTypeDefinitionVO;
31 import org.infoglue.cms.io.FileHelper;
32 import org.infoglue.cms.util.ConstraintExceptionBuffer;
33
34
35 public class CreateContentTypeDefinitionAction extends InfoGlueAbstractAction
36 {
37     private final static Logger logger = Logger.getLogger(CreateContentTypeDefinitionAction.class.getName());
38
39     private static final long serialVersionUID = 1L;
40     
41     private ContentTypeDefinitionVO contentTypeDefinitionVO;
42     private ConstraintExceptionBuffer ceb;
43     private String JavaDoc name;
44     private String JavaDoc description;
45
46     
47     public CreateContentTypeDefinitionAction()
48     {
49         this(new ContentTypeDefinitionVO());
50     }
51     
52     public CreateContentTypeDefinitionAction(ContentTypeDefinitionVO contentTypeDefinitionVO)
53     {
54         this.contentTypeDefinitionVO = contentTypeDefinitionVO;
55         
56         String JavaDoc schemaValue = "";
57         try
58         {
59             schemaValue = FileHelper.getStreamAsString(this.getClass().getResourceAsStream("/org/infoglue/cms/applications/defaultContentTypeDefinition.xml"));
60         }
61         catch(Exception JavaDoc e)
62         {
63             logger.error("The system could not find the default content type definition:" + e.getMessage(), e);
64         }
65         
66         this.contentTypeDefinitionVO.setSchemaValue(schemaValue);
67         this.ceb = new ConstraintExceptionBuffer();
68             
69     }
70     
71     public Integer JavaDoc getContentTypeDefinitionId()
72     {
73         return this.contentTypeDefinitionVO.getContentTypeDefinitionId();
74     }
75     
76     public java.lang.String JavaDoc getName()
77     {
78         return this.contentTypeDefinitionVO.getName();
79     }
80         
81     public void setName(java.lang.String JavaDoc name)
82     {
83         this.contentTypeDefinitionVO.setName(name);
84     }
85       
86 /*
87     public String getSchemaValue()
88     {
89         return this.contentTypeDefinitionVO.getSchemaValue();
90     }
91         
92     public void setSchemaValue(String schemaValue)
93     {
94         this.contentTypeDefinitionVO.setSchemaValue(schemaValue);
95     }
96 */

97
98
99     public String JavaDoc doExecute() throws Exception JavaDoc
100     {
101         ceb.add( this.contentTypeDefinitionVO.validate());
102         ceb.throwIfNotEmpty();
103         this.contentTypeDefinitionVO = ContentTypeDefinitionController.getController().create(this.contentTypeDefinitionVO);
104         
105         return "success";
106     }
107         
108     public String JavaDoc doInput() throws Exception JavaDoc
109     {
110         return "input";
111     }
112     
113     public Integer JavaDoc getType()
114     {
115         return this.contentTypeDefinitionVO.getType();
116     }
117
118     public void setType(Integer JavaDoc type)
119     {
120         this.contentTypeDefinitionVO.setType(type);
121     }
122
123 }
124
Popular Tags