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 2022/02/20 21:25:22 UTC

[jspwiki] 03/06: code format

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 6513f074eb8af6293104942e4a9fc7123a44f567
Author: Juan Pablo Santos Rodríguez <ju...@gmail.com>
AuthorDate: Sun Feb 20 22:19:37 2022 +0100

    code format
---
 jspwiki-war/src/main/webapp/NewGroup.jsp        | 25 +++++---------
 jspwiki-war/src/main/webapp/UserPreferences.jsp | 43 +++++++++----------------
 2 files changed, 23 insertions(+), 45 deletions(-)

diff --git a/jspwiki-war/src/main/webapp/NewGroup.jsp b/jspwiki-war/src/main/webapp/NewGroup.jsp
index d4422ad..3fd4a0b 100644
--- a/jspwiki-war/src/main/webapp/NewGroup.jsp
+++ b/jspwiki-war/src/main/webapp/NewGroup.jsp
@@ -40,7 +40,7 @@
     Engine wiki = Wiki.engine().find( getServletConfig() );
     // Create wiki context and check for authorization
     Context wikiContext = Wiki.context().create( wiki, request, ContextEnum.WIKI_CREATE_GROUP.getRequestContext() );
-    if(!wiki.getManager( AuthorizationManager.class ).hasAccess( wikiContext, response )) return;
+    if( !wiki.getManager( AuthorizationManager.class ).hasAccess( wikiContext, response ) ) return;
     
     // Extract the current user, group name, members and action attributes
     Session wikiSession = wikiContext.getWikiSession();
@@ -56,40 +56,31 @@
     }
     
     // Are we saving the group?
