head	1.5;
access;
symbols
	TIGRIS_1_1_0RC2:1.4.2.7
	TIGRIS_1_1_0RC1:1.4.2.7
	TIGRIS_1_1:1.4.2.7.0.2
	TIGRIS_1_0_8:1.4.2.7
	TIGRIS_1_0_8RC3:1.4.2.7
	TIGRIS_1_0_8RC2:1.4.2.7
	TIGRIS_1_0_8RC1:1.4.2.7
	TIGRIS_1_0_7:1.4.2.7
	TIGRIS_1_0_7RC3:1.4.2.7
	TIGRIS_1_0_7RC2:1.4.2.7
	TIGRIS_1_0_7RC1:1.4.2.7
	TIGRIS_1_0_6:1.4.2.7
	TIGRIS_1_0_6RC5:1.4.2.7
	TIGRIS_1_0_6RC4:1.4.2.7
	TIGRIS_1_0_6RC3:1.4.2.7
	TIGRIS_1_0_6RC2:1.4.2.3
	TIGRIS_1_0_6RC1:1.4.2.2
	TIGRIS_1_0:1.4.0.2;
locks; strict;
comment	@# @;


1.5
date	2001.08.03.02.40.12;	author dlr;	state dead;
branches;
next	1.4;

1.4
date	2001.06.01.18.41.09;	author leonardr;	state Exp;
branches
	1.4.2.1;
next	1.3;

1.3
date	2001.05.23.00.33.21;	author leonardr;	state Exp;
branches;
next	1.2;

1.2
date	2001.05.18.21.56.26;	author leonardr;	state Exp;
branches;
next	1.1;

1.1
date	2001.05.18.16.45.15;	author leonardr;	state Exp;
branches;
next	;

1.4.2.1
date	2001.06.01.19.18.07;	author leonardr;	state Exp;
branches;
next	1.4.2.2;

1.4.2.2
date	2001.06.05.21.13.42;	author leonardr;	state Exp;
branches;
next	1.4.2.3;

1.4.2.3
date	2001.06.07.18.28.49;	author leonardr;	state Exp;
branches;
next	1.4.2.4;

1.4.2.4
date	2001.06.07.21.24.15;	author leonardr;	state Exp;
branches;
next	1.4.2.5;

1.4.2.5
date	2001.06.07.21.25.14;	author leonardr;	state Exp;
branches;
next	1.4.2.6;

1.4.2.6
date	2001.06.07.22.06.38;	author leonardr;	state Exp;
branches;
next	1.4.2.7;

1.4.2.7
date	2001.06.07.23.29.03;	author leonardr;	state Exp;
branches;
next	;


desc
@@


1.5
log
@Deprecated by Spread.
@
text
@/* ================================================================
 * Copyright (c) 2001 CollabNet.  All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 * 
 * 1. Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 * 
 * 2. Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * 
 * 3. The end-user documentation included with the redistribution, if
 * any, must include the following acknowlegement: "This product includes
 * software developed by CollabNet (http://www.collab.net/)."
 * Alternately, this acknowlegement may appear in the software itself, if
 * and wherever such third-party acknowlegements normally appear.
 * 
 * 4. The hosted project names must not be used to endorse or promote
 * products derived from this software without prior written
 * permission. For written permission, please contact info@@collab.net.
 * 
 * 5. Products derived from this software may not use the "Tigris" name
 * nor may "Tigris" appear in their names without prior written
 * permission of CollabNet.
 * 
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL COLLABNET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * ====================================================================
 * 
 * This software consists of voluntary contributions made by many
 * individuals on behalf of CollabNet.
 */

package org.tigris.helm.om;

import java.util.*;

import org.apache.turbine.om.*;
import org.apache.turbine.util.db.Criteria;
import org.apache.turbine.util.ObjectUtils;
import org.apache.turbine.util.StringUtils;
import org.apache.turbine.util.ParameterParser;
import org.apache.turbine.util.Log;
import org.apache.turbine.util.db.pool.DBConnection;

import org.tigris.helm.om.*;
import org.tigris.helm.tool.DBFlag;

/** 
 * The business object representing an event
 */
public class ClusterEvent extends BaseClusterEvent
{

    /**
     * Returns true iff this event occured after the given event.
     */
    public boolean newerThan(ClusterEvent e)
    {
        Date stamp = getStamp();
        if (stamp == null) 
        {
            return false;
        }
        else
        {
            return stamp.before(e.getStamp());
        }
    }

