List of usage examples for org.apache.commons.lang.time FastDateFormat FULL
int FULL
To view the source code for org.apache.commons.lang.time FastDateFormat FULL.
Click Source Link
From source file:com.manydesigns.portofino.pageactions.activitystream.ActivityItem.java
public ActivityItem(Locale locale, Date timestamp, String imageSrc, String imageHref, String imageAlt, String message, String key) { this.locale = locale; this.timestamp = timestamp; this.imageSrc = imageSrc; this.imageHref = imageHref; this.imageAlt = imageAlt; this.message = message; this.key = key; dateFormat = FastDateFormat.getDateTimeInstance(FastDateFormat.FULL, FastDateFormat.FULL, locale); }
From source file:org.cesecore.audit.impl.queued.QueuedAuditorSessionBean.java
@Override public void delete(AuthenticationToken token, Date timestamp) { // get last signed log before the specified timestamp final AuditLogData lastSigned = AuditLogData.getLastSignedAuditLog(em, timestamp); final boolean delete = lastSigned != null; if (delete) { final Map<String, Object> details = new LinkedHashMap<String, Object>(); details.put("timestamp", FastDateFormat .getTimeInstance(FastDateFormat.FULL, TimeZone.getTimeZone("GMT")).format(timestamp)); securityEventsLogger.log(EventTypes.LOG_DELETE, EventStatus.VOID, ModuleTypes.SECURITY_AUDIT, ServiceTypes.CORE, token.toString(), null, null, null, details); if (log.isDebugEnabled()) { log.debug("deleting exported logs"); }/*from w w w . j av a 2 s . c om*/ // important to set flushmode to commit (commit only occurs on flush or explicit commit) em.setFlushMode(FlushModeType.COMMIT); // delete till the obtained log. AuditLogData.delete(em, QueryCriteria.create() .add(Criteria.lsr(AuditLogEntry.FIELD_SEQUENCENUMBER, lastSigned.getSequenceNumber()))); em.flush(); } }
From source file:org.cesecore.audit.impl.queued.QueuedAuditorSessionBean.java
@Override public AuditLogExportReport exportAuditLogs(final AuthenticationToken token, final CryptoToken cryptoToken, final Date timestamp, final boolean deleteAfterExport, final Map<String, Object> signatureDetails, final Properties properties, final Class<? extends AuditExporter> c) throws AuditLogExporterException { final AuditLogExportReport report = new AuditLogExportReport(); Connection conn = null;/*from w w w. j av a 2s.c o m*/ EventStatus status = EventStatus.SUCCESS; try { conn = ds.getConnection(); final File exportFile = AuditDevicesConfig.getExportFile(properties, timestamp); report.setExportedFile(exportFile.getCanonicalPath()); final SigningFileOutputStream fos = new SigningFileOutputStream(exportFile, cryptoToken, signatureDetails); final AuditLogDbExporter exporter = new AuditLogDbExporter(em, fos, conn); try { // get logs count till the specified timestamp if (log.isDebugEnabled()) { log.debug("exporting logs to file: " + exportFile.getAbsolutePath()); } exporter.export(timestamp, c, AuditDevicesConfig.getAuditLogExportFetchSize(properties)); } finally { try { fos.flush(); } catch (final IOException e) { log.error("Can not flush output stream: ", e); } fos.close(); } // sign the exported file ... it will write the signature on the side fos.writeSignature(); } catch (final Exception e) { log.warn(e.getMessage(), e); status = EventStatus.FAILURE; throw new AuditLogExporterException(e.getMessage(), e); } finally { if (conn != null) { try { conn.close(); } catch (final SQLException e) { throw new AuditLogExporterException(e.getMessage(), e); } } } final Map<String, Object> details = new LinkedHashMap<String, Object>(); details.put("deleted", deleteAfterExport); details.put("timestamp", FastDateFormat.getTimeInstance(FastDateFormat.FULL, TimeZone.getTimeZone("GMT")).format(timestamp)); securityEventsLogger.log(EventTypes.LOG_EXPORT, status, ModuleTypes.SECURITY_AUDIT, ServiceTypes.CORE, token.toString(), null, null, null, details); if (deleteAfterExport) { queuedAuditorSession.delete(token, timestamp); } return report; }
From source file:org.cesecore.audit.impl.queued.QueuedAuditorSessionBean.java
@Override public AuditLogValidationReport verifyLogsIntegrity(final AuthenticationToken token, final Date timestamp, final Properties properties) throws AuditLogValidatorException { Connection conn = null;/* w ww. j a va 2s . c o m*/ try { conn = ds.getConnection(); em.setFlushMode(FlushModeType.COMMIT); final AuditLogValidator validator = new AuditLogDbValidator(em, conn); final AuditLogValidationReport report = validator.validate(timestamp, AuditDevicesConfig.getAuditLogValidationFetchSize(properties)); final Map<String, Object> details = new LinkedHashMap<String, Object>(); details.put("timestamp", FastDateFormat .getTimeInstance(FastDateFormat.FULL, TimeZone.getTimeZone("GMT")).format(timestamp)); // Success or failure depending on if verification returns error or not EventStatus status = EventStatus.SUCCESS; if (report.errors().size() > 0) { status = EventStatus.FAILURE; details.put("errors", report.errors().size()); } securityEventsLogger.log(EventTypes.LOG_VERIFY, status, ModuleTypes.SECURITY_AUDIT, ServiceTypes.CORE, token.toString(), null, null, null, details); return report; } catch (final SQLException e) { throw new AuditLogValidatorException(e.getMessage(), e); } finally { em.flush(); if (conn != null) { try { conn.close(); } catch (final SQLException e) { throw new AuditLogValidatorException(e.getMessage(), e); } } } }
From source file:usingflume.ch05.HeaderAndBodyIndexRequestBuilderFactoryTest.java
@Test public void testPrepareIndexRequest() throws Exception { ElasticSearchIndexRequestBuilderFactory factory = new HeaderAndBodyIndexRequestBuilderFactory(); // There is a small race condition here. // If you start the test before midnight and continue after, // then this might fail because the date has changed. FastDateFormat date = FastDateFormat.getDateInstance(FastDateFormat.FULL); String suffix = date.format(System.currentTimeMillis()); final Client client = NodeBuilder.nodeBuilder().client(true).local(true).node().client(); ctx.put("writeHeaders", "true"); factory.configure(ctx);/*from ww w . j a v a 2 s . com*/ for (int i = 0; i < 10; i++) { final String iStr = String.valueOf(i); final String BODY_STR = TEST_EVENT_PREFIX + iStr; final String IDX_NAME = IDX_PREFIX + iStr; final String IDX_TYPE = IDX_TYPE_PREFIX + iStr; final Map<String, String> headers = Maps.newHashMap(); headers.put(EVENT_ID, iStr); final Event e = EventBuilder.withBody(BODY_STR.getBytes(Charsets.UTF_8), headers); final IndexRequestBuilder request = factory.createIndexRequest(client, IDX_NAME, IDX_TYPE, e); final Map src = request.request().sourceAsMap(); Assert.assertEquals(src.get(EVENT_ID), iStr); Assert.assertEquals(src.get("body"), BODY_STR); Assert.assertTrue(request.request().type().startsWith(IDX_TYPE)); Assert.assertTrue(request.request().index().startsWith(IDX_NAME)); Assert.assertTrue(request.request().index().endsWith(suffix)); } ctx.put("writeHeaders", "false"); factory.configure(ctx); final IndexRequestBuilder request = factory.createIndexRequest(client, IDX_PREFIX, IDX_TYPE_PREFIX, EventBuilder.withBody("test data", Charsets.UTF_8)); byte[] body = request.request().source().array(); Assert.assertEquals("test data", new String(body, Charsets.UTF_8)); Assert.assertTrue(request.request().type().startsWith(IDX_TYPE_PREFIX)); Assert.assertTrue(request.request().index().startsWith(IDX_PREFIX)); Assert.assertTrue(request.request().index().endsWith(suffix)); }