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/03/06 18:04:23 UTC
[jspwiki] 21/35: JSPWIKI-303: begin to use Session instead of
WikiSession (2)
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 dc3e9f22ca168764bee2970a0c842b193cf01d98
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Mar 4 21:40:17 2020 +0100
JSPWIKI-303: begin to use Session instead of WikiSession (2)
---
.../java/org/apache/wiki/rss/RSSGenerator.java | 3 +-
.../java/org/apache/wiki/tags/MessagesTag.java | 72 +++++--------
.../java/org/apache/wiki/tags/PermissionTag.java | 4 +-
.../java/org/apache/wiki/tags/UserCheckTag.java | 3 +-
.../java/org/apache/wiki/tags/UserNameTag.java | 3 +-
.../java/org/apache/wiki/tags/UserProfileTag.java | 38 ++-----
.../java/org/apache/wiki/ui/InputValidator.java | 4 +-
.../main/java/org/apache/wiki/ui/Installer.java | 3 +-
.../org/apache/wiki/ui/admin/beans/UserBean.java | 94 +++++++----------
.../wiki/variables/DefaultVariableManager.java | 4 +-
.../org/apache/wiki/workflow/DecisionQueue.java | 112 ++++++++-------------
.../wiki/workflow/DefaultWorkflowManager.java | 4 +-
.../org/apache/wiki/workflow/WorkflowManager.java | 6 +-
.../org/apache/wiki/xmlrpc/MetaWeblogHandler.java | 3 +-
14 files changed, 138 insertions(+), 215 deletions(-)
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java b/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java
index 44730a8..84d84b1 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java
@@ -24,6 +24,7 @@ import org.apache.wiki.WikiPage;
import org.apache.wiki.WikiProvider;
import org.apache.wiki.WikiSession;
import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
import org.apache.wiki.attachment.Attachment;
import org.apache.wiki.auth.AuthorizationManager;
import org.apache.wiki.auth.permissions.PagePermission;
@@ -318,7 +319,7 @@ public class RSSGenerator {
final Set< WikiPage > changed = m_engine.getManager( PageManager.class ).getRecentChanges();
- final WikiSession session = WikiSession.guestSession( m_engine );
+ final Session session = WikiSession.guestSession( m_engine );
int items = 0;
for( final Iterator< WikiPage > i = changed.iterator(); i.hasNext() && items < 15; items++ ) {
final WikiPage page = i.next();
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/MessagesTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/MessagesTag.java
index c770d66..2e8a20b 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/MessagesTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/MessagesTag.java
@@ -18,11 +18,11 @@
*/
package org.apache.wiki.tags;
-import java.io.IOException;
-
-import org.apache.wiki.WikiSession;
+import org.apache.wiki.api.core.Session;
import org.apache.wiki.util.TextUtil;
+import java.io.IOException;
+
/**
* Returns or clears the current messages associated with the user's wiki
* session. This tag accepts four attributes: <ul> <li><code>action</code> -
@@ -37,80 +37,61 @@ import org.apache.wiki.util.TextUtil;
* messages in; if not supplied, <code>information</code> is assumed</li></ul>
* @since 2.3.54
*/
-public class MessagesTag extends WikiTagBase
-{
+public class MessagesTag extends WikiTagBase {
+
private static final long serialVersionUID = 0L;
private String m_action = null;
-
private String m_prefix = "";
-
private String m_topic = null;
-
private String m_div = "information";
private static final String CLEAR = "clear";
- public void initTag()
- {
+ @Override
+ public void initTag() {
super.initTag();
m_action = m_topic = null;
m_prefix = "";
m_div = "information";
}
-
- public void setTopic( String topic )
- {
+ public void setTopic( final String topic ) {
m_topic = topic;
}
- public void setPrefix( String prefix )
- {
+ public void setPrefix( final String prefix ) {
m_prefix = prefix;
}
- public void setDiv( String div )
- {
+ public void setDiv( final String div ) {
m_div = div;
}
- public void setAction( String action )
- {
+ public void setAction( final String action ) {
m_action = action.toLowerCase();
}
- public final int doWikiStartTag() throws IOException
- {
- WikiSession session = m_wikiContext.getWikiSession();
- if ( CLEAR.equals( m_action ) )
- {
- if ( m_topic == null )
- {
+ @Override
+ public final int doWikiStartTag() throws IOException {
+ final Session session = m_wikiContext.getWikiSession();
+ if( CLEAR.equals( m_action ) ) {
+ if( m_topic == null ) {
session.clearMessages();
- }
- else
- {
+ } else {
session.clearMessages( m_topic );
}
- }
- else
- {
- String[] messages = ( m_topic == null ) ? session.getMessages() : session.getMessages( m_topic );
- if ( messages.length > 0 )
- {
- StringBuilder sb = new StringBuilder();
- if ( messages.length == 1 )
- {
- sb.append( "<div class=\"" + m_div + "\">" + m_prefix + TextUtil.replaceEntities(messages[0]) + "</div>" );
- }
- else
- {
+ } else {
+ final String[] messages = ( m_topic == null ) ? session.getMessages() : session.getMessages( m_topic );
+ if( messages.length > 0 ) {
+ final StringBuilder sb = new StringBuilder();
+ if( messages.length == 1 ) {
+ sb.append( "<div class=\"" + m_div + "\">" + m_prefix + TextUtil.replaceEntities( messages[ 0 ] ) + "</div>" );
+ } else {
sb.append( "<div class=\"" + m_div + "\">" + m_prefix );
sb.append( "<ul>" );
- for( int i = 0; i < messages.length; i++ )
- {
- sb.append( "<li>" + TextUtil.replaceEntities(messages[i]) + "</li>" );
+ for( int i = 0; i < messages.length; i++ ) {
+ sb.append( "<li>" + TextUtil.replaceEntities( messages[ i ] ) + "</li>" );
}
sb.append( "</ul></div>" );
}
@@ -119,4 +100,5 @@ public class MessagesTag extends WikiTagBase
}
return SKIP_BODY;
}
+
}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/PermissionTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/PermissionTag.java
index e3f6c3d..aaf01ca 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/PermissionTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/PermissionTag.java
@@ -21,7 +21,7 @@ package org.apache.wiki.tags;
import org.apache.commons.lang3.StringUtils;
import org.apache.wiki.WikiPage;
import org.apache.wiki.WikiProvider;
-import org.apache.wiki.WikiSession;
+import org.apache.wiki.api.core.Session;
import org.apache.wiki.auth.AuthorizationManager;
import org.apache.wiki.auth.GroupPrincipal;
import org.apache.wiki.auth.permissions.AllPermission;
@@ -103,7 +103,7 @@ public class PermissionTag extends WikiTagBase {
* @return true if granted, false if not
*/
private boolean checkPermission( final String permission ) {
- final WikiSession session = m_wikiContext.getWikiSession();
+ final Session session = m_wikiContext.getWikiSession();
final WikiPage page = m_wikiContext.getPage();
final AuthorizationManager mgr = m_wikiContext.getEngine().getManager( AuthorizationManager.class );
boolean gotPermission = false;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/UserCheckTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/UserCheckTag.java
index 57fa5eb..42fd786 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/UserCheckTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/UserCheckTag.java
@@ -19,6 +19,7 @@
package org.apache.wiki.tags;
import org.apache.wiki.WikiSession;
+import org.apache.wiki.api.core.Session;
import org.apache.wiki.auth.AuthenticationManager;
/**
@@ -110,7 +111,7 @@ public class UserCheckTag extends WikiTagBase {
*/
@Override
public final int doWikiStartTag() {
- final WikiSession session = m_wikiContext.getWikiSession();
+ final Session session = m_wikiContext.getWikiSession();
final String status = session.getStatus();
final AuthenticationManager mgr = m_wikiContext.getEngine().getManager( AuthenticationManager.class );
final boolean containerAuth = mgr.isContainerAuthenticated();
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/UserNameTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/UserNameTag.java
index 9de5ee7..ee06f49 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/UserNameTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/UserNameTag.java
@@ -20,6 +20,7 @@ package org.apache.wiki.tags;
import org.apache.wiki.WikiSession;
import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
import org.apache.wiki.i18n.InternationalizationManager;
import org.apache.wiki.preferences.Preferences;
import org.apache.wiki.util.TextUtil;
@@ -47,7 +48,7 @@ public class UserNameTag extends WikiTagBase {
@Override public final int doWikiStartTag() throws IOException {
final Engine engine = m_wikiContext.getEngine();
- final WikiSession wikiSession = WikiSession.getWikiSession(engine, (HttpServletRequest) pageContext.getRequest());
+ final Session wikiSession = WikiSession.getWikiSession(engine, (HttpServletRequest) pageContext.getRequest());
final Principal user = wikiSession.getUserPrincipal();
if( user != null ) {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/UserProfileTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/UserProfileTag.java
index 7d6fa86..ab752d2 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/UserProfileTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/UserProfileTag.java
@@ -21,10 +21,10 @@ package org.apache.wiki.tags;
import org.apache.wiki.WikiContext;
import org.apache.wiki.WikiSession;
import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
import org.apache.wiki.auth.AuthenticationManager;
import org.apache.wiki.auth.GroupPrincipal;
import org.apache.wiki.auth.UserManager;
-import org.apache.wiki.auth.WikiSecurityException;
import org.apache.wiki.auth.authorize.Role;
import org.apache.wiki.auth.user.UserProfile;
import org.apache.wiki.i18n.InternationalizationManager;
@@ -50,25 +50,22 @@ import java.util.ResourceBundle;
* <li><code>email</code> - user's e-mail address</li>
* <li><code>fullname</code> - user's full name</li>
* <li><code>groups</code> - a sorted list of the groups a user belongs to</li>
- * <li><code>loginname</code> - user's login name. If the current user does not have
- * a profile, the user's login principal (such as one provided by a container
- * login module, user cookie, or anonyous IP address), will supply the login
- * name property</li>
+ * <li><code>loginname</code> - user's login name. If the current user does not have a profile, the user's login principal (such as one
+ * provided by a container login module, user cookie, or anonyous IP address), will supply the login name property</li>
* <li><code>roles</code> - a sorted list of the roles a user possesses</li>
* <li><code>wikiname</code> - user's wiki name</li>
* <li><code>modified</code> - last modification date</li>
- * <li><code>exists</code> - evaluates the body of the tag if user's profile exists
- * in the user database
- * <li><code>new</code> - evaluates the body of the tag if user's profile does not
- * exist in the user database
- * <li><code>canChangeLoginName</code> - always true if custom auth used; also true for container auth
- * and current UserDatabase.isSharedWithContainer() is true.</li>
+ * <li><code>exists</code> - evaluates the body of the tag if user's profile exists in the user database</li>
+ * <li><code>new</code> - evaluates the body of the tag if user's profile does not exist in the user database</li>
+ * <li><code>canChangeLoginName</code> - always true if custom auth used; also true for container auth and current
+ * UserDatabase.isSharedWithContainer() is true.</li>
* <li><code>canChangePassword</code> - always true if custom auth used; also true for container auth
* and current UserDatabase.isSharedWithContainer() is true.</li>
* </ul>
* <p>In addition, the values <code>exists</code>, <code>new</code>, <code>canChangeLoginName</code>
* and <code>canChangeLoginName</code> can also be prefixed with <code>!</code> to indicate the
* negative condition (for example, <code>!exists</code>).</p>
+ *
* @since 2.3
*/
public class UserProfileTag extends WikiTagBase {
@@ -78,35 +75,20 @@ public class UserProfileTag extends WikiTagBase {
public static final String BLANK = "(not set)";
private static final String CREATED = "created";
-
private static final String EMAIL = "email";
-
private static final String EXISTS = "exists";
-
private static final String NOT_EXISTS= "!exists";
-
private static final String FULLNAME = "fullname";
-
private static final String GROUPS = "groups";
-
private static final String LOGINNAME = "loginname";
-
private static final String MODIFIED = "modified";
-
private static final String NEW = "new";
-
private static final String NOT_NEW = "!new";
-
private static final String ROLES = "roles";
-
private static final String WIKINAME = "wikiname";
-
private static final String CHANGE_LOGIN_NAME = "canchangeloginname";
-
private static final String NOT_CHANGE_LOGIN_NAME = "!canchangeloginname";
-
private static final String CHANGE_PASSWORD = "canchangepassword";
-
private static final String NOT_CHANGE_PASSWORD = "!canchangepassword";
private String m_prop;
@@ -118,7 +100,7 @@ public class UserProfileTag extends WikiTagBase {
}
@Override
- public final int doWikiStartTag() throws IOException, WikiSecurityException {
+ public final int doWikiStartTag() throws IOException {
final UserManager manager = m_wikiContext.getEngine().getManager( UserManager.class );
final UserProfile profile = manager.getUserProfile( m_wikiContext.getWikiSession() );
String result = null;
@@ -149,7 +131,7 @@ public class UserProfileTag extends WikiTagBase {
// Default back to the declared user name
//
final Engine engine = this.m_wikiContext.getEngine();
- final WikiSession wikiSession = WikiSession.getWikiSession( engine, ( HttpServletRequest )pageContext.getRequest() );
+ final Session wikiSession = WikiSession.getWikiSession( engine, ( HttpServletRequest )pageContext.getRequest() );
final Principal user = wikiSession.getUserPrincipal();
if( user != null ) {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/InputValidator.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/InputValidator.java
index 65534b9..13aa834 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/InputValidator.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/InputValidator.java
@@ -19,7 +19,7 @@
package org.apache.wiki.ui;
import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiSession;
+import org.apache.wiki.api.core.Session;
import org.apache.wiki.i18n.InternationalizationManager;
import org.apache.wiki.preferences.Preferences;
@@ -55,7 +55,7 @@ public final class InputValidator {
private final String m_form;
- private final WikiSession m_session;
+ private final Session m_session;
private final WikiContext m_context;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/Installer.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/Installer.java
index cad8a35..f6968d2 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/Installer.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/Installer.java
@@ -21,6 +21,7 @@ package org.apache.wiki.ui;
import org.apache.wiki.WikiEngine;
import org.apache.wiki.WikiSession;
import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
import org.apache.wiki.auth.NoSuchPrincipalException;
import org.apache.wiki.auth.UserManager;
import org.apache.wiki.auth.WikiPrincipal;
@@ -66,7 +67,7 @@ public class Installer {
public static final String ADMIN_GROUP = "Admin";
public static final String PROPFILENAME = "jspwiki-custom.properties" ;
public static final String TMP_DIR = System.getProperty("java.io.tmpdir");
- private final WikiSession m_session;
+ private final Session m_session;
private final File m_propertyFile;
private final Properties m_props;
private final Engine m_engine;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/UserBean.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/UserBean.java
index 2d662c5..23c94b3 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/UserBean.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/UserBean.java
@@ -19,8 +19,8 @@
package org.apache.wiki.ui.admin.beans;
import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiSession;
import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
import org.apache.wiki.auth.NoSuchPrincipalException;
import org.apache.wiki.auth.UserManager;
import org.apache.wiki.auth.WikiSecurityException;
@@ -33,30 +33,29 @@ import javax.servlet.http.HttpServletRequest;
import java.util.Date;
-public class UserBean extends SimpleAdminBean
-{
- public UserBean( final Engine engine ) throws NotCompliantMBeanException
- {
+public class UserBean extends SimpleAdminBean {
+
+ public UserBean( final Engine engine ) throws NotCompliantMBeanException {
super();
}
- @Override public String[] getAttributeNames()
+ @Override
+ public String[] getAttributeNames()
{
return new String[0];
}
// FIXME: We don't yet support MBean for this kind of stuff.
- @Override public String[] getMethodNames()
+ @Override
+ public String[] getMethodNames()
{
return new String[0];
}
-
-
- @Override public String doPost( final WikiContext context)
- {
+ @Override
+ public String doPost( final WikiContext context ) {
final HttpServletRequest request = context.getHttpRequest();
- final WikiSession session = context.getWikiSession();
+ final Session session = context.getWikiSession();
final UserManager mgr = context.getEngine().getManager( UserManager.class );
final String loginid = request.getParameter("loginid");
@@ -66,66 +65,49 @@ public class UserBean extends SimpleAdminBean
final String password2 = request.getParameter("password2");
final String email = request.getParameter("email");
-
- if( request.getParameter("action").equalsIgnoreCase("remove") )
- {
- try
- {
- mgr.getUserDatabase().deleteByLoginName(loginid);
- session.addMessage("User profile "+loginid+" ("+fullname+") has been deleted");
- }
- catch ( final NoSuchPrincipalException e)
- {
- session.addMessage("User profile has already been removed");
- }
- catch ( final WikiSecurityException e)
- {
- session.addMessage("Security problem: "+e);
+ if( request.getParameter( "action" ).equalsIgnoreCase( "remove" ) ) {
+ try {
+ mgr.getUserDatabase().deleteByLoginName( loginid );
+ session.addMessage( "User profile " + loginid + " (" + fullname + ") has been deleted" );
+ } catch( final NoSuchPrincipalException e ) {
+ session.addMessage( "User profile has already been removed" );
+ } catch( final WikiSecurityException e ) {
+ session.addMessage( "Security problem: " + e );
}
return "";
}
-
- if( password != null && password.length() > 0 && !password.equals(password2) )
- {
- session.addMessage("Passwords do not match!");
+ if( password != null && password.length() > 0 && !password.equals( password2 ) ) {
+ session.addMessage( "Passwords do not match!" );
return "";
}
final UserProfile p;
- if( loginid.equals("--New--") )
- {
+ if( loginid.equals( "--New--" ) ) {
// Create new user
p = mgr.getUserDatabase().newProfile();
p.setCreated( new Date() );
- }
- else
- {
- try
- {
+ } else {
+ try {
p = mgr.getUserDatabase().findByLoginName( loginid );
- }
- catch ( final NoSuchPrincipalException e)
- {
- session.addMessage("I could not find user profile "+loginid);
+ } catch( final NoSuchPrincipalException e ) {
+ session.addMessage( "I could not find user profile " + loginid );
return "";
}
}
- p.setEmail(email);
- p.setFullname(fullname);
- if( password != null && password.length() > 0 ) p.setPassword(password);
- p.setLoginName(loginname);
+ p.setEmail( email );
+ p.setFullname( fullname );
+ if( password != null && password.length() > 0 )
+ p.setPassword( password );
+ p.setLoginName( loginname );
- try
- {
+ try {
mgr.getUserDatabase().save( p );
- }
- catch( final WikiSecurityException e )
- {
- session.addMessage("Unable to save "+e.getMessage());
+ } catch( final WikiSecurityException e ) {
+ session.addMessage( "Unable to save " + e.getMessage() );
}
session.addMessage("User profile has been updated");
@@ -133,13 +115,13 @@ public class UserBean extends SimpleAdminBean
return "";
}
- @Override public String getTitle()
- {
+ @Override
+ public String getTitle() {
return "User administration";
}
- @Override public int getType()
- {
+ @Override
+ public int getType() {
return AdminBean.UNKNOWN;
}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java b/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java
index 5764fcd..4858655 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java
@@ -23,7 +23,7 @@ import org.apache.wiki.Release;
import org.apache.wiki.WikiContext;
import org.apache.wiki.WikiPage;
import org.apache.wiki.WikiProvider;
-import org.apache.wiki.WikiSession;
+import org.apache.wiki.api.core.Session;
import org.apache.wiki.api.exceptions.NoSuchVariableException;
import org.apache.wiki.api.filters.PageFilter;
import org.apache.wiki.attachment.AttachmentManager;
@@ -373,7 +373,7 @@ public class DefaultVariableManager implements VariableManager {
}
public String getLoginstatus() {
- final WikiSession session = m_context.getWikiSession();
+ final Session session = m_context.getWikiSession();
return Preferences.getBundle( m_context, InternationalizationManager.CORE_BUNDLE ).getString( "varmgr." + session.getStatus() );
}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/workflow/DecisionQueue.java b/jspwiki-main/src/main/java/org/apache/wiki/workflow/DecisionQueue.java
index 135ce56..12cc0c1 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/workflow/DecisionQueue.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/workflow/DecisionQueue.java
@@ -18,54 +18,46 @@
*/
package org.apache.wiki.workflow;
+import org.apache.wiki.api.core.Session;
+import org.apache.wiki.api.exceptions.WikiException;
+
import java.io.Serializable;
import java.security.Principal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
-import org.apache.wiki.api.exceptions.WikiException;
-import org.apache.wiki.WikiSession;
-
/**
- * Keeps a queue of pending Decisions that need to be acted on by named
- * Principals.
+ * Keeps a queue of pending Decisions that need to be acted on by named Principals.
*
* @since 2.5
*/
-public class DecisionQueue implements Serializable
-{
+public class DecisionQueue implements Serializable {
+
private static final long serialVersionUID = -7172912793410302533L;
- private LinkedList<Decision> m_queue = new LinkedList<Decision>();
+ private LinkedList< Decision > m_queue = new LinkedList<>();
private volatile int m_next;
- /**
- * Constructs a new DecisionQueue.
- */
- public DecisionQueue()
- {
+ /** Constructs a new DecisionQueue. */
+ public DecisionQueue() {
m_next = 1000;
}
/**
- * Adds a Decision to the DecisionQueue; also sets the Decision's unique
- * identifier.
+ * Adds a Decision to the DecisionQueue; also sets the Decision's unique identifier.
*
- * @param decision
- * the Decision to add
+ * @param decision the Decision to add
*/
- protected synchronized void add( Decision decision )
- {
+ protected synchronized void add( final Decision decision ) {
m_queue.addLast( decision );
decision.setId( nextId() );
}
/**
- * Protected method that returns all pending Decisions in the queue, in
- * order of submission. If no Decisions are pending, this method returns a
- * zero-length array.
+ * Protected method that returns all pending Decisions in the queue, in order of submission. If no Decisions are pending, this
+ * method returns a zero-length array.
*
* @return the pending decisions
*/
@@ -76,46 +68,37 @@ public class DecisionQueue implements Serializable
/**
* Protected method that removes a Decision from the queue.
+ *
* @param decision the decision to remove
*/
- protected synchronized void remove(Decision decision)
+ protected synchronized void remove( final Decision decision )
{
m_queue.remove( decision );
}
/**
- * Returns a Collection representing the current Decisions that pertain to a
- * users's WikiSession. The Decisions are obtained by iterating through the
- * WikiSession's Principals and selecting those Decisions whose
- * {@link Decision#getActor()} value match. If the wiki session is not
- * authenticated, this method returns an empty Collection.
+ * Returns a Collection representing the current Decisions that pertain to a users's Session. The Decisions are obtained by iterating
+ * through the Session's Principals and selecting those Decisions whose {@link Decision#getActor()} value match. If the session
+ * is not authenticated, this method returns an empty Collection.
*
- * @param session
- * the wiki session
+ * @param session the wiki session
* @return the collection of Decisions, which may be empty
*/
- public Collection<Decision> getActorDecisions(WikiSession session)
- {
- ArrayList<Decision> decisions = new ArrayList<>();
- if ( session.isAuthenticated() )
- {
- Principal[] principals = session.getPrincipals();
- Principal[] rolePrincipals = session.getRoles();
- for ( Decision decision : m_queue )
- {
+ public Collection<Decision> getActorDecisions( final Session session ) {
+ final ArrayList< Decision > decisions = new ArrayList<>();
+ if( session.isAuthenticated() ) {
+ final Principal[] principals = session.getPrincipals();
+ final Principal[] rolePrincipals = session.getRoles();
+ for( final Decision decision : m_queue ) {
// Iterate through the Principal set
- for ( Principal principal : principals )
- {
- if ( principal.equals( decision.getActor() ) )
- {
+ for( final Principal principal : principals ) {
+ if( principal.equals( decision.getActor() ) ) {
decisions.add( decision );
}
}
// Iterate through the Role set
- for ( Principal principal : rolePrincipals )
- {
- if ( principal.equals( decision.getActor() ) )
- {
+ for( final Principal principal : rolePrincipals ) {
+ if( principal.equals( decision.getActor() ) ) {
decisions.add( decision );
}
}
@@ -125,41 +108,32 @@ public class DecisionQueue implements Serializable
}
/**
- * Attempts to complete a Decision by calling
- * {@link Decision#decide(Outcome)}. This will cause the Step immediately
- * following the Decision (if any) to start. If the decision completes
- * successfully, this method also removes the completed decision from the
+ * Attempts to complete a Decision by calling {@link Decision#decide(Outcome)}. This will cause the Step immediately following the
+ * Decision (if any) to start. If the decision completes successfully, this method also removes the completed decision from the
* queue.
*
* @param decision the Decision for which the Outcome will be supplied
* @param outcome the Outcome of the Decision
- * @throws WikiException if the succeeding Step cannot start
- * for any reason
+ * @throws WikiException if the succeeding Step cannot start for any reason
*/
- public void decide( Decision decision, Outcome outcome ) throws WikiException
- {
+ public void decide( final Decision decision, final Outcome outcome ) throws WikiException {
decision.decide( outcome );
- if ( decision.isCompleted() )
- {
+ if ( decision.isCompleted() ) {
remove( decision );
}
- // TODO: We should fire an event indicating the Outcome, and whether the
- // Decision completed successfully
+ // TODO: We should fire an event indicating the Outcome, and whether the Decision completed successfully
}
/**
- * Reassigns the owner of the Decision to a new owner. Under the covers,
- * this method calls {@link Decision#reassign(Principal)}.
+ * Reassigns the owner of the Decision to a new owner. Under the covers, this method calls {@link Decision#reassign(Principal)}.
*
* @param decision the Decision to reassign
* @param owner the new owner
* @throws WikiException never
*/
- public synchronized void reassign(Decision decision, Principal owner) throws WikiException
- {
- if (decision.isReassignable())
- {
+ public synchronized void reassign( final Decision decision, final Principal owner ) throws WikiException {
+ if( decision.isReassignable() ) {
decision.reassign( owner );
// TODO: We should fire an event indicating the reassignment
@@ -169,14 +143,12 @@ public class DecisionQueue implements Serializable
}
/**
- * Returns the next available unique identifier, which is subsequently
- * incremented.
+ * Returns the next available unique identifier, which is subsequently incremented.
*
* @return the id
*/
- private synchronized int nextId()
- {
- int current = m_next;
+ private synchronized int nextId() {
+ final int current = m_next;
m_next++;
return current;
}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/workflow/DefaultWorkflowManager.java b/jspwiki-main/src/main/java/org/apache/wiki/workflow/DefaultWorkflowManager.java
index 5459d10..8ba0838 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/workflow/DefaultWorkflowManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/workflow/DefaultWorkflowManager.java
@@ -18,8 +18,8 @@
*/
package org.apache.wiki.workflow;
-import org.apache.wiki.WikiSession;
import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
import org.apache.wiki.api.exceptions.WikiException;
import org.apache.wiki.auth.AuthorizationManager;
import org.apache.wiki.auth.acl.UnresolvedPrincipal;
@@ -187,7 +187,7 @@ public class DefaultWorkflowManager implements WorkflowManager {
* {@inheritDoc}
*/
@Override
- public List< Workflow > getOwnerWorkflows( final WikiSession session ) {
+ public List< Workflow > getOwnerWorkflows( final Session session ) {
final List< Workflow > workflows = new ArrayList<>();
if ( session.isAuthenticated() ) {
final Principal[] sessionPrincipals = session.getPrincipals();
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/workflow/WorkflowManager.java b/jspwiki-main/src/main/java/org/apache/wiki/workflow/WorkflowManager.java
index 0322a21..6e803c0 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/workflow/WorkflowManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/workflow/WorkflowManager.java
@@ -18,8 +18,8 @@
*/
package org.apache.wiki.workflow;
-import org.apache.wiki.WikiSession;
import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
import org.apache.wiki.api.exceptions.WikiException;
import org.apache.wiki.event.WikiEventListener;
@@ -139,12 +139,12 @@ public interface WorkflowManager extends WikiEventListener {
/**
* Returns the current workflows a wiki session owns. These are workflows whose {@link Workflow#getOwner()} method returns a Principal
- * also possessed by the wiki session (see {@link org.apache.wiki.WikiSession#getPrincipals()}). If the wiki session is not
+ * also possessed by the wiki session (see {@link org.apache.wiki.api.core.Session#getPrincipals()}). If the wiki session is not
* authenticated, this method returns an empty Collection.
*
* @param session the wiki session
* @return the collection workflows the wiki session owns, which may be empty
*/
- List< Workflow > getOwnerWorkflows( WikiSession session );
+ List< Workflow > getOwnerWorkflows( Session session );
}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java
index 6145a94..fbd82a9 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java
@@ -61,7 +61,8 @@ public class MetaWeblogHandler implements WikiRPCHandler {
/**
* {@inheritDoc}
*/
- @Override public void initialize( final WikiContext context )
+ @Override
+ public void initialize( final WikiContext context )
{
m_context = context;
}