public String generateRSS(Path indexFile) throws CorruptIndexException, IOException { StringBuffer output = new StringBuffer(); output.append(getRSSHeaders()); IndexSearcher searcher = null; try { reader = DirectoryReader.open(FSDirectory.open(indexFile)); searcher = new IndexSearcher(reader); GregorianCalendar gc = new java.util.GregorianCalendar(TimeZone.getDefault(), Locale.getDefault()); gc.setTime(new Date()); String nowDateTime = ISO8601.format(gc); gc.add(java.util.GregorianCalendar.MINUTE, -5); String fiveMinsAgo = ISO8601.format(gc); TermRangeQuery query = new TermRangeQuery( TikaCoreProperties.CREATED.getName(), new BytesRef(fiveMinsAgo), new BytesRef(nowDateTime), true, true); TopScoreDocCollector collector = TopScoreDocCollector.create(20); searcher.search(query, collector); ScoreDoc[] hits = collector.topDocs().scoreDocs; for (int i = 0; i < hits.length; i++) { Document doc = searcher.doc(hits[i].doc); output.append(getRSSItem(doc)); } } finally { if (reader != null) reader.close(); } output.append(getRSSFooters()); return output.toString(); }
/** * @param input Calendar value * @return ISO8601 string representation or null */ public static String calendarToString(Calendar input) { if (input == null) { return null; } return ISO8601.format(input); }
/** * Create a new <code>AbstractQValue</code>. * * @param value * @throws IllegalArgumentException if the passed <code>value</code> * is <code>null</code>. */ protected AbstractQValue(Calendar value) { val = ISO8601.format(value); type = PropertyType.DATE; }
@Override public String toString() { return ISO8601.format(this.value); } }
/** * @param input Calendar value * @return ISO8601 string representation or null */ public static String calendarToString(Calendar input) { if (input == null) { return null; } return ISO8601.format(input); }
private static String formatTime(long time){ Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(time); return ISO8601.format(cal); } }
private static String formatTime(long time){ Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(time); return ISO8601.format(cal); } }
/** * Convert to date. This default implementation delegates to {@link #toCalendar()} * and returns the {@code ISO8601.format(Calendar)} value of the calendar. * @return date representation of the converted value * @throws IllegalArgumentException if the string cannot be parsed into a date */ public String toDate() { return ISO8601.format(toCalendar()); }
/** * {@inheritDoc} */ protected String getInternalString() throws ValueFormatException { if (date != null) { return ISO8601.format(date); } else { throw new ValueFormatException("empty value"); } }
/** * {@inheritDoc} */ protected String getInternalString() throws ValueFormatException { if (date != null) { return ISO8601.format(date); } else { throw new ValueFormatException("empty value"); } }
/** * {@inheritDoc} */ protected String getInternalString() throws ValueFormatException { if (date != null) { return ISO8601.format(date); } else { throw new ValueFormatException("empty value"); } }
@Override public String toString() { return ISO8601.format(this.toCalendar()); } }
private static void setExpirationTime(@NotNull Tree tree, long time) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(time); tree.setProperty(TOKEN_ATTRIBUTE_EXPIRY, ISO8601.format(calendar), DATE); }
/** * Convert to date. This default implementation delegates to {@link #toCalendar()} * and returns the {@code ISO8601.format(Calendar)} value of the calendar. * @return date representation of the converted value * @throws IllegalArgumentException if the string cannot be parsed into a date */ public String toDate() { return ISO8601.format(toCalendar()); }
private static void setExpirationTime(@Nonnull Tree tree, long time) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(time); tree.setProperty(TOKEN_ATTRIBUTE_EXPIRY, ISO8601.format(calendar), DATE); }
@Override public String getString() throws ValueFormatException, IllegalStateException, RepositoryException { if (value == null) { return ""; } switch (type) { case PropertyType.DATE: return ISO8601.format((Calendar) value); } return value.toString(); }
private String getUpdatedTime(Calendar currentTime) { CommitInfo info = getIndexingContext().getCommitInfo(); String checkpointTime = (String) info.getInfo().get(IndexConstants.CHECKPOINT_CREATION_TIME); if (checkpointTime != null) { return checkpointTime; } return ISO8601.format(currentTime); }
public static PropertyState createDateProperty(@NotNull String name) { String now = ISO8601.format(Calendar.getInstance()); return PropertyStates.createProperty(name, now, DATE); }
public void setDate(String name, long time) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(time); tree.setProperty(name, ISO8601.format(calendar), DATE); }
@Test public void dateValueFromDateProperty() throws RepositoryException { String expected = ISO8601.format(Calendar.getInstance()); PropertyState dateProperty = PropertyStates.createProperty( "date", expected, Type.DATE); String actual = dateProperty.getValue(Type.DATE); assertEquals(expected, actual); } }