checkInterruption();
final Repository repo = repoRegistry.getRepository(repoId);
final AttributeStorage attributeStorage = repo
.getAttributesHandler().getAttributeStorage();
final File root = RepoHelp.repoRoot(repo);
final CarrotListener listener = new CarrotListenerSupport() {
private int countCleared;
private int countScanned;
private final int reportBatch = 1000;
@Override
public void onBegin() {
log.info("##########################################");
log.info("repo clean init : {}", repoId);
}
@Override
public void onEnd() {
log.info("repo stats : scanned={} cleared={}",
countScanned, countCleared);
log.info("repo clean done : {}", repoId);
log.info("##########################################");
}
@Override
public void onFile(final File file) {
try {
checkInterruption();
countScanned++;
if (countScanned % reportBatch == 0) {
log.info("scanned={}", countScanned);
}
final String path = //
rootFullPath(relativePath(root, file));
final ResourceStoreRequest request = //
new ResourceStoreRequest(path);
request.getRequestContext().put( //
AccessManager.REQUEST_AUTHORIZED, "true");
final StorageItem any = repo.retrieveItem(request);
final boolean isFile = any instanceof StorageFileItem;
if (!isFile) {
return;
}
final StorageFileItem item = (StorageFileItem) any;
final RepositoryItemUid uid = item
.getRepositoryItemUid();
final Attributes attributes = attributeStorage
.getAttributes(uid);
if (attributes.containsKey(ATTR_IS_SAVED)) {
attributes.remove(ATTR_IS_SAVED);
attributes.remove(ATTR_SAVE_TIME);
attributeStorage.putAttributes(uid, attributes);
countCleared++;
}