List of usage examples for java.util Date after
public boolean after(Date when)
From source file:com.abiquo.abiserver.business.authentication.AuthenticationManagerDB.java
@Override @SuppressWarnings("unchecked") public DataResult<LoginResult> doLogin(final Login login) { DataResult<LoginResult> dataResult = new DataResult<LoginResult>(); Session session = null;//from www .j a va 2 s.c o m Transaction transaction = null; try { session = HibernateUtil.getSession(); transaction = session.beginTransaction(); // Get the user from the appropiate source UserHB userHB = null; if (StringUtils.isBlank(login.getAuthToken())) { userHB = getUser(login, session); } else { userHB = getUserUsingToken(login, session); } if (userHB != null) { // User exists. Check if it is active if (userHB.getActive() == 1) { // User exists in database and is active. // Looking for all existing active sessions of this user, ordered by when were // created ArrayList<UserSession> oldUserSessions = (ArrayList<UserSession>) session .createCriteria(UserSession.class).add(Restrictions.eq("user", login.getUser())) .addOrder(Order.desc("key")).list(); Date currentTime = new Date(); // We erase old expired sessions for (UserSession existingSession : oldUserSessions) { if (currentTime.after(existingSession.getExpireDate())) { session.delete(existingSession); } } // Creating the user session UserSession userSession = new UserSession(); userSession.setUser(userHB.getUser()); userSession.setKey(String.valueOf(Calendar.getInstance().getTimeInMillis())); userSession.setLocale(login.getLocale()); userSession.setUserIdDb(userHB.getIdUser()); userSession.setEnterpriseName(userHB.getEnterpriseHB().getName()); int sessionTimeout = abiConfig.getSessionTimeout(); long expireMilis = new Date().getTime() + sessionTimeout * 60 * 1000; Date expireDate = new Date(expireMilis); userSession.setExpireDate(expireDate); // Saving in Data Base the created User Session session.save(userSession); // Generating the login result, with the user who has logged in and his session LoginResult loginResult = new LoginResult(); loginResult.setSession(userSession); loginResult.setUser(userHB.toPojo()); // Generating the DataResult dataResult.setSuccess(true); dataResult.setMessage(AuthenticationManagerDB.resourceManger.getMessage("doLogin.success")); dataResult.setData(loginResult); } else { // User is not active. Generating the DataResult errorManager.reportError(resourceManger, dataResult, "doLogin.userInActive"); } } else { // User not exists in database or bad credentials. Generating the DataResult errorManager.reportError(resourceManger, dataResult, "doLogin.passwordUserIncorrect"); dataResult.setResultCode(BasicResult.USER_INVALID); } transaction.commit(); } catch (Exception e) { if (transaction != null && transaction.isActive()) { transaction.rollback(); } errorManager.reportError(resourceManger, dataResult, "doLogin.exception", e); } return dataResult; }
From source file:com.gargoylesoftware.htmlunit.CookieManager.java
/** * Clears all cookies that have expired before supplied date. * If disabled, this returns false./* ww w .ja v a2 s. c o m*/ * @param date the date to use for comparison when clearing expired cookies * @return whether any cookies were found expired, and were cleared */ public synchronized boolean clearExpired(final Date date) { if (!isCookiesEnabled()) { return false; } if (date == null) { return false; } boolean foundExpired = false; for (final Iterator<Cookie> iter = cookies_.iterator(); iter.hasNext();) { final Cookie cookie = iter.next(); if (cookie.getExpires() != null && date.after(cookie.getExpires())) { iter.remove(); foundExpired = true; } } return foundExpired; }
From source file:com.inkubator.hrm.service.impl.JadwalKerjaMassExceptionMessagesListener.java
@Override @Transactional(readOnly = false, propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED, timeout = 50, rollbackFor = Exception.class) public void onMessage(Message message) { try {//from www.j a v a2 s . c o m TextMessage textMessage = (TextMessage) message; JSONObject jSONObject = new JSONObject(textMessage.getText()); long workingGroupId = Long.parseLong(jSONObject.getString("groupWorkingId")); String listEmp = jSONObject.getString("listEmpId"); Date createOn = new SimpleDateFormat("dd-MM-yyyy hh:mm").parse(jSONObject.getString("createDate")); String createBy = jSONObject.getString("createBy"); String startDateString = jSONObject.getString("startDate"); String endDateString = jSONObject.getString("endDate"); Date startProposeDate = new SimpleDateFormat("dd-MM-yyyy hh:mm") .parse(jSONObject.getString("startDate")); Gson gson = new GsonBuilder().create(); // List<TempJadwalKaryawan> dataToDelete = new ArrayList<>(); TypeToken<List<Long>> token = new TypeToken<List<Long>>() { }; List<Long> dataEmpId = gson.fromJson(listEmp, token.getType()); //Date now = new Date(); WtGroupWorking groupWorking = wtGroupWorkingDao.getEntiyByPK(workingGroupId); Date startDate = groupWorking.getBeginTime();//tidak ditempatkan di dalam loop karena untuk groupworking yang sama Date endDate = groupWorking.getEndTime(); int numberOfDay = DateTimeUtil.getTotalDayDifference(startDate, endDate); int totalDateDif = DateTimeUtil.getTotalDayDifference(startDate, startProposeDate) + 1; int num = numberOfDay + 1; int hasilBagi = (totalDateDif) / (num); Date tanggalAkhirJadwal = new SimpleDateFormat("dd-MM-yyyy hh:mm") .parse(jSONObject.getString("endDate")); // String dayBegin = new SimpleDateFormat("EEEE").format(endDate); // String dayNow = new SimpleDateFormat("EEEE").format(now); Date beginScheduleDate; if (new SimpleDateFormat("ddMMyyyy").format(tanggalAkhirJadwal) .equals(new SimpleDateFormat("ddMMyyyy").format(new Date()))) { beginScheduleDate = DateTimeUtil.getDateFrom(startDate, (hasilBagi * num) - num, CommonUtilConstant.DATE_FORMAT_DAY); } else { beginScheduleDate = DateTimeUtil.getDateFrom(startDate, (hasilBagi * num), CommonUtilConstant.DATE_FORMAT_DAY); } List<TempJadwalKaryawan> dataToSave = new ArrayList<>(); TempJadwalKaryawan jadwalKaryawan; for (Long id : dataEmpId) { // dataToDelete.addAll(tempJadwalKaryawanDao.getAllByEmpId(id)); for bussiner process Sake so must be close List<WtScheduleShift> dataScheduleShift = new ArrayList<>(groupWorking.getWtScheduleShifts()); // Collections.sort(dataScheduleShift, shortByDate1); int totaldayPropsot = DateTimeUtil.getTotalDayDifference(startProposeDate, tanggalAkhirJadwal); int loop = totaldayPropsot / dataScheduleShift.size(); List<WtScheduleShift> sortedDataScheduleShift = Lambda.sort(dataScheduleShift, Lambda.on(WtScheduleShift.class).getScheduleDate()); int i = 0; // for (int a = 0; a < loop; a++) { for (WtScheduleShift wtScheduleShift : sortedDataScheduleShift) { String onlyDate = new SimpleDateFormat("yyyy-MM-dd").format( DateTimeUtil.getDateFrom(beginScheduleDate, i, CommonUtilConstant.DATE_FORMAT_DAY)); Date olnyDate = new SimpleDateFormat("yyyy-MM-dd").parse(onlyDate); jadwalKaryawan = tempJadwalKaryawanDao.getByEmpId(id, olnyDate); if (jadwalKaryawan != null) { jadwalKaryawan.setUpdatedBy(createBy); jadwalKaryawan.setUpdatedOn(new Date()); // jadwalKaryawan = tempJadwalKaryawanDao.getByEmpId(empData.getId(), olnyDate); } else { jadwalKaryawan = new TempJadwalKaryawan(); jadwalKaryawan.setId(Long.parseLong(RandomNumberUtil.getRandomNumber(12))); jadwalKaryawan.setEmpData(empDataDao.getEntiyByPK(id)); jadwalKaryawan.setTanggalWaktuKerja( DateTimeUtil.getDateFrom(beginScheduleDate, i, CommonUtilConstant.DATE_FORMAT_DAY)); jadwalKaryawan.setCreatedBy(createBy); jadwalKaryawan.setCreatedOn(createOn); } // TempJadwalKaryawan jadwalKaryawan = new TempJadwalKaryawan(); // jadwalKaryawan.setEmpData(empDataDao.getEntiyByPK(id)); // jadwalKaryawan.setTanggalWaktuKerja(DateTimeUtil.getDateFrom(beginScheduleDate, i, CommonUtilConstant.DATE_FORMAT_DAY)); // jadwalKaryawan.setWtWorkingHour(wtScheduleShift.getWtWorkingHour()); WtHoliday holiday = wtHolidayDao.getWtHolidayByDate(jadwalKaryawan.getTanggalWaktuKerja()); if (holiday != null && groupWorking.getTypeSequeace().equals(HRMConstant.NORMAL_SCHEDULE)) { jadwalKaryawan.setWtWorkingHour(wtWorkingHourDao.getByCode("OFF")); } else { jadwalKaryawan.setWtWorkingHour(wtScheduleShift.getWtWorkingHour()); } // WtHoliday holiday = wtHolidayDao.getWtHolidayByDate(jadwalKaryawan.getTanggalWaktuKerja()); // if (holiday != null || wtScheduleShift.getWtWorkingHour().getCode().equalsIgnoreCase("OFF")) { // jadwalKaryawan.setAttendanceStatus(attendanceStatusDao.getByCode("OFF")); // } else { // jadwalKaryawan.setAttendanceStatus(attendanceStatusDao.getByCode("HD1")); // } jadwalKaryawan.setIsCollectiveLeave(Boolean.FALSE); Date jadwal = jadwalKaryawan.getTanggalWaktuKerja(); if (jadwal.equals(startProposeDate) || jadwal.equals(tanggalAkhirJadwal)) { dataToSave.add(jadwalKaryawan); } if ((jadwal.after(startProposeDate) && jadwal.before(tanggalAkhirJadwal))) { dataToSave.add(jadwalKaryawan); } i++; } // } } // tempJadwalKaryawanDao.deleteBacth(dataToDelete); tempJadwalKaryawanDao.saveBatch(dataToSave); //sending email process // this.sendingEmailJadwalKaryawan(dataToSave, jSONObject.getString("locale")); } catch (Exception ex) { LOGGER.error("Error", ex); } }
From source file:ob.PO.TaskPO.java
@Override public void run() { setTaskLog(""); if (thistype == 0) {// Date tasktime;/* www . ja va2 s .com*/ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-ddHH:mm:ss"); //???? try { tasktime = sdf.parse(thisstr1 + thisstr2); //if(cl.) } catch (ParseException ex) { setTaskLog(""); return; } Date nowtime = new Date(); if (nowtime.after(tasktime)) { setTaskLog("??"); return; } while (nowtime.before(tasktime)) { long deltaminute = (tasktime.getTime() - nowtime.getTime()) / (1000 * 60); // long day = deltaminute / (24 * 60); long hour = (deltaminute / 60) % 24; long minute = deltaminute % 60; setTaskLog("\n" + day + "" + hour + "" + minute + ""); try { Thread.sleep(5000); } catch (InterruptedException ex) { setTaskLog(""); return; } nowtime = new Date(); } if (nowtime.getTime() - tasktime.getTime() > 60 * 1000) {//? setTaskLog("?"); return; } setTaskLog(""); } else if (thistype == 1) {// int lastmessage_num = -1; POP3SClient pop3 = new POP3SClient(true); POP3MessageInfo[] messages; pop3.setDefaultTimeout(600000); while (true) { try { pop3.connect("pop." + thisstr1.split("@")[1]);//pop. + domain if (!pop3.login(thisstr1, AESUtil.Decryptor(thisstr2))) { pop3.disconnect(); setTaskLog("?."); return; } messages = pop3.listMessages(); if (lastmessage_num < 0) {//? lastmessage_num = messages.length;//? setTaskLog("?" + lastmessage_num); } else if (lastmessage_num < messages.length) {// break; } setTaskLog("?" + messages.length); Thread.sleep(10000); } catch (Exception ex) { setTaskLog(""); return; } } setTaskLog(""); } else if (thistype == 2) {//? setTaskLog("??"); while (true) { try { String Access_token; if ((Access_token = Sina.getToken(thisstr1, AESUtil.Decryptor(thisstr2)) .getAccessToken()) == null) { setTaskLog("???"); return; } String lasttimeline = GetUserTimeline.getTimeline(Access_token); if (lasttimeline == null) { } else { if (lasttimeline.contains(thistext)) {//? break; } } setTaskLog("??"); Thread.sleep(10000); } catch (Exception ex) { ex.printStackTrace(); setTaskLog("??"); return; } } setTaskLog("???"); } if (thattype == 1) {//? setTaskLog("??"); SimpleEmail email = new SimpleEmail(); Properties props = new Properties(); String user, pass; try { props.load( Thread.currentThread().getContextClassLoader().getResourceAsStream("adminmail.properties")); if ((user = (String) props.get("user")) == null || (pass = (String) props.get("pass")) == null) { setTaskLog("?"); return; } email.setHostName("smtp." + user.split("@")[1]);//? smtp. + domain email.setAuthentication(user, pass);//smtp???? email.setSSLOnConnect(true); email.addTo(thatusername, "JAVA IFTTT RECEIVER");// email.setFrom(user, "JAVA IFTTT SENDER");//? email.setSubject("JAVA IFTTT SEND EMAIL");// email.setCharset("UTF-8");//?? email.setMsg(thattext);// email.send();//?? } catch (Exception ex) { setTaskLog("??"); return; } setTaskLog("????"); } else if (thattype == 0) {//?? setTaskLog("???"); try { String Access_token; if ((Access_token = Sina.getToken(thatusername, AESUtil.Decryptor(thatpassword)) .getAccessToken()) == null) { setTaskLog("???"); return; } UpdateStatus.Update(Access_token, thattext); } catch (Exception ex) { ex.printStackTrace(); setTaskLog("???"); return; } setTaskLog("?????"); } }
From source file:com.mb.framework.util.DateTimeUtil.java
public static long daysDiff(Date dueDate, Date today) { Long daysDiff = new Long(0); if (dueDate.after(today)) { daysDiff = (dueDate.getTime() - today.getTime()) / (1000 * 60 * 60 * 24); }// w w w. ja v a2 s. c o m return daysDiff.intValue(); }
From source file:net.sf.statcvs.output.xml.chart.ModuleActivityChart.java
private ContourDataset createDataset() { List dirs = content.getDirectories(); List dateList = new ArrayList(); Date firstDate = content.getFirstDate(); Date lastDate = content.getLastDate(); Calendar cal = new GregorianCalendar(); cal.setTime(firstDate);// w w w . j a v a 2 s .co m while (cal.getTime().before(lastDate)) { dateList.add(cal.getTime()); cal.add(Calendar.DATE, 1); } dateList.add(lastDate); Double[][] values = new Double[dateList.size()][dirs.size()]; for (int i = 0; i < dateList.size(); i++) { Iterator dirsIt = dirs.iterator(); IntegerMap changesMap = new IntegerMap(); while (dirsIt.hasNext()) { Directory dir = (Directory) dirsIt.next(); RevisionIterator revIt = new RevisionSortIterator(dir.getRevisionIterator()); while (revIt.hasNext()) { CvsRevision rev = revIt.next(); Date revDate = rev.getDate(); Date currDate = (Date) dateList.get(i); Date nextDate = null; if (i < dateList.size() - 1) { nextDate = (Date) dateList.get(i + 1); } if (revDate.equals(currDate) || (revDate.after(currDate) && revDate.before(nextDate))) { changesMap.inc(dir); } } } Iterator cIt = changesMap.iteratorSortedByKey(); while (cIt.hasNext()) { Directory dir = (Directory) cIt.next(); int dirIndex = dirs.indexOf(dir); //values[i][dirIndex] = new Double(changesMap.getPercent(dir)); values[i][dirIndex] = new Double(changesMap.getPercentOfMaximum(dir)); } } int numValues = dateList.size() * dirs.size(); Date[] oDateX = new Date[numValues]; Double[] oDoubleY = new Double[numValues]; Double[] oDoubleZ = new Double[numValues]; for (int x = 0; x < dateList.size(); x++) { for (int y = 0; y < dirs.size(); y++) { int index = (x * dirs.size()) + y; oDateX[index] = (Date) dateList.get(x); oDoubleY[index] = new Double(y); if ((values[x][y] != null) && ((values[x][y].isNaN()) || (values[x][y].equals(new Double(0))))) { values[x][y] = null; } oDoubleZ[index] = values[x][y]; } } oDoubleZ[0] = new Double(0.0); return new DefaultContourDataset(getTitle(), oDateX, oDoubleY, oDoubleZ); }
From source file:be.fedict.trust.crl.CachedCrlRepository.java
public X509CRL findCrl(URI crlUri, X509Certificate issuerCertificate, Date validationDate) { SoftReference<X509CRL> crlRef = this.crlCache.get(crlUri); if (null == crlRef) { LOG.debug("no CRL entry found: " + crlUri); return refreshCrl(crlUri, issuerCertificate, validationDate); }/* w w w. j a va 2s . c o m*/ X509CRL crl = crlRef.get(); if (null == crl) { LOG.debug("CRL garbage collected: " + crlUri); return refreshCrl(crlUri, issuerCertificate, validationDate); } if (validationDate.after(crl.getNextUpdate())) { LOG.debug("CRL no longer valid: " + crlUri); LOG.debug("validation date: " + validationDate); LOG.debug("CRL next update: " + crl.getNextUpdate()); return refreshCrl(crlUri, issuerCertificate, validationDate); } /* * The Belgian PKI the nextUpdate CRL extension indicates 7 days. The * actual CRL refresh rate is every 3 hours. So it's a bit dangerous to * only base the CRL cache refresh strategy on the nextUpdate field as * indicated by the CRL. */ Date thisUpdate = crl.getThisUpdate(); DateTime cacheMaturityDateTime = new DateTime(thisUpdate).plusHours(this.cacheAgingHours); if (validationDate.after(cacheMaturityDateTime.toDate())) { LOG.debug("refreshing the CRL cache: " + crlUri); return refreshCrl(crlUri, issuerCertificate, validationDate); } LOG.debug("using cached CRL: " + crlUri); return crl; }
From source file:Fetcher.Fetcher.java
@Deprecated @Override//from w ww. j a v a2 s.c o m /** * run() is deprecated. Use startFetching() instead. */ public void run() { WebDocument link = null; HttpURLConnection connection; Proxy p; //PreConnfiguration //Configure proxy //TODO Anonymizer is deprecated. Use in following for warning generation. switch (Variables.anonymizerProxyType) { case DIRECT: p = new Proxy(Proxy.Type.DIRECT, new InetSocketAddress(Variables.anonymizerIP, Variables.anonymizerPort)); break; case HTTP: p = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(Variables.anonymizerIP, Variables.anonymizerPort)); break; case SOCKS: p = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(Variables.anonymizerIP, Variables.anonymizerPort)); break; case NONE: default: p = null; break; } link = Methods.getNextProfileLink(); while (link != null && isWorking) { //Start fetching ... //Check if it should work or not Date currentTime = Methods.getCurrentTime(); if (!currentTime.after(Variables.startTime) || !currentTime.before(Variables.endTime)) { try { synchronized (t) { getThread().wait(60000); //sleep 60 seconds } } catch (InterruptedException ex) { if (Variables.debug) { Variables.logger.Log(Fetcher.class, Variables.LogType.Error, "Time is not between start and end time and thread is in exception!"); } } finally { continue; } } String URL = link.getNextUrl(); String UA = Methods.getRandomUserAgent(); //Use this UA for refererd or single links. //loop for referer for (int i = 0; i <= link.getRefererCount(); URL = link.getNextUrl(), i++) { if (Variables.debug && Variables.vv) { Variables.logger.Log(Fetcher.class, Variables.LogType.Trace, "Fetcher (" + Methods.Colorize(name, Methods.Color.Green) + ") start getting " + URL); } try { //Anonymizer if (Variables.anonymizerProxyType == Variables.AnonymizerProxy.NONE) { connection = (HttpURLConnection) new URL(URL).openConnection(); } else { connection = (HttpURLConnection) new URL(URL).openConnection(p); } connection.setDoOutput(true); connection.setDoInput(true); connection.setRequestProperty("User-Agent", UA); connection.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); connection.setRequestProperty("Accept-Language", "en-US,en;q=0.5"); connection.setRequestProperty("Accept-Encoding", "gzip, deflated"); String referer = link.getNextReferrer(); if (referer != null) { connection.setRequestProperty("Referer", referer); referer = null; System.gc(); } //Send Cookie using user input if (!(Variables.Cookie == null || Variables.Cookie.equalsIgnoreCase(""))) { connection.setRequestProperty("Cookie", Variables.Cookie); } else if (cookies.getCookieStore().getCookies().size() > 0) { //From referer, there are some cookies connection.setRequestProperty("Cookie", Join(",", cookies.getCookieStore().getCookies())); } connection.setRequestMethod("GET"); connection.connect(); //Get Cookie from response getCookies(connection); if (connection.getResponseCode() == 200) { //Write to file String outputName = Variables.outputDirectory + link.getOutputName().substring(0, link.getOutputName().lastIndexOf(".")) + i + link.getOutputName().substring(link.getOutputName().lastIndexOf(".")); //Check extension if (!(outputName.endsWith("html") || outputName.endsWith("htm"))) { outputName += "html"; } //get content String html = ""; if (connection.getContentEncoding().equalsIgnoreCase("gzip")) { html = IOUtils.toString(new GZIPInputStream(connection.getInputStream())); } else if (connection.getContentEncoding().equalsIgnoreCase("deflate")) { html = IOUtils.toString(new InflaterInputStream(connection.getInputStream())); } FileWriter fw = new FileWriter(outputName); fw.write(html); fw.flush(); fw.close(); } else { //The returned code is not 200. if (Variables.debug) { Variables.logger.Log(Fetcher.class, Variables.LogType.Error, "Fetcher could not download (" + Methods.Colorize(URL, Methods.Color.Red) + ") in " + name); if (Variables.vv) { Variables.logger.Log(Fetcher.class, Variables.LogType.Error, "Server responded (" + Methods.Colorize(connection.getResponseCode() + " - " + connection.getResponseMessage(), Methods.Color.Red) + ") for " + URL); } } } //Close the connection connection.disconnect(); //Report progress Variables.logger.logResult(connection, link); Methods.oneFinished(); if (Variables.debug && Variables.vv) { Variables.logger.Log(Fetcher.class, Variables.LogType.Info, "[+] Done fetching (" + Methods.Colorize(URL, Methods.Color.Red) + "]"); } try { synchronized (t) { t.wait(Methods.getNextRandom() * 1000); } } catch (InterruptedException ex) { if (Variables.debug) { Variables.logger.Log(Fetcher.class, Variables.LogType.Error, "Cannot interrupt thread [" + Methods.Colorize(name, Methods.Color.Red) + "]. Interrupted before!"); } } catch (IllegalArgumentException ex) { if (Variables.debug) { Variables.logger.Log(Fetcher.class, Variables.LogType.Error, "-1 is returned as random number for thread [" + Methods.Colorize(name, Methods.Color.Red) + "]."); } } } catch (IOException ex) { if (Variables.debug) { if (Variables.vv) { Variables.logger.Log(Fetcher.class, Variables.LogType.Error, "Error in fetching [" + Methods.Colorize(URL, Methods.Color.Red) + "] in fetcher (" + Methods.Colorize(name, Methods.Color.Yellow) + ") for writing in (" + Methods.Colorize(link.getOutputName(), Methods.Color.White) + "). Detail:\r\n" + ex.getMessage()); } else { Variables.logger.Log(Fetcher.class, Variables.LogType.Error, "Error in fetching [" + Methods.Colorize(URL, Methods.Color.Red) + "]"); } } } catch (NullPointerException ex) { //Thrown sometimes and make the thread as Dead! if (Variables.debug) { if (Variables.vv) { Variables.logger.Log(Fetcher.class, Variables.LogType.Error, "Null pointer occured. Error in fetching [" + Methods.Colorize(URL, Methods.Color.Red) + "] in fetcher (" + Methods.Colorize(name, Methods.Color.Yellow) + ") for writing in (" + Methods.Colorize(link.getOutputName(), Methods.Color.White) + ")."); } else { Variables.logger.Log(Fetcher.class, Variables.LogType.Error, "Null pointer occured. Error in fetching [" + Methods.Colorize(URL, Methods.Color.Red) + "]"); } } } } //Check size limit and compress ... long size = Methods.getFolderSize(Variables.outputDirectory); if (size >= Variables.outputSizeLimit) { //Deactivate itself by waiting ... Variables.state = Variables.microbotState.Compressing; Variables.threadController.changeActiveThreads(false, t, Variables.microbotState.Compressing); } //Check if user terminated program or not if (isWorking) { link = Methods.getNextProfileLink(); } } //Thread finished. (Normally or by force) Variables.state = Variables.microbotState.Stopping; Variables.threadController.changeActiveThreads(false, t, Variables.microbotState.Stopping); //URLs done. This thread finishes its work. if (Variables.debug) { Variables.logger.Log(Fetcher.class, Variables.LogType.Info, "Fetcher (" + Methods.Colorize(name, Methods.Color.Green) + ") finished its work."); } }
From source file:org.jasig.schedassist.impl.SchedulingAssistantServiceImpl.java
@Override public List<AvailableBlock> calculateVisitorConflicts(IScheduleVisitor visitor, IScheduleOwner owner, Date start, Date end) { Date[] windowBoundaries = calculateOwnerWindowBounds(owner); Date localStart = start;/* w ww . j av a 2 s . co m*/ if (start.before(windowBoundaries[0])) { localStart = windowBoundaries[0]; } Date localEnd = end; if (end.after(windowBoundaries[1])) { localEnd = windowBoundaries[1]; } AvailableSchedule availableSchedule = this.availableScheduleDao.retrieve(owner, localStart, localEnd); // get the VISITOR's Calendar data Calendar calendar = calendarDao.getCalendar(visitor.getCalendarAccount(), localStart, localEnd); // calculate a VisibleSchedule using the owner's availability but the Visitor's calendar data VisibleSchedule result = this.visibleScheduleBuilder.calculateVisitorConflicts( availableSchedule.getScheduleStartTime(), availableSchedule.getScheduleEndTime(), calendar, availableSchedule, owner.getPreferredMeetingDurations(), visitor); // return only the conflicts (the busy list) List<AvailableBlock> visitorConflicts = result.getBusyList(); return visitorConflicts; }
From source file:org.apache.jmeter.protocol.http.control.CacheManager.java
/** * Check the cache, if the entry has an expires header and the entry has not expired, return true<br> * @param url {@link URL} to look up in cache * @return <code>true</code> if entry has an expires header and the entry has not expired, else <code>false</code> */// w w w .j ava2 s .c o m public boolean inCache(URL url) { CacheEntry entry = getCache().get(url.toString()); if (log.isDebugEnabled()) { log.debug("inCache " + url.toString() + " " + entry); } if (entry != null) { final Date expiresDate = entry.getExpires(); if (expiresDate != null) { if (expiresDate.after(new Date())) { if (log.isDebugEnabled()) { log.debug("Expires= " + expiresDate + " (Valid)"); } return true; } else { if (log.isDebugEnabled()) { log.debug("Expires= " + expiresDate + " (Expired)"); } } } } return false; }