Return-Path:
Delivered-To: apmail-incubator-jspwiki-commits-archive@locus.apache.org
Received: (qmail 61034 invoked from network); 3 Aug 2008 12:25:51 -0000
Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2)
by minotaur.apache.org with SMTP; 3 Aug 2008 12:25:51 -0000
Received: (qmail 3911 invoked by uid 500); 3 Aug 2008 12:25:51 -0000
Delivered-To: apmail-incubator-jspwiki-commits-archive@incubator.apache.org
Received: (qmail 3899 invoked by uid 500); 3 Aug 2008 12:25:51 -0000
Mailing-List: contact jspwiki-commits-help@incubator.apache.org; run by ezmlm
Precedence: bulk
List-Help:
List-Unsubscribe:
List-Post:
List-Id:
Reply-To: jspwiki-dev@incubator.apache.org
Delivered-To: mailing list jspwiki-commits@incubator.apache.org
Received: (qmail 3890 invoked by uid 99); 3 Aug 2008 12:25:50 -0000
Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136)
by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 03 Aug 2008 05:25:50 -0700
X-ASF-Spam-Status: No, hits=-2000.0 required=10.0
tests=ALL_TRUSTED
X-Spam-Check-By: apache.org
Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4)
by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 03 Aug 2008 12:25:02 +0000
Received: by eris.apache.org (Postfix, from userid 65534)
id 57585238899E; Sun, 3 Aug 2008 05:25:29 -0700 (PDT)
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: svn commit: r682149 [2/3] - in /incubator/jspwiki:
branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/url/
branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/
branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/ branch...
Date: Sun, 03 Aug 2008 12:25:26 -0000
To: jspwiki-commits@incubator.apache.org
From: ajaquith@apache.org
X-Mailer: svnmailer-1.0.8
Message-Id: <20080803122529.57585238899E@eris.apache.org>
X-Virus-Checked: Checked by ClamAV on apache.org
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/MailUtil.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/MailUtil.java?rev=682149&r1=682148&r2=682149&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/MailUtil.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/MailUtil.java Sun Aug 3 05:25:25 2008
@@ -1,21 +1,22 @@
/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
*/
package com.ecyrd.jspwiki.util;
@@ -54,8 +55,8 @@
* this is already taken care of. However, when using JNDI-supplied
* Session factories, these should be moved, not copied , to a classpath location
* where the JARs can be shared by both the JSPWiki webapp and the container. For example,
- * Tomcat 5 provides the directory $CATALINA_HOME> /common/lib
- * for storage of shared JARs; move mail.jar
and activation
+ * Tomcat 5 provides the directory $CATALINA_HOME /common/lib
+ * for storage of shared JARs; move mail.jar
and activation.jar
* there instead of keeping them in /WEB-INF/lib
.
* JavaMail configuration
* Regardless of the method used for supplying JavaMail sessions (JNDI container-managed
@@ -200,7 +201,7 @@
private static boolean c_useJndi = true;
- public static final String PROP_MAIL_AUTH = "mail.smtp.auth";
+ private static final String PROP_MAIL_AUTH = "mail.smtp.auth";
protected static final Logger log = Logger.getLogger(MailUtil.class);
@@ -211,7 +212,9 @@
protected static final String DEFAULT_MAIL_PORT = "25";
protected static final String DEFAULT_MAIL_TIMEOUT = "5000";
-
+
+ protected static final String DEFAULT_MAIL_CONN_TIMEOUT = "5000";
+
protected static final String DEFAULT_SENDER = "jspwiki@localhost";
protected static final String PROP_MAIL_JNDI_NAME = "jspwiki.mail.jndiname";
@@ -234,7 +237,8 @@
protected static final String PROP_MAIL_STARTTLS = "mail.smtp.starttls.enable";
- private static String fromAddress = null;
+ private static String c_fromAddress = null;
+
/**
* Private constructor prevents instantiation.
*/
@@ -243,7 +247,7 @@
}
/**
- *
Sends an e-mail to a specified receiver using a JavaMail Session supplied
+ *
Sends an e-mail to a specified receiver using a JavaMail Session supplied
* by a JNDI mail session factory (preferred) or a locally initialized
* session based on properties in jspwiki.properties
.
* See the top-level JavaDoc for this class for a description of
@@ -262,11 +266,11 @@
* @param to the receiver
* @param subject the subject line of the message
* @param content the contents of the mail message, as plain text
- * @throws AddressException
- * @throws MessagingException
+ * @throws AddressException If the address is invalid
+ * @throws MessagingException If the message cannot be sent.
*/
public static void sendMessage(WikiEngine engine, String to, String subject, String content)
- throws AddressException, MessagingException
+ throws AddressException, MessagingException
{
Properties props = engine.getWikiProperties();
Session session = getMailSession(engine);
@@ -276,7 +280,7 @@
{
// Create and address the message
MimeMessage msg = new MimeMessage(session);
- msg.setFrom(new InternetAddress(fromAddress));
+ msg.setFrom(new InternetAddress(c_fromAddress));
msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to, false));
msg.setSubject(subject);
msg.setText(content, "UTF-8");
@@ -286,7 +290,8 @@
Transport.send(msg);
if (log.isInfoEnabled())
{
- log.info("Sent e-mail to=" + to + ", subject=\"" + subject + "\", jndi=" + (c_useJndi ? TRUE : FALSE));
+ log.info("Sent e-mail to=" + to + ", subject=\"" + subject + "\", used "
+ + (c_useJndi ? "JNDI" : "standalone") + " mail session.");
}
}
catch (MessagingException e)
@@ -307,19 +312,31 @@
*/
protected static String getSenderEmailAddress(Session pSession, Properties pProperties)
{
- if (fromAddress == null)
+ if( c_fromAddress == null )
{
- // First, attempt to get the email address from the JNDI Mail Session.
- if (pSession != null && c_useJndi)
+ // First, attempt to get the email address from the JNDI Mail
+ // Session.
+ if( pSession != null && c_useJndi )
+ {
+ c_fromAddress = pSession.getProperty( MailUtil.PROP_MAIL_SENDER );
+ }
+ // If unsuccessful, get the email address from the properties or
+ // default.
+ if( c_fromAddress == null )
{
- fromAddress = pSession.getProperty(MailUtil.PROP_MAIL_SENDER);
+ c_fromAddress = pProperties.getProperty( PROP_MAIL_SENDER, DEFAULT_SENDER ).trim();
+ if( log.isDebugEnabled() )
+ log.debug( "Attempt to get the sender's mail address from the JNDI mail session failed, will use \""
+ + c_fromAddress + "\" (configured via jspwiki.properties or the internal default)." );
}
- // If unsuccessful, get the email address from the properties or default.
- if (fromAddress == null) {
- fromAddress = pProperties.getProperty(PROP_MAIL_SENDER, DEFAULT_SENDER).trim();
+ else
+ {
+ if( log.isDebugEnabled() )
+ log.debug( "Attempt to get the sender's mail address from the JNDI mail session was successful (" + c_fromAddress
+ + ")." );
}
}
- return fromAddress;
+ return c_fromAddress;
}
/**
@@ -336,6 +353,8 @@
if (c_useJndi)
{
// Try getting the Session from the JNDI factory first
+ if ( log.isDebugEnabled() )
+ log.debug("Try getting a mail session via JNDI name \"" + jndiName + "\".");
try
{
result = getJNDIMailSession(jndiName);
@@ -344,12 +363,16 @@
{
// Oops! JNDI factory must not be set up
c_useJndi = false;
+ if ( log.isInfoEnabled() )
+ log.info("Unable to get a mail session via JNDI, will use custom settings at least until next startup.");
}
}
// JNDI failed; so, get the Session from the standalone factory
if (result == null)
{
+ if ( log.isDebugEnabled() )
+ log.debug("Getting a standalone mail session configured by jspwiki.properties and/or internal default values.");
result = getStandaloneMailSession(props);
}
return result;
@@ -372,6 +395,8 @@
String port = props.getProperty( PROP_MAIL_PORT, DEFAULT_MAIL_PORT );
String account = props.getProperty( PROP_MAIL_ACCOUNT );
String password = props.getProperty( PROP_MAIL_PASSWORD );
+ String timeout = props.getProperty( PROP_MAIL_TIMEOUT, DEFAULT_MAIL_TIMEOUT);
+ String conntimeout = props.getProperty( PROP_MAIL_CONNECTION_TIMEOUT, DEFAULT_MAIL_CONN_TIMEOUT );
boolean starttls = TextUtil.getBooleanProperty( props, PROP_MAIL_STARTTLS, true);
boolean useAuthentication = account != null && account.length() > 0;
@@ -381,8 +406,8 @@
// Set JavaMail properties
mailProps.put( PROP_MAIL_HOST, host );
mailProps.put( PROP_MAIL_PORT, port );
- mailProps.put( PROP_MAIL_TIMEOUT, DEFAULT_MAIL_TIMEOUT );
- mailProps.put( PROP_MAIL_CONNECTION_TIMEOUT, DEFAULT_MAIL_TIMEOUT );
+ mailProps.put( PROP_MAIL_TIMEOUT, timeout );
+ mailProps.put( PROP_MAIL_CONNECTION_TIMEOUT, conntimeout );
mailProps.put( PROP_MAIL_STARTTLS, starttls ? TRUE : FALSE );
// Add SMTP authentication if required
@@ -401,7 +426,9 @@
if ( log.isDebugEnabled() )
{
- String mailServer = host + ":" + port + ", auth=" + ( useAuthentication ? TRUE : FALSE );
+ String mailServer = host + ":" + port + ", account=" + account + ", password not displayed, timeout="
+ + timeout + ", connectiontimeout=" + conntimeout + ", starttls.enable=" + starttls
+ + ", use authentication=" + ( useAuthentication ? TRUE : FALSE );
log.debug( "JavaMail session obtained from standalone mail factory: " + mailServer );
}
return session;
@@ -426,12 +453,12 @@
}
catch( NamingException e )
{
- log.warn( "JavaMail initialization error: " + e.getMessage() );
+ log.warn( "JNDI mail session initialization error: " + e.getMessage() );
throw e;
}
if ( log.isDebugEnabled() )
{
- log.debug( "JavaMail session obtained from JNDI mail factory: " + jndiName );
+ log.debug( "mail session obtained from JNDI mail factory: " + jndiName );
}
return session;
}
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/PriorityList.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/PriorityList.java?rev=682149&r1=682148&r2=682149&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/PriorityList.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/PriorityList.java Sun Aug 3 05:25:25 2008
@@ -1,27 +1,27 @@
/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2003 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
*/
package com.ecyrd.jspwiki.util;
import java.util.AbstractList;
import java.util.ArrayList;
-import java.util.List;
/**
* Builds a simple, priority-based List implementation. The list
@@ -31,13 +31,12 @@
*
* Priority is an integer, and the list is sorted in descending order
* (that is, 100 is before 10 is before 0 is before -40).
- *
- * @author Janne Jalkanen
*/
-public class PriorityList
- extends AbstractList
+@SuppressWarnings("unchecked")
+public class PriorityList
+ extends AbstractList
{
- private final List- > m_elements = new ArrayList
- >();
+ private ArrayList
m_elements = new ArrayList();
/**
* This is the default priority, which is used if no priority
@@ -52,13 +51,13 @@
* @param o Object to add.
* @param priority Priority.
*/
- public void add( T o, int priority )
+ public void add( Object o, int priority )
{
int i = 0;
for( ; i < m_elements.size(); i++ )
{
- Item item = m_elements.get(i);
+ Item item = (Item) m_elements.get(i);
if( item.m_priority < priority )
{
@@ -66,7 +65,7 @@
}
}
- Item newItem = new Item();
+ Item newItem = new Item();
newItem.m_priority = priority;
newItem.m_object = o;
@@ -79,7 +78,7 @@
* @param o Object to add.
* @return true, as per the general Collections.add contract.
*/
- public boolean add( T o )
+ public boolean add( Object o )
{
add( o, DEFAULT_PRIORITY );
@@ -92,9 +91,9 @@
* @param index The index.
* @return The object at the list at the position "index".
*/
- public T get( int index )
+ public Object get( int index )
{
- return m_elements.get( index ).m_object;
+ return ((Item)m_elements.get( index )).m_object;
}
/**
@@ -110,9 +109,9 @@
/**
* Provides a holder for the priority-object 2-tuple.
*/
- private static class Item
+ private static class Item
{
public int m_priority;
- public T m_object;
+ public Object m_object;
}
}
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/ProviderConverter.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/ProviderConverter.java?rev=682149&r1=682148&r2=682149&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/ProviderConverter.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/ProviderConverter.java Sun Aug 3 05:25:25 2008
@@ -1,21 +1,22 @@
/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
*/
package com.ecyrd.jspwiki.util;
@@ -39,7 +40,6 @@
* It leaves the converted directory in /tmp/converter-tmp/
* and does not touch the original in any way.
*
- * @author jalkanen
*
* @since
*/
@@ -147,7 +147,7 @@
}
/**
- * @param args
+ * @param args Normal arguments.
*/
public static void main( String[] args )
throws Exception
Added: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/Serializer.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/Serializer.java?rev=682149&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/Serializer.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/Serializer.java Sun Aug 3 05:25:25 2008
@@ -0,0 +1,103 @@
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+package com.ecyrd.jspwiki.util;
+
+import java.io.*;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.codec.binary.Base64;
+
+/**
+ * Provides static helper functions for serializing different objects.
+ *
+ * @since 2.8
+ */
+public final class Serializer
+{
+ /**
+ * Prefix used to indicated that a serialized item was encoded with Base64.
+ */
+ protected static final String BASE64_PREFIX = "base64 ";
+
+ /**
+ * Prevent instantiation.
+ */
+ private Serializer()
+ {}
+
+ /**
+ * Deserializes a Base64-encoded String into a HashMap. Both the keys and values
+ * must implement {@link java.io.Serializable}.
+ * @param rawString the String contents containing the map to be deserialized
+ * @return the attributes, parsed into a Map
+ * @throws IOException if the contents cannot be parsed for any reason
+ */
+ @SuppressWarnings("unchecked")
+ public static Map deserializeFromBase64( String rawString ) throws IOException
+ {
+ // Decode from Base64-encoded String to byte array
+ byte[] decodedBytes = Base64.decodeBase64( rawString.getBytes("UTF-8") );
+
+ // Deserialize from the input stream to the Map
+ InputStream bytesIn = new ByteArrayInputStream( decodedBytes );
+ ObjectInputStream in = new ObjectInputStream( bytesIn );
+ HashMap attributes;
+ try
+ {
+ attributes = (HashMap)in.readObject();
+ }
+ catch ( ClassNotFoundException e )
+ {
+ throw new IOException( "Could not deserialiaze user profile attributes. Reason: " + e.getMessage() );
+ }
+ finally
+ {
+ in.close();
+ }
+ return attributes;
+ }
+
+ /**
+ * Serializes a Map and formats it into a Base64-encoded String. For ease of serialization, the Map contents
+ * are first copied into a HashMap, then serialized into a byte array that is encoded as a Base64 String.
+ * @param map the Map to serialize
+ * @return a String representing the serialized form of the Map
+ * @throws IOException If serialization cannot be done
+ */
+ public static String serializeToBase64( Map map ) throws IOException
+ {
+ // Load the Map contents into a defensive HashMap
+ HashMap serialMap = new HashMap();
+ serialMap.putAll( map );
+
+ // Serialize the Map to an output stream
+ ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream( bytesOut );
+ out.writeObject( serialMap );
+ out.close();
+
+ // Transform to Base64-encoded String
+ byte[] result = Base64.encodeBase64( bytesOut.toByteArray() );
+ return new String( result ) ;
+ }
+
+}
Added: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/TimedCounterList.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/TimedCounterList.java?rev=682149&view=auto
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/TimedCounterList.java (added)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/TimedCounterList.java Sun Aug 3 05:25:25 2008
@@ -0,0 +1,245 @@
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+package com.ecyrd.jspwiki.util;
+
+import java.util.AbstractList;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+/**
+ * Provides a List in which all items store their addition time. This
+ * can then be used to clean the list from old items.
+ *
+ * This class is thread-safe - all modifications are blocking, but
+ * reading is non-blocking (unless a write is ongoing).
+ *
+ * @param The class you wish to store here
+ * @since 2.8
+ */
+public class TimedCounterList extends AbstractList
+{
+ private ArrayList> m_list = new ArrayList>();
+ private ReadWriteLock m_lock = new ReentrantReadWriteLock();
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public T set( int index, T element )
+ {
+ m_lock.writeLock().lock();
+
+ T t;
+
+ try
+ {
+ t = m_list.set(index,new CounterItem(element)).m_obj;
+ }
+ finally
+ {
+ m_lock.writeLock().unlock();
+ }
+
+ return t;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public T get( int index )
+ {
+ m_lock.readLock().lock();
+
+ T t;
+
+ try
+ {
+ t = m_list.get(index).m_obj;
+ }
+ finally
+ {
+ m_lock.readLock().unlock();
+ }
+
+ return t;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int size()
+ {
+ m_lock.readLock().lock();
+ int size = 0;
+
+ try
+ {
+ size = m_list.size();
+ }
+ finally
+ {
+ m_lock.readLock().unlock();
+ }
+
+ return size;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void add( int index, T element )
+ {
+ m_lock.writeLock().lock();
+
+ try
+ {
+ m_list.add(index, new CounterItem(element));
+ }
+ finally
+ {
+ m_lock.writeLock().unlock();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public T remove( int index )
+ {
+ m_lock.writeLock().lock();
+ T t;
+
+ try
+ {
+ t = m_list.remove( index ).m_obj;
+ }
+ finally
+ {
+ m_lock.writeLock().unlock();
+ }
+
+ return t;
+ }
+
+ /**
+ * Returns the count how many times this object is available in
+ * this list, using equals().
+ *
+ * @param obj The object to count.
+ * @return The count of the objects.
+ */
+ public int count( T obj )
+ {
+ int c = 0;
+ m_lock.readLock().lock();
+
+ try
+ {
+ for( CounterItem i : m_list )
+ {
+ if( i.m_obj.equals( obj ) )
+ {
+ c++;
+ }
+ }
+ }
+ finally
+ {
+ m_lock.readLock().unlock();
+ }
+
+ return c;
+ }
+
+ /**
+ * Performs a cleanup of all items older than maxage.
+ *
+ * @param maxage The maximum age in milliseconds after an item is removed.
+ */
+ public void cleanup( long maxage )
+ {
+ m_lock.writeLock().lock();
+
+ try
+ {
+ long now = System.currentTimeMillis();
+
+ for( Iterator> i = m_list.iterator(); i.hasNext(); )
+ {
+ CounterItem ci = i.next();
+
+ long age = now - ci.m_addTime;
+
+ if( age > maxage )
+ {
+ i.remove();
+ }
+ }
+ }
+ finally
+ {
+ m_lock.writeLock().unlock();
+ }
+ }
+
+ /**
+ * Returns the time when this particular item was added on the list.
+ *
+ * @param index The index of the object.
+ * @return The addition time in milliseconds (@see System.currentTimeMillis()).
+ */
+ public long getAddTime( int index )
+ {
+ m_lock.readLock().lock();
+ long res = 0;
+
+ try
+ {
+ res = m_list.get( index ).m_addTime;
+ }
+ finally
+ {
+ m_lock.readLock().unlock();
+ }
+
+ return res;
+ }
+
+ private static class CounterItem
+ {
+ private E m_obj;
+ private long m_addTime;
+
+ public CounterItem(E o)
+ {
+ m_addTime = System.currentTimeMillis();
+ m_obj = o;
+ }
+ }
+
+
+}
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/WatchDog.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/WatchDog.java?rev=682149&r1=682148&r2=682149&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/WatchDog.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/WatchDog.java Sun Aug 3 05:25:25 2008
@@ -1,22 +1,23 @@
-/*
- JSPWiki - a JSP-based WikiWiki clone.
+/*
+ JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2005 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
package com.ecyrd.jspwiki.util;
import java.lang.ref.WeakReference;
@@ -44,7 +45,6 @@
* the Thread is dead, and will stop itself accordingly. However, this object
* is not automatically released, so you might want to check it out after a while.
*
- * @author Janne Jalkanen
* @since 2.4.92
*/
public final class WatchDog
@@ -54,9 +54,11 @@
private boolean m_enabled = true;
private WikiEngine m_engine;
- private static Logger log = Logger.getLogger(WatchDog.class.getName());
+ private Logger log = Logger.getLogger(WatchDog.class.getName());
- private static HashMap> c_kennel = new HashMap>();
+ private static HashMap> c_kennel =
+ new HashMap>();
+
private static WikiBackgroundThread c_watcherThread;
/**
@@ -74,7 +76,7 @@
Thread t = Thread.currentThread();
WatchDog wd = null;
- WeakReference w = c_kennel.get( new Integer(t.hashCode()) );
+ WeakReference w = c_kennel.get( t.hashCode() );
if( w != null ) wd = w.get();
@@ -85,7 +87,7 @@
synchronized( c_kennel )
{
- c_kennel.put( new Integer(t.hashCode()), w );
+ c_kennel.put( t.hashCode(), w );
}
}
@@ -142,9 +144,11 @@
synchronized( c_kennel )
{
- for( Map.Entry> e : c_kennel.entrySet() )
+ for( Iterator i = c_kennel.entrySet().iterator(); i.hasNext(); )
{
- WeakReference w = e.getValue();
+ Map.Entry e = (Map.Entry) i.next();
+
+ WeakReference w = (WeakReference) e.getValue();
//
// Remove expired as well
@@ -338,8 +342,6 @@
/**
* This is the chief watchdog thread.
*
- * @author jalkanen
- *
*/
private static class WatchDogThread extends WikiBackgroundThread
{
@@ -370,13 +372,17 @@
*/
public void backgroundTask() throws Exception
{
+ if( c_kennel == null ) return;
+
synchronized( c_kennel )
{
- for( Map.Entry> entry : c_kennel.entrySet() )
+ for( Iterator i = c_kennel.entrySet().iterator(); i.hasNext(); )
{
- WeakReference wr = entry.getValue();
+ Map.Entry entry = (Map.Entry) i.next();
- WatchDog w = wr.get();
+ WeakReference wr = (WeakReference) entry.getValue();
+
+ WatchDog w = (WatchDog) wr.get();
if( w != null )
{
@@ -399,8 +405,6 @@
/**
* A class which just stores the state in our State stack.
- *
- * @author Janne Jalkanen
*/
private static class State
{
@@ -428,9 +432,6 @@
/**
* This class wraps a Thread so that it can become Watchable.
- *
- * @author Janne Jalkanen
- *
*/
private static class ThreadWrapper implements Watchable
{
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/Watchable.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/Watchable.java?rev=682149&r1=682148&r2=682149&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/Watchable.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/Watchable.java Sun Aug 3 05:25:25 2008
@@ -1,21 +1,22 @@
/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
*/
package com.ecyrd.jspwiki.util;
@@ -23,7 +24,6 @@
* A watchdog needs something to watch. If you wish to be watched,
* implement this interface.
*
- * @author jalkanen
*/
public interface Watchable
{
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/WikiBackgroundThread.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/WikiBackgroundThread.java?rev=682149&r1=682148&r2=682149&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/WikiBackgroundThread.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/util/WikiBackgroundThread.java Sun Aug 3 05:25:25 2008
@@ -1,21 +1,22 @@
/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
*/
package com.ecyrd.jspwiki.util;
@@ -63,6 +64,8 @@
/**
* Listens for {@link com.ecyrd.jspwiki.event.WikiEngineEvent#SHUTDOWN}
* and, if detected, marks the thread for death.
+ *
+ * @param event {@inheritDoc}
* @see com.ecyrd.jspwiki.event.WikiEventListener#actionPerformed(com.ecyrd.jspwiki.event.WikiEvent)
*/
public final void actionPerformed( WikiEvent event )
@@ -80,6 +83,8 @@
/**
* Abstract method that performs the actual work for this
* background thread; subclasses must implement this method.
+ *
+ * @throws Exception Any exception can be thrown
*/
public abstract void backgroundTask() throws Exception;
@@ -176,6 +181,8 @@
* Executes a task after shutdown signal was detected.
* By default, this method does nothing; override it
* to implement custom functionality.
+ *
+ * @throws Exception Any exception can be thrown.
*/
public void shutdownTask() throws Exception
{
@@ -186,6 +193,8 @@
* method starts, but before the {@link #backgroundTask()}
* task executes. By default, this method does nothing;
* override it to implement custom functionality.
+ *
+ * @throws Exception Any exception can be thrown.
*/
public void startupTask() throws Exception
{
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/AbstractStep.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/AbstractStep.java?rev=682149&r1=682148&r2=682149&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/AbstractStep.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/AbstractStep.java Sun Aug 3 05:25:25 2008
@@ -1,24 +1,26 @@
-/*
+/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2007 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
*/
package com.ecyrd.jspwiki.workflow;
+import java.io.Serializable;
import java.security.Principal;
import java.util.*;
@@ -45,7 +47,7 @@
private boolean m_completed;
- private final Map m_successors;
+ private final Map m_successors;
private Workflow m_workflow;
@@ -76,7 +78,7 @@
m_errors = new ArrayList();
m_outcome = Outcome.STEP_CONTINUE;
m_key = messageKey;
- m_successors = new LinkedHashMap();
+ m_successors = new LinkedHashMap();
}
/**
@@ -109,15 +111,16 @@
/**
* {@inheritDoc}
*/
- public final Collection getAvailableOutcomes()
+ public final Collection getAvailableOutcomes()
{
- return Collections.unmodifiableCollection( m_successors.keySet() );
+ Set outcomes = m_successors.keySet();
+ return Collections.unmodifiableCollection( outcomes );
}
/**
* {@inheritDoc}
*/
- public final List getErrors()
+ public final List getErrors()
{
return Collections.unmodifiableList( m_errors );
}
@@ -143,11 +146,11 @@
/**
* {@inheritDoc}
*/
- public final Object[] getMessageArguments()
+ public final Serializable[] getMessageArguments()
{
if ( m_workflow == null )
{
- return new Object[0];
+ return new Serializable[0];
}
return m_workflow.getMessageArguments();
}
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/Decision.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/Decision.java?rev=682149&r1=682148&r2=682149&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/Decision.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/Decision.java Sun Aug 3 05:25:25 2008
@@ -1,21 +1,22 @@
-/*
+/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2007 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
*/
package com.ecyrd.jspwiki.workflow;
@@ -30,16 +31,16 @@
*
* AbstractStep subclass that asks an actor Principal to choose an Outcome on
* behalf of an owner (also a Principal). The actor "makes the decision" by
- * calling the {@link #decide(Outcome)} method. When this method is called,
- * it will set the Decision's Outcome to the one supplied. If the parent
- * Workflow is in the {@link Workflow#WAITING} state, it will be re-started.
- * Any checked WikiExceptions thrown by the workflow after re-start will be
- * re-thrown to callers.
+ * calling the {@link #decide(Outcome)} method. When this method is called, it
+ * will set the Decision's Outcome to the one supplied. If the parent Workflow
+ * is in the {@link Workflow#WAITING} state, it will be re-started. Any checked
+ * WikiExceptions thrown by the workflow after re-start will be re-thrown to
+ * callers.
*
*
- * When a Decision completes, its
- * {@link #isCompleted()} method returns true
. It also tells its
- * parent WorkflowManager to remove it from the list of pending tasks by calling
+ * When a Decision completes, its {@link #isCompleted()} method returns
+ * true
. It also tells its parent WorkflowManager to remove it
+ * from the list of pending tasks by calling
* {@link DecisionQueue#remove(Decision)}.
*
*
@@ -47,7 +48,8 @@
* arbitrary key-value pairs called "facts." These facts can be presented by the
* user interface to show details the actor needs to know about. Facts are added
* by calling classes to the Decision, in order of expected presentation, by the
- * {@link #addFact(Fact)} method. They can be retrieved, in order, via {@link #getFacts()}.
+ * {@link #addFact(Fact)} method. They can be retrieved, in order, via
+ * {@link #getFacts()}.
*
*
* @author Andrew Jaquith
@@ -64,63 +66,69 @@
private final List m_facts;
/**
- * Constructs a new Decision for a required "actor" Principal, having a default Outcome.
+ * Constructs a new Decision for a required "actor" Principal, having a
+ * default Outcome.
+ *
* @param workflow the parent Workflow object
- * @param messageKey the i18n message key that represents the message the actor will see
- * @param actor the Principal (e.g. , a WikiPrincipal, Role, GroupPrincipal) who is
- * required to select an appropriate Outcome
- * @param defaultOutcome the Outcome that the user interface will recommend as the
- * default choice
+ * @param messageKey the i18n message key that represents the message the
+ * actor will see
+ * @param actor the Principal (e.g. , a WikiPrincipal, Role,
+ * GroupPrincipal) who is required to select an appropriate
+ * Outcome
+ * @param defaultOutcome the Outcome that the user interface will recommend
+ * as the default choice
*/
- public Decision(Workflow workflow, String messageKey, Principal actor, Outcome defaultOutcome)
+ public Decision( Workflow workflow, String messageKey, Principal actor, Outcome defaultOutcome )
{
- super(workflow, messageKey);
+ super( workflow, messageKey );
m_actor = actor;
m_defaultOutcome = defaultOutcome;
m_facts = new ArrayList();
- addSuccessor(defaultOutcome, null);
+ addSuccessor( defaultOutcome, null );
}
/**
* Appends a Fact to the list of Facts associated with this Decision.
- *
- * @param fact
- * the new fact to add
- */
- public final void addFact(Fact fact)
- {
- m_facts.add(fact);
+ *
+ * @param fact the new fact to add
+ */
+ public final void addFact( Fact fact )
+ {
+ m_facts.add( fact );
}
/**
- * Sets this Decision's outcome, and restarts the parent Workflow if
- * it is in the {@link Workflow#WAITING} state and this Decision is
- * its currently active Step. Any checked WikiExceptions thrown by
- * the workflow after re-start will be re-thrown to callers.
- * This method cannot be invoked if the Decision is not the
- * current Workflow step; all other invocations will throw
- * an IllegalStateException. If the Outcome supplied to this method
- * is one one of the Outcomes returned by {@link #getAvailableOutcomes()},
- * an IllegalArgumentException will be thrown.
- *
- * @param outcome
- * the Outcome of the Decision
- * @throws WikiException
- * if the act of restarting the Workflow throws an exception
+ *
+ * Sets this Decision's outcome, and restarts the parent Workflow if it is
+ * in the {@link Workflow#WAITING} state and this Decision is its currently
+ * active Step. Any checked WikiExceptions thrown by the workflow after
+ * re-start will be re-thrown to callers.
+ *
+ *
+ * This method cannot be invoked if the Decision is not the current Workflow
+ * step; all other invocations will throw an IllegalStateException. If the
+ * Outcome supplied to this method is one one of the Outcomes returned by
+ * {@link #getAvailableOutcomes()}, an IllegalArgumentException will be
+ * thrown.
+ *
+ *
+ * @param outcome the Outcome of the Decision
+ * @throws WikiException if the act of restarting the Workflow throws an
+ * exception
*/
- public void decide(Outcome outcome) throws WikiException
+ public void decide( Outcome outcome ) throws WikiException
{
- super.setOutcome(outcome);
+ super.setOutcome( outcome );
// If current workflow is waiting for input, restart it and remove
// Decision from DecisionQueue
Workflow w = getWorkflow();
- if (w.getCurrentState() == Workflow.WAITING && this.equals(w.getCurrentStep()))
+ if( w.getCurrentState() == Workflow.WAITING && this.equals( w.getCurrentStep() ) )
{
WorkflowManager wm = w.getWorkflowManager();
- if (wm != null)
+ if( wm != null )
{
- wm.getDecisionQueue().remove(this);
+ wm.getDecisionQueue().remove( this );
}
// Restart workflow
w.restart();
@@ -132,21 +140,22 @@
* if the current Outcome isn't a completion (which will be true if the
* {@link #decide(Outcome)} method hasn't been executed yet. This method
* will also add the Decision to the associated DecisionQueue.
+ *
* @return the Outcome of the execution
* @throws WikiException never
*/
public Outcome execute() throws WikiException
{
- if (getOutcome().isCompletion())
+ if( getOutcome().isCompletion() )
{
return getOutcome();
}
// Put decision in the DecisionQueue
WorkflowManager wm = getWorkflow().getWorkflowManager();
- if (wm != null)
+ if( wm != null )
{
- wm.getDecisionQueue().add(this);
+ wm.getDecisionQueue().add( this );
}
// Indicate we are waiting for user input
@@ -165,7 +174,7 @@
* Returns the default or suggested outcome, which must be one of those
* returned by {@link #getAvailableOutcomes()}. This method is guaranteed
* to return a non-null
Outcome.
- *
+ *
* @return the default outcome.
*/
public Outcome getDefaultOutcome()
@@ -176,19 +185,19 @@
/**
* Returns the Facts associated with this Decision, in the order in which
* they were added.
- *
+ *
* @return the list of Facts
*/
- public final List getFacts()
+ public final List getFacts()
{
- return Collections.unmodifiableList(m_facts);
+ return Collections.unmodifiableList( m_facts );
}
/**
* Returns the unique identifier for this Decision. Normally, this ID is
* programmatically assigned when the Decision is added to the
* DecisionQueue.
- *
+ *
* @return the identifier
*/
public final int getId()
@@ -199,7 +208,7 @@
/**
* Returns true
if the Decision can be reassigned to another
* actor. This implementation always returns true
.
- *
+ *
* @return the result
*/
public boolean isReassignable()
@@ -208,31 +217,30 @@
}
/**
- * Reassigns the Decision to a new actor (that is, provide an outcome).
- * If the Decision is not reassignable, this method throws
- * an IllegalArgumentException.
- *
+ * Reassigns the Decision to a new actor (that is, provide an outcome). If
+ * the Decision is not reassignable, this method throws an
+ * IllegalArgumentException.
+ *
* @param actor the actor to reassign the Decision to
*/
- public final synchronized void reassign(Principal actor)
+ public final synchronized void reassign( Principal actor )
{
- if (isReassignable())
+ if( isReassignable() )
{
m_actor = actor;
}
else
{
- throw new IllegalArgumentException("Decision cannot be reassigned.");
+ throw new IllegalArgumentException( "Decision cannot be reassigned." );
}
}
/**
* Sets the unique identfier for this Decision.
- *
- * @param id
- * the identifier
+ *
+ * @param id the identifier
*/
- public final void setId(int id)
+ public final void setId( int id )
{
m_id = id;
}
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/DecisionQueue.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/DecisionQueue.java?rev=682149&r1=682148&r2=682149&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/DecisionQueue.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/DecisionQueue.java Sun Aug 3 05:25:25 2008
@@ -1,24 +1,26 @@
-/*
+/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2007 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
*/
package com.ecyrd.jspwiki.workflow;
+import java.io.Serializable;
import java.security.Principal;
import java.util.ArrayList;
import java.util.Collection;
@@ -34,8 +36,9 @@
* @author Andrew Jaquith
* @since 2.5
*/
-public class DecisionQueue
+public class DecisionQueue implements Serializable
{
+ private static final long serialVersionUID = -7172912793410302533L;
private LinkedList m_queue = new LinkedList();
@@ -56,10 +59,10 @@
* @param decision
* the Decision to add
*/
- protected synchronized void add(Decision decision)
+ protected synchronized void add( Decision decision )
{
- m_queue.addLast(decision);
- decision.setId(nextId());
+ m_queue.addLast( decision );
+ decision.setId( nextId() );
}
/**
@@ -72,7 +75,7 @@
*/
protected Decision[] decisions()
{
- return m_queue.toArray(new Decision[m_queue.size()]);
+ return m_queue.toArray( new Decision[m_queue.size()] );
}
/**
@@ -81,7 +84,7 @@
*/
protected synchronized void remove(Decision decision)
{
- m_queue.remove(decision);
+ m_queue.remove( decision );
}
/**
@@ -95,29 +98,29 @@
* the wiki session
* @return the collection of Decisions, which may be empty
*/
- public Collection getActorDecisions(WikiSession session)
+ public Collection getActorDecisions(WikiSession session)
{
ArrayList decisions = new ArrayList();
- if (session.isAuthenticated())
+ if ( session.isAuthenticated() )
{
Principal[] principals = session.getPrincipals();
Principal[] rolePrincipals = session.getRoles();
for ( Decision decision : m_queue )
{
// Iterate through the Principal set
- for (int i = 0; i < principals.length; i++)
+ for ( Principal principal : principals )
{
- if (principals[i].equals(decision.getActor()))
+ if ( principal.equals( decision.getActor() ) )
{
- decisions.add(decision);
+ decisions.add( decision );
}
}
// Iterate through the Role set
- for (int i = 0; i < rolePrincipals.length; i++)
+ for ( Principal principal : rolePrincipals )
{
- if (rolePrincipals[i].equals(decision.getActor()))
+ if ( principal.equals( decision.getActor() ) )
{
- decisions.add(decision);
+ decisions.add( decision );
}
}
}
@@ -137,12 +140,12 @@
* @throws WikiException if the succeeding Step cannot start
* for any reason
*/
- public void decide(Decision decision, Outcome outcome) throws WikiException
+ public void decide( Decision decision, Outcome outcome ) throws WikiException
{
- decision.decide(outcome);
- if (decision.isCompleted())
+ decision.decide( outcome );
+ if ( decision.isCompleted() )
{
- remove(decision);
+ remove( decision );
}
// TODO: We should fire an event indicating the Outcome, and whether the
@@ -161,12 +164,12 @@
{
if (decision.isReassignable())
{
- decision.reassign(owner);
+ decision.reassign( owner );
// TODO: We should fire an event indicating the reassignment
return;
}
- throw new IllegalStateException("Reassignments not allowed for this decision.");
+ throw new IllegalStateException( "Reassignments not allowed for this decision." );
}
/**
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/DecisionRequiredException.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/DecisionRequiredException.java?rev=682149&r1=682148&r2=682149&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/DecisionRequiredException.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/DecisionRequiredException.java Sun Aug 3 05:25:25 2008
@@ -1,21 +1,22 @@
-/*
+/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2004 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
*/
package com.ecyrd.jspwiki.workflow;
@@ -39,8 +40,8 @@
* Constructs a new exception.
* @param message the message
*/
- public DecisionRequiredException(String message)
+ public DecisionRequiredException( String message )
{
- super(message);
+ super( message );
}
}
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/Fact.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/Fact.java?rev=682149&r1=682148&r2=682149&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/Fact.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/Fact.java Sun Aug 3 05:25:25 2008
@@ -1,39 +1,44 @@
/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
*/
package com.ecyrd.jspwiki.workflow;
+import java.io.Serializable;
+
/**
- * Represents a contextual artifact, which can be any Object, useful for making
+ * Represents a contextual artifact, which can be any serializable object, useful for making
* a Decision. Facts are key-value pairs, where the key is a String (message
- * key) and the value is an arbitrary Object. Generally, the supplied object's
+ * key) and the value is an arbitrary object. Generally, the supplied object's
* {@link #toString()} method should return a human-readable String. Facts are
* immutable objects.
*
* @author Andrew Jaquith
* @since 2.5
*/
-public final class Fact
+public final class Fact implements Serializable
{
+ private static final long serialVersionUID = -7459432935402796978L;
+
private final String m_key;
- private final Object m_obj;
+ private final Serializable m_obj;
/**
* Constructs a new Fact with a supplied message key and value.
@@ -43,7 +48,7 @@
* @param value
* the object to associate with the name
*/
- public Fact(String messageKey, Object value)
+ public Fact(String messageKey, Serializable value)
{
if ( messageKey == null || value == null )
{
@@ -66,7 +71,7 @@
* Returns this Fact's value.
* @return the value object
*/
- public Object getValue()
+ public Serializable getValue()
{
return m_obj;
}
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/NoSuchOutcomeException.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/NoSuchOutcomeException.java?rev=682149&r1=682148&r2=682149&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/NoSuchOutcomeException.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/NoSuchOutcomeException.java Sun Aug 3 05:25:25 2008
@@ -1,21 +1,22 @@
/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
*/
package com.ecyrd.jspwiki.workflow;
@@ -34,8 +35,8 @@
* Constructs a new exception.
* @param message the message
*/
- public NoSuchOutcomeException(String message)
+ public NoSuchOutcomeException( String message )
{
- super(message);
+ super( message );
}
}
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/Outcome.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/Outcome.java?rev=682149&r1=682148&r2=682149&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/Outcome.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/Outcome.java Sun Aug 3 05:25:25 2008
@@ -1,24 +1,27 @@
/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
*/
package com.ecyrd.jspwiki.workflow;
+import java.io.Serializable;
+
/**
* Resolution of a workflow Step, such as "approve," "deny," "hold," "task
* error," or other potential resolutions.
@@ -26,32 +29,34 @@
* @author Andrew Jaquith
* @since 2.5
*/
-public final class Outcome
+public final class Outcome implements Serializable
{
+ private static final long serialVersionUID = -338361947886288073L;
+
/** Complete workflow step (without errors) */
- public static final Outcome STEP_COMPLETE = new Outcome("outcome.step.complete", true);
+ public static final Outcome STEP_COMPLETE = new Outcome( "outcome.step.complete", true );
/** Terminate workflow step (without errors) */
- public static final Outcome STEP_ABORT = new Outcome("outcome.step.abort", true);
+ public static final Outcome STEP_ABORT = new Outcome( "outcome.step.abort", true );
/** Continue workflow step (without errors) */
- public static final Outcome STEP_CONTINUE = new Outcome("outcome.step.continue", false);
+ public static final Outcome STEP_CONTINUE = new Outcome( "outcome.step.continue", false );
/** Acknowlege the Decision. */
- public static final Outcome DECISION_ACKNOWLEDGE = new Outcome("outcome.decision.acknowledge", true);
+ public static final Outcome DECISION_ACKNOWLEDGE = new Outcome( "outcome.decision.acknowledge", true );
/** Approve the Decision (and complete the step). */
- public static final Outcome DECISION_APPROVE = new Outcome("outcome.decision.approve", true);
+ public static final Outcome DECISION_APPROVE = new Outcome( "outcome.decision.approve", true );
/** Deny the Decision (and complete the step). */
- public static final Outcome DECISION_DENY = new Outcome("outcome.decision.deny", true);
+ public static final Outcome DECISION_DENY = new Outcome( "outcome.decision.deny", true );
/** Put the Decision on hold (and pause the step). */
- public static final Outcome DECISION_HOLD = new Outcome("outcome.decision.hold", false);
+ public static final Outcome DECISION_HOLD = new Outcome( "outcome.decision.hold", false );
/** Reassign the Decision to another actor (and pause the step). */
- public static final Outcome DECISION_REASSIGN = new Outcome("outcome.decision.reassign", false);
+ public static final Outcome DECISION_REASSIGN = new Outcome( "outcome.decision.reassign", false );
private static final Outcome[] OUTCOMES = new Outcome[] { STEP_COMPLETE, STEP_ABORT, STEP_CONTINUE, DECISION_ACKNOWLEDGE,
DECISION_APPROVE, DECISION_DENY, DECISION_HOLD, DECISION_REASSIGN };
@@ -69,11 +74,11 @@
* whether this Outcome should be interpreted as the logical
* completion of a Step.
*/
- private Outcome(String key, boolean completion)
+ private Outcome( String key, boolean completion )
{
- if (key == null)
+ if ( key == null )
{
- throw new IllegalArgumentException("Key cannot be null.");
+ throw new IllegalArgumentException( "Key cannot be null." );
}
m_key = key;
m_completion = completion;
@@ -110,7 +115,7 @@
*/
public int hashCode()
{
- return m_key.hashCode() * (m_completion ? 1 : 2);
+ return m_key.hashCode() * ( m_completion ? 1 : 2 );
}
/**
@@ -118,13 +123,13 @@
* @param obj the object to test
* @return true
if logically equal, false
if not
*/
- public boolean equals(Object obj)
+ public boolean equals( Object obj )
{
if (!(obj instanceof Outcome))
{
return false;
}
- return m_key.equals(((Outcome) obj).getMessageKey());
+ return m_key.equals( ( (Outcome) obj ).getMessageKey() );
}
/**
@@ -137,19 +142,19 @@
* @throws NoSuchOutcomeException
* if an Outcome matching the key isn't found.
*/
- public static Outcome forName(String key) throws NoSuchOutcomeException
+ public static Outcome forName( String key ) throws NoSuchOutcomeException
{
- if (key != null)
+ if ( key != null )
{
for (int i = 0; i < OUTCOMES.length; i++)
{
- if (OUTCOMES[i].m_key.equals(key))
+ if ( OUTCOMES[i].m_key.equals( key ) )
{
return OUTCOMES[i];
}
}
}
- throw new NoSuchOutcomeException("Outcome " + key + " not found.");
+ throw new NoSuchOutcomeException( "Outcome " + key + " not found." );
}
/**
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/SimpleDecision.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/SimpleDecision.java?rev=682149&r1=682148&r2=682149&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/SimpleDecision.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/SimpleDecision.java Sun Aug 3 05:25:25 2008
@@ -1,21 +1,22 @@
/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
*/
package com.ecyrd.jspwiki.workflow;
@@ -32,6 +33,8 @@
public class SimpleDecision extends Decision
{
+ private static final long serialVersionUID = 8192213077644617341L;
+
/**
* Constructs a new SimpleDecision assigned to a specified actor.
* @param workflow the parent Workflow
@@ -40,12 +43,12 @@
* @param actor the Principal (e.g. , WikiPrincipal,
* GroupPrincipal, Role) who will decide
*/
- public SimpleDecision(Workflow workflow, String messageKey, Principal actor)
+ public SimpleDecision( Workflow workflow, String messageKey, Principal actor )
{
- super(workflow, messageKey, actor, Outcome.DECISION_APPROVE);
+ super( workflow, messageKey, actor, Outcome.DECISION_APPROVE );
// Add the other default outcomes
- super.addSuccessor(Outcome.DECISION_DENY, null);
+ super.addSuccessor( Outcome.DECISION_DENY, null );
}
}
Modified: incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/SimpleNotification.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/SimpleNotification.java?rev=682149&r1=682148&r2=682149&view=diff
==============================================================================
--- incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/SimpleNotification.java (original)
+++ incubator/jspwiki/branches/JSPWIKI_2_9_STRIPES_BRANCH/src/com/ecyrd/jspwiki/workflow/SimpleNotification.java Sun Aug 3 05:25:25 2008
@@ -1,21 +1,22 @@
/*
JSPWiki - a JSP-based WikiWiki clone.
- Copyright (C) 2001-2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
*/
package com.ecyrd.jspwiki.workflow;
@@ -34,6 +35,8 @@
public final class SimpleNotification extends Decision
{
+ private static final long serialVersionUID = -3392947495169819527L;
+
/**
* Constructs a new SimpleNotification object with a supplied message key,
* associated Workflow, and named actor who must acknowledge the message.
@@ -49,9 +52,9 @@
* @param actor
* the Principal who will acknowledge the message
*/
- public SimpleNotification(Workflow workflow, String messageKey, Principal actor)
+ public SimpleNotification( Workflow workflow, String messageKey, Principal actor )
{
- super(workflow, messageKey, actor, Outcome.DECISION_ACKNOWLEDGE);
+ super( workflow, messageKey, actor, Outcome.DECISION_ACKNOWLEDGE );
}
/**
@@ -61,7 +64,7 @@
*/
public void acknowledge() throws WikiException
{
- this.decide( Outcome.DECISION_ACKNOWLEDGE );
+ this.decide( Outcome.DECISION_ACKNOWLEDGE );
}
/**