continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r510559 - in /maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action: AddMavenOneProjectAction.java AddMavenProjectAction.java AddMavenTwoProjectAction.java AddProjectAction.java AddProjectGroupAction.java
Date Thu, 22 Feb 2007 15:52:48 GMT
Author: evenisse
Date: Thu Feb 22 07:52:47 2007
New Revision: 510559

URL: http://svn.apache.org/viewvc?view=rev&rev=510559
Log:
Remove more SecureAction implementation

Modified:
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenOneProjectAction.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenProjectAction.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddProjectAction.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddProjectGroupAction.java

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenOneProjectAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenOneProjectAction.java?view=diff&rev=510559&r1=510558&r2=510559
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenOneProjectAction.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenOneProjectAction.java
Thu Feb 22 07:52:47 2007
@@ -19,21 +19,18 @@
  * under the License.
  */
 
-import java.io.File;
-
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
 
+import java.io.File;
+
 /**
  * Add a Maven 1 project to Continuum.
- * 
+ *
  * @author Nick Gonzalez
  * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
  * @version $Id$
- *
- * @plexus.component
- *   role="com.opensymphony.xwork.Action"
- *   role-hint="addMavenOneProject"
+ * @plexus.component role="com.opensymphony.xwork.Action" role-hint="addMavenOneProject"
  */
 public class AddMavenOneProjectAction
     extends AddMavenProjectAction

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenProjectAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenProjectAction.java?view=diff&rev=510559&r1=510558&r2=510559
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenProjectAction.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenProjectAction.java
Thu Feb 22 07:52:47 2007
@@ -22,10 +22,7 @@
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.model.project.ProjectGroup;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
-import org.apache.maven.continuum.security.ContinuumRoleConstants;
-import org.codehaus.plexus.security.ui.web.interceptor.SecureAction;
-import org.codehaus.plexus.security.ui.web.interceptor.SecureActionBundle;
-import org.codehaus.plexus.security.ui.web.interceptor.SecureActionException;
+import org.apache.maven.continuum.web.exception.AuthorizationRequiredException;
 import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
@@ -37,15 +34,13 @@
 
 /**
  * Action to add a Maven project to Continuum, either Maven 1 or Maven 2.
- * 
+ *
  * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
  * @version $Id$
  */
 public abstract class AddMavenProjectAction
     extends ContinuumActionSupport
