List of usage examples for java.util Date before
public boolean before(Date when)
From source file:de.ingrid.iplug.sns.SNSController.java
/** * @param baseTopic//from w w w. j a v a2s . c o m * @param typePattern * @param associationTypes * @param totalSize * @param expired return also expired topics ? * @return Topic array of associated topics filter by the given patterns * @throws Exception */ private Topic[] getAssociatedTopics(Topic baseTopic, String[] typePattern, Map associationTypes, int[] totalSize, boolean expired) throws Exception { List resultList = new ArrayList(); final TopicMapFragment mapFragment = this.fServiceClient.getPSI(baseTopic.getId(), 1, null); final Topic[] topics = mapFragment.getTopicMap().getTopic(); if (null != mapFragment.getListExcerpt()) { if (null != mapFragment.getListExcerpt().getTotalSize()) { totalSize[0] = mapFragment.getListExcerpt().getTotalSize().intValue(); } } final Association[] associations = mapFragment.getTopicMap().getAssociation(); // iterate through associations to find the correct association types if (associations != null) { for (int i = 0; i < associations.length; i++) { final Association association = associations[i]; // association type final String assocType = association.getInstanceOf().getTopicRef().getHref(); if (containsTypes(typePattern, assocType)) { // association members are the basetopic and it association final Member[] members = association.getMember(); for (int j = 0; j < members.length; j++) { final Member member = members[j]; // here is only the topic id available final String topicId = member.getTopicRef()[0].getHref(); final String assocMember = member.getRoleSpec().getTopicRef().getHref(); if (!topicId.equals(baseTopic.getId())) { final Topic topicById = getTopicById(topics, topicId); if (topicById != null) { if (!expired) { Date expiredDate = getExpiredDate(topicById); if ((null != expiredDate) && expiredDate.before(new Date())) { continue; } } if (null != associationTypes) { associationTypes.put(topicById.getId(), assocMember); } resultList.add(topicById); } } } } } return (Topic[]) resultList.toArray(new Topic[resultList.size()]); } return null; }
From source file:mitm.common.security.crl.PKIXRevocationChecker.java
private RevocationDetail getRevocationDetail(List<X509CRL> crls, X509Certificate targetCertificate, X509Certificate issuerCertificate, PublicKey issuerPublicKey, Date now) throws NoSuchProviderException { RevocationDetailImpl detail = new RevocationDetailImpl(RevocationStatus.UNKNOWN); boolean validCRLFound = false; int reasonMask = 0; for (X509CRL crl : crls) { BigInteger serialNumber = targetCertificate.getSerialNumber(); X509CRLEntry crlEntry = crl.getRevokedCertificate(serialNumber); Date revocationDate = null; if (crlEntry != null) { revocationDate = crlEntry.getRevocationDate(); if (revocationDate == null || !now.before(revocationDate)) { /*//from www. j a v a 2 s. co m * X.509 7.3 NOTE 4 When an implementation processing a certificate revocation list does not * recognize a critical extension in the crlEntryExtensions field, it shall assume that, * at a minimum, the identified certificate has been revoked and is no longer valid and * perform additional actions concerning that revoked certificate as dictated by local policy. * * We do not need to check for unsupported critical extension because if we do not support them * we should assume that the certificate is revoked. */ // TODO: add support for onHold/removeFromCRL Integer reasonCode = null; try { reasonCode = X509CRLEntryInspector.getReasonCode(crlEntry); } catch (IOException e) { logger.error("Error retrieving reasonCode.", e); } detail = (reasonCode != null ? new RevocationDetailImpl(RevocationStatus.REVOKED, reasonCode) : new RevocationDetailImpl(RevocationStatus.REVOKED)); /* there is no need to continue because certificate is revoked */ break; } else { if (now.before(revocationDate)) { logger.info("Certificate is revoked in the future."); } } } if (hasUnsupportedCriticalExtensions(crl)) { logger.debug("The CRL has unsupported critical extensions."); detail = new RevocationDetailImpl(RevocationStatus.UNSUPPORTED_CRITICAL_EXTENSION); continue; } /* * check that the start time the CRL is valid is before the time the certificate is * no longer valid. In other words, that the expiration date of the certificate is * later than the date the CRL was issued. It is possible that the certificate was * at some point revoked but the CA removed it because the certificate is no longer * valid */ if (crl.getThisUpdate() != null && targetCertificate.getNotAfter().before(crl.getThisUpdate())) { logger.info("Certificate has expired before the CRL was valid."); continue; } try { if (X509CRLInspector.isDeltaCRL(crl)) { DeltaCRLStatus deltaStatus = getDeltaCRLStatus(targetCertificate, crl, issuerPublicKey, now); if (deltaStatus == DeltaCRLStatus.UNSUPPORTED_CRITICAL_EXTENSION) { detail = new RevocationDetailImpl(RevocationStatus.UNSUPPORTED_CRITICAL_EXTENSION); continue; } else if (deltaStatus == DeltaCRLStatus.UNKNOWN) { continue; } } else { if (!acceptCRL_6_3_3_b(targetCertificate, crl)) { logger.debug("CRL not valid according to acceptCRL_6_3_3_b."); continue; } } } catch (IOException e) { logger.error("Error inspecting CRL.", e); continue; } if (crl.getNextUpdate() != null && now.after(crl.getNextUpdate())) { /* * an CRL cannot really expire but, when we want at least to log that the * nextUpdate is overdue */ logger.debug("The CRL next update is overdue."); /* we need to set the nextUpdate if this is a newer CRL */ if (detail.getStatus() != RevocationStatus.EXPIRED || detail.getNextUpdate() == null) { detail = new RevocationDetailImpl(RevocationStatus.EXPIRED, crl.getNextUpdate()); } else { if (crl.getNextUpdate().after(detail.getNextUpdate())) { /* the nextUpdate of the current CRL is later so it's longer valid */ detail = new RevocationDetailImpl(RevocationStatus.EXPIRED, crl.getNextUpdate()); } } continue; } try { reasonMask = reasonMask | getInterimReasonsMask(targetCertificate, crl); /* a valid crl was found. Continue search. */ validCRLFound = true; } catch (IOException e) { logger.error("Error getting interim mask.", e); } } /* * if one the CRLs was good and the certificate was not revoked we will set the * status to NOT_REVOKED */ if (validCRLFound && detail.getStatus() != RevocationStatus.REVOKED) { /* check if all reasons are covered */ if (reasonMask == allReasons) { detail = new RevocationDetailImpl(RevocationStatus.NOT_REVOKED); } else { logger.debug("Not all reasons were covered."); detail = new RevocationDetailImpl(RevocationStatus.UNKNOWN); } } return detail; }
From source file:com.mimp.controllers.familia.java
@RequestMapping("/Festado") public ModelAndView Festado(ModelMap map, HttpSession session) { Familia usuario = (Familia) session.getAttribute("usuario"); if (usuario == null) { String mensaje = "La sesin ha finalizado. Favor identificarse nuevamente"; map.addAttribute("mensaje", mensaje); return new ModelAndView("login", map); } else {/*from w ww . ja va 2 s. c o m*/ String si = "SI"; String no = "NO"; //Inicialmente seteamos todos los valores en no map.addAttribute("sesion", no); map.addAttribute("taller", no); map.addAttribute("ficha", no); map.addAttribute("boton", 0); map.addAttribute("eval", no); map.addAttribute("espera", no); map.addAttribute("adop", no); map.addAttribute("postadop", no); Date fechaactual = new Date(); Date ultfecha = new Date(10, 0, 01); for (Iterator iter = usuario.getFormularioSesions().iterator(); iter.hasNext();) { FormularioSesion form = (FormularioSesion) iter.next(); if (ultfecha.before(form.getFechaSol())) { ultfecha = form.getFechaSol(); } } if ((ultfecha.getYear() < fechaactual.getYear()) && (usuario.getConstancia() == null)) { map.addAttribute("sesion", no); map.addAttribute("taller", no); map.addAttribute("ficha", no); map.addAttribute("boton", 0); map.addAttribute("eval", no); map.addAttribute("espera", no); map.addAttribute("adop", no); map.addAttribute("postadop", no); } else { map.addAttribute("sesion", si); if (usuario.getConstancia() == null) { map.addAttribute("taller", no); map.addAttribute("ficha", no); map.addAttribute("boton", 0); map.addAttribute("eval", no); map.addAttribute("espera", no); map.addAttribute("adop", no); map.addAttribute("postadop", no); } else { map.addAttribute("taller", si); map.addAttribute("ficha", si); map.addAttribute("boton", 0); map.addAttribute("eval", si); for (Iterator iter3 = usuario.getExpedienteFamilias().iterator(); iter3.hasNext();) { ExpedienteFamilia exp = (ExpedienteFamilia) iter3.next(); Boolean flag = false; ArrayList<Evaluacion> listaEval = ServicioFamilia .getEvaluaciones(exp.getIdexpedienteFamilia()); for (Evaluacion eval : listaEval) { if (eval.getTipo().equals("legal") && eval.getResultado().equals("favorable")) { flag = true; } } if (exp.getEstado().equals("Apto") || flag) { map.addAttribute("espera", si); ArrayList<Designacion> listaDeg = ServicioFamilia .getDesignaciones(exp.getIdexpedienteFamilia()); if (!listaDeg.isEmpty()) { for (Designacion deg : listaDeg) { if (deg.getAceptacionConsejo() == 1) { map.addAttribute("adop", no); map.addAttribute("postadop", no); } else { map.addAttribute("adop", si); Boolean flag2 = false; for (Evaluacion eval : listaEval) { ArrayList<Resolucion> listaRes = ServicioFamilia .getResoluciones(eval.getIdevaluacion()); for (Resolucion resol : listaRes) { if (resol.getTipo().equals("Adopcin")) { flag2 = true; } } } if (flag2) { map.addAttribute("postadop", si); } else { map.addAttribute("postadop", no); } } } } else { map.addAttribute("adop", no); map.addAttribute("postadop", no); } } else { map.addAttribute("espera", no); map.addAttribute("adop", no); map.addAttribute("postadop", no); } } } } } String pagina = "/Familia/estado_proc"; return new ModelAndView(pagina, map); }
From source file:com.globalsight.everest.util.ajax.AjaxService.java
public void validateTime() { String time = request.getParameter("time"); String[] ts = time.split("\\|"); TimeZone timezone = (TimeZone) request.getSession().getAttribute(WebAppConstants.USER_TIME_ZONE); SimpleDateFormat f = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); f.setTimeZone(timezone);/*from w w w . j a va 2 s.co m*/ Date d; Date n = new Date(); try { String r = "true"; for (String t : ts) { if (t.trim().length() == 0) continue; d = f.parse(t); if (d.before(n)) { r = "false"; break; } } writer.write(r); } catch (ParseException e) { // e.printStackTrace(); writer.write("false"); } }
From source file:org.opentravel.schemacompiler.repository.impl.RemoteRepositoryClient.java
/** * Returns true if the copy of the item in the remote repository has been updated * since the local copy was last downloaded. * //from w w w. j a va 2 s . c o m * @param item the repository item to check for staleness * @return boolean * @throws RepositoryException thrown if the remote web service is not available */ @SuppressWarnings("unchecked") private boolean isLocalContentStale(RepositoryItem item) throws RepositoryException { try { HttpPost metadataRequest = newPostRequest(REPOSITORY_ITEM_METADATA_ENDPOINT); RepositoryItemIdentityType itemIdentity = new RepositoryItemIdentityType(); Marshaller marshaller = RepositoryFileManager.getSharedJaxbContext().createMarshaller(); StringWriter xmlWriter = new StringWriter(); itemIdentity.setBaseNamespace(item.getBaseNamespace()); itemIdentity.setFilename(item.getFilename()); itemIdentity.setVersion(item.getVersion()); marshaller.marshal(objectFactory.createRepositoryItemIdentity(itemIdentity), xmlWriter); metadataRequest.setEntity(new StringEntity(xmlWriter.toString(), ContentType.TEXT_XML)); // Send the request for meta-data to the remote web service HttpResponse metadataResponse = executeWithAuthentication(metadataRequest); if (metadataResponse.getStatusLine().getStatusCode() != HTTP_RESPONSE_STATUS_OK) { throw new RepositoryException(getResponseErrorMessage(metadataResponse)); } Unmarshaller unmarshaller = RepositoryFileManager.getSharedJaxbContext().createUnmarshaller(); JAXBElement<LibraryInfoType> jaxbElement = (JAXBElement<LibraryInfoType>) unmarshaller .unmarshal(metadataResponse.getEntity().getContent()); LibraryInfoType remoteMetadata = jaxbElement.getValue(); // Get the local meta-data for the item and compare the last-updated timestamps LibraryInfoType localMetadata = manager.getFileManager().loadLibraryMetadata(item.getBaseNamespace(), item.getFilename(), item.getVersion()); Date localLastUpdated = XMLGregorianCalendarConverter.toJavaDate(localMetadata.getLastUpdated()); Date remoteLastUpdated = XMLGregorianCalendarConverter.toJavaDate(remoteMetadata.getLastUpdated()); return localLastUpdated.before(remoteLastUpdated); } catch (IOException e) { throw new RepositoryUnavailableException("The remote repository is unavailable.", e); } catch (JAXBException e) { throw new RepositoryException("The format of the library meta-data is unreadable.", e); } }
From source file:ch.puzzle.itc.mobiliar.business.deploy.boundary.DeploymentService.java
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public Integer createDeploymentReturnTrackingId(Integer appServerGroupId, Integer releaseId, Date deploymentDate, Date stateToDeploy, List<Integer> contextIds, List<ApplicationWithVersion> applicationWithVersion, List<DeploymentParameter> deployParams, boolean sendEmail, boolean requestOnly, boolean doSimulate, boolean isExecuteShakedownTest, boolean isNeighbourhoodTest) { Integer trackingId = sequencesService.getNextValueAndUpdate(DeploymentEntity.SEQ_NAME); Date now = new Date(); if (deploymentDate == null || deploymentDate.before(now)) { deploymentDate = now;/*from w w w. j a va 2 s . c o m*/ } createDeploymentForAppserver(appServerGroupId, releaseId, deploymentDate, stateToDeploy, contextIds, applicationWithVersion, deployParams, sendEmail, requestOnly, doSimulate, isExecuteShakedownTest, isNeighbourhoodTest, trackingId); if (deploymentDate == now && !requestOnly) { deploymentEvent.fire(new DeploymentEvent(DeploymentEventType.NEW, DeploymentState.scheduled)); } return trackingId; }
From source file:ch.puzzle.itc.mobiliar.business.deploy.boundary.DeploymentBoundary.java
/** * Setze DeploymentTime auf dem Entity auf der Datenbank auf den deployment * Zeitpunkt des gelieferten (Detachten) Deployment Parameters falls das * Deployment nicht bereits ausgefhrt oder gestartet wurde. *//*w w w.j ava2 s . co m*/ public DeploymentEntity changeDeploymentDate(Integer deploymentId, Date newDate) throws DeploymentStateException { DeploymentEntity deployment = getDeploymentById(deploymentId); Date now = new Date(); checkValidation(isChangeDeploymentDatePossible(deployment), deployment); if (newDate == null || newDate.before(now)) { newDate = now; } deployment.setDeploymentDate(newDate); deployment = saveDeployment(deployment); return deployment; }
From source file:de.tuttas.servlets.DokuServlet.java
private MyTableDataModel getModelAnwesenheit(Klasse kl, Date parsedFrom, Date parsedTo, int filter1Id, int filter2Id) { TypedQuery<AnwesenheitEintrag> query = em.createNamedQuery("findAnwesenheitbyKlasse", AnwesenheitEintrag.class); query.setParameter("paramKName", kl.getKNAME()); query.setParameter("paramFromDate", new java.sql.Date(parsedFrom.getTime())); query.setParameter("paramToDate", new java.sql.Date(parsedTo.getTime())); Log.d("setze From auf " + new java.sql.Date(parsedFrom.getTime())); List<AnwesenheitObjekt> anwesenheit = getData(query); Query q = em.createNamedQuery("findSchuelerEinerBenanntenKlasse"); q.setParameter("paramNameKlasse", kl.getKNAME()); List<Schueler> schueler = q.getResultList(); /**// w w w. ja v a 2 s . c o m * Termindaten holen */ Termine t1 = null; Termine t2 = null; if (filter1Id != -1) { t1 = em.find(Termine.class, filter1Id); } if (filter2Id != -1) { t2 = em.find(Termine.class, filter2Id); } List<Termin> termine = null; TypedQuery<Termin> tquery = null; if (filter1Id != 0) { // zwei Filter if (filter2Id != 0) { tquery = em.createNamedQuery("findAllTermineTwoFilters", Termin.class); tquery.setParameter("filter1", t1.getId()); tquery.setParameter("filter2", t2.getId()); tquery.setParameter("fromDate", new java.sql.Date(parsedFrom.getTime())); tquery.setParameter("toDate", new java.sql.Date(parsedTo.getTime())); termine = tquery.getResultList(); } // nur Filter1 else { tquery = em.createNamedQuery("findAllTermineOneFilter", Termin.class); tquery.setParameter("filter1", t1.getId()); tquery.setParameter("fromDate", new java.sql.Date(parsedFrom.getTime())); tquery.setParameter("toDate", new java.sql.Date(parsedTo.getTime())); termine = tquery.getResultList(); } } else { // nur Filter2 if (filter2Id != 0) { tquery = em.createNamedQuery("findAllTermineOneFilter", Termin.class); tquery.setParameter("filter1", t2.getId()); tquery.setParameter("fromDate", new java.sql.Date(parsedFrom.getTime())); tquery.setParameter("toDate", new java.sql.Date(parsedTo.getTime())); termine = tquery.getResultList(); } // kein Filter, Termine so generieren else { termine = new ArrayList<>(); Date current = new Date(parsedFrom.getTime()); parsedTo.setTime(parsedTo.getTime() + 1000); while (current.before(parsedTo)) { termine.add(new Termin(new Timestamp(current.getTime()))); Log.d("Erzeuge neuen Termin:" + new Termin(new Timestamp(current.getTime()))); current.setTime(current.getTime() + 24 * 60 * 60 * 1000); } } } Log.d("Result List:" + anwesenheit); List<String> sb = new ArrayList<>(); GregorianCalendar c = (GregorianCalendar) GregorianCalendar.getInstance(); for (Termin t : termine) { c.setTime(new Date(t.getDate().getTime())); sb.add("" + DatumUtil.getWochentag(c.get(GregorianCalendar.DAY_OF_WEEK)) + ":" + c.get(GregorianCalendar.DATE) + "." + (c.get(GregorianCalendar.MONTH) + 1) + "." + c.get(GregorianCalendar.YEAR)); } Log.d("Es werden " + sb.size() + " Tage dargestellt"); sb.add(0, "Name"); String[] cols = new String[sb.size()]; for (int i = 0; i < cols.length; i++) { cols[i] = sb.get(i); } MyTableDataModel mo = new MyTableDataModel(schueler.size(), cols); Schueler s; for (int y = 0; y < schueler.size(); y++) { s = schueler.get(y); mo.setData(0, y, s.getVNAME() + " " + s.getNNAME()); int x = 1; for (Termin t : termine) { mo.setData(x, y, findVermerk(s.getId(), t.getDate(), anwesenheit)); x++; } } return mo; }
From source file:com.streamreduce.core.service.InventoryServiceImpl.java
private void pullFeedActivity(Connection connection) throws ConnectionNotFoundException, InvalidCredentialsException, IOException { Date lastActivityPoll = connection.getLastActivityPollDate(); Date lastActivity = lastActivityPoll; if (lastActivityPoll != null) { logger.debug("Creating feed messages for messages newer than (" + lastActivityPoll + ") for [" + connection.getId() + "]: " + connection.getAlias()); } else {// w w w . j a v a2 s . c om logger.debug("Creating feed messages for all messages [" + connection.getId() + "]: " + connection.getAlias()); } try (XmlReader xmlReader = new XmlReader(URI.create(connection.getUrl()).toURL())) { SyndFeed rssFeed = new SyndFeedInput().build(xmlReader); List feedEntries = rssFeed.getEntries(); Collections.sort(feedEntries, new Comparator<Object>() { @Override public int compare(Object first, Object second) { SyndEntry firstEntry = (SyndEntry) first; SyndEntry secondEntry = (SyndEntry) second; Date firstDate = firstEntry.getPublishedDate() != null ? firstEntry.getPublishedDate() : new Date(); Date secondDate = secondEntry.getPublishedDate() != null ? secondEntry.getPublishedDate() : new Date(); return firstDate.compareTo(secondDate); } }); for (Object rawEntry : feedEntries) { SyndEntry entry = (SyndEntry) rawEntry; //use published date if it exists... otherwise don't process the message as it is an update //this skips feed messages from feeds that don't include a publishedDate Date pubDate = entry.getPublishedDate(); if (pubDate == null || pubDate.before(lastActivityPoll)) { continue; } lastActivity = pubDate.after(lastActivity) ? pubDate : lastActivity; Map<String, Object> eventContext = new HashMap<>(); String messageBodyAsJson = determineMessageBodyAsJsonFromSyndEntry(entry); eventContext.put("activityPubDate", pubDate); eventContext.put("activityTitle", entry.getTitle()); eventContext.put("payload", messageBodyAsJson); Event event = eventService.createEvent(EventId.ACTIVITY, connection, eventContext); FeedEntryDetails details = new FeedEntryDetails.Builder().url(entry.getUri()) .title(entry.getTitle()) .description(entry.getDescription() != null ? entry.getDescription().getValue() : null) .publishedDate(pubDate).build(); // Create a new message to be delivered to inboxes messageService.sendActivityMessage(event, connection, pubDate.getTime(), details); } } catch (IOException e) { logger.error(String.format("Error opening the connection %s for feed %s. Returned error: %s", connection.getId(), connection.getUrl(), e.getMessage())); } catch (Exception e) { logger.error( String.format("Unable to process messages for connection %s with feed %s. Returned error: %s", connection.getId(), connection.getUrl(), e.getMessage())); } finally { // Update the connection's last polling timeconnection.setLastActivityPollDate(new Date(lastActivity.getTime() + 1)); try { connectionService.updateConnection(connection, true); } catch (Exception e) { // This is a silent update to only update the last polling time so this should never throw an exception } } }