-    if( "save".equals(request.getParameter("action")) )
-    {
+    if( "save".equals( request.getParameter( "action" ) ) ) {
         // Validate the group
         groupMgr.validateGroup( wikiContext, group );
         
-        try 
-        {
+        try {
             groupMgr.getGroup( group.getName() );
 
             // Oops! The group already exists. This is mischief!
             ResourceBundle rb = Preferences.getBundle( wikiContext, "CoreResources");
             wikiSession.addMessage( GroupManager.MESSAGES_KEY,
                                     MessageFormat.format(rb.getString("newgroup.exists"),group.getName()));
-        }
-        catch ( NoSuchPrincipalException e )
-        {
+        } catch( NoSuchPrincipalException e ) {
             // Group not found; this is good!
         }
 
         // If no errors, save the group now
-        if ( wikiSession.getMessages( GroupManager.MESSAGES_KEY ).length == 0 )
-        {
-            try
-            {
+        if( wikiSession.getMessages( GroupManager.MESSAGES_KEY ).length == 0 ) {
+            try {
                 groupMgr.setGroup( wikiSession, group );
-            }
-            catch( WikiSecurityException e )
-            {
+            } catch( WikiSecurityException e ) {
                 // Something went horribly wrong! Maybe it's an I/O error...
                 wikiSession.addMessage( GroupManager.MESSAGES_KEY, e.getMessage() );
             }
         }
-        if ( wikiSession.getMessages( GroupManager.MESSAGES_KEY ).length == 0 )
-        {
+        if ( wikiSession.getMessages( GroupManager.MESSAGES_KEY ).length == 0 ) {
             response.sendRedirect( "Group.jsp?group=" + group.getName() );
             return;
         }
diff --git a/jspwiki-war/src/main/webapp/UserPreferences.jsp b/jspwiki-war/src/main/webapp/UserPreferences.jsp
index b333807..b4e0fe2 100644
--- a/jspwiki-war/src/main/webapp/UserPreferences.jsp
+++ b/jspwiki-war/src/main/webapp/UserPreferences.jsp
@@ -49,7 +49,7 @@
     Engine wiki = Wiki.engine().find( getServletConfig() );
     // Create wiki context and check for authorization
     Context wikiContext = Wiki.context().create( wiki, request, ContextEnum.WIKI_PREFS.getRequestContext() );
-    if(!wiki.getManager( AuthorizationManager.class ).hasAccess( wikiContext, response ) ) return;
+    if( !wiki.getManager( AuthorizationManager.class ).hasAccess( wikiContext, response ) ) return;
     
     // Extract the user profile and action attributes
     UserManager userMgr = wiki.getManager( UserManager.class );
@@ -64,58 +64,46 @@
 */
 
     // Are we saving the profile?
-    if( "saveProfile".equals(request.getParameter("action")) )
-    {
+    if( "saveProfile".equals( request.getParameter( "action" ) ) ) {
         UserProfile profile = userMgr.parseProfile( wikiContext );
-         
+
         // Validate the profile
         userMgr.validateProfile( wikiContext, profile );
 
         // If no errors, save the profile now & refresh the principal set!
-        if ( wikiSession.getMessages( "profile" ).length == 0 )
-        {
-            try
-            {
+        if( wikiSession.getMessages( "profile" ).length == 0 ) {
+            try {
                 userMgr.setUserProfile( wikiContext, profile );
                 CookieAssertionLoginModule.setUserCookie( response, profile.getFullname() );
-            }
-            catch( DuplicateUserException due )
-            {
+            } catch( DuplicateUserException due ) {
                 // User collision! (full name or wiki name already taken)
                 wikiSession.addMessage( "profile", wiki.getManager( InternationalizationManager.class )
                                                        .get( InternationalizationManager.CORE_BUNDLE,
                                                     		 Preferences.getLocale( wikiContext ), 
                                                              due.getMessage(), due.getArgs() ) );
-            }
-            catch( DecisionRequiredException e )
-            {
+            } catch( DecisionRequiredException e ) {
                 String redirect = wiki.getURL( ContextEnum.PAGE_VIEW.getRequestContext(), "ApprovalRequiredForUserProfiles", null );
                 response.sendRedirect( redirect );
                 return;
-            }
-            catch( WikiSecurityException e )
-            {
+            } catch( WikiSecurityException e ) {
                 // Something went horribly wrong! Maybe it's an I/O error...
                 wikiSession.addMessage( "profile", e.getMessage() );
             }
         }
-        if ( wikiSession.getMessages( "profile" ).length == 0 )
-        {
+        if( wikiSession.getMessages( "profile" ).length == 0 ) {
             String redirectPage = request.getParameter( "redirect" );
 
-            if( !wiki.getManager( PageManager.class ).wikiPageExists( redirectPage ) )
-            {
+            if( !wiki.getManager( PageManager.class ).wikiPageExists( redirectPage ) ) {
                redirectPage = wiki.getFrontPage();
             }
-            
+
             String viewUrl = ( "UserPreferences".equals( redirectPage ) ) ? "Wiki.jsp" : wikiContext.getViewURL( redirectPage );
-            log.info( "Redirecting user to " + viewUrl );
+            log.info( "Redirecting user to {}", viewUrl );
             response.sendRedirect( viewUrl );
             return;
         }
     }
-    if( "setAssertedName".equals( request.getParameter( "action" ) ) )
-    {
+    if( "setAssertedName".equals( request.getParameter( "action" ) ) ) {
         Preferences.reloadPreferences( pageContext );
         
         String assertedName = request.getParameter( "assertedName" );
@@ -128,12 +116,11 @@
         }
         String viewUrl = ( "UserPreferences".equals( redirectPage ) ) ? "Wiki.jsp" : wikiContext.getViewURL( redirectPage );
 
-        log.info( "Redirecting user to " + viewUrl );
+        log.info( "Redirecting user to {}", viewUrl );
         response.sendRedirect( viewUrl );
         return;
     }
-    if( "clearAssertedName".equals( request.getParameter( "action" ) ) )
-    {
+    if( "clearAssertedName".equals( request.getParameter( "action" ) ) ) {
         HttpUtil.clearCookie( response, Preferences.COOKIE_USER_PREFS_NAME );
         CookieAssertionLoginModule.clearUserCookie( response );
         Preferences.reloadPreferences( pageContext );