KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > dotmarketing > portlets > communications > struts > CommunicationsForm


1 package com.dotmarketing.portlets.communications.struts;
2
3 import java.text.ParseException JavaDoc;
4 import java.text.SimpleDateFormat JavaDoc;
5
6 import javax.servlet.http.HttpServletRequest JavaDoc;
7
8 import org.apache.struts.action.ActionErrors;
9 import org.apache.struts.action.ActionMapping;
10 import org.apache.struts.action.ActionMessage;
11 import org.apache.struts.action.ActionMessages;
12 import org.apache.struts.validator.ValidatorForm;
13
14 import com.dotmarketing.portlets.categories.factories.CategoryFactory;
15 import com.dotmarketing.portlets.categories.model.Category;
16 import com.dotmarketing.util.Logger;
17 import com.dotmarketing.util.UtilMethods;
18 import com.liferay.portal.jaas.ext.pramati.PortalUserManager;
19 import com.liferay.portal.util.Constants;
20 import com.liferay.portal.util.PortalUtil;
21 import com.liferay.util.servlet.SessionMessages;
22
23 /**
24  * Communications Struts forms
25  * @author Oswaldo
26  *
27  */

28 public class CommunicationsForm extends ValidatorForm {
29
30     private static final long serialVersionUID = 1L;
31     private String JavaDoc title;
32     private long trackBackLinkInode;
33     private String JavaDoc communicationType;
34     private String JavaDoc fromEmail;
35     private String JavaDoc fromName;
36     private String JavaDoc emailSubject;
37     private long htmlPage;
38     private String JavaDoc selectedhtmlPage;
39     private String JavaDoc textMessage;
40     private java.util.Date JavaDoc modDate;
41     private String JavaDoc modifiedBy;
42     private String JavaDoc webModDate;
43     private long inode;
44     private long identifier;
45     private String JavaDoc type;
46     private String JavaDoc externalCommunicationIdentifier;
47     
48     /**
49      * Gets the COmmunication Identifier
50      * @return long
51      */

52     public long getIdentifier() {
53         return identifier;
54     }
55
56     /**
57      * Set the Communication identifier
58      * @param identifier
59      */

60     public void setIdentifier(long identifier) {
61         this.identifier = identifier;
62     }
63
64     /**
65      * Gets the Communication inode
66      * @return long
67      */

68     public long getInode() {
69         return inode;
70     }
71
72     /**
73      * Set the communication inode
74      * @param inode
75      */

76     public void setInode(long inode) {
77         this.inode = inode;
78     }
79
80     /**
81      * Get the modification date of the communication
82      * @return java.util.Date
83      */

84     public java.util.Date JavaDoc getModDate() {
85         return modDate;
86     }
87     
88     /**
89      * Set the communication modification date
90      * @param createDate
91      */

92     public void setModDate(java.util.Date JavaDoc modDate) {
93         this.modDate = modDate;
94     }
95     
96     /**
97      * Get the userId of the user that modify the communication
98      * @return String
99      */

100     public String JavaDoc getModifiedBy() {
101         return modifiedBy;
102     }
103     
104     /**
105      * Set the userId of the user that modify the communication
106      * @param createdBy
107      */

108     public void setModifiedBy(String JavaDoc modifiedBy) {
109         this.modifiedBy = modifiedBy;
110     }
111     
112     /**
113      * Get the email subject of the communication only apply to email communication
114      * @return String
115      */

116     public String JavaDoc getEmailSubject() {
117         return emailSubject;
118     }
119     
120     /**
121      * Set the email subject of the communication only apply to email communication
122      * @param emailSubject
123      */

124     public void setEmailSubject(String JavaDoc emailSubject) {
125         this.emailSubject = emailSubject;
126     }
127     
128     /**
129      * Get the email of the user that create the communication only apply to email communication
130      * @return String
131      */

132     public String JavaDoc getFromEmail() {
133         return fromEmail;
134     }
135     
136     /**
137      * Set the email of the user that create the comunication only apply to email communication
138      * @param fromEmail
139      */

140     public void setFromEmail(String JavaDoc fromEmail) {
141         this.fromEmail = fromEmail;
142     }
143     
144     /**
145      * Get the name of the user that create the communication only apply to email communication
146      * @return String
147      */

148     public String JavaDoc getFromName() {
149         return fromName;
150     }
151     
152     /**
153      * Set the name of the user that create the communication only apply to email communication
154      * @param fromName
155      */

156     public void setFromName(String JavaDoc fromName) {
157         this.fromName = fromName;
158     }
159     
160     /**
161      * Get the html inode of the email communication
162      * @return long
163      */

164     public long getHtmlPage() {
165         return htmlPage;
166     }
167     
168     /**
169      * Set the email html page inode
170      * @param htmlPageInode
171      */

172     public void setHtmlPage(long htmlPageInode) {
173         this.htmlPage = htmlPageInode;
174     }
175     
176     /**
177      * Get the email text Message of the communication
178      * @return String
179      */

180     public String JavaDoc getTextMessage() {
181         return textMessage;
182     }
183     
184     /**
185      * Set the email text message of the communication
186      * @param textMessage
187      */

188     public void setTextMessage(String JavaDoc textMessage) {
189         this.textMessage = textMessage;
190     }
191     
192     /**
193      * Get the communication title
194      * @return String
195      */

196     public String JavaDoc getTitle() {
197         return title;
198     }
199     
200     /**
201      * Set the communication title
202      * @param title
203      */

204     public void setTitle(String JavaDoc title) {
205         this.title = title;
206     }
207     
208     /**
209      * Get the page inode link of the offline communication
210      * @return long
211      */

212     public long getTrackBackLinkInode() {
213         return trackBackLinkInode;
214     }
215     
216     /**
217      * Set the inode of the offline communication
218      * @param trackBackLinkInode
219      */

220     public void setTrackBackLinkInode(long trackBackLinkInode) {
221         this.trackBackLinkInode = trackBackLinkInode;
222     }
223     
224     /**
225      * Get the type of communication email or offline
226      * @return String
227      */

228     public String JavaDoc getCommunicationType() {
229         return communicationType;
230     }
231     
232     /**
233      * Set the communication type
234      */

235     public void setCommunicationType(String JavaDoc communicationType) {
236         this.communicationType = communicationType;
237         this.type = communicationType;
238     }
239     
240     /**
241      * Returns the webCompletedDate.
242      * @return String
243      */

244     public String JavaDoc getWebModDate() {
245         return UtilMethods.dateToHTMLDate(modDate) + " " + UtilMethods.dateToHTMLTime(modDate);
246     }
247     
248     /**
249      * Sets the webCompletedDate.
250      * @param webCompletedDate The webCompletedDate to set
251      */

252     public void setWebModDate(String JavaDoc webModDate) {
253
254         this.webModDate = webModDate;
255         try {
256             Logger.debug(this, "Setting Web Create Date " + webModDate);
257             this.modDate = new SimpleDateFormat JavaDoc("MM/dd/yyyy HH:mm").parse(webModDate);
258             Logger.debug(this, "Setting Create Date " + this.webModDate);
259         } catch(ParseException JavaDoc ex) {
260         }
261     }
262
263     public ActionErrors validate(ActionMapping mapping, HttpServletRequest JavaDoc request) {
264         if(request.getParameter("cmd")!=null && request.getParameter("cmd").equals(Constants.ADD)) {
265             //return super.validate(mapping, request);
266
ActionErrors ae = super.validate(mapping, request);
267
268             Logger.debug(this, "action errors: " + ae);
269             if(communicationType.equals("email")){
270                 if(!UtilMethods.isSet(title)){
271                     ae.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.communicationsTitle"));
272                     
273                 }
274                 if(!UtilMethods.isSet(fromName)){
275                     ae.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.communicationsFromName"));
276                     
277                 }
278                 if(!UtilMethods.isSet(fromEmail)){
279                     ae.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.communicationsFromEmail"));
280                     
281                 }
282                 if(!UtilMethods.isSet(emailSubject)){
283                     ae.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.communicationsSubject"));
284                     
285                 }
286                 if(!UtilMethods.isSet(selectedhtmlPage) && !UtilMethods.isSet(textMessage)){
287                     ae.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.communicationsTextMessage"));
288                     
289                 }
290                 
291                 return ae;
292                 
293             }else {
294                 if(!UtilMethods.isSet(title)){
295                     ae.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.communicationsTitle"));
296                     
297                 }
298                 if(trackBackLinkInode == 0){
299                     ae.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.communicationsTrackBackLinkInode"));
300                     
301                 }
302                 
303                 return ae;
304             }
305             
306         }
307         
308         return null;
309     }
310
311     /**
312      * Gets the htmlPAge title
313      * @return String
314      */

315     public String JavaDoc getSelectedhtmlPage() {
316         return selectedhtmlPage;
317     }
318
319     /**
320      * Set the htmlPage selected
321      * @param selectedHtmlPage
322      */

323     public void setSelectedhtmlPage(String JavaDoc selectedHtmlPage) {
324         this.selectedhtmlPage = selectedHtmlPage;
325     }
326
327     /**
328      * Get the type of communication email or offline
329      * @return String
330      */

331     public String JavaDoc getType() {
332         return type;
333     }
334
335     /**
336      * Set the communication type
337      */

338     public void setType(String JavaDoc type) {
339         this.type = type;
340     }
341     
342     /**
343      * Get the External Communication Identifier of the communication
344      * @return Strin
345      */

346     public String JavaDoc getExternalCommunicationIdentifier() {
347         return externalCommunicationIdentifier;
348     }
349     
350     /**
351      * Set the External Communication Identifier
352      * @param modDate
353      */

354     public void setExternalCommunicationIdentifier(
355             String JavaDoc externalCommunicationIdentifier) {
356         this.externalCommunicationIdentifier = externalCommunicationIdentifier;
357     }
358
359 }
360
Popular Tags