UserObject userobjectd = (UserObject)session.getAttribute("userobject");
UserPrefererences userPrefs = userobjectd.getUserPref();
TimeZone tz = TimeZone.getTimeZone(userPrefs.getTimeZone());
Locale locale = request.getLocale();
int individualID = userobjectd.getIndividualID();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// date format for writing to the form should be in the format based on
// locale
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale);
DateFormat tf = DateFormat.getTimeInstance(DateFormat.SHORT, locale);
int activitytype = 0;
int activityid = Integer.parseInt(requestForm.getActivityID());
String result = "";
// created session facade to call EJB methods (SyncFacade is a local class,
// not an EJB!)
SyncFacade syncfacade = new SyncFacade();
syncfacade.setDataSource(dataSource);
// if session is correct
if (userobjectd.getSessionID().equals(sessionID)) {
// A cheap way to check for NullPointerExceptions.
try {
ActivityForm activityForm = new ActivityForm();
activityForm.setLocale(locale);
activityForm.setActivityID(Integer.toString(activityid));
String detailpriority = requestForm.getPriority();
String detailstatus = requestForm.getStatus();
if (detailstatus == null) {
detailstatus = "1";
}
if (detailstatus != null && !detailstatus.equals("")) {
if (detailstatus.equals("Pending")) {
detailstatus = "1";
} else if (detailstatus.equals("Completed")) {
detailstatus = "2";
}
}
String detailtitle = requestForm.getTitle();
String detaildetail = requestForm.getDescription();
// call to getting activity details
ActivityVO vo = null;
activitytype = syncfacade.getActivityType(activityid);
vo = syncfacade.getActivity(activityid, individualID);
ActivityGenericFillVOX agf = new ActivityGenericFillVOX();
activityForm.setLocale(request.getLocale());
agf.fillBasicForm(vo, activityForm);
// if user wants to edit any field , that will not be null , so
// that field is set to ActivityForm
if (detailpriority != null) {
activityForm.setActivityPriority(detailpriority);
}
if (detailstatus != null) {
activityForm.setActivityStatus(detailstatus);
}
if (detailtitle != null) {
activityForm.setActivityTitle(detailtitle);
}
if (detaildetail != null) {
activityForm.setActivityDetail(detaildetail);
}
// startdate
String activitystartdate = requestForm.getStartDateTime();
Calendar start = new GregorianCalendar(tz, locale);
if (activitystartdate != null) {
try {
Date dd = simpleDateFormat.parse(activitystartdate);
start.setTime(dd);
} catch (Exception e) {
logger.error("[execute]: Exception", e);
}
}
activityForm.setActivityStartDate(df.format(start.getTime()));
activityForm.setActivityStartTime(tf.format(start.getTime()));
String activityenddate = requestForm.getEndDateTime();
Calendar end = new GregorianCalendar(tz, locale);
if (activityenddate != null) {
try {
Date dd = simpleDateFormat.parse(activityenddate);
end.setTime(dd);
} catch (Exception e) {
logger.error("[execute]: Exception", e);
}
}
activityForm.setActivityEndDate(df.format(end.getTime()));
activityForm.setActivityEndTime(tf.format(end.getTime()));
// alarm date time
String alarmDateTime = requestForm.getAlarmDateTime();
Calendar remind = new GregorianCalendar(tz, locale);
// if alarmDateTime is not null , so set it to ActivityForm
if (alarmDateTime != null) {
try {
Date d = simpleDateFormat.parse(alarmDateTime);
remind.setTime(d);
} catch (Exception e) {
logger.error("[execute]: Exception", e);
}
}
activityForm.setActivityRemindDate(df.format(remind));
activityForm.setActivityReminderTime(tf.format(remind));
activityForm.setActivityType(String.valueOf(activitytype));
result = syncfacade.updateActivity(activityForm, individualID);
String recurrenceType = requestForm.getRecurrenceType();
if (recurrenceType != null && !recurrenceType.equals("")) {
// This is a recurring activity - update the recurring info
int every = requestForm.getEvery();
int recurrOn = requestForm.getOn();
String recurringStartDateString = requestForm.getStartDateTime();
String recurringEndDateString = requestForm.getRecurrenceEndDate();
Date recurringStartDate = null;
Date recurringEndDate = null;
try {
recurringStartDate = simpleDateFormat.parse(recurringStartDateString);
} catch (Exception dateException) {
recurringStartDate = null;
}
try {
recurringEndDate = simpleDateFormat.parse(recurringEndDateString);
} catch (Exception dateException) {
recurringEndDate = null;
}
try {