List of usage examples for org.joda.time DateTimeConstants SECONDS_PER_WEEK
int SECONDS_PER_WEEK
To view the source code for org.joda.time DateTimeConstants SECONDS_PER_WEEK.
Click Source Link
From source file:org.wannatrak.server.LoginServiceImpl.java
License:Apache License
public String login(String login, String password, Boolean keepMyLogin) throws LoginFailedException { final UserWorker userWorker = ServiceLocator.lookup(UserWorker.JNDI_NAME); final SessionWorker sessionWorker = ServiceLocator.lookup(SessionWorker.JNDI_NAME); final String sessionId = getThreadLocalRequest().getSession().getId(); try {/*w w w . j a v a2s .c o m*/ userWorker.loginOrContinueSession(sessionId, login, password, keepMyLogin); final User user = sessionWorker.getUser(sessionId); if (user == null) { throw new LoginFailedException(); } if (keepMyLogin) { final Cookie sessionCookie = getSessionCookie(); if (sessionCookie != null) { sessionCookie.setMaxAge(DateTimeConstants.SECONDS_PER_WEEK * 2); getThreadLocalResponse().addCookie(sessionCookie); } } return createLoginResult(user); } catch (org.wannatrak.middleware.exception.LoginFailedException e) { throw new LoginFailedException(); } }
From source file:org.wannatrak.server.LoginServiceImpl.java
License:Apache License
public String tryToLogin() throws LoginFailedException { final SessionWorker sessionWorker = ServiceLocator.lookup(SessionWorker.JNDI_NAME); final String sessionId = getThreadLocalRequest().getSession().getId(); final Session session = sessionWorker.getSession(sessionId); if (session == null) { throw new LoginFailedException(); }//from www .j a v a 2 s . co m final User user = session.getUser(); if (user == null) { throw new LoginFailedException(); } if (session.isKeepInCookie()) { final Cookie sessionCookie = getSessionCookie(); if (sessionCookie != null) { sessionCookie.setMaxAge(DateTimeConstants.SECONDS_PER_WEEK * 2); getThreadLocalResponse().addCookie(sessionCookie); } } return createLoginResult(user); }
From source file:uk.ac.susx.tag.method51.core.params.codec.concrete.DurationCodec.java
License:Apache License
@Override public Duration decodeString(String value) throws DecodeException { Duration result = null;/*from ww w.ja v a 2 s. com*/ long milliseconds; try { milliseconds = Long.parseLong(value); } catch (NumberFormatException e) { try { if (value.length() == 0) { throw new IllegalArgumentException("zero length interval specification"); } value = value.toUpperCase(); if (!value.matches(".*[DWMHS].*")) { throw new IllegalArgumentException( "no time units specified, see ISO 8601 duration specification (months / years not supported): http://en.wikipedia.org/wiki/ISO_8601#Durations"); } if (!value.startsWith("P")) { value = "P" + value; } Matcher m = Pattern.compile("[HMS]").matcher(value); if (!value.contains("T") && m.find()) { String c = m.group(0); int i = value.indexOf(c); value = value.substring(0, i - 1) + "T" + value.substring(i - 1); } Period period = ISOPeriodFormat.standard().parsePeriod(value); long seconds = 0; seconds += period.getSeconds(); seconds += period.getMinutes() * DateTimeConstants.SECONDS_PER_MINUTE; seconds += period.getHours() * DateTimeConstants.SECONDS_PER_HOUR; seconds += period.getDays() * DateTimeConstants.SECONDS_PER_DAY; seconds += period.getWeeks() * DateTimeConstants.SECONDS_PER_WEEK; milliseconds = seconds * 1000; } catch (IllegalArgumentException e1) { throw new DecodeException("'" + value + "' is not a number, or an ISO 8601 duration", e1); } } result = new Duration(milliseconds); return result; }