KickJava   Java API By Example, From Geeks To Geeks.

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


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.controllers.kernel.impl.simple.ServiceDefinitionController;
27 import org.infoglue.cms.entities.management.ServiceDefinitionVO;
28 import org.infoglue.cms.exception.ConstraintException;
29 import org.infoglue.cms.util.ConstraintExceptionBuffer;
30
31
32 /**
33   * This is the action-class for UpdateServiceDefinition
34   *
35   * @author Mattias Bogeblad
36   */

37 public class UpdateServiceDefinitionAction extends ViewServiceDefinitionAction // WebworkAbstractAction
38
{
39     
40     private ServiceDefinitionVO serviceDefinitionVO;
41     private Integer JavaDoc serviceDefinitionId;
42     private String JavaDoc name;
43     private String JavaDoc description;
44     private String JavaDoc className;
45     private ConstraintExceptionBuffer ceb;
46     
47     public UpdateServiceDefinitionAction()
48     {
49         this(new ServiceDefinitionVO());
50     }
51     
52     public UpdateServiceDefinitionAction(ServiceDefinitionVO serviceDefinitionVO)
53     {
54         this.serviceDefinitionVO = serviceDefinitionVO;
55         this.ceb = new ConstraintExceptionBuffer();
56     }
57     
58     public String JavaDoc doExecute() throws Exception JavaDoc
59     {
60         super.initialize(getServiceDefinitionId());
61
62         ceb.add(this.serviceDefinitionVO.validate());
63         ceb.throwIfNotEmpty();
64         
65         ServiceDefinitionController.getController().update(this.serviceDefinitionVO);
66         
67         return "success";
68     }
69
70     public String JavaDoc doSaveAndExit() throws Exception JavaDoc
71     {
72         doExecute();
73                         
74         return "saveAndExit";
75     }
76
77     public void setServiceDefinitionId(Integer JavaDoc serviceDefinitionId)
78     {
79         this.serviceDefinitionVO.setServiceDefinitionId(serviceDefinitionId);
80     }
81
82     public java.lang.Integer JavaDoc getServiceDefinitionId()
83     {
84         return this.serviceDefinitionVO.getServiceDefinitionId();
85     }
86         
87     public java.lang.String JavaDoc getName()
88     {
89         if(this.name != null)
90             return this.name;
91     
92         return this.serviceDefinitionVO.getName();
93     }
94         
95     public void setName(java.lang.String JavaDoc name)
96     {
97         try
98         {
99             this.serviceDefinitionVO.setName(name);
100         }
101         catch(ConstraintException ce)
102         {
103             this.name = name;
104             this.ceb.add(new ConstraintExceptionBuffer(ce));
105         }
106     }
107
108     public String JavaDoc getDescription()
109     {
110         if(this.description != null)
111             return this.description;
112             
113         return this.serviceDefinitionVO.getDescription();
114     }
115         
116     public void setDescription(String JavaDoc description)
117     {
118         try
119         {
120             this.serviceDefinitionVO.setDescription(description);
121         }
122         catch(ConstraintException ce)
123         {
124             this.description = description;
125             this.ceb.add(new ConstraintExceptionBuffer(ce));
126         }
127     }
128     
129     public String JavaDoc getClassName()
130     {
131         if(this.className != null)
132             return this.className;
133             
134         return this.serviceDefinitionVO.getClassName();
135     }
136         
137     public void setClassName(String JavaDoc className)
138     {
139         try
140         {
141             this.serviceDefinitionVO.setClassName(className);
142         }
143         catch(ConstraintException ce)
144         {
145             this.className = className;
146             this.ceb.add(new ConstraintExceptionBuffer(ce));
147         }
148     }
149 }
150
Popular Tags