Permalink
Browse files

LPS-27469 - Source formatting

  • Loading branch information...
1 parent 8139dc2 commit 8510ef5d078aefc7b10ea7e1ed039c14d487b665 @brianchandotcom brianchandotcom committed Jun 28, 2012
@@ -6,7 +6,7 @@
<portlet-name>1</portlet-name>
<configuration-action-class>com.liferay.calendar.action.ConfigurationActionImpl</configuration-action-class>
<scheduler-entry>
- <scheduler-event-listener-class>com.liferay.calendar.messaging.CheckBookingMessageListener</scheduler-event-listener-class>
+ <scheduler-event-listener-class>com.liferay.calendar.messaging.CheckBookingsMessageListener</scheduler-event-listener-class>
<trigger>
<simple>
<property-key>calendar.notification.check.interval</property-key>
@@ -65,21 +65,27 @@ else if (!Validator.isEmailAddress(emailFromAddress)) {
protected void validateTemplate(ActionRequest actionRequest)
throws Exception {
- String templateBodyParameterName = ParamUtil.getString(
- actionRequest, "templateBodyParameterName");
- String templateSubjectParameterName = ParamUtil.getString(
- actionRequest, "templateSubjectParameterName");
-
- String templateBody = getParameter(
- actionRequest, templateBodyParameterName);
- String templateSubject = getParameter(
- actionRequest, templateSubjectParameterName);
-
- if (Validator.isNull(templateBody)) {
- SessionErrors.add(actionRequest, "templateSubject");
+ String notificationTemplateContentBodyParameterName =
+ ParamUtil.getString(
+ actionRequest, "notificationTemplateContentBodyParameterName");
+
+ String notificationTemplateContentBody = getParameter(
+ actionRequest, notificationTemplateContentBodyParameterName);
+
+ String notificationTemplateContentSubjectParameterName =
+ ParamUtil.getString(
+ actionRequest,
+ "notificationTemplateContentSubjectParameterName");
+
+ String notificationTemplateContentSubject = getParameter(
+ actionRequest, notificationTemplateContentSubjectParameterName);
+
+ if (Validator.isNull(notificationTemplateContentBody)) {
+ SessionErrors.add(
+ actionRequest, "notificationTemplateContentSubject");
}
- else if (Validator.isNull(templateSubject)) {
- SessionErrors.add(actionRequest, "templateBody");
+ else if (Validator.isNull(notificationTemplateContentSubject)) {
+ SessionErrors.add(actionRequest, "notificationTemplateContentBody");
}
}
@@ -22,7 +22,7 @@
* @author Fabio Pezzutto
* @author Eduardo Lundgren
*/
-public class CheckBookingMessageListener extends BaseMessageListener {
+public class CheckBookingsMessageListener extends BaseMessageListener {
@Override
protected void doReceive(Message message) throws Exception {
@@ -66,7 +66,7 @@ public void sendNotification(
mailMessage.setHTMLFormat(notificationRecipient.isHTMLFormat());
InternetAddress toInternetAddress = new InternetAddress(
- notificationRecipient.getEmail());
+ notificationRecipient.getEmailAddress());
mailMessage.setTo(toInternetAddress);
@@ -25,25 +25,26 @@
*/
public class NotificationRecipient {
- public NotificationRecipient(String email) {
- _email = email;
+ public NotificationRecipient(String emailAddress) {
+ _emailAddress = emailAddress;
}
public NotificationRecipient(User user) {
_user = user;
- _email = user.getEmailAddress();
+
+ _emailAddress = user.getEmailAddress();
}
- public String getEmail() {
- return _email;
+ public String getEmailAddress() {
+ return _emailAddress;
}
public String getFormat() {
return _format;
}
public InternetAddress getInternetAddress() throws AddressException {
- return new InternetAddress(_email);
+ return new InternetAddress(_emailAddress);
}
public String getName() {
@@ -62,8 +63,8 @@ public boolean isHTMLFormat() {
return _format.equals(ContentTypes.TEXT_HTML);
}
- public void setEmail(String email) {
- _email = email;
+ public void setEmailAddress(String emailAddress) {
+ _emailAddress = emailAddress;
}
public void setFormat(String format) {
@@ -78,7 +79,7 @@ public void setUser(User user) {
_user = user;
}
- private String _email;
+ private String _emailAddress;
private String _format = ContentTypes.TEXT_HTML;
private String _name;
private User _user;
@@ -28,13 +28,11 @@
public class NotificationTemplateContext implements Cloneable, Serializable {
public NotificationTemplateContext() {
- _attributes = new LinkedHashMap<String, Serializable>();
_notificationType = NotificationType.parse(
PortletPropsValues.CALENDAR_NOTIFICATION_DEFAULT_TYPE);
}
public NotificationTemplateContext(NotificationType notificationType) {
- _attributes = new LinkedHashMap<String, Serializable>();
_notificationType = notificationType;
}
@@ -84,7 +82,8 @@ public void setNotificationType(NotificationType notificationType) {
_notificationType = notificationType;
}
- private Map<String, Serializable> _attributes;
+ private Map<String, Serializable> _attributes =
+ new LinkedHashMap<String, Serializable>();
private long _companyId;
private long _groupId;
private NotificationType _notificationType;
@@ -55,66 +55,72 @@ public static NotificationTemplateContext getInstance(
CalendarBooking calendarBooking, User user)
throws PortalException, SystemException {
- long companyId = calendarBooking.getCompanyId();
-
- Company company = CompanyLocalServiceUtil.getCompany(companyId);
-
NotificationTemplateContext notificationTemplateContext =
new NotificationTemplateContext();
- notificationTemplateContext.setCompanyId(companyId);
- notificationTemplateContext.setGroupId(calendarBooking.getGroupId());
-
Format dateFormatDateTime = FastDateFormatFactoryUtil.getDateTime(
user.getLocale(), user.getTimeZone());
Date endDate = calendarBooking.getEndDate();
- Date startDate = calendarBooking.getStartDate();
notificationTemplateContext.setAttribute(
"endDate", dateFormatDateTime.format(endDate.getTime()));
+
+ PortletPreferences portletPreferences =
+ PortletPreferencesLocalServiceUtil.getPreferences(
+ calendarBooking.getCompanyId(), calendarBooking.getGroupId(),
+ PortletKeys.PREFS_OWNER_TYPE_GROUP,
+ PortletKeys.PREFS_PLID_SHARED, PortletKeys.CALENDAR, null);
+
+ String fromAddress = NotificationUtil.getEmailFromAddress(
+ portletPreferences, calendarBooking.getCompanyId());
+ String fromName = NotificationUtil.getEmailFromName(
+ portletPreferences, calendarBooking.getCompanyId());
+
+ notificationTemplateContext.setAttribute("fromAddress", fromAddress);
+ notificationTemplateContext.setAttribute("fromName", fromName);
+
notificationTemplateContext.setAttribute(
"location", calendarBooking.getLocation());
+
+ Company company = CompanyLocalServiceUtil.getCompany(
+ calendarBooking.getCompanyId());
+
notificationTemplateContext.setAttribute(
"portalUrl", company.getPortalURL(calendarBooking.getGroupId()));
+
+ notificationTemplateContext.setAttribute(
+ "portletName",
+ LanguageUtil.get(
+ getPortletConfig(), user.getLocale(),
+ "javax.portlet.title.".concat(PortletKeys.CALENDAR)));
+
+ Date startDate = calendarBooking.getStartDate();
+
notificationTemplateContext.setAttribute(
"startDate", dateFormatDateTime.format(startDate.getTime()));
+
notificationTemplateContext.setAttribute(
"title", calendarBooking.getTitle(user.getLocale()));
notificationTemplateContext.setAttribute(
"toAddress", user.getEmailAddress());
notificationTemplateContext.setAttribute("toName", user.getFullName());
- notificationTemplateContext.setAttribute(
- "portletName", LanguageUtil.get(
- getPortletConfig(), user.getLocale(),
- "javax.portlet.title.".concat(PortletKeys.CALENDAR)));
- PortletPreferences preferences =
- PortletPreferencesLocalServiceUtil.getPreferences(
- companyId, calendarBooking.getGroupId(),
- PortletKeys.PREFS_OWNER_TYPE_GROUP,
- PortletKeys.PREFS_PLID_SHARED, PortletKeys.CALENDAR, null);
-
- String fromAddress = NotificationUtil.getEmailFromAddress(
- preferences, companyId);
-
- String fromName = NotificationUtil.getEmailFromName(
- preferences, companyId);
-
- notificationTemplateContext.setAttribute("fromAddress", fromAddress);
- notificationTemplateContext.setAttribute("fromName", fromName);
-
- Enumeration<String> enu = preferences.getNames();
+ Enumeration<String> enu = portletPreferences.getNames();
while (enu.hasMoreElements()) {
String name = enu.nextElement();
String value = GetterUtil.getString(
- preferences.getValue(name, StringPool.BLANK));
+ portletPreferences.getValue(name, StringPool.BLANK));
notificationTemplateContext.setAttribute(name, value);
}
+ notificationTemplateContext.setCompanyId(
+ calendarBooking.getCompanyId());
+ notificationTemplateContext.setGroupId(calendarBooking.getGroupId());
+
return notificationTemplateContext;
}
@@ -14,11 +14,6 @@
package com.liferay.calendar.service.impl;
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
import com.liferay.calendar.CalendarNameException;
import com.liferay.calendar.model.Calendar;
import com.liferay.calendar.model.CalendarResource;
@@ -33,6 +28,11 @@
import com.liferay.portal.model.User;
import com.liferay.portal.service.ServiceContext;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
/**
* @author Eduardo Lundgren
* @author Fabio Pezzutto
@@ -9,9 +9,9 @@ add-calendar=Add Calendar
add-guests-groups-rooms=Add Guests, Groups, Rooms...
add-new-calendar-for-x=Add New Calendar for {0}
add-other-calendars=Add other calendars
-booking-location=Booking Location
-booking-start-date=Booking Start Date
-booking-title=The booking title
+the-booking-location=The booking location
+the-booking-start-date=The booking start date
+the-booking-title=The booking title
calendar-resource-already-exists=Calendar resource already exists.
calendar-settings=Calendar Settings
changing-templates-could-loose-unsaved-data-do-you-want-to-proceed=Changing templates could loose unsaved data. Do you want to proceed?
@@ -4,7 +4,10 @@ resource.actions.configs=resource-actions/default.xml
calendar.color.default=0xD96666
+calendar.notification.check.interval=1
calendar.notification.default.type=email
+calendar.notification.from.name=
+calendar.notification.from.address=
calendar.notification.body[email][invite]=dependencies/email/booking_invite_body.tmpl
calendar.notification.enabled[email][invite]=true
@@ -22,12 +25,7 @@ calendar.notification.body[im][reminder]=dependencies/im/booking_reminder_body.t
calendar.notification.enabled[im][reminder]=true
calendar.notification.subject[im][reminder]=dependencies/im/booking_reminder_subject.tmpl
-calendar.notification.from.name=
-calendar.notification.from.address=
-
-calendar.notification.check.interval=1
-
calendar.resource.types=\
- car,\
- projector,\
- other
+ car,\
+ projector,\
+ other
Oops, something went wrong. Retry.

0 comments on commit 8510ef5

Please sign in to comment.