Sweeper.java [src/csip] Revision: e3b2437676c97ed1e4ec35623fb8f67820908b1a  Date: Thu Apr 07 10:16:29 MDT 2016
/*
 * $Id$
 * 
 * This file is part of the Cloud Services Integration Platform (CSIP),
 * 2010-2013, Olaf David and others, Colorado State University.
 *
 * CSIP is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, version 2.1.
 *
 * CSIP is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with OMS.  If not, see <http://www.gnu.org/licenses/lgpl.txt>.
 */
package csip;

import csip.utils.Services;
import java.io.File;
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 {
            ModelSession ms = Config.getSessionStore().getSession(suid);
            Config.getAccessLogStore().log(suid, ms.getService(), ms.getReqIP(), Services.LOCAL_IP_ADDR, ms.getTstamp(), "Expired", -1);
        } catch (Exception ex) {
            System.err.println(ex);
        }
        Config.getSessionStore().removeSession(suid);
        if (resultsDir != null && resultsDir.exists()) {
            FileUtils.deleteQuietly(resultsDir);
        }
    }
}