03-27-2015 02:09 PM
2015-03-27 07:31:08,717 DEBUG [content.cleanup.TrashcanCleaner] [DefaultScheduler_Worker-4] Trashcan cleaner query :
2015-03-27 07:31:09,139 DEBUG [content.cleanup.TrashcanCleaner] [DefaultScheduler_Worker-4] @\{http\://www.alfresco.org/model/system/1.0\}archivedDate:[1970-01-01T00:00:00.000Z TO 2015-03-26T06:31:08.717Z]
2015-03-27 07:31:15,662 INFO [content.cleanup.TrashcanCleaner] [DefaultScheduler_Worker-4] Trashcan Cleaner is about to purge the following items :
2015-03-27 07:31:15,662 INFO [content.cleanup.TrashcanCleaner] [DefaultScheduler_Worker-4] - file1
2015-03-27 07:31:15,662 INFO [content.cleanup.TrashcanCleaner] [DefaultScheduler_Worker-4] - file2
2015-03-27 07:31:15,662 INFO [content.cleanup.TrashcanCleaner] [DefaultScheduler_Worker-4] - file3
public void execute()
{
if (this.protectedDays > 0)
{
Date fromDate = new Date(0L);
Date toDate = new Date(new Date().getTime() - 86400000L * Long.valueOf(this.protectedDays).longValue());
if (toDate == null)
{
throw new RuntimeException("Error while building the query.");
}
String strFromDate = ISO8601DateFormat.format(fromDate);
String strToDate = ISO8601DateFormat.format(toDate);
StringBuilder buf = new StringBuilder(128);
buf.append("@").append(Repository.escapeQName(ContentModel.PROP_ARCHIVED_DATE))
.append(":").append("[").append(strFromDate)
.append(" TO ").append(strToDate).append("] ");
String query = buf.toString();
SearchParameters sp = new SearchParameters();
sp.setLanguage("lucene");
sp.setQuery(query);
NodeRef archiveRootRef = this.nodeArchiveService.getStoreArchiveNode(Repository.getStoreRef());
sp.addStore(archiveRootRef.getStoreRef());
if (logger.isDebugEnabled())
{
logger.debug("Trashcan cleaner query : ");
logger.debug(query);
}
UserTransaction tx = null;
ResultSet results = null;
try
{
tx = this.transactionService.getNonPropagatingUserTransaction(false);
tx.begin();
results = this.searchService.query(sp);
List<NodeRef> deletedItemsToPurge = results.getNodeRefs();
if (logger.isInfoEnabled())
{
logger.info("Trashcan Cleaner is about to purge the following items :");
for (NodeRef item : deletedItemsToPurge)
{
String itemName = (String)this.nodeService.getProperty(item, ContentModel.PROP_NAME);
logger.info(" - " + itemName);
}
}
this.nodeArchiveService.purgeArchivedNodes(deletedItemsToPurge);
tx.commit();
}
catch (Throwable err)
{
if (logger.isWarnEnabled())
logger.warn("Error while cleaning the trashcan : " + err.getMessage());
try
{
if (tx != null)
{
tx.rollback();
}
}
catch (Exception tex)
{
if (logger.isWarnEnabled())
logger.warn("Error while during the rollback : " + tex.getMessage());
}
}
finally
{
if (results != null)
{
results.close();
}
}
}
}
ISO8601DateFormat.format(new Date())
is returing a timestamp one hour before the actual invoking time of this method.03-28-2015 03:03 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.