Skip to content

Commit

Permalink
SAK-43117 use the JSF timeZone attribute to set the current time in u…
Browse files Browse the repository at this point in the history
…ser's preferred timezone (sakaiproject#7913)

This reverts commit d3eebe3.
  • Loading branch information
ottenhoff authored Feb 19, 2020
1 parent 6b3dd14 commit 3d5d064
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@
import org.sakaiproject.util.ResourceLoader;
import org.sakaiproject.util.api.FormattedText;

import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

/**
Expand All @@ -96,25 +94,157 @@
*
*/
@Slf4j
@Getter
@Setter
public class SakaiFacadeImpl implements SakaiFacade {

private FunctionManager functionManager;

private static ResourceLoader rb= new ResourceLoader();

private FunctionManager functionManager;
/**
* set a Sakai FunctionManager object
*
* @param functionManager
* a Sakai FunctionManager object
*/
public void setFunctionManager(FunctionManager functionManager) {
this.functionManager = functionManager;
}

private ToolManager toolManager;

/**
* set a Sakai ToolManager object
*
* @param toolManager
* a Sakai ToolManager object
*/
public void setToolManager(ToolManager toolManager) {
this.toolManager = toolManager;
}

/**
* get the ToolManager object.
*
* @return a ToolManager object.
*/
public ToolManager getToolManager() {
return this.toolManager;
}

private SecurityService securityService;

/**
* set a Sakai SecurityService object
*
* @param securityService
* a Sakai SecurityService object
*/
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}

private SessionManager sessionManager;

/**
* set a Sakai SessionManager object
*
* @param sessionManager
* a Sakai SessionManager object
*/
public void setSessionManager(SessionManager sessionManager) {
this.sessionManager = sessionManager;
}

private SiteService siteService;

/**
* set a Sakai SiteService object
*
* @param siteService
* a Sakai SiteService object
*/
public void setSiteService(SiteService siteService) {
this.siteService = siteService;
}

/**
* {@inheritDoc}
*/
public SiteService getSiteService() {
return siteService;
}

private UserDirectoryService userDirectoryService;

/**
* set a Sakai UserDirectoryService object
*
* @param userDirectoryService
* a Sakai UserDirectoryService object
*/
public void setUserDirectoryService(UserDirectoryService userDirectoryService) {
this.userDirectoryService = userDirectoryService;
}

private CalendarService calendarService;

/**
* set a Sakai CalendarService object
*
* @param calendarService
* a Sakai CalendarService object
*/
public void setCalendarService(CalendarService calendarService) {
this.calendarService = calendarService;
}

private ServerConfigurationService serverConfigurationService;

/**
* {@inheritDoc}
*/
public ServerConfigurationService getServerConfigurationService() {
return serverConfigurationService;
}

/**
* set a Sakai ServerConfigurationService object
*
* @param serverConfigurationService
* a Sakai ServerConfigurationService object
*/
public void setServerConfigurationService(ServerConfigurationService serverConfigurationService) {
this.serverConfigurationService = serverConfigurationService;
}

private AuthzGroupService authzGroupService;

private FormattedText formattedText;
private TimeService timeService;
private ContentHostingService contentHostingService;

/**
* {@inheritDoc}
*/
@Override
public FormattedText getFormattedText() {
return formattedText;
}

/**
* Sets the FormattedText Service.
*
* @param formattedText
* a FormattedText object
*/
public void setFormattedText(FormattedText formattedText) {
this.formattedText = formattedText;
}

