Skip to content

Instantly share code, notes, and snippets.

@svendahlstrand
Last active May 21, 2016 20:30
Show Gist options
  • Save svendahlstrand/5d2660a5b79a0bdf52d0 to your computer and use it in GitHub Desktop.
Save svendahlstrand/5d2660a5b79a0bdf52d0 to your computer and use it in GitHub Desktop.
Ta bort gamla filer ur SiteVisions filarkiv
/* globals sitevisionUtils, jcrSession, node, java, out*/
(function () {
var settings = {
date: '2010-01-28'
};
var nodeTypeUtil = sitevisionUtils.getNodeTypeUtil();
var file = jcrSession.getNodeByIdentifier(node.toString());
if (nodeTypeUtil.isFile(file)) {
var propertyUtil = sitevisionUtils.getPropertyUtil();
var lastModified = propertyUtil.getCalendar(file, 'lastModifiedDate');
if (lastModified) {
var instanceCreatorUtil = sitevisionUtils.getInstanceCreatorUtil();
var reference = java.util.Calendar.getInstance();
var sdf = instanceCreatorUtil.getDefaultInstance('java.text.SimpleDateFormat');
sdf.applyPattern('yyyy-MM-dd');
reference.setTime(sdf.parse(settings.date));
if (lastModified.before(reference)) {
out.println('Would remove "' + propertyUtil.getString(file, 'displayName') + '" (' + propertyUtil.getString(file, 'lastModifiedDate') + ').');
}
}
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment