Sweeper.java [src/csip] Revision: default Date:
/*
* $Id$
*
* This file is part of the Cloud Services Integration Platform (CSIP),
* a Model-as-a-Service framework, API and application suite.
*
* 2012-2022, Olaf David and others, OMSLab, Colorado State University.
*
* OMSLab licenses this file to you under the MIT license.
* See the LICENSE file in the project root for more information.
*/
package csip;
import java.io.File;
import java.util.ArrayList;
import java.util.TimerTask;
import org.apache.commons.io.FileUtils;
/**
*
* @author od
*/
class Sweeper extends TimerTask {
File resultsDir;
String suid;
Sweeper(File resultsDir, String suid) {
this.resultsDir = resultsDir;
this.suid = suid;
}
@Override
public void run() {
try {
// remove all file locks for the workspace
for (File key : new ArrayList<>(Config.wsFileLocks.keySet())) {
if (key.toString().startsWith(resultsDir.toString()))
Config.wsFileLocks.remove(key);
}
Config.getSessionStore().removeSession(suid);
} catch (Exception E) {
Config.LOG.warning("Error removing session: " + suid + " " + E.getMessage());
}
if (resultsDir != null && resultsDir.exists())
FileUtils.deleteQuietly(resultsDir);
Config.getPublisher().publish("Expired", suid);
}
}