public AuthzGroupService getAuthzGroupService() {
return authzGroupService;
}
public void setAuthzGroupService(AuthzGroupService authzGroupService) {
this.authzGroupService=authzGroupService;
}
// Returns Google calendar if the calendar has been created in Google
public Calendar getAdditionalCalendar(String siteId) throws PermissionException {
CalendarService additionalCalendarService = null;
Expand Down Expand Up @@ -920,7 +1050,43 @@ public Group getGroup(String siteId, String groupId) throws IdUnusedException {
return site.getGroup(groupId);
}

private TimeService timeService;

/**
* {@inheritDoc}
*/
public TimeService getTimeService() {
return timeService;
}

/**
* This is a setter.
*
* @param timeService
* a TimeService object.
*/
public void setTimeService(TimeService timeService) {
this.timeService = timeService;
}

private ContentHostingService contentHostingService;

/**
* {@inheritDoc}
*/
public ContentHostingService getContentHostingService() {
return contentHostingService;
}

/**
* This is a setter.
* @param contentHostingService
* a ContentHostingService object
*/
public void setContentHostingService(ContentHostingService contentHostingService) {
this.contentHostingService = contentHostingService;
}

/**
* {@inheritDoc}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package org.sakaiproject.signup.tool.jsf;

import java.text.MessageFormat;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
Expand All @@ -40,7 +39,6 @@
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;
import org.sakaiproject.component.cover.ComponentManager;
import org.sakaiproject.exception.IdUnusedException;
import org.sakaiproject.exception.PermissionException;
import org.sakaiproject.signup.logic.SakaiFacade;
Expand All @@ -60,7 +58,6 @@
import org.sakaiproject.signup.tool.util.SignupBeanConstants;
import org.sakaiproject.signup.tool.util.Utilities;
import org.sakaiproject.site.api.Site;
import org.sakaiproject.time.api.TimeService;
import org.sakaiproject.user.api.User;
import org.sakaiproject.util.DateFormatterUtil;

Expand Down Expand Up @@ -229,10 +226,7 @@ private void init() {
signupMeeting = new SignupMeeting();
signupMeeting.setMeetingType(INDIVIDUAL);

TimeService timeService = (TimeService) ComponentManager.get(TimeService.class);
Date date = new Date();
date = new Date(date.getTime() + timeService.getLocalTimeZone().getOffset(Instant.now().toEpochMilli()));

Calendar startCal = Calendar.getInstance();
startCal.setTime(date);
startCal.set(Calendar.MINUTE, 0);
Expand Down
2 changes: 1 addition & 1 deletion signup/tool/src/webapp/WEB-INF/applicationContext.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@
class="org.sakaiproject.signup.tool.entityproviders.SignupRESTfulSessionManager">
</bean>

</beans>
</beans>
6 changes: 3 additions & 3 deletions signup/tool/src/webapp/signup/newMeeting/step1.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
useTime: 1,
parseFormat: 'YYYY-MM-DD HH:mm:ss',
allowEmptyDate: false,
val: '<h:outputText value="#{NewSignupMeetingBean.signupMeeting.startTime}"><f:convertDateTime pattern="yyyy-MM-dd HH:mm:ss"/></h:outputText>',
val: '<h:outputText value="#{NewSignupMeetingBean.signupMeeting.startTime}"><f:convertDateTime timeZone="#{UserTimeZone.userTimeZone}" pattern="yyyy-MM-dd HH:mm:ss"/></h:outputText>',
ashidden: {
iso8601: 'startTimeISO8601',
month:"meeting_startTime_month",
Expand All @@ -43,7 +43,7 @@
useTime: 1,
parseFormat: 'YYYY-MM-DD HH:mm:ss',
allowEmptyDate: false,
val: '<h:outputText value="#{NewSignupMeetingBean.signupMeeting.endTime}"><f:convertDateTime pattern="yyyy-MM-dd HH:mm:ss"/></h:outputText>',
val: '<h:outputText value="#{NewSignupMeetingBean.signupMeeting.endTime}"><f:convertDateTime timeZone="#{UserTimeZone.userTimeZone}" pattern="yyyy-MM-dd HH:mm:ss"/></h:outputText>',
ashidden: {
iso8601: 'endTimeISO8601',
month:"meeting_endTime_month",
Expand All @@ -59,7 +59,7 @@
useTime: 0,
parseFormat: 'YYYY-MM-DD',
allowEmptyDate: false,
val: '<h:outputText value="#{NewSignupMeetingBean.repeatUntil}"><f:convertDateTime pattern="yyyy-MM-dd"/></h:outputText>',
val: '<h:outputText value="#{NewSignupMeetingBean.repeatUntil}"><f:convertDateTime timeZone="#{UserTimeZone.userTimeZone}" pattern="yyyy-MM-dd"/></h:outputText>',
ashidden: {
iso8601: 'untilISO8601',
month:"meeting_until_month",
Expand Down

0 comments on commit 3d5d064

Please sign in to comment.