@Override
    public void active(Frog f)

package com.github.drinkjava2.frog.brain.organ;

import com.github.drinkjava2.frog.Frog;
import com.github.drinkjava2.frog.brain.Organ;

/**
 * Move down frog 1 unit if outputs of nerve cells active in this zone
 */
public class RFootDrop extends Organ {

    private static final long serialVersionUID = 1L;

{
        if (f.rFootStatus == "DOWN")
            return;
        if (activedByCells(f)) {
            actived = true;
            f.rFootStatus = "DOWN";
        } else
            actived = false;
    }
}


{
        if (f.rFootStatus == "DOWN")
            return;
        if (activedByCells(f)) {
            actived = true;
            f.rFootStatus = "DOWN";
        } else
            actived = false;
    }

package com.github.drinkjava2.frog.brain.organ;

import com.github.drinkjava2.frog.Frog;
import com.github.drinkjava2.frog.brain.Organ;

/**
 * Move down frog 1 unit if outputs of nerve cells active in this zone
 */
public class RFootDrop extends Organ {

    private static final long serialVersionUID = 1L;

    @Override
    public void active(Frog f)


        if (f.rFootStatus == "DOWN")
            return;

package com.github.drinkjava2.frog.brain.organ;

import com.github.drinkjava2.frog.Frog;
import com.github.drinkjava2.frog.brain.Organ;

/**
 * Move down frog 1 unit if outputs of nerve cells active in this zone
 */
public class RFootDrop extends Organ {

    private static final long serialVersionUID = 1L;

    @Override
    public void active(Frog f) {

        if (activedByCells(f)) {
            actived = true;
            f.rFootStatus = "DOWN";
        } else
            actived = false;
    }
}


if (activedByCells(f)) {
            actived = true;
            f.rFootStatus = "DOWN";
        } else
            actived = false;

package com.github.drinkjava2.frog.brain.organ;

import com.github.drinkjava2.frog.Frog;
import com.github.drinkjava2.frog.brain.Organ;

/**
 * Move down frog 1 unit if outputs of nerve cells active in this zone
 */
public class RFootDrop extends Organ {

    private static final long serialVersionUID = 1L;