-    implements SecureAction
 {
-
     private static final long serialVersionUID = -3965565189557706469L;
 
     private static final int DEFINED_BY_POM_GROUP_ID = -1;
@@ -55,9 +50,9 @@
     private File pomFile;
 
     private String pom = null;
-    
+
     private String scmUsername;
-    
+
     private String scmPassword;
 
     private Collection projectGroups;
@@ -71,6 +66,25 @@
     public String execute()
         throws ContinuumException
     {
+        try
+        {
+            initializeProjectGroupName();
+
+            if ( StringUtils.isEmpty( getProjectGroupName() ) )
+            {
+                checkAddProjectGroupAuthorization();
+            }
+            else
+            {
+                checkAddProjectToGroupAuthorization( getProjectGroupName() );
+            }
+        }
+        catch ( AuthorizationRequiredException authzE )
+        {
+            addActionError( authzE.getMessage() );
+            return REQUIRES_AUTHORIZATION;
+        }
+
         boolean checkProtocol = true;
 
         if ( !StringUtils.isEmpty( pomUrl ) )
@@ -78,17 +92,18 @@
             try
             {
                 URL url = new URL( pomUrl );
-                if ( pomUrl.startsWith( "http" ) && !StringUtils.isEmpty(scmUsername)
)
+                if ( pomUrl.startsWith( "http" ) && !StringUtils.isEmpty( scmUsername
) )
                 {
                     StringBuffer urlBuffer = new StringBuffer();
                     urlBuffer.append( url.getProtocol() ).append( "://" );
-                    urlBuffer.append(scmUsername).append( ':' ).append(scmPassword).append(
'@' ).append( url.getHost() );
+                    urlBuffer.append( scmUsername ).append( ':' ).append( scmPassword ).append(
'@' ).append(
+                        url.getHost() );
                     if ( url.getPort() != -1 )
                     {
                         urlBuffer.append( url.getPort() );
                     }
                     urlBuffer.append( url.getPath() );
-                    
+
                     pom = urlBuffer.toString();
                 }
                 else
@@ -144,17 +159,37 @@
 
     /**
      * Subclasses must implement this method calling the appropiate operation on the continuum
service.
-     * 
-     * @param pomUrl url of the pom specified by the user
+     *
+     * @param pomUrl               url of the pom specified by the user
      * @param selectedProjectGroup project group id selected by the user
-     * @param checkProtocol check if the protocol is allowed, use false if the pom is uploaded
+     * @param checkProtocol        check if the protocol is allowed, use false if the pom
is uploaded
      * @return result of adding the pom to continuum
      */
-    protected abstract ContinuumProjectBuildingResult doExecute( String pomUrl, int selectedProjectGroup,
boolean checkProtocol )
+    protected abstract ContinuumProjectBuildingResult doExecute( String pomUrl, int selectedProjectGroup,
+                                                                 boolean checkProtocol )
         throws ContinuumException;
 
     public String doDefault()
     {
+        try
+        {
+            initializeProjectGroupName();
+
+            if ( StringUtils.isEmpty( getProjectGroupName() ) )
+            {
+                checkAddProjectGroupAuthorization();
+            }
+            else
+            {
+                checkAddProjectToGroupAuthorization( getProjectGroupName() );
+            }
+        }
+        catch ( AuthorizationRequiredException authzE )
+        {
+            addActionError( authzE.getMessage() );
+            return REQUIRES_AUTHORIZATION;
+        }
+
         Collection allProjectGroups = getContinuum().getAllProjectGroups();
         projectGroups = new ArrayList();
 
@@ -169,7 +204,7 @@
             //TODO: must implement same functionality using plexus-security
             //if ( pg.getPermissions().isWrite() )
             //{
-                projectGroups.add( pg );
+            projectGroups.add( pg );
             //}
         }
 
@@ -223,7 +258,7 @@
         this.pomUrl = pomUrl;
     }
 
-    public void setScmPassword( String scmPassword)
+    public void setScmPassword( String scmPassword )
     {
         this.scmPassword = scmPassword;
     }
@@ -233,7 +268,7 @@
         return scmUsername;
     }
 
-    public void setScmUsername( String scmUsername)
+    public void setScmUsername( String scmUsername )
     {
         this.scmUsername = scmUsername;
     }
@@ -271,25 +306,5 @@
     public void setDisableGroupSelection( boolean disableGroupSelection )
     {
         this.disableGroupSelection = disableGroupSelection;
-    }
-
-    public SecureActionBundle getSecureActionBundle()
-        throws SecureActionException
-    {
-        initializeProjectGroupName();
-
-        SecureActionBundle bundle = new SecureActionBundle();
-        bundle.setRequiresAuthentication( true );
-
-        if ( StringUtils.isEmpty( projectGroupName ) )
-        {
-            bundle.addRequiredAuthorization( ContinuumRoleConstants.CONTINUUM_ADD_GROUP_OPERATION
);
-        }
-        else
-        {
-            bundle.addRequiredAuthorization( ContinuumRoleConstants.CONTINUUM_ADD_PROJECT_TO_GROUP_OPERATION,
projectGroupName );
-        }
-
-        return bundle;
     }
 }

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java?view=diff&rev=510559&r1=510558&r2=510559
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java
Thu Feb 22 07:52:47 2007
@@ -34,28 +34,27 @@
 
 /**
  * Add a Maven 2 project to Continuum.
- * 
+ *
  * @author Nick Gonzalez
  * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
  * @version $Id$
- *
- * @plexus.component
- *   role="com.opensymphony.xwork.Action"
- *   role-hint="addMavenTwoProject"
+ * @plexus.component role="com.opensymphony.xwork.Action" role-hint="addMavenTwoProject"
  */
 public class AddMavenTwoProjectAction
     extends AddMavenProjectAction
 {
     // TODO: remove this part once uploading of an m2 project with modules is supported (
CONTINUUM-1098 )
     public static final String ERROR_UPLOADING_M2_PROJECT_WITH_MODULES = "add.m2.project.upload.modules.error";
+
     public static final String ERROR_READING_POM_EXCEPTION_MESSAGE = "Error reading POM";
+
     public static final String FILE_SCHEME = "file:/";