    /**
     * Returns true iff this event is more than the specified number of
     * milliseconds old.
     */
    public boolean ageExceeds(long maxAge)
    {
        return getStamp().before(new Date(System.currentTimeMillis()-maxAge));
    }

    public boolean isUnset()
    {
        return (getStamp() == null);
    }

    public void freshen()
    {
        setStamp(new Date());
    }
}
@


1.4
log
@Handle null timestamps.
@
text
@@


1.4.2.1
log
@Ported minimal cluster functionality so that I could also port IssueTrackingRebuildService, which builds on it.
@
text
@d99 1
a99 1
    {        
@


1.4.2.2
log
@Put in workaround for annoying but thankfully archaic Turbine bug.
@
text
@a101 19

    /**
     * Delete the event and recreate; this works around a bug in this
     * version of Turbine. 
     */
    public void replace()
        throws Exception
    {
        String[] read = {};
        String[] write = {ClusterEventPeer.TABLE_NAME};
        DBConnection conn = ClusterEventPeer.lockTables(read,write);
        ClusterEventPeer.deleteInstance(getType().toString(), 
                                        getDescriptor().toString());
        ClusterEvent e = ClusterEventPeer.retrieveInstance
            (getType().toString(), getDescriptor().toString(), conn);
        e.setStamp(getStamp());
        e.save();
        ClusterEventPeer.unlockTables(conn);
    }
@


1.4.2.3
log
@Factored out duplicate Turbine workaroudn code and got rid of table-locking deadlocks.
@
text
@d113 2
a114 15
        replace(conn);
        ClusterEventPeer.unlockTables(conn);
    }

    /**
     * Delete the event and recreate; this works around a bug in this
     * version of Turbine. 
     */
    public void replace(DBConnection conn)
        throws Exception
    {
        Criteria c = new Criteria(2)
            .add(ClusterEventPeer.TYPE, getType())
            .add(ClusterEventPeer.DESCRIPTOR, getDescriptor());        
        ClusterEventPeer.doDelete(c, conn);
d118 2
a119 1
        e.save(conn);
@


1.4.2.4
log
@Sidestep Turbine altogether for this thing that causes the quoting bug.
@
text
@d104 2
a105 1
     * Sets a new timestamp for this event in the database.
d107 1
a107 1
    public void saveNewStamp()
d110 5
a114 1
        saveNewStamp(null);
d118 2
a119 1
     * Sets a new timestamp for this event in the database.
d121 1
a121 1
    public void saveNewStamp(DBConnection conn)
d124 8
a131 18
        StringBuffer query = new StringBuffer("UPDATE ")
            .append(ClusterEventPeer.TABLE_NAME)
            .append(" SET ").append(ClusterEventPeer.STAMP).append("='now'")
            .append(" WHERE ")
            .append(ClusterEventPeer.TYPE).append("=\"").append(getType())
            .append("\" AND ")
            .append(ClusterEventPeer.DESCRIPTOR).append("=\"")
            .append(getDescriptor()).append("\"");

        String q = query.toString();
        if (conn == null)
        {
            ClusterEventPeer.executeStatement(q);
        }
        else
        {
            ClusterEventPeer.executeStatement(q, HelmPeer.DATABASE_NAME, conn);
        }
@


1.4.2.5
log
@Reinstated horrible hack notice.
@
text
@d113 1
a113 3
     * Sets a new timestamp for this event in the database.  This is a
     * horrible hack to get around an apparant bug in old versions of
     * Turbine.  
@


1.4.2.6
log
@Fixed bonehead SQL error and added better logging.
@
text
@d122 1
a122 1
            .append(" SET ").append(ClusterEventPeer.STAMP).append("=now()")
a129 1
        Log.debug(q);
@


1.4.2.7
log
@Got rid of extraneous debug.
@
text
@d130 1
@


1.3
log
@Got rid of annoying debugging.
@
text
@d73 9
a81 1
        return getStamp().before(e.getStamp());
@


1.2
log
@Fixed up cluster singleton interface and made the task runner into a cluster singleton.
@
text
@a72 1
        Log.debug("Is " + getStamp() + " newer than " + e.getStamp() + "?");
@


1.1
log
@Changed timestamp table to cluster event table.
@
text
@d73 1
@

