You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openmeetings.apache.org by so...@apache.org on 2016/11/01 08:44:02 UTC
svn commit: r1767449 - in /openmeetings/application:
branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/calendar/
branches/3.1.x/openmeetings-util/src/main/java/org/apache/openmeetings/util/
branches/3.1.x/openmeetings-util/...
Author: solomax
Date: Tue Nov 1 08:44:02 2016
New Revision: 1767449
URL: http://svn.apache.org/viewvc?rev=1767449&view=rev
Log:
[OPENMEETINGS-1496] dates are being parsed as expected
Added:
openmeetings/application/branches/3.1.x/openmeetings-util/src/test/java/org/apache/openmeetings/util/TestCalendarPatterns.java
openmeetings/application/branches/3.2.x/openmeetings-util/src/test/java/org/apache/openmeetings/util/TestCalendarPatterns.java
openmeetings/application/trunk/openmeetings-util/src/test/java/org/apache/openmeetings/util/TestCalendarPatterns.java
Modified:
openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/calendar/Appointment.java
openmeetings/application/branches/3.1.x/openmeetings-util/src/main/java/org/apache/openmeetings/util/CalendarPatterns.java
openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/calendar/Appointment.java
openmeetings/application/branches/3.2.x/openmeetings-util/src/main/java/org/apache/openmeetings/util/CalendarPatterns.java
openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/calendar/Appointment.java
openmeetings/application/trunk/openmeetings-util/src/main/java/org/apache/openmeetings/util/CalendarPatterns.java
Modified: openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/calendar/Appointment.java
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/calendar/Appointment.java?rev=1767449&r1=1767448&r2=1767449&view=diff
==============================================================================
--- openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/calendar/Appointment.java (original)
+++ openmeetings/application/branches/3.1.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/calendar/Appointment.java Tue Nov 1 08:44:02 2016
@@ -50,11 +50,11 @@ import org.simpleframework.xml.Root;
@Entity
@Table(name = "appointment")
@NamedQueries({
- @NamedQuery(name="getAppointmentById", query="SELECT a FROM Appointment a WHERE a.deleted = false AND a.id = :id")
- , @NamedQuery(name="getAppointmentByIdAny", query="SELECT a FROM Appointment a WHERE a.id = :id")
- , @NamedQuery(name="getAppointments", query="SELECT a FROM Appointment a WHERE a.deleted = false ORDER BY a.id")
- , @NamedQuery(name="appointmentsInRange",
- query="SELECT a FROM Appointment a "
+ @NamedQuery(name="getAppointmentById", query="SELECT a FROM Appointment a WHERE a.deleted = false AND a.id = :id")
+ , @NamedQuery(name="getAppointmentByIdAny", query="SELECT a FROM Appointment a WHERE a.id = :id")
+ , @NamedQuery(name="getAppointments", query="SELECT a FROM Appointment a WHERE a.deleted = false ORDER BY a.id")
+ , @NamedQuery(name="appointmentsInRange",
+ query="SELECT a FROM Appointment a "
+ "WHERE a.deleted = false "
+ " AND ( "
+ " (a.start BETWEEN :start AND :end) "
@@ -62,8 +62,8 @@ import org.simpleframework.xml.Root;
+ " OR (a.start < :start AND a.end > :end) "
+ " )"
+ " AND a.owner.id = :userId"
- )
- , @NamedQuery(name="joinedAppointmentsInRange",
+ )
+ , @NamedQuery(name="joinedAppointmentsInRange",
query="SELECT a FROM MeetingMember mm INNER JOIN mm.appointment a "
+ "WHERE mm.deleted = false AND mm.user.id <> a.owner.id AND mm.user.id = :userId "
+ " AND a.id NOT IN (SELECT a.id FROM Appointment a WHERE a.owner.id = :userId)"
@@ -73,8 +73,8 @@ import org.simpleframework.xml.Root;
+ " OR (a.end BETWEEN :start AND :end) "
+ " OR (a.start < :start AND a.end > :end) "
+ " )"
- )
- , @NamedQuery(name="appointmentsInRangeRemind",
+ )
+ , @NamedQuery(name="appointmentsInRangeRemind",
query="SELECT a FROM Appointment a "
//only ReminderType simple mail is concerned!
+ "WHERE a.deleted = false AND a.reminderEmailSend = false"
@@ -84,11 +84,11 @@ import org.simpleframework.xml.Root;
+ " OR (a.end BETWEEN :start AND :end) "
+ " OR (a.start < :start AND a.end > :end) "
+ " )"
- )
- , @NamedQuery(name="getAppointmentByRoomId", query="SELECT a FROM Appointment a WHERE a.room.id = :roomId")
- , @NamedQuery(name="getAppointmentByOwnerRoomId", query="SELECT a FROM Appointment a WHERE a.deleted = false AND a.owner.id = :userId AND a.room.id = :roomId")
+ )
+ , @NamedQuery(name="getAppointmentByRoomId", query="SELECT a FROM Appointment a WHERE a.room.id = :roomId")
+ , @NamedQuery(name="getAppointmentByOwnerRoomId", query="SELECT a FROM Appointment a WHERE a.deleted = false AND a.owner.id = :userId AND a.room.id = :roomId")
//TODO this query returns duplicates if the user books an appointment with his own user as second meeting-member, swagner 19.02.2012
- , @NamedQuery(name="appointmentsInRangeByUser",
+ , @NamedQuery(name="appointmentsInRangeByUser",
query="SELECT a FROM MeetingMember mm, IN(mm.appointment) a "
+ "WHERE mm.deleted = false AND mm.user.id <> a.owner.id AND mm.user.id = :userId "
+ " AND ( "
@@ -96,8 +96,8 @@ import org.simpleframework.xml.Root;
+ " OR (a.end BETWEEN :start AND :end) "
+ " OR (a.start < :start AND a.end > :end) "
+ " )"
- )
- , @NamedQuery(name="appointedRoomsInRangeByUser",
+ )
+ , @NamedQuery(name="appointedRoomsInRangeByUser",
query="SELECT a.room FROM MeetingMember mm, IN(mm.appointment) a "
+ "WHERE mm.deleted = false AND mm.user.id <> a.owner.id AND mm.user.id = :userId "
+ " AND ( "
@@ -105,40 +105,40 @@ import org.simpleframework.xml.Root;
+ " OR (a.end BETWEEN :start AND :end) "
+ " OR (a.start < :start AND a.end > :end) "
+ " )"
- )
- , @NamedQuery(name="getNextAppointment", query="SELECT a FROM Appointment a WHERE a.deleted = false AND a.start > :start AND a.owner.id = :userId")
- , @NamedQuery(name="getAppointmentsByTitle", query="SELECT a FROM Appointment a WHERE a.deleted = false AND a.title LIKE :title AND a.owner.id = :userId")
+ )
+ , @NamedQuery(name="getNextAppointment", query="SELECT a FROM Appointment a WHERE a.deleted = false AND a.start > :start AND a.owner.id = :userId")
+ , @NamedQuery(name="getAppointmentsByTitle", query="SELECT a FROM Appointment a WHERE a.deleted = false AND a.title LIKE :title AND a.owner.id = :userId")
})
-@Root(name="appointment")
+@Root(name = "appointment")
public class Appointment implements IDataProviderEntity {
private static final long serialVersionUID = 1L;
public static final int REMINDER_NONE_ID = 1;
public static final int REMINDER_EMAIL_ID = 2;
public static final int REMINDER_ICAL_ID = 3;
+
public enum Reminder {
- none(REMINDER_NONE_ID)
- , email(REMINDER_EMAIL_ID)
- , ical(REMINDER_ICAL_ID);
-
+ none(REMINDER_NONE_ID), email(REMINDER_EMAIL_ID), ical(REMINDER_ICAL_ID);
+
private int id;
-
- Reminder() {} //default;
+
+ Reminder() {} // default;
+
Reminder(int id) {
this.id = id;
}
-
+
public int getId() {
return id;
}
-
+
public static Reminder get(Long type) {
return get(type == null ? 1 : type.intValue());
}
-
+
public static Reminder get(Integer type) {
return get(type == null ? 1 : type.intValue());
}
-
+
public static Reminder get(int type) {
Reminder r = Reminder.none;
switch (type) {
@@ -149,102 +149,102 @@ public class Appointment implements IDat
r = Reminder.ical;
break;
default:
- //no-op
+ // no-op
}
return r;
}
}
-
+
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
@Element(name = "appointmentId", data = true)
private Long id;
-
+
@Column(name = "title")
- @Element(name="appointmentName", data=true, required=false)
+ @Element(name = "appointmentName", data = true, required = false)
private String title;
-
+
@Column(name = "location")
- @Element(name="appointmentLocation", data=true, required=false)
+ @Element(name = "appointmentLocation", data = true, required = false)
private String location;
-
- @Column(name = "app_start") //Oracle fails in case 'start' is used as column name
- @Element(name="appointmentStarttime", data=true)
+
+ @Column(name = "app_start") // Oracle fails in case 'start' is used as column name
+ @Element(name = "appointmentStarttime", data = true)
private Date start;
-
- @Column(name = "app_end") //renamed to be in sync with 'app_start'
- @Element(name="appointmentEndtime", data=true)
+
+ @Column(name = "app_end") // renamed to be in sync with 'app_start'
+ @Element(name = "appointmentEndtime", data = true)
private Date end;
-
- @Lob
- @Column(name = "description", length=2048)
- @Element(name="appointmentDescription", data=true, required=false)
+
+ @Lob
+ @Column(name = "description", length = 2048)
+ @Element(name = "appointmentDescription", data = true, required = false)
private String description;
-
+
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "user_id", nullable = true)
@ForeignKey(enabled = true)
- @Element(name="users_id", data=true, required=false)
+ @Element(name = "users_id", data = true, required = false)
private User owner;
@Column(name = "inserted")
- @Element(name="inserted", data=true, required=false)
+ @Element(name = "inserted", data = true, required = false)
private Date inserted;
-
+
@Column(name = "updated")
- @Element(name="updated", data=true, required=false)
+ @Element(name = "updated", data = true, required = false)
private Date updated;
-
+
@Column(name = "deleted")
- @Element(data=true)
+ @Element(data = true)
private boolean deleted;
-
+
@Column(name = "reminder")
@Enumerated(EnumType.STRING)
- @Element(name="typId", data=true, required=false)
+ @Element(name = "typId", data = true, required = false)
private Reminder reminder = Reminder.none;
@Column(name = "isdaily")
- @Element(data=true, required = false)
+ @Element(data = true, required = false)
private Boolean isDaily;
-
+
@Column(name = "isweekly")
- @Element(data=true, required = false)
+ @Element(data = true, required = false)
private Boolean isWeekly;
-
+
@Column(name = "ismonthly")
- @Element(data=true, required = false)
+ @Element(data = true, required = false)
private Boolean isMonthly;
-
+
@Column(name = "isyearly")
- @Element(data=true, required = false)
+ @Element(data = true, required = false)
private Boolean isYearly;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "room_id", nullable = true)
@ForeignKey(enabled = true)
- @Element(name="room_id", data=true, required=false)
+ @Element(name = "room_id", data = true, required = false)
private Room room;
@Column(name = "icalId")
- @Element(data=true, required=false)
+ @Element(data = true, required = false)
private String icalId;
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumn(name = "appointment_id")
private List<MeetingMember> meetingMembers;
-
+
@Column(name = "language_id")
- @Element(name="language_id", data=true, required=false)
+ @Element(name = "language_id", data = true, required = false)
private Long languageId;
-
+
@Column(name = "is_password_protected")
- @Element(name="isPasswordProtected", data=true, required=false)
+ @Element(name = "isPasswordProtected", data = true, required = false)
private boolean passwordProtected;
-
+
@Column(name = "password")
- @Element(data=true, required=false)
+ @Element(data = true, required = false)
private String password;
@Column(name = "is_connected_event")
@@ -456,5 +456,5 @@ public class Appointment implements IDat
return "Appointment [id=" + id + ", title=" + title + ", start=" + start + ", end=" + end + ", owner=" + owner
+ ", deleted=" + deleted + ", icalId=" + icalId + "]";
}
-
+
}
Modified: openmeetings/application/branches/3.1.x/openmeetings-util/src/main/java/org/apache/openmeetings/util/CalendarPatterns.java
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-util/src/main/java/org/apache/openmeetings/util/CalendarPatterns.java?rev=1767449&r1=1767448&r2=1767449&view=diff
==============================================================================
--- openmeetings/application/branches/3.1.x/openmeetings-util/src/main/java/org/apache/openmeetings/util/CalendarPatterns.java (original)
+++ openmeetings/application/branches/3.1.x/openmeetings-util/src/main/java/org/apache/openmeetings/util/CalendarPatterns.java Tue Nov 1 08:44:02 2016
@@ -20,10 +20,11 @@ package org.apache.openmeetings.util;
import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
-import java.text.SimpleDateFormat;
+import java.text.ParseException;
import java.util.Date;
import java.util.TimeZone;
+import org.apache.commons.lang3.time.FastDateFormat;
import org.red5.logging.Red5LoggerFactory;
import org.slf4j.Logger;
@@ -34,49 +35,24 @@ import org.slf4j.Logger;
public class CalendarPatterns {
private static final Logger log = Red5LoggerFactory.getLogger(CalendarPatterns.class, webAppRootKey);
- public static ThreadLocal<SimpleDateFormat> dateFormat__ddMMyyyyHHmmss = new ThreadLocal<SimpleDateFormat>() {
- @Override
- protected SimpleDateFormat initialValue() {
- return new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
- };
- };
- public static ThreadLocal<SimpleDateFormat> dateFormat__ddMMyyyy = new ThreadLocal<SimpleDateFormat>() {
- @Override
- protected SimpleDateFormat initialValue() {
- return new SimpleDateFormat("dd.MM.yyyy");
- };
- };
- public static ThreadLocal<SimpleDateFormat> dateFormat__ddMMyyyyBySeparator = new ThreadLocal<SimpleDateFormat>() {
- @Override
- protected SimpleDateFormat initialValue() {
- return new SimpleDateFormat("dd-MM-yyyy");
- };
- };
- public static ThreadLocal<SimpleDateFormat> dateFormat__yyyyMMddHHmmss = new ThreadLocal<SimpleDateFormat>() {
- @Override
- protected SimpleDateFormat initialValue() {
- return new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
- };
- };
+ public static FastDateFormat dateFormat__ddMMyyyyHHmmss = FastDateFormat.getInstance("dd.MM.yyyy HH:mm:ss");
+ public static FastDateFormat dateFormat__ddMMyyyy = FastDateFormat.getInstance("dd.MM.yyyy");
+ public static FastDateFormat dateFormat__ddMMyyyyBySeparator = FastDateFormat.getInstance("dd-MM-yyyy");
+ public static FastDateFormat dateFormat__yyyyMMddHHmmss = FastDateFormat.getInstance("yyyy.MM.dd HH:mm:ss");
+ public static FastDateFormat STREAM_DATE_FORMAT = FastDateFormat.getInstance("yyyy_MM_dd_HH_mm_ss");
+ public static String FULL_DF_PATTERN = "dd.MM.yyyy HH:mm:ss z (Z)";
+ public static FastDateFormat FULL_DATE_FORMAT = FastDateFormat.getInstance(FULL_DF_PATTERN);
public static String getDateByMiliSeconds(Date t) {
- return dateFormat__yyyyMMddHHmmss.get().format(t);
+ return dateFormat__yyyyMMddHHmmss.format(t);
}
public static String getDateWithTimeByMiliSeconds(Date t) {
- return t == null ? null : dateFormat__yyyyMMddHHmmss.get().format(t);
+ return t == null ? null : dateFormat__yyyyMMddHHmmss.format(t);
}
public static String getDateWithTimeByMiliSecondsWithZone(Date t) {
- if (t == null) {
- return null;
- }
- SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss z (Z)");
- Date dateOld = new Date();
- long timeAdv = t.getTime();
- dateOld.setTime(timeAdv);
- String result = sdf.format(dateOld);
- return result;
+ return t == null ? null : FULL_DATE_FORMAT.format(t);
}
public static String getExportDate(Date t) {
@@ -91,13 +67,13 @@ public class CalendarPatterns {
Date resultDate = null;
- resultDate = validDate(dateFormat__ddMMyyyyHHmmss.get(), dateString);
+ resultDate = validDate(dateFormat__ddMMyyyyHHmmss, dateString);
if (resultDate != null) {
return resultDate;
}
- resultDate = validDate(dateFormat__ddMMyyyy.get(), dateString);
+ resultDate = validDate(dateFormat__ddMMyyyy, dateString);
if (resultDate != null) {
return resultDate;
@@ -130,16 +106,13 @@ public class CalendarPatterns {
return null;
}
- private static Date validDate(SimpleDateFormat sdf, String testdate) {
+ private static Date validDate(FastDateFormat sdf, String testdate) {
Date resultDate = null;
try {
resultDate = sdf.parse(testdate);
- }
-
- // if the format of the string provided doesn't match the format we
- // declared in SimpleDateFormat() we will get an exception
-
- catch (java.text.ParseException e) {
+ } catch (ParseException|NumberFormatException e) {
+ // if the format of the string provided doesn't match the format we
+ // declared in SimpleDateFormat() we will get an exception
return null;
}
@@ -148,35 +121,19 @@ public class CalendarPatterns {
}
return resultDate;
-
}
- public static String getDateWithTimeByMiliSecondsAndTimeZone(Date t,
- TimeZone timezone) {
- if (t == null) {
- return null;
- }
- SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss z (Z)");
- sdf.setTimeZone(timezone);
- Date dateOld = new Date();
- long timeAdv = t.getTime();
- dateOld.setTime(timeAdv);
- String result = sdf.format(dateOld);
- return result;
+ public static String getDateWithTimeByMiliSecondsAndTimeZone(Date t, TimeZone timezone) {
+ return t == null ? null : FastDateFormat.getInstance(FULL_DF_PATTERN, timezone).format(t);
}
public static String getTimeForStreamId(Date t) {
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss");
- Date dateOld = new Date();
- long timeAdv = t.getTime();
- dateOld.setTime(timeAdv);
- String result = sdf.format(dateOld);
- return result;
+ return STREAM_DATE_FORMAT.format(t);
}
public static Date parseDate(String dateString) {
try {
- return dateFormat__ddMMyyyy.get().parse(dateString);
+ return dateFormat__ddMMyyyy.parse(dateString);
} catch (Exception e) {
log.error("parseDate", e);
}
@@ -185,7 +142,7 @@ public class CalendarPatterns {
public static Date parseDateBySeparator(String dateString) {
try {
- return dateFormat__ddMMyyyyBySeparator.get().parse(dateString);
+ return dateFormat__ddMMyyyyBySeparator.parse(dateString);
} catch (Exception e) {
log.error("parseDate", e);
}
@@ -198,20 +155,10 @@ public class CalendarPatterns {
|| dateString.equals("null")) {
return null;
}
- return dateFormat__ddMMyyyyHHmmss.get().parse(dateString);
+ return dateFormat__ddMMyyyyHHmmss.parse(dateString);
} catch (Exception e) {
log.error("parseDate", e);
}
return null;
}
-
- public static String getYear(Date t) {
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
- Date dateOld = new Date();
- long timeAdv = t.getTime();
- dateOld.setTime(timeAdv);
- String result = sdf.format(dateOld);
- return result;
- }
-
}
Added: openmeetings/application/branches/3.1.x/openmeetings-util/src/test/java/org/apache/openmeetings/util/TestCalendarPatterns.java
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-util/src/test/java/org/apache/openmeetings/util/TestCalendarPatterns.java?rev=1767449&view=auto
==============================================================================
--- openmeetings/application/branches/3.1.x/openmeetings-util/src/test/java/org/apache/openmeetings/util/TestCalendarPatterns.java (added)
+++ openmeetings/application/branches/3.1.x/openmeetings-util/src/test/java/org/apache/openmeetings/util/TestCalendarPatterns.java Tue Nov 1 08:44:02 2016
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") + you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openmeetings.util;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Date;
+
+import org.junit.Test;
+
+public class TestCalendarPatterns {
+
+ @Test
+ public void backupDateParseTest() {
+ Date d = CalendarPatterns.parseImportDate("1360832400000");
+ assertNotNull("Date parsed should not be NULL", d);
+ }
+}
Modified: openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/calendar/Appointment.java
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/calendar/Appointment.java?rev=1767449&r1=1767448&r2=1767449&view=diff
==============================================================================
--- openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/calendar/Appointment.java (original)
+++ openmeetings/application/branches/3.2.x/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/calendar/Appointment.java Tue Nov 1 08:44:02 2016
@@ -117,20 +117,20 @@ import org.simpleframework.xml.Root;
, @NamedQuery(name = "deleteAppointmentsbyCalendar",
query = "UPDATE Appointment a SET a.deleted = true WHERE a.calendar.id = :calId")
})
-@Root(name="appointment")
+@Root(name = "appointment")
public class Appointment implements IDataProviderEntity {
private static final long serialVersionUID = 1L;
public static final int REMINDER_NONE_ID = 1;
public static final int REMINDER_EMAIL_ID = 2;
public static final int REMINDER_ICAL_ID = 3;
+
public enum Reminder {
- none(REMINDER_NONE_ID)
- , email(REMINDER_EMAIL_ID)
- , ical(REMINDER_ICAL_ID);
+ none(REMINDER_NONE_ID), email(REMINDER_EMAIL_ID), ical(REMINDER_ICAL_ID);
private int id;
- Reminder() {} //default;
+ Reminder() {} // default;
+
Reminder(int id) {
this.id = id;
}
@@ -157,7 +157,7 @@ public class Appointment implements IDat
r = Reminder.ical;
break;
default:
- //no-op
+ // no-op
}
return r;
}
@@ -177,11 +177,11 @@ public class Appointment implements IDat
@Element(name = "appointmentLocation", data = true, required = false)
private String location;
- @Column(name = "app_start") //Oracle fails in case 'start' is used as column name
+ @Column(name = "app_start") // Oracle fails in case 'start' is used as column name
@Element(name = "appointmentStarttime", data = true)
private Date start;
- @Column(name = "app_end") //renamed to be in sync with 'app_start'
+ @Column(name = "app_end") // renamed to be in sync with 'app_start'
@Element(name = "appointmentEndtime", data = true)
private Date end;
Modified: openmeetings/application/branches/3.2.x/openmeetings-util/src/main/java/org/apache/openmeetings/util/CalendarPatterns.java
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-util/src/main/java/org/apache/openmeetings/util/CalendarPatterns.java?rev=1767449&r1=1767448&r2=1767449&view=diff
==============================================================================
--- openmeetings/application/branches/3.2.x/openmeetings-util/src/main/java/org/apache/openmeetings/util/CalendarPatterns.java (original)
+++ openmeetings/application/branches/3.2.x/openmeetings-util/src/main/java/org/apache/openmeetings/util/CalendarPatterns.java Tue Nov 1 08:44:02 2016
@@ -20,6 +20,7 @@ package org.apache.openmeetings.util;
import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
+import java.text.ParseException;
import java.util.Date;
import java.util.TimeZone;
@@ -109,12 +110,9 @@ public class CalendarPatterns {
Date resultDate = null;
try {
resultDate = sdf.parse(testdate);
- }
-
- // if the format of the string provided doesn't match the format we
- // declared in SimpleDateFormat() we will get an exception
-
- catch (java.text.ParseException e) {
+ } catch (ParseException|NumberFormatException e) {
+ // if the format of the string provided doesn't match the format we
+ // declared in SimpleDateFormat() we will get an exception
return null;
}
@@ -123,7 +121,6 @@ public class CalendarPatterns {
}
return resultDate;
-
}
public static String getDateWithTimeByMiliSecondsAndTimeZone(Date t, TimeZone timezone) {
Added: openmeetings/application/branches/3.2.x/openmeetings-util/src/test/java/org/apache/openmeetings/util/TestCalendarPatterns.java
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-util/src/test/java/org/apache/openmeetings/util/TestCalendarPatterns.java?rev=1767449&view=auto
==============================================================================
--- openmeetings/application/branches/3.2.x/openmeetings-util/src/test/java/org/apache/openmeetings/util/TestCalendarPatterns.java (added)
+++ openmeetings/application/branches/3.2.x/openmeetings-util/src/test/java/org/apache/openmeetings/util/TestCalendarPatterns.java Tue Nov 1 08:44:02 2016
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") + you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openmeetings.util;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Date;
+
+import org.junit.Test;
+
+public class TestCalendarPatterns {
+
+ @Test
+ public void backupDateParseTest() {
+ Date d = CalendarPatterns.parseImportDate("1360832400000");
+ assertNotNull("Date parsed should not be NULL", d);
+ }
+}
Modified: openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/calendar/Appointment.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/calendar/Appointment.java?rev=1767449&r1=1767448&r2=1767449&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/calendar/Appointment.java (original)
+++ openmeetings/application/trunk/openmeetings-db/src/main/java/org/apache/openmeetings/db/entity/calendar/Appointment.java Tue Nov 1 08:44:02 2016
@@ -117,20 +117,20 @@ import org.simpleframework.xml.Root;
, @NamedQuery(name = "deleteAppointmentsbyCalendar",
query = "UPDATE Appointment a SET a.deleted = true WHERE a.calendar.id = :calId")
})
-@Root(name="appointment")
+@Root(name = "appointment")
public class Appointment implements IDataProviderEntity {
private static final long serialVersionUID = 1L;
public static final int REMINDER_NONE_ID = 1;
public static final int REMINDER_EMAIL_ID = 2;
public static final int REMINDER_ICAL_ID = 3;
+
public enum Reminder {
- none(REMINDER_NONE_ID)
- , email(REMINDER_EMAIL_ID)
- , ical(REMINDER_ICAL_ID);
+ none(REMINDER_NONE_ID), email(REMINDER_EMAIL_ID), ical(REMINDER_ICAL_ID);
private int id;
- Reminder() {} //default;
+ Reminder() {} // default;
+
Reminder(int id) {
this.id = id;
}
@@ -157,7 +157,7 @@ public class Appointment implements IDat
r = Reminder.ical;
break;
default:
- //no-op
+ // no-op
}
return r;
}
@@ -177,11 +177,11 @@ public class Appointment implements IDat
@Element(name = "appointmentLocation", data = true, required = false)
private String location;
- @Column(name = "app_start") //Oracle fails in case 'start' is used as column name
+ @Column(name = "app_start") // Oracle fails in case 'start' is used as column name
@Element(name = "appointmentStarttime", data = true)
private Date start;
- @Column(name = "app_end") //renamed to be in sync with 'app_start'
+ @Column(name = "app_end") // renamed to be in sync with 'app_start'
@Element(name = "appointmentEndtime", data = true)
private Date end;
Modified: openmeetings/application/trunk/openmeetings-util/src/main/java/org/apache/openmeetings/util/CalendarPatterns.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-util/src/main/java/org/apache/openmeetings/util/CalendarPatterns.java?rev=1767449&r1=1767448&r2=1767449&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-util/src/main/java/org/apache/openmeetings/util/CalendarPatterns.java (original)
+++ openmeetings/application/trunk/openmeetings-util/src/main/java/org/apache/openmeetings/util/CalendarPatterns.java Tue Nov 1 08:44:02 2016
@@ -20,6 +20,7 @@ package org.apache.openmeetings.util;
import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
+import java.text.ParseException;
import java.util.Date;
import java.util.TimeZone;
@@ -109,12 +110,9 @@ public class CalendarPatterns {
Date resultDate = null;
try {
resultDate = sdf.parse(testdate);
- }
-
- // if the format of the string provided doesn't match the format we
- // declared in SimpleDateFormat() we will get an exception
-
- catch (java.text.ParseException e) {
+ } catch (ParseException|NumberFormatException e) {
+ // if the format of the string provided doesn't match the format we
+ // declared in SimpleDateFormat() we will get an exception
return null;
}
@@ -123,7 +121,6 @@ public class CalendarPatterns {
}
return resultDate;
-
}
public static String getDateWithTimeByMiliSecondsAndTimeZone(Date t, TimeZone timezone) {
Added: openmeetings/application/trunk/openmeetings-util/src/test/java/org/apache/openmeetings/util/TestCalendarPatterns.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-util/src/test/java/org/apache/openmeetings/util/TestCalendarPatterns.java?rev=1767449&view=auto
==============================================================================
--- openmeetings/application/trunk/openmeetings-util/src/test/java/org/apache/openmeetings/util/TestCalendarPatterns.java (added)
+++ openmeetings/application/trunk/openmeetings-util/src/test/java/org/apache/openmeetings/util/TestCalendarPatterns.java Tue Nov 1 08:44:02 2016
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") + you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openmeetings.util;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Date;
+
+import org.junit.Test;
+
+public class TestCalendarPatterns {
+
+ @Test
+ public void backupDateParseTest() {
+ Date d = CalendarPatterns.parseImportDate("1360832400000");
+ assertNotNull("Date parsed should not be NULL", d);
+ }
+}