-    
+
     protected ContinuumProjectBuildingResult doExecute( String pomUrl, int selectedProjectGroup,
boolean checkProtocol )
         throws ContinuumException
     {
         ContinuumProjectBuildingResult result = null;
-        
+
         // TODO: remove this part once uploading of an m2 project with modules is supported
( CONTINUUM-1098 )
         if ( checkProtocol == false )
         {
@@ -93,7 +92,7 @@
             catch ( IOException e )
             {
                 throw new ContinuumException( ERROR_READING_POM_EXCEPTION_MESSAGE, e );
-           }
+            }
             catch ( XmlPullParserException e )
             {
                 throw new ContinuumException( ERROR_READING_POM_EXCEPTION_MESSAGE, e );
@@ -104,7 +103,7 @@
         {
             result = getContinuum().addMavenTwoProject( pomUrl, selectedProjectGroup, checkProtocol
);
         }
-        
+
         return result;
     }
 

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddProjectAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddProjectAction.java?view=diff&rev=510559&r1=510558&r2=510559
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddProjectAction.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddProjectAction.java
Thu Feb 22 07:52:47 2007
@@ -20,30 +20,25 @@
  */
 
 import com.opensymphony.xwork.Validateable;
-import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.Continuum;
+import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectGroup;
-import org.apache.maven.continuum.security.ContinuumRoleConstants;
-import org.codehaus.plexus.security.ui.web.interceptor.SecureAction;
-import org.codehaus.plexus.security.ui.web.interceptor.SecureActionBundle;
-import org.codehaus.plexus.security.ui.web.interceptor.SecureActionException;
+import org.apache.maven.continuum.web.exception.AuthorizationRequiredException;
+import org.codehaus.plexus.util.StringUtils;
 
-import java.util.Iterator;
-import java.util.Collection;
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
 
 /**
  * @author Nick Gonzalez
  * @version $Id$
- *
- * @plexus.component
- *   role="com.opensymphony.xwork.Action"
- *   role-hint="addProject"
+ * @plexus.component role="com.opensymphony.xwork.Action" role-hint="addProject"
  */
 public class AddProjectAction
     extends ContinuumActionSupport
-    implements Validateable, SecureAction
+    implements Validateable
 {
 
     private String projectName;
@@ -102,6 +97,23 @@
     public String add()
         throws ContinuumException
     {
+        try
+        {
+            if ( StringUtils.isEmpty( getProjectGroupName() ) )
+            {
+                checkAddProjectGroupAuthorization();
+            }
+            else
+            {
+                checkAddProjectToGroupAuthorization( getProjectGroupName() );
+            }
+        }
+        catch ( AuthorizationRequiredException authzE )
+        {
+            addActionError( authzE.getMessage() );
+            return REQUIRES_AUTHORIZATION;
+        }
+
         Project project = new Project();
 
         project.setName( projectName );
@@ -124,6 +136,23 @@
     public String input()
         throws ContinuumException
     {
+        try
+        {
+            if ( StringUtils.isEmpty( getProjectGroupName() ) )
+            {
+                checkAddProjectGroupAuthorization();
+            }
+            else
+            {
+                checkAddProjectToGroupAuthorization( getProjectGroupName() );
+            }
+        }
+        catch ( AuthorizationRequiredException authzE )
+        {
+            addActionError( authzE.getMessage() );
+            return REQUIRES_AUTHORIZATION;
+        }
+
         projectGroups = new ArrayList();
 
         Collection allProjectGroups = getContinuum().getAllProjectGroups();
@@ -138,8 +167,8 @@
 
         if ( !disableGroupSelection )
         {
-            selectedProjectGroup = getContinuum().getProjectGroupByGroupId(
-                Continuum.DEFAULT_PROJECT_GROUP_GROUP_ID ).getId();
+            selectedProjectGroup =
+                getContinuum().getProjectGroupByGroupId( Continuum.DEFAULT_PROJECT_GROUP_GROUP_ID
).getId();
         }
 
         return SUCCESS;
@@ -213,17 +242,6 @@
     public void setProjectVersion( String projectVersion )
     {
         this.projectVersion = projectVersion;
-    }
-
-
-    public SecureActionBundle getSecureActionBundle()
-        throws SecureActionException
-    {
-        SecureActionBundle bundle = new SecureActionBundle();
-        bundle.setRequiresAuthentication( true );
-        bundle.addRequiredAuthorization( ContinuumRoleConstants.CONTINUUM_ADD_GROUP_OPERATION
);
-
-        return bundle;
     }
 
     public Collection getProjectGroups()

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddProjectGroupAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddProjectGroupAction.java?view=diff&rev=510559&r1=510558&r2=510559
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddProjectGroupAction.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddProjectGroupAction.java
Thu Feb 22 07:52:47 2007
@@ -71,33 +71,33 @@
         try
         {
             checkAddProjectGroupAuthorization();
+        }
+        catch ( AuthorizationRequiredException authzE )
+        {
+            addActionError( authzE.getMessage() );
+            return REQUIRES_AUTHORIZATION;
+        }
 
-            ProjectGroup projectGroup = new ProjectGroup();
-
-            projectGroup.setName( name );
-
-            projectGroup.setGroupId( groupId );
+        ProjectGroup projectGroup = new ProjectGroup();
 
-            projectGroup.setDescription( description );
+        projectGroup.setName( name );
 
-            try
-            {
-                getContinuum().addProjectGroup( projectGroup );
-            }
-            catch ( ContinuumException e )
-            {
-                getLogger().error( "Error adding project group: " + e.getLocalizedMessage()
);
+        projectGroup.setGroupId( groupId );
 
-                return ERROR;
-            }
+        projectGroup.setDescription( description );
 
-            return SUCCESS;
+        try
+        {
+            getContinuum().addProjectGroup( projectGroup );
         }
-        catch ( AuthorizationRequiredException authzE )
+        catch ( ContinuumException e )
         {
-            addActionError( authzE.getMessage() );
-            return REQUIRES_AUTHORIZATION;
+            getLogger().error( "Error adding project group: " + e.getLocalizedMessage() );
+
+            return ERROR;
         }
+
+        return SUCCESS;
     }
 
     public String input()



Mime
View raw message