View Javadoc

1   /**
2    * Copyright 2005-2007 the original author or authors.
3    *
4    * Licensed under the Gnu General Pubic License, Version 2.0 (the
5    * "License"); you may not use this file except in compliance with
6    * the License. You may obtain a copy of the License at
7    *
8    *      http://www.opensource.org/licenses/gpl-license.php
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13   * See the Gnu General Public License for more details.
14   */
15  package org.figure8.join.control.form;
16  
17  import org.figure8.join.control.JoinForm;
18  import org.figure8.join.control.action.DeploymentsActions;
19  
20  import org.apache.struts.action.ActionMapping;
21  
22  import javax.servlet.http.HttpServletRequest;
23  /**
24   * This is a Struts for used when retrieving deployments using different criteria.
25   * @author <a href="mailto:laurent.broudoux@free.fr">Laurent Broudoux</a>
26   * @version $Revision: 1.1 $
27   * @struts.form name="DeploymentsForm"
28   */
29  public class DeploymentsForm extends JoinForm{
30  
31     // Attributes ---------------------------------------------------------------
32  
33     /** The key of logical environment to get deployments for. */
34     private String logicalEnvKey;
35     /** The unique key of physical environment to get deployments for. */
36     private String physicalEnvKey;
37  
38  
39     // Constructors -------------------------------------------------------------
40     
41     /** Creates a new instance of DeploymentsForm */
42     public DeploymentsForm(){
43     }
44  
45  
46     // Public -------------------------------------------------------------------
47  
48     /** @return The unique key of logical environment to get deployements for */
49     public String getLogicalEnvKey(){
50        return logicalEnvKey;
51     }
52     /** @param logicalEnvKey The unique key of logical environment to get deployements for */
53     public void setLogicalEnvKey(String logicalEnvKey){
54        this.logicalEnvKey = logicalEnvKey;
55     }
56  
57     /** @return The unique key of physical environment to get deployements for */
58     public String getPhysicalEnvKey(){
59        return physicalEnvKey;
60     }
61     /** @param physicalEnvKey The unique key of physical to get deployements for */
62     public void setPhysicalEnvKey(String physicalEnvKey){
63        this.physicalEnvKey = physicalEnvKey;
64     }
65  
66  
67     // Implementation of JoinForm -----------------------------------------------
68  
69     /**
70      * Validation of the form attributes.
71      * @param operation String representing the operation to invoke on Action
72      * @param mapping Mapping between forwards name and path for this action
73      * @param request The servlet container request wrapper
74      */
75     public void doValidate(String operation, ActionMapping mapping, HttpServletRequest request){
76  
77        if (DeploymentsActions.LOGICALENV_OP.equals(operation)){
78           // Check if logical environment key is missing.
79           if (logicalEnvKey == null || logicalEnvKey.length() == 0)
80              addActionError("errors.required", getGuiMessageResources().getMessage("label.deployment.environment"));
81        }
82        else if (DeploymentsActions.PHYSICALENV_OP.equals(operation)){
83           // Check if physical environment key is missing.
84           if (physicalEnvKey == null || physicalEnvKey.length() == 0)
85              addActionError("errors.required", getGuiMessageResources().getMessage("label.deployment.environment"));
86        }
87        else if (DeploymentsActions.ENVMAPPING_OP.equals(operation)){
88           // Use generic identifier in this case.
89           validateEntityObjectId();
90        }
91     }
92     
93     
94     // Override of ActionForm ---------------------------------------------------
95  
96     /**
97      * Reset form attributes.
98      * @param mapping Mapping between forwards name and path for this action
99      * @param request The servlet container request wrapper
100     */
101    public void reset(ActionMapping mapping, HttpServletRequest request){
102       super.reset(mapping, request);
103       logicalEnvKey = null;
104       physicalEnvKey = null;
105    }
106 }