List of usage examples for java.time LocalDateTime now
public static LocalDateTime now()
From source file:br.ufac.sion.service.InscricaoService.java
public void confirmaInscricao(Inscricao inscricao) throws NegocioException { if (StringUtils.isNotBlank(inscricao.getJustificativaStatus())) { inscricao.setStatus(SituacaoInscricao.CONFIRMADA); inscricao.setDataJustificativaStatus(LocalDateTime.now()); em.merge(inscricao);/*from w w w .j a va 2 s . c om*/ } else { throw new NegocioException("A justificativa obrigatria"); } }
From source file:de.alpharogroup.user.service.UserTokensBusinessService.java
/** * New user tokens./*from ww w . j av a 2 s. co m*/ * * @param username * the username * @return the user tokens */ private UserTokens newUserTokens(String username) { UserTokens userTokens; // expires in one year Date expiry = Date.from(LocalDateTime.now().plusMonths(12).atZone(ZoneId.systemDefault()).toInstant()); // create a token String token = RandomExtensions.randomToken(); userTokens = UserTokens.builder().expiry(expiry).username(username).token(token).build(); return userTokens; }
From source file:org.graylog.plugins.backup.strategy.FsBackupStrategy.java
@Override protected void pack() throws Exception { LocalDateTime now = LocalDateTime.now(); String dateFormat = now.format(formatter); String srcFolder = backupStruct.getTargetPath() + File.separator + GRAYLOG_SCHEMA_NAME; String dstFolder = backupStruct.getTargetPath() + File.separator + GRAYLOG_SCHEMA_NAME + dateFormat + ".zip"; ZipUtil.pack(new File(srcFolder), new File(dstFolder)); LOG.info("Graylog config backup completed"); FileUtils.deleteDirectory(new File(srcFolder)); }
From source file:org.jbb.security.impl.lockout.DefaultMemberLockoutService.java
@Override @Transactional/*from ww w . ja v a2 s . c o m*/ public void releaseMemberLock(Long memberId) { Validate.notNull(memberId, MEMBER_VALIDATION_MESSAGE); log.debug("Clean all data from repositories {} and {} for member {}", MemberLockRepository.class.getName(), FailedSignInAttemptRepository.class.getName(), memberId); Optional<MemberLockEntity> userLockEntity = lockRepository.findByMemberIdAndActiveTrue(memberId); userLockEntity.ifPresent(entity -> { entity.setActive(false); entity.setDeactivationDate(LocalDateTime.now()); lockRepository.saveAndFlush(entity); log.debug("Account lock for member with ID {} is removed", memberId); eventBus.post(new MemberUnlockedEvent(memberId)); }); }
From source file:org.nuxeo.ecm.blob.azure.AzureBinaryManager.java
@Override protected URI getRemoteUri(String digest, ManagedBlob blob, HttpServletRequest servletRequest) throws IOException { try {//from w ww .j a v a2s . c o m CloudBlockBlob blockBlobReference = container.getBlockBlobReference(digest); SharedAccessBlobPolicy policy = new SharedAccessBlobPolicy(); policy.setPermissionsFromString("r"); Instant endDateTime = LocalDateTime.now().plusSeconds(directDownloadExpire) .atZone(ZoneId.systemDefault()).toInstant(); policy.setSharedAccessExpiryTime(Date.from(endDateTime)); SharedAccessBlobHeaders headers = new SharedAccessBlobHeaders(); headers.setContentDisposition(getContentDispositionHeader(blob, servletRequest)); headers.setContentType(getContentTypeHeader(blob)); String sas = blockBlobReference.generateSharedAccessSignature(policy, headers, null); CloudBlockBlob signedBlob = new CloudBlockBlob(blockBlobReference.getUri(), new StorageCredentialsSharedAccessSignature(sas)); return signedBlob.getQualifiedUri(); } catch (URISyntaxException | InvalidKeyException | StorageException e) { throw new IOException(e); } }
From source file:org.thingsboard.server.dao.audit.sink.ElasticsearchAuditLogSink.java
private String createElasticJsonRecord(AuditLog auditLog) { ObjectNode auditLogNode = mapper.createObjectNode(); auditLogNode.put("postDate", LocalDateTime.now().toString()); auditLogNode.put("id", auditLog.getId().getId().toString()); auditLogNode.put("entityName", auditLog.getEntityName()); auditLogNode.put("tenantId", auditLog.getTenantId().getId().toString()); if (auditLog.getCustomerId() != null) { auditLogNode.put("customerId", auditLog.getCustomerId().getId().toString()); }//from w ww .j a v a 2 s . c o m auditLogNode.put("entityId", auditLog.getEntityId().getId().toString()); auditLogNode.put("entityType", auditLog.getEntityId().getEntityType().name()); auditLogNode.put("userId", auditLog.getUserId().getId().toString()); auditLogNode.put("userName", auditLog.getUserName()); auditLogNode.put("actionType", auditLog.getActionType().name()); if (auditLog.getActionData() != null) { auditLogNode.put("actionData", auditLog.getActionData().toString()); } auditLogNode.put("actionStatus", auditLog.getActionStatus().name()); auditLogNode.put("actionFailureDetails", auditLog.getActionFailureDetails()); return auditLogNode.toString(); }
From source file:org.lecture.service.CompilerServiceImpl.java
private CompilationReport createCompilationReport(CompilationResult result) { CompilationReport compilationReport = new CompilationReport(); compilationReport.setDate(LocalDateTime.now()); if (result.hasErrors()) compilationReport.setErrors(// w ww.j a v a 2 s.c om result.getErrors().stream().map(CompilationDiagnostic::new).collect(Collectors.toList())); if (result.hasWarnings()) compilationReport.setWarnings( result.getWarnings().stream().map(CompilationDiagnostic::new).collect(Collectors.toList())); return compilationReport; }
From source file:org.wallride.service.CommentService.java
public List<Comment> bulkApproveComment(CommentBulkApproveRequest request, AuthorizedUser authorizedUser) { if (!authorizedUser.getRoles().contains(User.Role.ADMIN)) { throw new ServiceException(); }//ww w . java 2s .c o m List<Comment> comments = new ArrayList<>(); for (long id : request.getIds()) { Comment comment = commentRepository.findOneForUpdateById(id); if (comment.isApproved()) { continue; } LocalDateTime now = LocalDateTime.now(); comment.setApproved(true); comment.setUpdatedAt(now); comment.setUpdatedBy(authorizedUser.toString()); comment = commentRepository.saveAndFlush(comment); comments.add(comment); } return comments; }
From source file:org.apache.geode.management.internal.cli.commands.ExportLogsDUnitTest.java
@Test public void startAndEndDateCanIncludeLogs() throws Exception { ZonedDateTime now = LocalDateTime.now().atZone(ZoneId.systemDefault()); ZonedDateTime yesterday = now.minusDays(1); ZonedDateTime tomorrow = now.plusDays(1); DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(ONLY_DATE_FORMAT); CommandStringBuilder commandStringBuilder = new CommandStringBuilder("export logs"); commandStringBuilder.addOption("start-time", dateTimeFormatter.format(yesterday)); commandStringBuilder.addOption("end-time", dateTimeFormatter.format(tomorrow)); commandStringBuilder.addOption("log-level", "debug"); gfshConnector.executeAndVerifyCommand(commandStringBuilder.toString()); Set<String> acceptedLogLevels = Stream.of("info", "error", "debug").collect(toSet()); verifyZipFileContents(acceptedLogLevels); }
From source file:org.ow2.proactive.workflow_catalog.rest.service.WorkflowRevisionServiceTest.java
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); workflowRevisionService = Mockito.spy(workflowRevisionService); Mockito.doReturn(new Link("test")).when(workflowRevisionService).createLink(Matchers.any(Long.class), Matchers.any(Long.class), Matchers.any(WorkflowRevision.class)); Long revCnt = EXISTING_ID;// w w w . j av a 2 s . co m mockedBucket = newMockedBucket(EXISTING_ID); revisions = new TreeSet<>(); revisions.add(newWorkflowRevision(mockedBucket.getId(), revCnt++, LocalDateTime.now().minusHours(1))); revisions.add(newWorkflowRevision(mockedBucket.getId(), revCnt, LocalDateTime.now())); workflow2Rev = newMockedWorkflow(EXISTING_ID, mockedBucket, revisions, 2L); }