Source Code Cross Referenced for SaveEventService.java in  » Web-Mail » claros-intouch2-2.2-beta » org » claros » intouch » calendar » services » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Mail » claros intouch2 2.2 beta » org.claros.intouch.calendar.services 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.claros.intouch.calendar.services;
002:
003:        import java.io.IOException;
004:        import java.io.PrintWriter;
005:        import java.sql.Timestamp;
006:        import java.text.DecimalFormat;
007:        import java.util.Calendar;
008:        import java.util.Date;
009:        import java.util.List;
010:
011:        import javax.servlet.ServletException;
012:        import javax.servlet.http.HttpServletRequest;
013:        import javax.servlet.http.HttpServletResponse;
014:
015:        import org.claros.commons.auth.models.AuthProfile;
016:        import org.claros.intouch.calendar.controllers.CalendarController;
017:        import org.claros.intouch.calendar.controllers.CalendarDBController;
018:        import org.claros.intouch.calendar.models.CalendarDailyItems;
019:        import org.claros.intouch.calendar.models.CalendarHourItems;
020:        import org.claros.intouch.calendar.models.CalendarObject;
021:        import org.claros.intouch.calendar.models.CalendarObjectWrap;
022:        import org.claros.intouch.common.services.BaseService;
023:
024:        public class SaveEventService extends BaseService {
025:
026:            /**
027:             * 
028:             */
029:            private static final long serialVersionUID = 1L;
030:
031:            /**
032:             * @param request the request send by the client to the server
033:             * @param response the response send by the server to the client
034:             * @throws ServletException if an error occurred
035:             * @throws IOException if an error occurred
036:             */
037:            public void doPost(HttpServletRequest request,
038:                    HttpServletResponse response) throws ServletException,
039:                    IOException {
040:                response.setHeader("Expires", "-1");
041:                response.setHeader("Pragma", "no-cache");
042:                response.setHeader("Cache-control", "no-cache");
043:                response.setHeader("Content-Type", "text/html; charset=utf-8");
044:                PrintWriter out = response.getWriter();
045:
046:                DecimalFormat df = new DecimalFormat("00");
047:
048:                try {
049:                    String sEventId = request.getParameter("eventId");
050:
051:                    String sBegin = request.getParameter("begin");
052:                    String sEnd = request.getParameter("end");
053:                    String sColor = request.getParameter("color");
054:                    String sRepeatType = request.getParameter("repeatType");
055:                    String sDescription = request.getParameter("description");
056:                    String sLocation = request.getParameter("location");
057:                    String sReminderDays = request.getParameter("reminderDays");
058:                    String sReminderMethod = request
059:                            .getParameter("reminderMethod");
060:                    String sYear = request.getParameter("year");
061:                    String sMonth = df.format(Integer.parseInt(request
062:                            .getParameter("month")));
063:                    String sDay = df.format(Integer.parseInt(request
064:                            .getParameter("day")));
065:
066:                    Timestamp recordDate = Timestamp.valueOf(sYear + "-"
067:                            + sMonth + "-" + sDay + " " + sBegin + ":00.000");
068:                    Timestamp endDate = Timestamp.valueOf(sYear + "-" + sMonth
069:                            + "-" + sDay + " " + sEnd + ":00.000");
070:
071:                    Timestamp ts = Timestamp.valueOf(sYear + "-" + sMonth + "-"
072:                            + sDay + " 00:00:00.000");
073:                    Calendar cal = Calendar.getInstance();
074:                    cal.setTime(new Date(ts.getTime()));
075:                    CalendarDailyItems items = CalendarController
076:                            .populateDailyContent(getAuthProfile(request), cal,
077:                                    false);
078:                    List hrs = items.getHours();
079:                    CalendarHourItems hr = null;
080:
081:                    for (int i = 0; i < hrs.size(); i++) {
082:                        hr = (CalendarHourItems) hrs.get(i);
083:                        List apps = hr.getAppointments();
084:                        if (apps != null) {
085:                            CalendarObjectWrap w = null;
086:                            for (int j = 0; j < apps.size(); j++) {
087:                                w = (CalendarObjectWrap) apps.get(j);
088:
089:                                Timestamp ocEnd = w.getEndDate();
090:                                Calendar cl = Calendar.getInstance();
091:                                cl.setTimeInMillis(ocEnd.getTime());
092:                                Timestamp ocBegin = w.getOccuringDate();
093:                                Calendar cl2 = Calendar.getInstance();
094:                                cl2.setTimeInMillis(ocBegin.getTime());
095:                                ocEnd = Timestamp
096:                                        .valueOf(cl2.get(Calendar.YEAR)
097:                                                + "-"
098:                                                + df
099:                                                        .format(cl2
100:                                                                .get(Calendar.MONTH) + 1)
101:                                                + "-"
102:                                                + df.format(cl2
103:                                                        .get(Calendar.DATE))
104:                                                + " "
105:                                                + df
106:                                                        .format(cl
107:                                                                .get(Calendar.HOUR_OF_DAY))
108:                                                + ":"
109:                                                + df.format(cl
110:                                                        .get(Calendar.MINUTE))
111:                                                + ":00.000");
112:
113:                                if ((recordDate.before(w.getOccuringDate()) && (endDate
114:                                        .equals(w.getOccuringDate()) || endDate
115:                                        .before(w.getOccuringDate())))
116:                                        || (recordDate.equals(ocEnd) || recordDate
117:                                                .after(ocEnd))) {
118:                                    // do nothing it is valid
119:                                    System.out.println("ab-> " + recordDate
120:                                            + " ae->" + endDate + " xb->"
121:                                            + w.getOccuringDate() + " xe->"
122:                                            + ocEnd);
123:                                } else {
124:                                    if (!sEventId.equals(w.getId().toString())) {
125:                                        out.print("collapse");
126:                                        return;
127:                                    }
128:                                }
129:                            }
130:                        }
131:                    }
132:
133:                    AuthProfile auth = getAuthProfile(request);
134:                    CalendarObject item = new CalendarObject();
135:                    item.setColor(sColor);
136:                    item.setDescription(sDescription);
137:                    item.setEndDate(endDate);
138:                    if (sEventId != null && !sEventId.equals("null")
139:                            && sEventId.length() > 0) {
140:                        try {
141:                            item.setId(new Long(sEventId));
142:                        } catch (NumberFormatException nf) {
143:                        }
144:                    }
145:                    item.setLocation(sLocation);
146:                    item.setRecordDate(recordDate);
147:                    item.setReminderDays(new Integer(sReminderDays));
148:                    item.setReminderMethod(new Integer(sReminderMethod));
149:                    item.setRepeatType(new Integer(sRepeatType));
150:                    item.setUsername(auth.getUsername());
151:                    // this item is modified so we shall set the alarm again. 
152:                    item.setRemindedBefore("false");
153:                    item.setLastDismissedAt(null);
154:
155:                    CalendarDBController.saveEvent(auth, item);
156:
157:                    List events = CalendarDBController
158:                            .getCalendarObjectsByUser(auth, false);
159:                    Long lastId = null;
160:                    if (events != null) {
161:                        CalendarObject tmp = (CalendarObject) events.get(0);
162:                        lastId = tmp.getId();
163:                    }
164:                    out.print("ok" + lastId.longValue());
165:                } catch (Exception e) {
166:                    out.print("fail");
167:                }
168:            }
169:
170:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.