You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by ju...@apache.org on 2020/01/28 20:34:28 UTC
[jspwiki] 27/32: apply formatting fixes suggested by intellij
This is an automated email from the ASF dual-hosted git repository.
juanpablo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git
commit 08eec1ee807bdf2edae8867aeea30c5c2cb67f45
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Jan 24 00:56:29 2020 +0100
apply formatting fixes suggested by intellij
---
.../org/apache/wiki/event/WikiEngineEvent.java | 63 ++++++-----
.../main/java/org/apache/wiki/event/WikiEvent.java | 114 ++++++++------------
.../org/apache/wiki/event/WikiEventListener.java | 2 +-
.../java/org/apache/wiki/event/WikiEventUtils.java | 120 ++++++++-------------
.../org/apache/wiki/event/WikiPageRenameEvent.java | 55 ++++------
.../org/apache/wiki/event/WikiSecurityEvent.java | 101 +++++++----------
.../java/org/apache/wiki/event/WorkflowEvent.java | 13 ++-
7 files changed, 186 insertions(+), 282 deletions(-)
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEngineEvent.java b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEngineEvent.java
index fed4cd0..7cb6758 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEngineEvent.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEngineEvent.java
@@ -31,47 +31,45 @@ public class WikiEngineEvent extends WikiEvent {
private static final long serialVersionUID = 1829433967558773970L;
- /** Indicates a WikiEngine initialization event, fired as the
- * wiki service is being initialized (in progress). */
+ /** Indicates a WikiEngine initialization event, fired as the wiki service is being initialized (in progress). */
public static final int INITIALIZING = -1;
- /** Indicates a WikiEngine initialized event, fired after the
- * wiki service is fully available. */
+ /** Indicates a WikiEngine initialized event, fired after the wiki service is fully available. */
public static final int INITIALIZED = 0;
- /** Indicates a WikiEngine closing event, fired as a signal that
- * the wiki service is shutting down. */
+ /** Indicates a WikiEngine closing event, fired as a signal that the wiki service is shutting down. */
public static final int SHUTDOWN = 1;
- /** Indicates a WikiEngine stopped event, fired after halting the wiki service.
- * A WikiEngine in this state is not expected to provide further services.
- */
+ /**
+ * Indicates a WikiEngine stopped event, fired after halting the wiki service.
+ * A WikiEngine in this state is not expected to provide further services.
+ */
public static final int STOPPED = 2;
private WikiEngine m_engine;
/**
* Constructs an instance of this event.
- * @param eventSource the Object that is the source of the event,
- * which <b>must</b> be the WikiEngine. If it is not, this
+ *
+ * @param eventSource the Object that is the source of the event, which <b>must</b> be the WikiEngine. If it is not, this
* method thows a ClassCastException
* @param type the event type
*/
- public WikiEngineEvent( Object eventSource, int type ) {
+ public WikiEngineEvent( final Object eventSource, final int type ) {
super( eventSource, type );
- m_engine = (WikiEngine)eventSource;
+ m_engine = ( WikiEngine )eventSource;
}
/**
* Sets the type of this event.
*
- * @param type the type of this WikiEngineEvent.
+ * @param type the type of this WikiEngineEvent.
*/
- protected void setType( int type ) {
- if ( type >= INITIALIZING && type <= STOPPED ) {
- super.setType(type);
+ protected void setType( final int type ) {
+ if( type >= INITIALIZING && type <= STOPPED ) {
+ super.setType( type );
} else {
- super.setType(ERROR);
+ super.setType( ERROR );
}
}
@@ -80,18 +78,17 @@ public class WikiEngineEvent extends WikiEvent {
*
* @return the WikiEngine that spawned this event.
*/
- public WikiEngine getEngine()
- {
+ public WikiEngine getEngine() {
return m_engine;
}
- /**
+ /**
* Returns <code>true</code> if the int value is a WikiPageEvent type.
+ *
* @param type the event type
* @return the result
*/
- public static boolean isValidType( int type )
- {
+ public static boolean isValidType( final int type ) {
return type >= INITIALIZING && type <= STOPPED;
}
@@ -102,11 +99,11 @@ public class WikiEngineEvent extends WikiEvent {
*/
public final String eventName() {
switch ( getType() ) {
- case INITIALIZING: return "INITIALIZING";
- case INITIALIZED: return "INITIALIZED";
- case SHUTDOWN: return "SHUTDOWN";
- case STOPPED: return "STOPPED";
- default: return super.eventName();
+ case INITIALIZING: return "INITIALIZING";
+ case INITIALIZED: return "INITIALIZED";
+ case SHUTDOWN: return "SHUTDOWN";
+ case STOPPED: return "STOPPED";
+ default: return super.eventName();
}
}
@@ -117,11 +114,11 @@ public class WikiEngineEvent extends WikiEvent {
*/
public final String getTypeDescription() {
switch ( getType() ) {
- case INITIALIZING: return "wiki engine initializing";
- case INITIALIZED: return "wiki engine initialized";
- case SHUTDOWN: return "wiki engine shutting down";
- case STOPPED: return "wiki engine stopped";
- default: return super.getTypeDescription();
+ case INITIALIZING: return "wiki engine initializing";
+ case INITIALIZED: return "wiki engine initialized";
+ case SHUTDOWN: return "wiki engine shutting down";
+ case STOPPED: return "wiki engine stopped";
+ default: return super.getTypeDescription();
}
}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEvent.java b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEvent.java
index 22fcd5d..7ee9a96 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEvent.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEvent.java
@@ -26,8 +26,8 @@ import java.util.EventObject;
*
* @since 2.3.79
*/
-public abstract class WikiEvent extends EventObject
-{
+public abstract class WikiEvent extends EventObject {
+
private static final long serialVersionUID = 1829433967558773960L;
/** Indicates a exception or error state. */
@@ -42,14 +42,13 @@ public abstract class WikiEvent extends EventObject
// ............
-
- /**
+ /**
* Constructs an instance of this event.
+ *
* @param src the Object that is the source of the event.
- * @param type the event type.
+ * @param type the event type.
*/
- public WikiEvent( Object src, int type )
- {
+ public WikiEvent( final Object src, final int type ) {
super( src );
m_when = System.currentTimeMillis();
setType( type );
@@ -61,108 +60,85 @@ public abstract class WikiEvent extends EventObject
* @return the typed object to which the event applied.
*/
@SuppressWarnings("unchecked")
- public <T> T getSrc()
- {
- return (T) super.getSource();
+ public < T > T getSrc() {
+ return ( T )super.getSource();
}
+ /**
+ * Returns the timestamp of when this WikiEvent occurred.
+ *
+ * @return this event's timestamp
+ * @since 2.4.74
+ */
+ public long getWhen() {
+ return m_when;
+ }
/**
- * Returns the timestamp of when this WikiEvent occurred.
- *
- * @return this event's timestamp
- * @since 2.4.74
- */
- public long getWhen()
- {
- return m_when;
- }
-
-
- /**
- * Sets the type of this event. Validation of acceptable
- * type values is the responsibility of each subclass.
+ * Sets the type of this event. Validation of acceptable type values is the responsibility of each subclass.
*
- * @param type the type of this WikiEvent.
+ * @param type the type of this WikiEvent.
*/
- protected void setType( int type )
- {
+ protected void setType( final int type ) {
m_type = type;
}
-
- /**
+ /**
* Returns the type of this event.
*
- * @return the type of this WikiEvent. See the enumerated values
- * defined in {@link org.apache.wiki.event.WikiEvent}).
+ * @return the type of this WikiEvent. See the enumerated values defined in {@link org.apache.wiki.event.WikiEvent}).
*/
- public int getType()
- {
+ public int getType() {
return m_type;
}
-
- /** Returns a String (human-readable) description of an event type.
- * This should be subclassed as necessary.
+ /**
+ * Returns a String (human-readable) description of an event type. This should be subclassed as necessary.
+ *
* @return the String description
*/
- public String getTypeDescription()
- {
- switch ( m_type )
- {
- case ERROR: return "exception or error event";
- case UNDEFINED: return "undefined event type";
- default: return "unknown event type (" + m_type + ")";
+ public String getTypeDescription() {
+ switch( m_type ) {
+ case ERROR: return "exception or error event";
+ case UNDEFINED: return "undefined event type";
+ default: return "unknown event type (" + m_type + ")";
}
}
-
- /**
- * Returns true if the int value is a valid WikiEvent type.
- * Because the WikiEvent class does not itself any event types,
- * this method returns true if the event type is anything except
- * {@link #ERROR} or {@link #UNDEFINED}. This method is meant to
+ /**
+ * Returns true if the int value is a valid WikiEvent type. Because the WikiEvent class does not itself any event types,
+ * this method returns true if the event type is anything except {@link #ERROR} or {@link #UNDEFINED}. This method is meant to
* be subclassed as appropriate.
*
* @param type The value to test.
* @return true, if the value is a valid WikiEvent type.
*/
- public static boolean isValidType( int type )
- {
+ public static boolean isValidType( final int type ) {
return type != ERROR && type != UNDEFINED;
}
/**
* Returns a textual representation of an event type.
+ *
* @return the String representation
*/
- public String eventName()
- {
- switch( m_type )
- {
- case ERROR: return "ERROR";
- case UNDEFINED: return "UNDEFINED";
- default: return "UNKNOWN (" + m_type + ")";
+ public String eventName() {
+ switch( m_type ) {
+ case ERROR: return "ERROR";
+ case UNDEFINED: return "UNDEFINED";
+ default: return "UNKNOWN (" + m_type + ")";
}
}
/**
- * Prints a String (human-readable) representation of this object.
- * This should be subclassed as necessary.
+ * Prints a String (human-readable) representation of this object. This should be subclassed as necessary.
+ *
* @see java.lang.Object#toString()
* @return the String representation
*/
- public String toString()
- {
- StringBuilder out = new StringBuilder();
- out.append( "WikiEvent." );
- out.append( eventName() );
- out.append( " [source=" );
- out.append( getSource().toString() );
- out.append( "]" );
- return out.toString();
+ public String toString() {
+ return "WikiEvent." + eventName() + " [source=" + getSource().toString() + "]";
}
}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEventListener.java b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEventListener.java
index 6fbbfae..4f426c9 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEventListener.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEventListener.java
@@ -29,7 +29,7 @@ import java.util.EventListener;
*/
public interface WikiEventListener extends EventListener {
- /**
+ /**
* Fired when a WikiEvent is triggered by an event source.
*
* @param event a WikiEvent object
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEventUtils.java b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEventUtils.java
index 31cfd6b..4d54d7c 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEventUtils.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEventUtils.java
@@ -22,65 +22,54 @@ package org.apache.wiki.event;
import org.apache.wiki.WikiEngine;
/**
- * A utility class that adds some JSPWiki-specific functionality to the
- * WikiEventManager (which is really a general-purpose event manager).
+ * A utility class that adds some JSPWiki-specific functionality to the WikiEventManager (which is really a general-purpose event manager).
*
* @since 2.4.20
*/
-public class WikiEventUtils
-{
+public class WikiEventUtils {
+
/**
- * This ungainly convenience method adds a WikiEventListener to the
- * appropriate component of the provided client Object, to listen
- * for events of the provided type (or related types, see the table
- * below).
+ * This ungainly convenience method adds a WikiEventListener to the appropriate component of the provided client Object, to listen
+ * for events of the provided type (or related types, see the table below).
* <p>
- * If the type value is valid but does not match any WikiEvent type
- * known to this method, this will just attach the listener to the
- * client Object. This may mean that the Object never fires events
- * of the desired type; type-to-client matching is left to you to
+ * If the type value is valid but does not match any WikiEvent type known to this method, this will just attach the listener to the
+ * client Object. This may mean that the Object never fires events of the desired type; type-to-client matching is left to you to
* guarantee. Silence is golden, but not if you want those events.
* </p>
* <p>
- * Most event types expect a WikiEngine as the client, with the rest
- * attaching the listener directly to the supplied source object, as
+ * Most event types expect a WikiEngine as the client, with the rest attaching the listener directly to the supplied source object, as
* described below:
* </p>
* <table border="1" cellpadding="4">
- * <tr><th>WikiEvent Type(s) </th><th>Required Source Object </th><th>Actually Attached To </th>
- * </tr>
- * <tr><td>any WikiEngineEvent </td><td>WikiEngine </td><td>WikiEngine </td></tr>
+ * <tr><th>WikiEvent Type(s) </th><th>Required Source Object </th><th>Actually Attached To </th></tr>
+ * <tr><td>any WikiEngineEvent </td><td>WikiEngine </td><td>WikiEngine </td></tr>
* <tr><td>WikiPageEvent.PAGE_LOCK,
- * WikiPageEvent.PAGE_UNLOCK </td><td>WikiEngine or
- * PageManager </td><td>PageManager </td></tr>
+ * WikiPageEvent.PAGE_UNLOCK </td><td>WikiEngine or PageManager </td><td>PageManager </td></tr>
* <tr><td>WikiPageEvent.PAGE_REQUESTED,
- * WikiPageEvent.PAGE_DELIVERED </td>
- * <td>WikiServletFilter </td>
- * <td>WikiServletFilter </td></tr>
- * <tr><td>WikiPageEvent (<a href="#pbeTypes">phase boundary event</a>)</td>
- * <td>WikiEngine </td><td>FilterManager </td></tr>
- * <tr><td>WikiPageEvent (<a href="#ipeTypes">in-phase event</a>)</td>
- * <tr><td>WikiPageEvent (in-phase event)</td>
- * <td>any </td><td>source object </td></tr>
- * <tr><td>WikiSecurityEvent </td><td>any </td><td>source object </td></tr>
- * <tr><td>any other valid type </td><td>any </td><td>source object </td></tr>
- * <tr><td>any invalid type </td><td>any </td><td>nothing </td></tr>
+ * WikiPageEvent.PAGE_DELIVERED </td><td>WikiServletFilter </td><td>WikiServletFilter </td></tr>
+ * <tr><td>WikiPageEvent (<a href="#pbeTypes">phase
+ * boundary event</a>)</td><td>WikiEngine </td><td>FilterManager </td></tr>
+ * <tr><td>WikiPageEvent (<a href="#ipeTypes">in-phase
+ * event</a>)</td><td>WikiEngine </td><td>WikiEngine </td></tr>
+ * <tr><td>WikiPageEvent (in-phase event) </td><td>any </td><td>source object </td></tr>
+ * <tr><td>WikiSecurityEvent </td><td>any </td><td>source object </td></tr>
+ * <tr><td>any other valid type </td><td>any </td><td>source object </td></tr>
+ * <tr><td>any invalid type </td><td>any </td><td>nothing </td></tr>
* </table>
*
* <p id="pbeTypes"><small><b>phase boundary event types:</b>
- * <tt>WikiPageEvent.PRE_TRANSLATE_BEGIN</tt>, <tt>WikiPageEvent.PRE_TRANSLATE_END</tt>,
- * <tt>WikiPageEvent.POST_TRANSLATE_BEGIN</tt>, <tt>WikiPageEvent.POST_TRANSLATE_END</tt>,
- * <tt>WikiPageEvent.PRE_SAVE_BEGIN</tt>, <tt>WikiPageEvent.PRE_SAVE_END</tt>,
+ * <tt>WikiPageEvent.PRE_TRANSLATE_BEGIN</tt>, <tt>WikiPageEvent.PRE_TRANSLATE_END</tt>, <tt>WikiPageEvent.POST_TRANSLATE_BEGIN</tt>,
+ * <tt>WikiPageEvent.POST_TRANSLATE_END</tt>, <tt>WikiPageEvent.PRE_SAVE_BEGIN</tt>, <tt>WikiPageEvent.PRE_SAVE_END</tt>,
* <tt>WikiPageEvent.POST_SAVE_BEGIN</tt>, and <tt>WikiPageEvent.POST_SAVE_END</tt>.
* </small></p>
* <p id="ipeTypes"><small><b>in-phase event types:</b>
- * <tt>WikiPageEvent.PRE_TRANSLATE</tt>, <tt>WikiPageEvent.POST_TRANSLATE</tt>,
- * <tt>WikiPageEvent.PRE_SAVE</tt>, and <tt>WikiPageEvent.POST_SAVE</tt>.
+ * <tt>WikiPageEvent.PRE_TRANSLATE</tt>, <tt>WikiPageEvent.POST_TRANSLATE</tt>, <tt>WikiPageEvent.PRE_SAVE</tt>, and
+ * <tt>WikiPageEvent.POST_SAVE</tt>.
* </small></p>
*
* <p>
- * <b>Note:</b> The <i>Actually Attached To</i> column may also be considered as the
- * class(es) that fire events of the type(s) shown in the <i>WikiEvent Type</i> column.
+ * <b>Note:</b> The <i>Actually Attached To</i> column may also be considered as the class(es) that fire events of the type(s)
+ * shown in the <i>WikiEvent Type</i> column.
* </p>
*
* @see org.apache.wiki.event.WikiEvent
@@ -89,9 +78,7 @@ public class WikiEventUtils
* @see org.apache.wiki.event.WikiSecurityEvent
* @throws ClassCastException if there is a type mismatch between certain event types and the client Object
*/
- public static synchronized void addWikiEventListener(
- Object client, int type, WikiEventListener listener )
- {
+ public static synchronized void addWikiEventListener( final Object client, final int type, final WikiEventListener listener ) {
// Make sure WikiEventManager exists
WikiEventManager.getInstance();
@@ -99,31 +86,22 @@ public class WikiEventUtils
// tie us into known types, but WikiEvent.isValidType() will return true so
// long as the type was set to any non-ERROR or non-UNKNOWN value
- if ( WikiEngineEvent.isValidType(type) )
- {
+ if( WikiEngineEvent.isValidType( type ) ) {
// add listener directly to WikiEngine
WikiEventManager.addWikiEventListener( client, listener );
- }
- else if ( WikiPageEvent.isValidType(type) )
- {
+ } else if( WikiPageEvent.isValidType( type ) ) {
// add listener to one of several options
if( type == WikiPageEvent.PAGE_LOCK
- || type == WikiPageEvent.PAGE_UNLOCK )
- {
+ || type == WikiPageEvent.PAGE_UNLOCK ) {
// attach to PageManager
- if( client instanceof WikiEngine )
- {
+ if( client instanceof WikiEngine ) {
WikiEventManager.addWikiEventListener( ((WikiEngine)client).getPageManager(), listener );
- }
- else
- {
+ } else {
// client instanceof PageManager
WikiEventManager.addWikiEventListener( client, listener );
}
- }
- else if( type == WikiPageEvent.PAGE_REQUESTED
- || type == WikiPageEvent.PAGE_DELIVERED )
- {
+ } else if( type == WikiPageEvent.PAGE_REQUESTED
+ || type == WikiPageEvent.PAGE_DELIVERED ) {
// attach directly to WikiServletFilter
WikiEventManager.addWikiEventListener( client, listener );
}
@@ -134,34 +112,24 @@ public class WikiEventUtils
|| type == WikiPageEvent.PRE_SAVE_BEGIN
|| type == WikiPageEvent.PRE_SAVE_END
|| type == WikiPageEvent.POST_SAVE_BEGIN
- || type == WikiPageEvent.POST_SAVE_END )
- {
+ || type == WikiPageEvent.POST_SAVE_END ) {
// attach to FilterManager
WikiEventManager.addWikiEventListener( ((WikiEngine)client).getFilterManager(), listener );
- }
- else //if ( type == WikiPageEvent.PRE_TRANSLATE
- // || type == WikiPageEvent.POST_TRANSLATE
- // || type == WikiPageEvent.PRE_SAVE
- // || type == WikiPageEvent.POST_SAVE ) // attach to client
- {
+ } else { //if ( type == WikiPageEvent.PRE_TRANSLATE
+ // || type == WikiPageEvent.POST_TRANSLATE
+ // || type == WikiPageEvent.PRE_SAVE
+ // || type == WikiPageEvent.POST_SAVE ) // attach to client
WikiEventManager.addWikiEventListener( client, listener );
}
- }
- else if( WikiSecurityEvent.isValidType(type) )
- {
+ } else if( WikiSecurityEvent.isValidType( type ) ) {
// currently just attach it to the client (we are ignorant of other options)
WikiEventManager.addWikiEventListener( client, listener );
- }
- else if( WikiEvent.isValidType(type) )
- {
+ } else if( WikiEvent.isValidType( type ) ) {
// we don't know what to do
WikiEventManager.addWikiEventListener( client, listener );
- }
- else
- {
- // is error or unknown
- // why are we being called with this?
+ } else {
+ // is error or unknown, why are we being called with this?
}
}
-} // end org.apache.wiki.event.WikiEventUtils
+}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiPageRenameEvent.java b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiPageRenameEvent.java
index 4a35215..7d0608c 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiPageRenameEvent.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiPageRenameEvent.java
@@ -20,28 +20,24 @@
package org.apache.wiki.event;
/**
- * WikiPageRenameEvent extends WikiPageEvent to indicate a change in
- * the name of a WikiPage.
+ * WikiPageRenameEvent extends WikiPageEvent to indicate a change in the name of a WikiPage.
* <p>
- * This reuses {@link #getPageName()} to return the new name of the
- * page, with {@link #getOldPageName()} returning the old name.
+ * This reuses {@link #getPageName()} to return the new name of the page, with {@link #getOldPageName()} returning the old name.
*
* @see org.apache.wiki.event.WikiPageEvent
* @since 2.5.108
*/
-public class WikiPageRenameEvent extends WikiPageEvent
-{
+public class WikiPageRenameEvent extends WikiPageEvent {
+
private static final long serialVersionUID = 1L;
- /** Indicates a page rename event. This is based on events
- * generated by {@link org.apache.wiki.content.PageRenamer}. */
+ /** Indicates a page rename event. This is based on events generated by {@link org.apache.wiki.content.PageRenamer}. */
public static final int PAGE_RENAMED = 28;
- private String m_oldpagename = null;
+ private String m_oldpagename;
// ............
-
/**
* Constructs an instance of this event.
*
@@ -49,53 +45,43 @@ public class WikiPageRenameEvent extends WikiPageEvent
* @param oldname the old name of the WikiPage being acted upon.
* @param newname the new name of the WikiPage being acted upon.
*/
- public WikiPageRenameEvent( Object src, String oldname, String newname )
- {
+ public WikiPageRenameEvent( final Object src, final String oldname, final String newname ) {
super( src, PAGE_RENAMED, newname );
m_oldpagename = oldname;
}
-
- /**
- * Returns the old Wiki page name associated with this event.
- * This may be null if unavailable.
+ /**
+ * Returns the old Wiki page name associated with this event. This may be null if unavailable.
*
* @return the old Wiki page name associated with this WikiEvent, or null.
*/
- public String getOldPageName()
- {
+ public String getOldPageName() {
return m_oldpagename;
}
-
- /**
- * Returns the new Wiki page name associated with this event. This
- * returns the same value as the superclass' {@link #getPageName()}.
+ /**
+ * Returns the new Wiki page name associated with this event. This returns the same value as the superclass' {@link #getPageName()}.
* This may be null if unavailable.
*
* @return the new Wiki page name associated with this WikiEvent, or null.
*/
- public String getNewPageName()
- {
+ public String getNewPageName() {
return super.getPageName();
}
-
- /**
+ /**
* Returns true if the int value is a WikiPageRenameEvent type.
*/
- public static boolean isValidType( int type )
- {
+ public static boolean isValidType( final int type ) {
return type == PAGE_RENAMED;
}
-
/**
* Returns a textual representation of the event type.
+ *
* @return a String representation of the type
*/
- public String eventName()
- {
+ public String eventName() {
return "PAGE_RENAMED";
// switch ( getType() )
// {
@@ -105,11 +91,10 @@ public class WikiPageRenameEvent extends WikiPageEvent
}
- /** Returns a human-readable description of the event type.
+ /** Returns a human-readable description of the event type.
* @return a String description of the type
*/
- public String getTypeDescription()
- {
+ public String getTypeDescription() {
return "page renamed event";
// switch ( getType() )
// {
@@ -118,4 +103,4 @@ public class WikiPageRenameEvent extends WikiPageEvent
// }
}
-} // end class org.apache.wiki.event.WikiPageRenameEvent
+}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiSecurityEvent.java b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiSecurityEvent.java
index e7d1cc8..94a633c 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiSecurityEvent.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiSecurityEvent.java
@@ -25,9 +25,8 @@ import org.apache.log4j.Logger;
import java.security.Principal;
/**
- * <p>Event class for security events: login/logout, wiki group adds/changes, and
- * authorization decisions. When a WikiSecurityEvent is constructed, the
- * security logger {@link #log} is notified.</p>
+ * <p>Event class for security events: login/logout, wiki group adds/changes, and authorization decisions. When a WikiSecurityEvent
+ * is constructed, the security logger {@link #log} is notified.</p>
* <p>These events are logged with priority <code>ERROR</code>:</p>
* <ul>
* <li>login failed - bad credential or password</li>
@@ -56,8 +55,7 @@ import java.security.Principal;
* </ul>
* @since 2.3.79
*/
-public final class WikiSecurityEvent extends WikiEvent
-{
+public final class WikiSecurityEvent extends WikiEvent {
private static final long serialVersionUID = -6751950399721334496L;
@@ -121,114 +119,97 @@ public final class WikiSecurityEvent extends WikiEvent
private static final int[] ERROR_EVENTS = { LOGIN_FAILED };
- private static final int[] WARN_EVENTS = { LOGIN_ACCOUNT_EXPIRED,
- LOGIN_CREDENTIAL_EXPIRED };
+ private static final int[] WARN_EVENTS = { LOGIN_ACCOUNT_EXPIRED, LOGIN_CREDENTIAL_EXPIRED };
- private static final int[] INFO_EVENTS = { LOGIN_AUTHENTICATED,
- SESSION_EXPIRED, LOGOUT, PROFILE_NAME_CHANGED };
+ private static final int[] INFO_EVENTS = { LOGIN_AUTHENTICATED, SESSION_EXPIRED, LOGOUT, PROFILE_NAME_CHANGED };
/**
- * Constructs a new instance of this event type, which signals a security
- * event has occurred. The <code>source</code> parameter is required, and
- * may not be <code>null</code>. When the WikiSecurityEvent is
- * constructed, the security logger {@link #log} is notified.
- * @param src the source of the event, which can be any object: a wiki
- * page, group or authentication/authentication/group manager.
+ * Constructs a new instance of this event type, which signals a security event has occurred. The <code>source</code> parameter is
+ * required, and may not be <code>null</code>. When the WikiSecurityEvent is constructed, the security logger {@link #log} is notified.
+ *
+ * @param src the source of the event, which can be any object: a wiki page, group or authentication/authentication/group manager.
* @param type the type of event
* @param principal the subject of the event, which may be <code>null</code>
* @param target the changed Object, which may be <code>null</code>
*/
- public WikiSecurityEvent( Object src, int type, Principal principal, Object target )
- {
+ public WikiSecurityEvent( final Object src, final int type, final Principal principal, final Object target ) {
super( src, type );
- if ( src == null )
- {
+ if( src == null ) {
throw new IllegalArgumentException( "Argument(s) cannot be null." );
}
this.m_principal = principal;
this.m_target = target;
- if ( log.isEnabledFor( Level.ERROR ) && ArrayUtils.contains( ERROR_EVENTS, type ) )
- {
+ if( log.isEnabledFor( Level.ERROR ) && ArrayUtils.contains( ERROR_EVENTS, type ) ) {
log.error( this );
- }
- else if ( log.isEnabledFor( Level.WARN ) && ArrayUtils.contains( WARN_EVENTS, type ) )
- {
+ } else if( log.isEnabledFor( Level.WARN ) && ArrayUtils.contains( WARN_EVENTS, type ) ) {
log.warn( this );
- }
- else if ( log.isEnabledFor( Level.INFO ) && ArrayUtils.contains( INFO_EVENTS, type ) )
- {
+ } else if( log.isEnabledFor( Level.INFO ) && ArrayUtils.contains( INFO_EVENTS, type ) ) {
log.info( this );
}
log.debug( this );
}
/**
- * Constructs a new instance of this event type, which signals a security
- * event has occurred. The <code>source</code> parameter is required, and
- * may not be <code>null</code>. When the WikiSecurityEvent is
- * constructed, the security logger {@link #log} is notified.
- * @param src the source of the event, which can be any object: a wiki
- * page, group or authentication/authentication/group manager.
+ * Constructs a new instance of this event type, which signals a security event has occurred. The <code>source</code> parameter
+ * is required, and may not be <code>null</code>. When the WikiSecurityEvent is constructed, the security logger {@link #log}
+ * is notified.
+ *
+ * @param src the source of the event, which can be any object: a wiki page, group or authentication/authentication/group manager.
* @param type the type of event
* @param target the changed Object, which may be <code>null</code>.
*/
- public WikiSecurityEvent( Object src, int type, Object target )
- {
+ public WikiSecurityEvent( final Object src, final int type, final Object target ) {
this( src, type, null, target );
}
/**
- * Returns the principal to whom the opeation applied, if supplied. This
- * method may return <code>null</code>
+ * Returns the principal to whom the opeation applied, if supplied. This method may return <code>null</code>
* <em>— and calling methods should check for this condition</em>.
+ *
* @return the changed object
*/
- public Object getPrincipal()
- {
+ public Object getPrincipal() {
return m_principal;
}
/**
- * Returns the object that was operated on, if supplied. This method may
- * return <code>null</code>
+ * Returns the object that was operated on, if supplied. This method may return <code>null</code>
* <em>— and calling methods should check for this condition</em>.
+ *
* @return the changed object
*/
- public Object getTarget()
- {
+ public Object getTarget() {
return m_target;
}
/**
* Prints a String (human-readable) representation of this object.
+ *
* @see java.lang.Object#toString()
*/
- public String toString()
- {
- StringBuilder msg = new StringBuilder();
+ public String toString() {
+ final StringBuilder msg = new StringBuilder();
msg.append( "WikiSecurityEvent." );
msg.append( eventName( getType() ) );
- Object obj = getSrc(); // cfr. https://forums.oracle.com/forums/thread.jspa?threadID=1184115
- msg.append( " [source=" + obj.toString() );
- if( m_principal != null )
- {
- msg.append( ", princpal=" + m_principal.getClass().getName() );
- msg.append( " " + m_principal.getName() );
+ final Object obj = getSrc(); // cfr. https://forums.oracle.com/forums/thread.jspa?threadID=1184115
+ msg.append( " [source=" ).append( obj.toString() );
+ if( m_principal != null ) {
+ msg.append( ", princpal=" ).append( m_principal.getClass().getName() );
+ msg.append( " " ).append( m_principal.getName() );
}
- msg.append( ", target=" + m_target );
+ msg.append( ", target=" ).append( m_target );
msg.append( "]" );
return msg.toString();
}
/**
* Returns a textual representation of an event type.
+ *
* @param type the type
* @return the string representation
*/
- public String eventName( int type )
- {
- switch( type )
- {
+ public String eventName( final int type ) {
+ switch( type ) {
case LOGIN_AUTHENTICATED: return "LOGIN_AUTHENTICATED";
case LOGIN_ACCOUNT_EXPIRED: return "LOGIN_ACCOUNT_EXPIRED";
case LOGIN_CREDENTIAL_EXPIRED: return "LOGIN_ACCOUNT_EXPIRED";
@@ -252,10 +233,8 @@ public final class WikiSecurityEvent extends WikiEvent
*
* @return a String description of the type
*/
- public String getTypeDescription()
- {
- switch ( getType() )
- {
+ public String getTypeDescription() {
+ switch ( getType() ) {
case LOGIN_AUTHENTICATED: return "login authenticated";
case LOGIN_ACCOUNT_EXPIRED: return "login failed: expired account";
case LOGIN_CREDENTIAL_EXPIRED: return "login failed: credential expired";
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/event/WorkflowEvent.java b/jspwiki-main/src/main/java/org/apache/wiki/event/WorkflowEvent.java
index 5f2c552..d9be3b9 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/event/WorkflowEvent.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/event/WorkflowEvent.java
@@ -63,11 +63,10 @@ public final class WorkflowEvent extends WikiEvent {
* The <code>source</code> parameter is required, and may not be <code>null</code>. When the
* WikiSecurityEvent is constructed, the security logger {@link WikiSecurityEvent#log} is notified.
*
- * @param src the source of the event, which can be any object: a wiki page, group or
- * authentication/authentication/group manager.
+ * @param src the source of the event, which can be any object: a wiki page, group or authentication/authentication/group manager.
* @param type the type of event
*/
- public WorkflowEvent( Object src, int type ) {
+ public WorkflowEvent( final Object src, final int type ) {
super( src, type );
if( src == null ) {
throw new IllegalArgumentException( "Argument(s) cannot be null." );
@@ -80,11 +79,11 @@ public final class WorkflowEvent extends WikiEvent {
* @see java.lang.Object#toString()
*/
public String toString() {
- StringBuilder msg = new StringBuilder();
+ final StringBuilder msg = new StringBuilder();
msg.append( "WorkflowEvent." );
msg.append( eventName( getType() ) );
- Object obj = getSrc(); // cfr. https://forums.oracle.com/forums/thread.jspa?threadID=1184115
- msg.append( " [source=" + obj.toString() );
+ final Object obj = getSrc(); // cfr. https://forums.oracle.com/forums/thread.jspa?threadID=1184115
+ msg.append( " [source=" ).append( obj.toString() );
msg.append( "]" );
return msg.toString();
}
@@ -95,7 +94,7 @@ public final class WorkflowEvent extends WikiEvent {
* @param type the type
* @return the string representation
*/
- public String eventName( int type ) {
+ public String eventName( final int type ) {
switch( type ) {
case CREATED: return "CREATED";
case ABORTED: return "ABORTED";