    @Override
    public void active(Frog f) {
        if (f.rFootStatus == "DOWN")
            return;


package com.github.drinkjava2.frog.brain.organ;

import com.github.drinkjava2.frog.Frog;
import com.github.drinkjava2.frog.brain.Organ;

/**
 * Move down frog 1 unit if outputs of nerve cells active in this zone
 */
public class RFootDrop extends Organ {

    private static final long serialVersionUID = 1L;

    @Override
    public void active(Frog f) {
        if (f.rFootStatus == "DOWN")
            return;
        if (activedByCells(f)) {
            actived = true;
            f.rFootStatus = "DOWN";
        } else
            actived = false;


package com.github.drinkjava2.frog.brain.organ;

import com.github.drinkjava2.frog.Frog;
import com.github.drinkjava2.frog.brain.Organ;

/**
 * Move down frog 1 unit if outputs of nerve cells active in this zon

e
 */
public class RFootDrop extends Organ {

    private static final long serialVersionUID = 1L;

    @Override
    public void active(Frog f) {
        if (f.rFootStatus == "DOWN")
            return;
        if (activedByCells(f)) {
            actived = true;
            f.rFootStatus = "DOWN";
        } else
            actived = false;
    }
}


protected static void doEndNotifications(IJobDescription jobDescription, INotificationConnectionManager notificationManager, INotificationConnectorPool notificationPool) throws ManifoldCFException

package org.apache.manifoldcf.crawler.system;

import org.apache.manifoldcf.core.interfaces.*;
import org.apache.manifoldcf.agents.interfaces.*;
import org.apache.manifoldcf.crawler.interfaces.*;
import org.apache.manifoldcf.crawler.system.Logging;
import java.util.*;
import java.lang.reflect.*;

/**
 * This class represents the thread that notices jobs that have completed their shutdown phase, and puts them in the
 * "notify connector" state.
 */
public class JobResetThread extends Thread {

    public static final String _rcsid = "@(#)$Id: JobResetThread.java 991295 2010-08-31 19:12:14Z kwright $";

    // Local data
    /**
     * Process ID
     */
    protected final String processID;

    public JobResetThread(String processID) throws ManifoldCFException {
        super();
        setName("Job reset thread");
        setDaemon(true);
        this.processID = processID;
    }

    public void run() {
        try {
            // Create a thread context object.
            IThreadContext threadContext = ThreadContextFactory.make();
            IJobManager jobManager = JobManagerFactory.make(threadContext);
            IRepositoryConnectionManager connectionManager = RepositoryConnectionManagerFactory.make(threadContext);
            INotificationConnectionManager notificationManager = NotificationConnectionManagerFactory.make(threadContext);
            INotificationConnectorPool notificationPool = NotificationConnectorPoolFactory.make(threadContext);
            // Loop
            while (true) {
                // Do another try/catch around everything in the loop
                try {
                    // See if there are any completed jobs
                    long currentTime = System.currentTimeMillis();
                    List<IJobDescription> jobStops = new ArrayList<IJobDescription>();
                    List<Integer> jobStopNotifications = new ArrayList<Integer>();
                    jobManager.finishJobStops(currentTime, jobStops, jobStopNotifications);
                    List<IJobDescription> jobResumes = new ArrayList<IJobDescription>();
                    jobManager.finishJobResumes(currentTime, jobResumes);
                    List<IJobDescription> jobCompletions = new ArrayList<IJobDescription>();
                    jobManager.resetJobs(currentTime, jobCompletions);
                    // If there were any job aborts, we must reprioritize all active documents, since we've done something
                    // not predicted by the algorithm that assigned those priorities.  This is, of course, quite expensive,
                    // but it cannot be helped (at least, I cannot find a way to avoid it).
                    if (jobStops.size() > 0) {
                        Logging.threads.debug("Job reset thread reprioritizing documents...");
                        ManifoldCF.resetAllDocumentPriorities(threadContext, processID);
                        Logging.threads.debug("Job reset thread done reprioritizing documents.");
                    }
                    int k = 0;
                    while (k < jobStops.size()) {
                        IJobDescription desc = jobStops.get(k);
                        Integer notificationType = jobStopNotifications.get(k);
                        connectionManager.recordHistory(desc.getConnectionName(), null, connectionManager.ACTIVITY_JOBSTOP, null, desc.getID().toString() + "(" + desc.getDescription() + ")", null, null, null);
                        // As a courtesy, call all the notification connections (if any)
                        doStopNotifications(desc, notificationType, notificationManager, notificationPool);
                        k++;
                    }
                    k = 0;
                    while (k < jobResumes.size()) {
                        IJobDescription desc = jobResumes.get(k++);
                        connectionManager.recordHistory(desc.getConnectionName(), null, connectionManager.ACTIVITY_JOBCONTINUE, null, desc.getID().toString() + "(" + desc.getDescription() + ")", null, null, null);
                    }
                    k = 0;
                    while (k < jobCompletions.size()) {
                        IJobDescription desc = jobCompletions.get(k++);
                        connectionManager.recordHistory(desc.getConnectionName(), null, connectionManager.ACTIVITY_JOBEND, null, desc.getID().toString() + "(" + desc.getDescription() + ")", null, null, null);
                        // As a courtesy, call all the notification connections (if any)
                        doEndNotifications(desc, notificationManager, notificationPool);
                    }
                    ManifoldCF.sleep(10000L);
                } catch (ManifoldCFException e) {
                    if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                        break;
                    if (e.getErrorCode() == ManifoldCFException.DATABASE_CONNECTION_ERROR) {
                        Logging.threads.error("Job reset thread aborting and restarting due to database connection reset: " + e.getMessage(), e);
                        try {
                            // Give the database a chance to catch up/wake up
                            ManifoldCF.sleep(10000L);
                        } catch (InterruptedException se) {
                            break;
                        }
                        continue;
                    }
                    // Log it, but keep the thread alive
                    Logging.threads.error("Exception tossed: " + e.getMessage(), e);
                    if (e.getErrorCode() == ManifoldCFException.SETUP_ERROR) {
                        // Shut the whole system down!
                        ManifoldCF.systemExit(1);
                    }
                } catch (InterruptedException e) {
                    // We're supposed to quit
                    break;
                } catch (OutOfMemoryError e) {
                    System.err.println("agents process ran out of memory - shutting down");
                    e.printStackTrace(System.err);
                    ManifoldCF.systemExit(-200);
                } catch (Throwable e) {
                    // A more severe error - but stay alive
                    Logging.threads.fatal("Error tossed: " + e.getMessage(), e);
                }
            }
        } catch (Throwable e) {
            // Severe error on initialization
            System.err.println("agents process could not start - shutting down");
            Logging.threads.fatal("JobResetThread initialization error tossed: " + e.getMessage(), e);
            ManifoldCF.systemExit(-300);
        }
    }

    protected static void doStopNotifications(IJobDescription jobDescription, int notificationType, INotificationConnectionManager notificationManager, INotificationConnectorPool notificationPool) throws ManifoldCFException {
        for (int j = 0; j < jobDescription.countNotifications(); j++) {
            String notificationConnectionName = jobDescription.getNotificationConnectionName(j);
            try {
                INotificationConnection c = notificationManager.load(notificationConnectionName);
                if (c != null) {
                    INotificationConnector connector = notificationPool.grab(c);
                    if (connector != null) {
                        try {
                            switch(notificationType) {
                                case IJobManager.STOP_ERRORABORT:
                                    connector.notifyOfJobStopErrorAbort(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_MANUALABORT:
                                    connector.notifyOfJobStopManualAbort(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_MANUALPAUSE:
                                    connector.notifyOfJobStopManualPause(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_SCHEDULEPAUSE:
                                    connector.notifyOfJobStopSchedulePause(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_RESTART:
                                    connector.notifyOfJobStopRestart(jobDescription.getNotificationSpecification(j));
                                    break;
                                default:
                                    throw new RuntimeException("Unhandled notification type: " + notificationType);
                            }
                        } finally {
                            notificationPool.release(c, connector);
                        }
                    }
                }
            } catch (ServiceInterruption e) {
                Logging.connectors.warn("Can't notify right now: " + e.getMessage(), e);
            } catch (ManifoldCFException e) {
                if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                    throw e;
                Logging.connectors.warn("Error notifying: " + e.getMessage(), e);
            }
        }
    }

{
        for (int j = 0; j < jobDescription.countNotifications(); j++) {
            String notificationConnectionName = jobDescription.getNotificationConnectionName(j);
            try {
                INotificationConnection c = notificationManager.load(notificationConnectionName);
                if (c != null) {
                    INotificationConnector connector = notificationPool.grab(c);
                    if (connector != null) {
                        try {
                            connector.notifyOfJobEnd(jobDescription.getNotificationSpecification(j));
                        } finally {
                            notificationPool.release(c, connector);
                        }
                    }
                }
            } catch (ServiceInterruption e) {
                Logging.connectors.warn("Can't notify right now: " + e.getMessage(), e);
            } catch (ManifoldCFException e) {
                if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                    throw e;
                Logging.connectors.warn("Error notifying: " + e.getMessage(), e);
            }
        }
    }
}


package org.apache.manifoldcf.crawler.system;

import org.apache.manifoldcf.core.interfaces.*;
import org.apache.manifoldcf.agents.interfaces.*;
import org.apache.manifoldcf.crawler.interfaces.*;
import org.apache.manifoldcf.crawler.system.Logging;
import java.util.*;
import java.lang.reflect.*;

/**
 * This class represents the thread that notices jobs that have completed their shutdown phase, and puts them in the
 * "notify connector" state.
 */
public class JobResetThread extends Thread {

    public static final String _rcsid = "@(#)$Id: JobResetThread.java 991295 2010-08-31 19:12:14Z kwright $";

    // Local data
    /**
     * Process ID
     */
    protected final String processID;

    public JobResetThread(String processID) throws ManifoldCFException {
        super();
        setName("Job reset thread");
        setDaemon(true);
        this.processID = processID;
    }

    public void run() {

        try {
            // Create a thread context object.
            IThreadContext threadContext = ThreadContextFactory.make();
            IJobManager jobManager = JobManagerFactory.make(threadContext);
            IRepositoryConnectionManager connectionManager = RepositoryConnectionManagerFactory.make(threadContext);
            INotificationConnectionManager notificationManager = NotificationConnectionManagerFactory.make(threadContext);
            INotificationConnectorPool notificationPool = NotificationConnectorPoolFactory.make(threadContext);
            // Loop
            while (true) {
                // Do another try/catch around everything in the loop
                try {
                    // See if there are any completed jobs
                    long currentTime = System.currentTimeMillis();
                    List<IJobDescription> jobStops = new ArrayList<IJobDescription>();
                    List<Integer> jobStopNotifications = new ArrayList<Integer>();
                    jobManager.finishJobStops(currentTime, jobStops, jobStopNotifications);
                    List<IJobDescription> jobResumes = new ArrayList<IJobDescription>();
                    jobManager.finishJobResumes(currentTime, jobResumes);
                    List<IJobDescription> jobCompletions = new ArrayList<IJobDescription>();
                    jobManager.resetJobs(currentTime, jobCompletions);
                    // If there were any job aborts, we must reprioritize all active documents, since we've done something
                    // not predicted by the algorithm that assigned those priorities.  This is, of course, quite expensive,
                    // but it cannot be helped (at least, I cannot find a way to avoid it).
                    if (jobStops.size() > 0) {
                        Logging.threads.debug("Job reset thread reprioritizing documents...");
                        ManifoldCF.resetAllDocumentPriorities(threadContext, processID);
                        Logging.threads.debug("Job reset thread done reprioritizing documents.");
                    }
                    int k = 0;
                    while (k < jobStops.size()) {
                        IJobDescription desc = jobStops.get(k);
                        Integer notificationType = jobStopNotifications.get(k);
                        connectionManager.recordHistory(desc.getConnectionName(), null, connectionManager.ACTIVITY_JOBSTOP, null, desc.getID().toString() + "(" + desc.getDescription() + ")", null, null, null);
                        // As a courtesy, call all the notification connections (if any)
                        doStopNotifications(desc, notificationType, notificationManager, notificationPool);
                        k++;
                    }
                    k = 0;
                    while (k < jobResumes.size()) {
                        IJobDescription desc = jobResumes.get(k++);
                        connectionManager.recordHistory(desc.getConnectionName(), null, connectionManager.ACTIVITY_JOBCONTINUE, null, desc.getID().toString() + "(" + desc.getDescription() + ")", null, null, null);
                    }
                    k = 0;
                    while (k < jobCompletions.size()) {
                        IJobDescription desc = jobCompletions.get(k++);
                        connectionManager.recordHistory(desc.getConnectionName(), null, connectionManager.ACTIVITY_JOBEND, null, desc.getID().toString() + "(" + desc.getDescription() + ")", null, null, null);
                        // As a courtesy, call all the notification connections (if any)
                        doEndNotifications(desc, notificationManager, notificationPool);
                    }
                    ManifoldCF.sleep(10000L);
                } catch (ManifoldCFException e) {
                    if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                        break;
                    if (e.getErrorCode() == ManifoldCFException.DATABASE_CONNECTION_ERROR) {
                        Logging.threads.error("Job reset thread aborting and restarting due to database connection reset: " + e.getMessage(), e);
                        try {
                            // Give the database a chance to catch up/wake up
                            ManifoldCF.sleep(10000L);
                        } catch (InterruptedException se) {
                            break;
                        }
                        continue;
                    }
                    // Log it, but keep the thread alive
                    Logging.threads.error("Exception tossed: " + e.getMessage(), e);
                    if (e.getErrorCode() == ManifoldCFException.SETUP_ERROR) {
                        // Shut the whole system down!
                        ManifoldCF.systemExit(1);
                    }
                } catch (InterruptedException e) {
                    // We're supposed to quit
                    break;
                } catch (OutOfMemoryError e) {
                    System.err.println("agents process ran out of memory - shutting down");
                    e.printStackTrace(System.err);
                    ManifoldCF.systemExit(-200);
                } catch (Throwable e) {
                    // A more severe error - but stay alive
                    Logging.threads.fatal("Error tossed: " + e.getMessage(), e);
                }
            }
        } catch (Throwable e) {
            // Severe error on initialization
            System.err.println("agents process could not start - shutting down");
            Logging.threads.fatal("JobResetThread initialization error tossed: " + e.getMessage(), e);
            ManifoldCF.systemExit(-300);
        }
    }

    protected static void doStopNotifications(IJobDescription jobDescription, int notificationType, INotificationConnectionManager notificationManager, INotificationConnectorPool notificationPool) throws ManifoldCFException {
        for (int j = 0; j < jobDescription.countNotifications(); j++) {
            String notificationConnectionName = jobDescription.getNotificationConnectionName(j);
            try {
                INotificationConnection c = notificationManager.load(notificationConnectionName);
                if (c != null) {
                    INotificationConnector connector = notificationPool.grab(c);
                    if (connector != null) {
                        try {
                            switch(notificationType) {
                                case IJobManager.STOP_ERRORABORT:
                                    connector.notifyOfJobStopErrorAbort(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_MANUALABORT:
                                    connector.notifyOfJobStopManualAbort(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_MANUALPAUSE:
                                    connector.notifyOfJobStopManualPause(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_SCHEDULEPAUSE:
                                    connector.notifyOfJobStopSchedulePause(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_RESTART:
                                    connector.notifyOfJobStopRestart(jobDescription.getNotificationSpecification(j));
                                    break;
                                default:
                                    throw new RuntimeException("Unhandled notification type: " + notificationType);
                            }
                        } finally {
                            notificationPool.release(c, connector);
                        }
                    }
                }
            } catch (ServiceInterruption e) {
                Logging.connectors.warn("Can't notify right now: " + e.getMessage(), e);
            } catch (ManifoldCFException e) {
                if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                    throw e;
                Logging.connectors.warn("Error notifying: " + e.getMessage(), e);
            }
        }
    }

    protected static void doEndNotifications(IJobDescription jobDescription, INotificationConnectionManager notificationManager, INotificationConnectorPool notificationPool) throws ManifoldCFException {
        for (int j = 0; j < jobDescription.countNotifications(); j++) {
            String notificationConnectionName = jobDescription.getNotificationConnectionName(j);
            try {
                INotificationConnection c = notificationManager.load(notificationConnectionName);
                if (c != null) {
                    INotificationConnector connector = notificationPool.grab(c);
                    if (connector != null) {
                        try {
                            connector.notifyOfJobEnd(jobDescription.getNotificationSpecification(j));
                        } finally {
                            notificationPool.release(c, connector);
                        }
                    }
                }
            } catch (ServiceInterruption e) {
                Logging.connectors.warn("Can't notify right now: " + e.getMessage(), e);
            } catch (ManifoldCFException e) {
                if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                    throw e;
                Logging.connectors.warn("Error notifying: " + e.getMessage(), e);
            }
        }
    }
}


try {
            // Create a thread context object.
            IThreadContext threadContext = ThreadContextFactory.make();
            IJobManager jobManager = JobManagerFactory.make(threadContext);
            IRepositoryConnectionManager connectionManager = RepositoryConnectionManagerFactory.make(threadContext);
            INotificationConnectionManager notificationManager = NotificationConnectionManagerFactory.make(threadContext);
            INotificationConnectorPool notificationPool = NotificationConnectorPoolFactory.make(threadContext);
            // Loop
            while (true) {
                // Do another try/catch around everything in the loop
                try {
                    // See if there are any completed jobs
                    long currentTime = System.currentTimeMillis();
                    List<IJobDescription> jobStops = new ArrayList<IJobDescription>();
                    List<Integer> jobStopNotifications = new ArrayList<Integer>();
                    jobManager.finishJobStops(currentTime, jobStops, jobStopNotifications);
                    List<IJobDescription> jobResumes = new ArrayList<IJobDescription>();
                    jobManager.finishJobResumes(currentTime, jobResumes);
                    List<IJobDescription> jobCompletions = new ArrayList<IJobDescription>();
                    jobManager.resetJobs(currentTime, jobCompletions);
                    // If there were any job aborts, we must reprioritize all active documents, since we've done something
                    // not predicted by the algorithm that assigned those priorities.  This is, of course, quite expensive,
                    // but it cannot be helped (at least, I cannot find a way to avoid it).
                    if (jobStops.size() > 0) {
                        Logging.threads.debug("Job reset thread reprioritizing documents...");
                        ManifoldCF.resetAllDocumentPriorities(threadContext, processID);
                        Logging.threads.debug("Job reset thread done reprioritizing documents.");
                    }
                    int k = 0;
                    while (k < jobStops.size()) {
                        IJobDescription desc = jobStops.get(k);
                        Integer notificationType = jobStopNotifications.get(k);
                        connectionManager.recordHistory(desc.getConnectionName(), null, connectionManager.ACTIVITY_JOBSTOP, null, desc.getID().toString() + "(" + desc.getDescription() + ")", null, null, null);
                        // As a courtesy, call all the notification connections (if any)
                        doStopNotifications(desc, notificationType, notificationManager, notificationPool);
                        k++;
                    }
                    k = 0;
                    while (k < jobResumes.size()) {
                        IJobDescription desc = jobResumes.get(k++);
                        connectionManager.recordHistory(desc.getConnectionName(), null, connectionManager.ACTIVITY_JOBCONTINUE, null, desc.getID().toString() + "(" + desc.getDescription() + ")", null, null, null);
                    }
                    k = 0;
                    while (k < jobCompletions.size()) {
                        IJobDescription desc = jobCompletions.get(k++);
                        connectionManager.recordHistory(desc.getConnectionName(), null, connectionManager.ACTIVITY_JOBEND, null, desc.getID().toString() + "(" + desc.getDescription() + ")", null, null, null);
                        // As a courtesy, call all the notification connections (if any)
                        doEndNotifications(desc, notificationManager, notificationPool);
                    }
                    ManifoldCF.sleep(10000L);
                } catch (ManifoldCFException e) {
                    if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                        break;
                    if (e.getErrorCode() == ManifoldCFException.DATABASE_CONNECTION_ERROR) {
                        Logging.threads.error("Job reset thread aborting and restarting due to database connection reset: " + e.getMessage(), e);
                        try {
                            // Give the database a chance to catch up/wake up
                            ManifoldCF.sleep(10000L);
                        } catch (InterruptedException se) {
                            break;
                        }
                        continue;
                    }
                    // Log it, but keep the thread alive
                    Logging.threads.error("Exception tossed: " + e.getMessage(), e);
                    if (e.getErrorCode() == ManifoldCFException.SETUP_ERROR) {
                        // Shut the whole system down!
                        ManifoldCF.systemExit(1);
                    }
                } catch (InterruptedException e) {
                    // We're supposed to quit
                    break;
                } catch (OutOfMemoryError e) {
                    System.err.println("agents process ran out of memory - shutting down");
                    e.printStackTrace(System.err);
                    ManifoldCF.systemExit(-200);
                } catch (Throwable e) {
                    // A more severe error - but stay alive
                    Logging.threads.fatal("Error tossed: " + e.getMessage(), e);
                }
            }
        } catch (Throwable e) {
            // Severe error on initialization
            System.err.println("agents process could not start - shutting down");
            Logging.threads.fatal("JobResetThread initialization error tossed: " + e.getMessage(), e);
            ManifoldCF.systemExit(-300);
        }

    }

    protected static void doStopNotifications(IJobDescription jobDescription, int notificationType, INotificationConnectionManager notificationManager, INotificationConnectorPool notificationPool) throws ManifoldCFException {
        for (int j = 0; j < jobDescription.countNotifications(); j++) {
            String notificationConnectionName = jobDescription.getNotificationConnectionName(j);
            try {
                INotificationConnection c = notificationManager.load(notificationConnectionName);
                if (c != null) {
                    INotificationConnector connector = notificationPool.grab(c);
                    if (connector != null) {
                        try {
                            switch(notificationType) {
                                case IJobManager.STOP_ERRORABORT:
                                    connector.notifyOfJobStopErrorAbort(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_MANUALABORT:
                                    connector.notifyOfJobStopManualAbort(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_MANUALPAUSE:
                                    connector.notifyOfJobStopManualPause(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_SCHEDULEPAUSE:
                                    connector.notifyOfJobStopSchedulePause(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_RESTART:
                                    connector.notifyOfJobStopRestart(jobDescription.getNotificationSpecification(j));
                                    break;
                                default:
                                    throw new RuntimeException("Unhandled notification type: " + notificationType);
                            }
                        } finally {
                            notificationPool.release(c, connector);
                        }
                    }
                }
            } catch (ServiceInterruption e) {
                Logging.connectors.warn("Can't notify right now: " + e.getMessage(), e);
            } catch (ManifoldCFException e) {
                if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                    throw e;
                Logging.connectors.warn("Error notifying: " + e.getMessage(), e);
            }
        }
    }

    protected static void doEndNotifications(IJobDescription jobDescription, INotificationConnectionManager notificationManager, INotificationConnectorPool notificationPool) throws ManifoldCFException {
        for (int j = 0; j < jobDescription.countNotifications(); j++) {
            String notificationConnectionName = jobDescription.getNotificationConnectionName(j);
            try {
                INotificationConnection c = notificationManager.load(notificationConnectionName);
                if (c != null) {
                    INotificationConnector connector = notificationPool.grab(c);
                    if (connector != null) {
                        try {
                            connector.notifyOfJobEnd(jobDescription.getNotificationSpecification(j));
                        } finally {
                            notificationPool.release(c, connector);
                        }
                    }
                }
            } catch (ServiceInterruption e) {
                Logging.connectors.warn("Can't notify right now: " + e.getMessage(), e);
            } catch (ManifoldCFException e) {
                if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                    throw e;
                Logging.connectors.warn("Error notifying: " + e.getMessage(), e);
            }
        }
    }
}


package org.apache.manifoldcf.crawler.system;

import org.apache.manifoldcf.core.interfaces.*;
import org.apache.manifoldcf.agents.interfaces.*;
import org.apache.manifoldcf.crawler.interfaces.*;
import org.apache.manifoldcf.crawler.system.Logging;
import java.util.*;
import java.lang.reflect.*;

/**
 * This class represents the thread that notices jobs that have completed their shutdown phase, and puts them in the
 * "notify connector" state.
 */
public class JobResetThread extends Thread {

    public static final String _rcsid = "@(#)$Id: JobResetThread.java 991295 2010-08-31 19:12:14Z kwright $";

    // Local data
    /**
     * Process ID
     */
    protected final String processID;

    public JobResetThread(String processID) throws ManifoldCFException {
        super();
        setName("Job reset thread");
        setDaemon(true);
        this.processID = processID;
    }

    public void run() {
        try {
            // Create a thread context object.
            IThreadContext threadContext = ThreadContextFactory.make();
            IJobManager jobManager = JobManagerFactory.make(threadContext);
            IRepositoryConnectionManager connectionManager = RepositoryConnectionManagerFactory.make(threadContext);
            INotificationConnectionManager notificationManager = NotificationConnectionManagerFactory.make(threadContext);
            INotificationConnectorPool notificationPool = NotificationConnectorPoolFactory.make(threadContext);
            // Loop
            while (true) {
                // Do another try/catch around everything in the loop
                try {
                    // See if there are any completed jobs
                    long currentTime = System.currentTimeMillis();
                    List<IJobDescription> jobStops = new ArrayList<IJobDescription>();
                    List<Integer> jobStopNotifications = new ArrayList<Integer>();
                    jobManager.finishJobStops(currentTime, jobStops, jobStopNotifications);
                    List<IJobDescription> jobResumes = new ArrayList<IJobDescription>();
                    jobManager.finishJobResumes(currentTime, jobResumes);
                    List<IJobDescription> jobCompletions = new ArrayList<IJobDescription>();
                    jobManager.resetJobs(currentTime, jobCompletions);
                    // If there were any job aborts, we must reprioritize all active documents, since we've done something
                    // not predicted by the algorithm that assigned those priorities.  This is, of course, quite expensive,
                    // but it cannot be helped (at least, I cannot find a way to avoid it).
                    if (jobStops.size() > 0) {
                        Logging.threads.debug("Job reset thread reprioritizing documents...");
                        ManifoldCF.resetAllDocumentPriorities(threadContext, processID);
                        Logging.threads.debug("Job reset thread done reprioritizing documents.");
                    }
                    int k = 0;
                    while (k < jobStops.size()) {
                        IJobDescription desc = jobStops.get(k);
                        Integer notificationType = jobStopNotifications.get(k);
                        connectionManager.recordHistory(desc.getConnectionName(), null, connectionManager.ACTIVITY_JOBSTOP, null, desc.getID().toString() + "(" + desc.getDescription() + ")", null, null, null);
                        // As a courtesy, call all the notification connections (if any)
                        doStopNotifications(desc, notificationType, notificationManager, notificationPool);
                        k++;
                    }
                    k = 0;
                    while (k < jobResumes.size()) {
                        IJobDescription desc = jobResumes.get(k++);
                        connectionManager.recordHistory(desc.getConnectionName(), null, connectionManager.ACTIVITY_JOBCONTINUE, null, desc.getID().toString() + "(" + desc.getDescription() + ")", null, null, null);
                    }
                    k = 0;
                    while (k < jobCompletions.size()) {
                        IJobDescription desc = jobCompletions.get(k++);
                        connectionManager.recordHistory(desc.getConnectionName(), null, connectionManager.ACTIVITY_JOBEND, null, desc.getID().toString() + "(" + desc.getDescription() + ")", null, null, null);
                        // As a courtesy, call all the notification connections (if any)
                        doEndNotifications(desc, notificationManager, notificationPool);
                    }
                    ManifoldCF.sleep(10000L);
                } catch (ManifoldCFException e) {
                    if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                        break;
                    if (e.getErrorCode() == ManifoldCFException.DATABASE_CONNECTION_ERROR) {
                        Logging.threads.error("Job reset thread aborting and restarting due to database connection reset: " + e.getMessage(), e);
                        try {
                            // Give the database a chance to catch up/wake up
                            ManifoldCF.sleep(10000L);
                        } catch (InterruptedException se) {
                            break;
                        }
                        continue;
                    }
                    // Log it, but keep the thread alive
                    Logging.threads.error("Exception tossed: " + e.getMessage(), e);
                    if (e.getErrorCode() == ManifoldCFException.SETUP_ERROR) {
                        // Shut the whole system down!
                        ManifoldCF.systemExit(1);
                    }
                } catch (InterruptedException e) {
                    // We're supposed to quit
                    break;
                } catch (OutOfMemoryError e) {
                    System.err.println("agents process ran out of memory - shutting down");
                    e.printStackTrace(System.err);
                    ManifoldCF.systemExit(-200);
                } catch (Throwable e) {
                    // A more severe error - but stay alive
                    Logging.threads.fatal("Error tossed: " + e.getMessage(), e);
                }
            }
        } catch (Throwable e) {
            // Severe error on initialization
            System.err.println("agents process could not start - shutting down");
            Logging.threads.fatal("JobResetThread initialization error tossed: " + e.getMessage(), e);
            ManifoldCF.systemExit(-300);
        }

    protected static void doStopNotifications(IJobDescription jobDescription, int notificationType, INotificationConnectionManager notificationManager, INotificationConnectorPool notificationPool) throws ManifoldCFException {
        for (int j = 0; j < jobDescription.countNotifications(); j++) {
            String notificationConnectionName = jobDescription.getNotificationConnectionName(j);
            try {
                INotificationConnection c = notificationManager.load(notificationConnectionName);
                if (c != null) {
                    INotificationConnector connector = notificationPool.grab(c);
                    if (connector != null) {
                        try {
                            switch(notificationType) {
                                case IJobManager.STOP_ERRORABORT:
                                    connector.notifyOfJobStopErrorAbort(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_MANUALABORT:
                                    connector.notifyOfJobStopManualAbort(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_MANUALPAUSE:
                                    connector.notifyOfJobStopManualPause(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_SCHEDULEPAUSE:
                                    connector.notifyOfJobStopSchedulePause(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_RESTART:
                                    connector.notifyOfJobStopRestart(jobDescription.getNotificationSpecification(j));
                                    break;
                                default:
                                    throw new RuntimeException("Unhandled notification type: " + notificationType);
                            }
                        } finally {
                            notificationPool.release(c, connector);
                        }
                    }
                }
            } catch (ServiceInterruption e) {
                Logging.connectors.warn("Can't notify right now: " + e.getMessage(), e);
            } catch (ManifoldCFException e) {
                if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                    throw e;
                Logging.connectors.warn("Error notifying: " + e.getMessage(), e);
            }
        }
    }

    protected static void doEndNotifications(IJobDescription jobDescription, INotificationConnectionManager notificationManager, INotificationConnectorPool notificationPool) throws ManifoldCFException {
        for (int j = 0; j < jobDescription.countNotifications(); j++) {
            String notificationConnectionName = jobDescription.getNotificationConnectionName(j);
            try {
                INotificationConnection c = notificationManager.load(notificationConnectionName);
                if (c != null) {
                    INotificationConnector connector = notificationPool.grab(c);
                    if (connector != null) {
                        try {
                            connector.notifyOfJobEnd(jobDescription.getNotificationSpecification(j));
                        } finally {
                            notificationPool.release(c, connector);
                        }
                    }
                }
            } catch (ServiceInterruption e) {
                Logging.connectors.warn("Can't notify right now: " + e.getMessage(), e);
            } catch (ManifoldCFException e) {
                if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                    throw e;
                Logging.connectors.warn("Error notifying: " + e.getMessage(), e);
            }
        }
    }
}


package org.apache.manifoldcf.crawler.system;

import org.apache.manifoldcf.core.interfaces.*;
import org.apache.manifoldcf.agents.interfaces.*;
import org.apache.manifoldcf.crawler.interfaces.*;
import org.apache.manifoldcf.crawler.system.Logging;
import java.util.*;
import java.lang.reflect.*;

/**
 * This class represents the thread that notices jobs that have completed their shutdown phase, and puts them in the
 * "notify connector" state.
 */
public class JobResetThread extends Thread {

    public static final String _rcsid = "@(#)$Id: JobResetThread.java 991295 2010-08-31 19:12:14Z kwright $";

    // Local data
    /**
     * Process ID
     */
    protected final String processID;

    public JobResetThread(String processID) throws ManifoldCFException {
        super();
        setName("Job reset thread");
        setDaemon(true);
        this.processID = processID;
    }

    public void run() {
        try {
            // Create a thread context object.
            IThreadContext threadContext = ThreadContextFactory.make();
            IJobManager jobManager = JobManagerFactory.make(threadContext);
            IRepositoryConnectionManager connectionManager = RepositoryConnectionManagerFactory.make(threadContext);
            INotificationConnectionManager notificationManager = NotificationConnectionManagerFactory.make(threadContext);
            INotificationConnectorPool notificationPool = NotificationConnectorPoolFactory.make(threadContext);
            // Loop
            while (true) {
                // Do another try/catch around everything in the loop
                try {
                    // See if there are any completed jobs
                    long currentTime = System.currentTimeMillis();
                    List<IJobDescription> jobStops = new ArrayList<IJobDescription>();
                    List<Integer> jobStopNotifications = new ArrayList<Integer>();
                    jobManager.finishJobStops(currentTime, jobStops, jobStopNotifications);
                    List<IJobDescription> jobResumes = new ArrayList<IJobDescription>();
                    jobManager.finishJobResumes(currentTime, jobResumes);
                    List<IJobDescription> jobCompletions = new ArrayList<IJobDescription>();
                    jobManager.resetJobs(currentTime, jobCompletions);
                    // If there were any job aborts, we must reprioritize all active documents, since we've done something
                    // not predicted by the algorithm that assigned those priorities.  This is, of course, quite expensive,
                    // but it cannot be helped (at least, I cannot find a way to avoid it).
                    if (jobStops.size() > 0) {
                        Logging.threads.debug("Job reset thread reprioritizing documents...");
                        ManifoldCF.resetAllDocumentPriorities(threadContext, processID);
                        Logging.threads.debug("Job reset thread done reprioritizing documents.");
                    }
                    int k = 0;
                    while (k < jobStops.size()) {
                        IJobDescription desc = jobStops.get(k);
                        Integer notificationType = jobStopNotifications.get(k);
                        connectionManager.recordHistory(desc.getConnectionName(), null, connectionManager.ACTIVITY_JOBSTOP, null, desc.getID().toString() + "(" + desc.getDescription() + ")", null, null, null);
                        // As a courtesy, call all the notification connections (if any)
                        doStopNotifications(desc, notificationType, notificationManager, notificationPool);
                        k++;
                    }
                    k = 0;
                    while (k < jobResumes.size()) {
                        IJobDescription desc = jobResumes.get(k++);
                        connectionManager.recordHistory(desc.getConnectionName(), null, connectionManager.ACTIVITY_JOBCONTINUE, null, desc.getID().toString() + "(" + desc.getDescription() + ")", null, null, null);
                    }
                    k = 0;
                    while (k < jobCompletions.size()) {
                        IJobDescription desc = jobCompletions.get(k++);
                        connectionManager.recordHistory(desc.getConnectionName(), null, connectionManager.ACTIVITY_JOBEND, null, desc.getID().toString() + "(" + desc.getDescription() + ")", null, null, null);
                        // As a courtesy, call all the notification connections (if any)
                        doEndNotifications(desc, notificationManager, notificationPool);
                    }
                    ManifoldCF.sleep(10000L);
                } catch (ManifoldCFException e) {
                    if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                        break;
                    if (e.getErrorCode() == ManifoldCFException.DATABASE_CONNECTION_ERROR) {
                        Logging.threads.error("Job reset thread aborting and restarting due to database connection reset: " + e.getMessage(), e);
                        try {
                            // Give the database a chance to catch up/wake up
                            ManifoldCF.sleep(10000L);
                        } catch (InterruptedException se) {
                            break;
                        }
                        continue;
                    }
                    // Log it, but keep the thread alive
                    Logging.threads.error("Exception tossed: " + e.getMessage(), e);
                    if (e.getErrorCode() == ManifoldCFException.SETUP_ERROR) {
                        // Shut the whole system down!
                        ManifoldCF.systemExit(1);
                    }
                } catch (InterruptedException e) {
                    // We're supposed to quit
                    break;
                } catch (OutOfMemoryError e) {
                    System.err.println("agents process ran out of memory - shutting down");
                    e.printStackTrace(System.err);
                    ManifoldCF.systemExit(-200);
                } catch (Throwable e) {
                    // A more severe error - but stay alive
                    Logging.threads.fatal("Error tossed: " + e.getMessage(), e);
                }
            }
        } catch (Throwable e) {
            // Severe error on initialization
            System.err.println("agents process could not start - shutting down");
            Logging.threads.fatal("JobResetThread initialization error tossed: " + e.getMessage(), e);
            ManifoldCF.systemExit(-300);
        }
    }

    protected static void doStopNotifications(IJobDescription jobDescription, int notificationType, INotificationConnectionManager notificationManager, INotificationConnectorPool notificationPool) throws ManifoldCFException {
        for (int j = 0; j < jobDescription.countNotifications(); j++) {
            String notificationConnectionName = jobDescription.getNotificationConnectionName(j);
            try {
                INotificationConnection c = notificationManager.load(notificationConnectionName);
                if (c != null) {
                    INotificationConnector connector = notificationPool.grab(c);
                    if (connector != null) {
                        try {
                            switch(notificationType) {
                                case IJobManager.STOP_ERRORABORT:
                                    connector.notifyOfJobStopErrorAbort(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_MANUALABORT:
                                    connector.notifyOfJobStopManualAbort(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_MANUALPAUSE:
                                    connector.notifyOfJobStopManualPause(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_SCHEDULEPAUSE:
                                    connector.notifyOfJobStopSchedulePause(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_RESTART:
                                    connector.notifyOfJobStopRestart(jobDescription.getNotificationSpecification(j));
                                    break;
                                default:
                                    throw new RuntimeException("Unhandled notification type: " + notificationType);
                            }
                        } finally {
                            notificationPool.release(c, connector);
                        }
                    }
                }
            } catch (ServiceInterruption e) {
                Logging.connectors.warn("Can't notify right now: " + e.getMessage(), e);
            } catch (ManifoldCFException e) {

                Logging.connectors.warn("Error notifying: " + e.getMessage(), e);
            }
        }
    }

    protected static void doEndNotifications(IJobDescription jobDescription, INotificationConnectionManager notificationManager, INotificationConnectorPool notificationPool) throws ManifoldCFException {
        for (int j = 0; j < jobDescription.countNotifications(); j++) {
            String notificationConnectionName = jobDescription.getNotificationConnectionName(j);
            try {
                INotificationConnection c = notificationManager.load(notificationConnectionName);
                if (c != null) {
                    INotificationConnector connector = notificationPool.grab(c);
                    if (connector != null) {
                        try {
                            connector.notifyOfJobEnd(jobDescription.getNotificationSpecification(j));
                        } finally {
                            notificationPool.release(c, connector);
                        }
                    }
                }
            } catch (ServiceInterruption e) {
                Logging.connectors.warn("Can't notify right now: " + e.getMessage(), e);
            } catch (ManifoldCFException e) {
                if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                    throw e;
                Logging.connectors.warn("Error notifying: " + e.getMessage(), e);
            }
        }
    }
}


while (k < jobResumes.size()) {
                        IJobDescription desc = jobResumes.get(k++);
                        connectionManager.recordHistory(desc.getConnectionName(), null, connectionManager.ACTIVITY_JOBCONTINUE, null, desc.getID().toString() + "(" + desc.getDescription() + ")", null, null, null);
                    }

package org.apache.manifoldcf.crawler.system;

import org.apache.manifoldcf.core.interfaces.*;
import org.apache.manifoldcf.agents.interfaces.*;
import org.apache.manifoldcf.crawler.interfaces.*;
import org.apache.manifoldcf.crawler.system.Logging;
import java.util.*;
import java.lang.reflect.*;

/**
 * This class represents the thread that notices jobs that have completed their shutdown phase, and puts them in the
 * "notify connector" state.
 */
public class JobResetThread extends Thread {

    public static final String _rcsid = "@(#)$Id: JobResetThread.java 991295 2010-08-31 19:12:14Z kwright $";

    // Local data
    /**
     * Process ID
     */
    protected final String processID;

    public JobResetThread(String processID) throws ManifoldCFException {
        super();
        setName("Job reset thread");
        setDaemon(true);
        this.processID = processID;
    }

    public void run() {
        try {
            // Create a thread context object.
            IThreadContext threadContext = ThreadContextFactory.make();
            IJobManager jobManager = JobManagerFactory.make(threadContext);
            IRepositoryConnectionManager connectionManager = RepositoryConnectionManagerFactory.make(threadContext);
            INotificationConnectionManager notificationManager = NotificationConnectionManagerFactory.make(threadContext);
            INotificationConnectorPool notificationPool = NotificationConnectorPoolFactory.make(threadContext);
            // Loop
            while (true) {
                // Do another try/catch around everything in the loop
                try {
                    // See if there are any completed jobs
                    long currentTime = System.currentTimeMillis();
                    List<IJobDescription> jobStops = new ArrayList<IJobDescription>();
                    List<Integer> jobStopNotifications = new ArrayList<Integer>();
                    jobManager.finishJobStops(currentTime, jobStops, jobStopNotifications);
                    List<IJobDescription> jobResumes = new ArrayList<IJobDescription>();
                    jobManager.finishJobResumes(currentTime, jobResumes);
                    List<IJobDescription> jobCompletions = new ArrayList<IJobDescription>();
                    jobManager.resetJobs(currentTime, jobCompletions);
                    // If there were any job aborts, we must reprioritize all active documents, since we've done something
                    // not predicted by the algorithm that assigned those priorities.  This is, of course, quite expensive,
                    // but it cannot be helped (at least, I cannot find a way to avoid it).
                    if (jobStops.size() > 0) {
                        Logging.threads.debug("Job reset thread reprioritizing documents...");
                        ManifoldCF.resetAllDocumentPriorities(threadContext, processID);
                        Logging.threads.debug("Job reset thread done reprioritizing documents.");
                    }
                    int k = 0;
                    while (k < jobStops.size()) {
                        IJobDescription desc = jobStops.get(k);
                        Integer notificationType = jobStopNotifications.get(k);
                        connectionManager.recordHistory(desc.getConnectionName(), null, connectionManager.ACTIVITY_JOBSTOP, null, desc.getID().toString() + "(" + desc.getDescription() + ")", null, null, null);
                        // As a courtesy, call all the notification connections (if any)
                        doStopNotifications(desc, notificationType, notificationManager, notificationPool);
                        k++;
                    }
                    k = 0;

                    k = 0;
                    while (k < jobCompletions.size()) {
                        IJobDescription desc = jobCompletions.get(k++);
                        connectionManager.recordHistory(desc.getConnectionName(), null, connectionManager.ACTIVITY_JOBEND, null, desc.getID().toString() + "(" + desc.getDescription() + ")", null, null, null);
                        // As a courtesy, call all the notification connections (if any)
                        doEndNotifications(desc, notificationManager, notificationPool);
                    }
                    ManifoldCF.sleep(10000L);
                } catch (ManifoldCFException e) {
                    if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                        break;
                    if (e.getErrorCode() == ManifoldCFException.DATABASE_CONNECTION_ERROR) {
                        Logging.threads.error("Job reset thread aborting and restarting due to database connection reset: " + e.getMessage(), e);
                        try {
                            // Give the database a chance to catch up/wake up
                            ManifoldCF.sleep(10000L);
                        } catch (InterruptedException se) {
                            break;
                        }
                        continue;
                    }
                    // Log it, but keep the thread alive
                    Logging.threads.error("Exception tossed: " + e.getMessage(), e);
                    if (e.getErrorCode() == ManifoldCFException.SETUP_ERROR) {
                        // Shut the whole system down!
                        ManifoldCF.systemExit(1);
                    }
                } catch (InterruptedException e) {
                    // We're supposed to quit
                    break;
                } catch (OutOfMemoryError e) {
                    System.err.println("agents process ran out of memory - shutting down");
                    e.printStackTrace(System.err);
                    ManifoldCF.systemExit(-200);
                } catch (Throwable e) {
                    // A more severe error - but stay alive
                    Logging.threads.fatal("Error tossed: " + e.getMessage(), e);
                }
            }
        } catch (Throwable e) {
            // Severe error on initialization
            System.err.println("agents process could not start - shutting down");
            Logging.threads.fatal("JobResetThread initialization error tossed: " + e.getMessage(), e);
            ManifoldCF.systemExit(-300);
        }
    }

    protected static void doStopNotifications(IJobDescription jobDescription, int notificationType, INotificationConnectionManager notificationManager, INotificationConnectorPool notificationPool) throws ManifoldCFException {
        for (int j = 0; j < jobDescription.countNotifications(); j++) {
            String notificationConnectionName = jobDescription.getNotificationConnectionName(j);
            try {
                INotificationConnection c = notificationManager.load(notificationConnectionName);
                if (c != null) {
                    INotificationConnector connector = notificationPool.grab(c);
                    if (connector != null) {
                        try {
                            switch(notificationType) {
                                case IJobManager.STOP_ERRORABORT:
                                    connector.notifyOfJobStopErrorAbort(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_MANUALABORT:
                                    connector.notifyOfJobStopManualAbort(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_MANUALPAUSE:
                                    connector.notifyOfJobStopManualPause(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_SCHEDULEPAUSE:
                                    connector.notifyOfJobStopSchedulePause(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_RESTART:
                                    connector.notifyOfJobStopRestart(jobDescription.getNotificationSpecification(j));
                                    break;
                                default:
                                    throw new RuntimeException("Unhandled notification type: " + notificationType);
                            }
                        } finally {
                            notificationPool.release(c, connector);
                        }
                    }
                }
            } catch (ServiceInterruption e) {
                Logging.connectors.warn("Can't notify right now: " + e.getMessage(), e);
            } catch (ManifoldCFException e) {
                if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                    throw e;
                Logging.connectors.warn("Error notifying: " + e.getMessage(), e);
            }
        }
    }

    protected static void doEndNotifications(IJobDescription jobDescription, INotificationConnectionManager notificationManager, INotificationConnectorPool notificationPool) throws ManifoldCFException {
        for (int j = 0; j < jobDescription.countNotifications(); j++) {
            String notificationConnectionName = jobDescription.getNotificationConnectionName(j);
            try {
                INotificationConnection c = notificationManager.load(notificationConnectionName);
                if (c != null) {
                    INotificationConnector connector = notificationPool.grab(c);
                    if (connector != null) {
                        try {
                            connector.notifyOfJobEnd(jobDescription.getNotificationSpecification(j));
                        } finally {
                            notificationPool.release(c, connector);
                        }
                    }
                }
            } catch (ServiceInterruption e) {
                Logging.connectors.warn("Can't notify right now: " + e.getMessage(), e);
            } catch (ManifoldCFException e) {
                if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                    throw e;
                Logging.connectors.warn("Error notifying: " + e.getMessage(), e);
            }
        }
    }
}


try {
                            // Give the database a chance to catch up/wake up
                            ManifoldCF.sleep(10000L);
                        } catch (InterruptedException se) {
                            break;
                        }

package org.apache.manifoldcf.crawler.system;

import org.apache.manifoldcf.core.interfaces.*;
import org.apache.manifoldcf.agents.interfaces.*;
import org.apache.manifoldcf.crawler.interfaces.*;
import org.apache.manifoldcf.crawler.system.Logging;
import java.util.*;
import java.lang.reflect.*;

/**
 * This class represents the thread that notices jobs that have completed their shutdown phase, and puts them in the
 * "notify connector" state.
 */
public class JobResetThread extends Thread {

    public static final String _rcsid = "@(#)$Id: JobResetThread.java 991295 2010-08-31 19:12:14Z kwright $";

    // Local data
    /**
     * Process ID
     */
    protected final String processID;

    public JobResetThread(String processID) throws ManifoldCFException {
        super();
        setName("Job reset thread");
        setDaemon(true);
        this.processID = processID;
    }

    public void run() {
        try {
            // Create a thread context object.
            IThreadContext threadContext = ThreadContextFactory.make();
            IJobManager jobManager = JobManagerFactory.make(threadContext);
            IRepositoryConnectionManager connectionManager = RepositoryConnectionManagerFactory.make(threadContext);
            INotificationConnectionManager notificationManager = NotificationConnectionManagerFactory.make(threadContext);
            INotificationConnectorPool notificationPool = NotificationConnectorPoolFactory.make(threadContext);
            // Loop
            while (true) {
                // Do another try/catch around everything in the loop
                try {
                    // See if there are any completed jobs
                    long currentTime = System.currentTimeMillis();
                    List<IJobDescription> jobStops = new ArrayList<IJobDescription>();
                    List<Integer> jobStopNotifications = new ArrayList<Integer>();
                    jobManager.finishJobStops(currentTime, jobStops, jobStopNotifications);
                    List<IJobDescription> jobResumes = new ArrayList<IJobDescription>();
                    jobManager.finishJobResumes(currentTime, jobResumes);
                    List<IJobDescription> jobCompletions = new ArrayList<IJobDescription>();
                    jobManager.resetJobs(currentTime, jobCompletions);
                    // If there were any job aborts, we must reprioritize all active documents, since we've done something
                    // not predicted by the algorithm that assigned those priorities.  This is, of course, quite expensive,
                    // but it cannot be helped (at least, I cannot find a way to avoid it).
                    if (jobStops.size() > 0) {
                        Logging.threads.debug("Job reset thread reprioritizing documents...");
                        ManifoldCF.resetAllDocumentPriorities(threadContext, processID);
                        Logging.threads.debug("Job reset thread done reprioritizing documents.");
                    }
                    int k = 0;
                    while (k < jobStops.size()) {
                        IJobDescription desc = jobStops.get(k);
                        Integer notificationType = jobStopNotifications.get(k);
                        connectionManager.recordHistory(desc.getConnectionName(), null, connectionManager.ACTIVITY_JOBSTOP, null, desc.getID().toString() + "(" + desc.getDescription() + ")", null, null, null);
                        // As a courtesy, call all the notification connections (if any)
                        doStopNotifications(desc, notificationType, notificationManager, notificationPool);
                        k++;
                    }
                    k = 0;
                    while (k < jobResumes.size()) {
                        IJobDescription desc = jobResumes.get(k++);
                        connectionManager.recordHistory(desc.getConnectionName(), null, connectionManager.ACTIVITY_JOBCONTINUE, null, desc.getID().toString() + "(" + desc.getDescription() + ")", null, null, null);
                    }
                    k = 0;
                    while (k < jobCompletions.size()) {
                        IJobDescription desc = jobCompletions.get(k++);
                        connectionManager.recordHistory(desc.getConnectionName(), null, connectionManager.ACTIVITY_JOBEND, null, desc.getID().toString() + "(" + desc.getDescription() + ")", null, null, null);
                        // As a courtesy, call all the notification connections (if any)
                        doEndNotifications(desc, notificationManager, notificationPool);
                    }
                    ManifoldCF.sleep(10000L);
                } catch (ManifoldCFException e) {
                    if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                        break;
                    if (e.getErrorCode() == ManifoldCFException.DATABASE_CONNECTION_ERROR) {
                        Logging.threads.error("Job reset thread aborting and restarting due to database connection reset: " + e.getMessage(), e);

                        continue;
                    }
                    // Log it, but keep the thread alive
                    Logging.threads.error("Exception tossed: " + e.getMessage(), e);
                    if (e.getErrorCode() == ManifoldCFException.SETUP_ERROR) {
                        // Shut the whole system down!
                        ManifoldCF.systemExit(1);
                    }
                } catch (InterruptedException e) {
                    // We're supposed to quit
                    break;
                } catch (OutOfMemoryError e) {
                    System.err.println("agents process ran out of memory - shutting down");
                    e.printStackTrace(System.err);
                    ManifoldCF.systemExit(-200);
                } catch (Throwable e) {
                    // A more severe error - but stay alive
                    Logging.threads.fatal("Error tossed: " + e.getMessage(), e);
                }
            }
        } catch (Throwable e) {
            // Severe error on initialization
            System.err.println("agents process could not start - shutting down");
            Logging.threads.fatal("JobResetThread initialization error tossed: " + e.getMessage(), e);
            ManifoldCF.systemExit(-300);
        }
    }

    protected static void doStopNotifications(IJobDescription jobDescription, int notificationType, INotificationConnectionManager notificationManager, INotificationConnectorPool notificationPool) throws ManifoldCFException {
        for (int j = 0; j < jobDescription.countNotifications(); j++) {
            String notificationConnectionName = jobDescription.getNotificationConnectionName(j);
            try {
                INotificationConnection c = notificationManager.load(notificationConnectionName);
                if (c != null) {
                    INotificationConnector connector = notificationPool.grab(c);
                    if (connector != null) {
                        try {
                            switch(notificationType) {
                                case IJobManager.STOP_ERRORABORT:
                                    connector.notifyOfJobStopErrorAbort(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_MANUALABORT:
                                    connector.notifyOfJobStopManualAbort(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_MANUALPAUSE:
                                    connector.notifyOfJobStopManualPause(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_SCHEDULEPAUSE:
                                    connector.notifyOfJobStopSchedulePause(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_RESTART:
                                    connector.notifyOfJobStopRestart(jobDescription.getNotificationSpecification(j));
                                    break;
                                default:
                                    throw new RuntimeException("Unhandled notification type: " + notificationType);
                            }
                        } finally {
                            notificationPool.release(c, connector);
                        }
                    }
                }
            } catch (ServiceInterruption e) {
                Logging.connectors.warn("Can't notify right now: " + e.getMessage(), e);
            } catch (ManifoldCFException e) {
                if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                    throw e;
                Logging.connectors.warn("Error notifying: " + e.getMessage(), e);
            }
        }
    }

    protected static void doEndNotifications(IJobDescription jobDescription, INotificationConnectionManager notificationManager, INotificationConnectorPool notificationPool) throws ManifoldCFException {
        for (int j = 0; j < jobDescription.countNotifications(); j++) {
            String notificationConnectionName = jobDescription.getNotificationConnectionName(j);
            try {
                INotificationConnection c = notificationManager.load(notificationConnectionName);
                if (c != null) {
                    INotificationConnector connector = notificationPool.grab(c);
                    if (connector != null) {
                        try {
                            connector.notifyOfJobEnd(jobDescription.getNotificationSpecification(j));
                        } finally {
                            notificationPool.release(c, connector);
                        }
                    }
                }
            } catch (ServiceInterruption e) {
                Logging.connectors.warn("Can't notify right now: " + e.getMessage(), e);
            } catch (ManifoldCFException e) {
                if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                    throw e;
                Logging.connectors.warn("Error notifying: " + e.getMessage(), e);
            }
        }
    }
}


package org.apache.manifoldcf.crawler.system;

import org.apache.manifoldcf.core.interfaces.*;
import org.apache.manifoldcf.agents.interfaces.*;
import org.apache.manifoldcf.crawler.interfaces.*;
import org.apache.manifoldcf.crawler.system.Logging;
import java.util.*;
import java.lang.reflect.*;

/**
 * This class represents the thread that notices jobs that have completed their shutdown phase, and puts them in the
 * "notify connector" state.
 */
public class JobResetThread extends Thread {

    public static final String _rcsid = "@(#)$Id: JobResetThread.java 991295 2010-08-31 19:12:14Z kwright $";

    // Local data
    /**
     * Process ID
     */
    protected final String processID;

    public JobResetThread(String processID) throws ManifoldCFException {
        super();
        setName("Job reset thread");
        setDaemon(true);
        this.processID = processID;
    }

    public void run() {
        try {
            // Create a thread context object.
            IThreadContext threadContext = ThreadContextFactory.make();
            IJobManager jobManager = JobManagerFactory.make(threadContext);
            IRepositoryConnectionManager connectionManager = RepositoryConnectionManagerFactory.make(threadContext);
            INotificationConnectionManager notificationManager = NotificationConnectionManagerFactory.make(threadContext);
            INotificationConnectorPool notificationPool = NotificationConnectorPoolFactory.make(threadContext);
            // Loop
            while (true) {
                // Do another try/catch around everything in the loop
                try {
                    // See if there are any completed jobs
                    long currentTime = System.currentTimeMillis();
                    List<IJobDescription> jobStops = new ArrayList<IJobDescription>();
                    List<Integer> jobStopNotifications = new ArrayList<Integer>();
                    jobManager.finishJobStops(currentTime, jobStops, jobStopNotifications);
                    List<IJobDescription> jobResumes = new ArrayList<IJobDescription>();
                    jobManager.finishJobResumes(currentTime, jobResumes);
                    List<IJobDescription> jobCompletions = new ArrayList<IJobDescription>();
                    jobManager.resetJobs(currentTime, jobCompletions);
                    // If there were any job aborts, we must reprioritize all active documents, since we've done something
                    // not predicted by the algorithm that assigned those priorities.  This is, of course, quite expensive,
                    // but it cannot be helped (at least, I cannot find a way to avoid it).
                    if (jobStops.size() > 0) {
                        Logging.threads.debug("Job reset thread reprioritizing documents...");
                        ManifoldCF.resetAllDocumentPriorities(threadContext, processID);
                        Logging.threads.debug("Job reset thread done reprioritizing documents.");
                    }
                    int k = 0;
                    while (k < jobStops.size()) {
                        IJobDescription desc = jobStops.get(k);
                        Integer notificationType = jobStopNotifications.get(k);
                        connectionManager.recordHistory(desc.getConnectionName(), null, connectionManager.ACTIVITY_JOBSTOP, null, desc.getID().toString() + "(" + desc.getDescription() + ")", null, null, null);
                        // As a courtesy, call all the notification connections (if any)
                        doStopNotifications(desc, notificationType, notificationManager, notificationPool);
                        k++;
                    }
                    k = 0;
                    while (k < jobResumes.size()) {
                        IJobDescription desc = jobResumes.get(k++);
                        connectionManager.recordHistory(desc.getConnectionName(), null, connectionManager.ACTIVITY_JOBCONTINUE, null, desc.getID().toString() + "(" + desc.getDescription() + ")", null, null, null);
                    }
                    k = 0;
                    while (k < jobCompletions.size()) {
                        IJobDescription desc = jobCompletions.get(k++);
                        connectionManager.recordHistory(desc.getConnectionName(), null, connectionManager.ACTIVITY_JOBEND, null, desc.getID().toString() + "(" + desc.getDescription() + ")", null, null, null);
                        // As a courtesy, call all the notification connections (if any)
                        doEndNotifications(desc, notificationManager, notificationPool);
                    }
                    ManifoldCF.sleep(10000L);
                } catch (ManifoldCFException e) {
                    if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                        break;
                    if (e.getErrorCode() == ManifoldCFException.DATABASE_CONNECTION_ERROR) {
                        Logging.threads.error("Job reset thread aborting and restarting due to database connection reset: " + e.getMessage(), e);
                        try {
                            // Give the database a chance to catch up/wake up
                            ManifoldCF.sleep(10000L);
                        } catch (InterruptedException se) {
                            break;
                        }
                        continue;
                    }
                    // Log it, but keep the thread alive
                    Logging.threads.error("Exception tossed: " + e.getMessage(), e);
                    if (e.getErrorCode() == ManifoldCFException.SETUP_ERROR) {
                        // Shut the whole system down!
                        ManifoldCF.systemExit(1);
                    }
                } catch (InterruptedException e) {
                    // We're supposed to quit
                    break;
                } catch (OutOfMemoryError e) {
                    System.err.println("agents process ran out of memory - shutting down");
                    e.printStackTrace(System.err);
                    ManifoldCF.systemExit(-200);
                } catch (Throwable e) {
                    // A more severe error - but stay alive
                    Logging.threads.fatal("Error tossed: " + e.getMessage(), e);
                }
            }
        } catch (Throwable e) {
            // Severe error on initialization
            System.err.println("agents process could not start - shutting down");
            Logging.threads.fatal("JobResetThread initialization error tossed: " + e.getMessage(), e);
            ManifoldCF.systemExit(-300);
        }
    }

    protected static void doStopNotifications(IJobDescription jobDescription, int notificationType, INotificationConnectionManager notificationManager, INotificationConnectorPool notificationPool) throws ManifoldCFException {
        for (int j = 0; j < jobDescription.countNotifications(); j++) {
            String notificationConnectionName = jobDescription.getNotificationConnectionName(j);
            try {
                INotificationConnection c = notificationManager.load(notificationConnectionName);
                if (c != null) {
                    INotificationConnector connector = notificationPool.grab(c);
                    if (connector != null) {
                        try {
                            swit

ch(notificationType) {
                                case IJobManager.STOP_ERRORABORT:
                                    connector.notifyOfJobStopErrorAbort(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_MANUALABORT:
                                    connector.notifyOfJobStopManualAbort(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_MANUALPAUSE:
                                    connector.notifyOfJobStopManualPause(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_SCHEDULEPAUSE:
                                    connector.notifyOfJobStopSchedulePause(jobDescription.getNotificationSpecification(j));
                                    break;
                                case IJobManager.STOP_RESTART:
                                    connector.notifyOfJobStopRestart(jobDescription.getNotificationSpecification(j));
                                    break;
                                default:
                                    throw new RuntimeException("Unhandled notification type: " + notificationType);
                            }
                        } finally {
                            notificationPool.release(c, connector);
                        }
                    }
                }
            } catch (ServiceInterruption e) {
                Logging.connectors.warn("Can't notify right now: " + e.getMessage(), e);
            } catch (ManifoldCFException e) {
                if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                    throw e;
                Logging.connectors.warn("Error notifying: " + e.getMessage(), e);
            }
        }
    }

    protected static void doEndNotifications(IJobDescription jobDescription, INotificationConnectionManager notificationManager, INotificationConnectorPool notificationPool) throws ManifoldCFException {
        for (int j = 0; j < jobDescription.countNotifications(); j++) {
            String notificationConnectionName = jobDescription.getNotificationConnectionName(j);
            try {
                INotificationConnection c = notificationManager.load(notificationConnectionName);
                if (c != null) {
                    INotificationConnector connector = notificationPool.grab(c);
                    if (connector != null) {
                        try {
                            connector.notifyOfJobEnd(jobDescription.getNotificationSpecification(j));
                        } finally {
                            notificationPool.release(c, connector);
                        }
                    }
                }
            } catch (ServiceInterruption e) {
                Logging.connectors.warn("Can't notify right now: " + e.getMessage(), e);
            } catch (ManifoldCFException e) {
                if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
                    throw e;
                Logging.connectors.warn("Error notifying: " + e.getMessage(), e);
            }
        }
    }
}


@Override
    public List<TypeInstrumentation> typeInstrumentations()

/*
 * Copyright The OpenTelemetry Authors
 */
package io.opentelemetry.javaagent.instrumentation.myfaces;

import static java.util.Arrays.asList;
import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import java.util.List;

@AutoService(InstrumentationModule.class)
public class MyFacesInstrumentationModule extends InstrumentationModule {

    public MyFacesInstrumentationModule() {
        super("myfaces", "myfaces-1.2");
    }

{
        return asList(new ActionListenerImplInstrumentation(), new RestoreViewExecutorInstrumentation());
    }
}


{
        return asList(new ActionListenerImplInstrumentation(), new RestoreViewExecutorInstrumentation());
    }

/*
 * Copyright The OpenTelemetry Authors
 */
package io.opentelemetry.javaagent.instrumentation.myfaces;

import static java.util.Arrays.asList;
import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import java.util.List;

@AutoService(InstrumentationModule.class)
public class MyFacesInstrumentationModule extends InstrumentationModule {

    public MyFacesInstrumentationModule() {
        super("myfaces", "myfaces-1.2");
    }

    @Override
    public List<TypeInstrumentation> typeInstrumentations()


turn asList(new ActionListenerImplInstrumentation(), new RestoreViewExecutorInstrumentation());

/*
 * Copyright The OpenTelemetry Authors
 */
package io.opentelemetry.javaagent.instrumentation.myfaces;

import static java.util.Arrays.asList;
import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import java.util.List;

@AutoService(InstrumentationModule.class)
public class MyFacesInstrumentationModule extends InstrumentationModule {

    public MyFacesInstrumentationModule() {
        super("myfaces", "myfaces-1.2");
    }

    @Override
    public List<TypeInstrumentation> typeInstrumentations() {
        re


/*
 * Copyright The OpenTelemetry Authors
 */
package io.opentelemetry.javaagent.instrumentation.myfaces;

import static java.util.Arrays.asList;
import com.google.a

uto.service.AutoService;
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import java.util.List;

@AutoService(InstrumentationModule.class)
public class MyFacesInstrumentationModule extends InstrumentationModule {

    public MyFacesInstrumentationModule() {
        super("myfaces", "myfaces-1.2");
    }

    @Override
    public List<TypeInstrumentation> typeInstrumentations() {
        return asList(new ActionListenerImplInstrumentation(), new RestoreViewExecutorInstrumentation());
    }
}


@Override
    public void onApplicationEvent(AbstractAuthenticationEvent event)

package it.infn.mw.iam.audit;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.security.authentication.event.AbstractAuthenticationEvent;
import org.springframework.security.authentication.event.AuthenticationSuccessEvent;
import org.springframework.security.authentication.event.InteractiveAuthenticationSuccessEvent;
import org.springframework.stereotype.Component;
import it.infn.mw.iam.audit.events.auth.IamAuthenticationSuccessEvent;

@Component
public class IamAuthenticationSuccessAuditListener implements ApplicationListener<AbstractAuthenticationEvent> {

    private final AuditEventLogger logger;

    @Autowired
    public IamAuthenticationSuccessAuditListener(AuditEventLogger logger) {
        this.logger = logger;
    }

{
        if ((event instanceof AuthenticationSuccessEvent) || (event instanceof InteractiveAuthenticationSuccessEvent)) {
            IamAuthenticationSuccessEvent ev = new IamAuthenticationSuccessEvent(event);
            logger.logAuditEvent(ev);
        }
    }
}


{
        if ((event instanceof AuthenticationSuccessEvent) || (event instanceof InteractiveAuthenticationSuccessEvent)) {
            IamAuthenticationSuccessEvent ev = new IamAuthenticationSuccessEvent(event);
            logger.logAuditEvent(ev);
        }
    }

package it.infn.mw.iam.audit;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.security.authentication.event.AbstractAuthenticationEvent;
import org.springframework.security.authentication.event.AuthenticationSuccessEvent;
import org.springframework.security.authentication.event.InteractiveAuthenticationSuccessEvent;
import org.springframework.stereotype.Component;
import it.infn.mw.iam.audit.events.auth.IamAuthenticationSuccessEvent;

@Component
public class IamAuthenticationSuccessAuditListener implements ApplicationListener<AbstractAuthenticationEvent> {

    private final AuditEventLogger logger;

    @Autowired
    public IamAuthenticationSuccessAuditListener(AuditEventLogger logger) {
        this.logger = logger;
    }

    @Override
    public void onApplicationEvent(AbstractAuthenticationEvent event)


if ((event instanceof AuthenticationSuccessEvent) || (event instanceof InteractiveAuthenticationSuccessEvent)) {
            IamAuthenticationSuccessEvent ev = new IamAuthenticationSuccessEvent(event);
            logger.logAuditEvent(ev);
        }

package it.infn.mw.iam.audit;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.security.authentication.event.AbstractAuthenticationEvent;
import org.springframework.security.authentication.event.AuthenticationSuccessEvent;
import org.springframework.security.authentication.event.InteractiveAuthenticationSuccessEvent;
import org.springframework.stereotype.Component;
import it.infn.mw.iam.audit.events.auth.IamAuthenticationSuccessEvent;

@Component
public class IamAuthenticationSuccessAuditListener implements ApplicationListener<AbstractAuthenticationEvent> {

    private final AuditEventLogger logger;

    @Autowired
    public IamAuthenticationSuccessAuditListener(AuditEventLogger logger) {
        this.logger = logger;
    }

    @Override
    public void onApplicationEvent(AbstractAuthenticationEvent event) {


package it.infn.mw.iam.audit;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.security.authentication.event.AbstractAuthenticationEvent;
import org.springframework.security.authentication.event.AuthenticationSuccessEvent;
import org.springframework.security.authentication.event.InteractiveAuthenticationSuccessEvent;
import org.springframework.stereotype.Component;
import it.infn.mw.iam.a

udit.events.auth.IamAuthenticationSuccessEvent;

@Component
public class IamAuthenticationSuccessAuditListener implements ApplicationListener<AbstractAuthenticationEvent> {

    private final AuditEventLogger logger;

    @Autowired
    public IamAuthenticationSuccessAuditListener(AuditEventLogger logger) {
        this.logger = logger;
    }

    @Override
    public void onApplicationEvent(AbstractAuthenticationEvent event) {
        if ((event instanceof AuthenticationSuccessEvent) || (event instanceof InteractiveAuthenticationSuccessEvent)) {
            IamAuthenticationSuccessEvent ev = new IamAuthenticationSuccessEvent(event);
            logger.logAuditEvent(ev);
        }
    }
}


package com.oc.hawk.container.domain.model.runtime.build;

import com.oc.hawk.container.domain.model.runtime.config.Instance

Id;
import lombok.Getter;

@Getter
public class ProjectBuildPost {

    private InstanceId instanceId;

    private String instanceName;

    public ProjectBuildPost(InstanceId instanceId, String instanceName) {
        this.instanceId = instanceId;
        this.instanceName = instanceName;
    }
}