continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r581164 - in /maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action: AddMavenProjectAction.java AddProjectAction.java
Date Tue, 02 Oct 2007 09:12:24 GMT
Author: evenisse
Date: Tue Oct  2 02:12:23 2007
New Revision: 581164

URL: http://svn.apache.org/viewvc?rev=581164&view=rev
Log:
Add only authorized project groups to the list

Modified:
    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/AddProjectAction.java

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?rev=581164&r1=581163&r2=581164&view=diff
==============================================================================
--- 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
Tue Oct  2 02:12:23 2007
@@ -19,14 +19,6 @@
  * under the License.
  */
 
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.builddefinition.BuildDefinitionServiceException;
 import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
@@ -35,6 +27,14 @@
 import org.apache.maven.continuum.web.exception.AuthorizationRequiredException;
 import org.codehaus.plexus.util.StringUtils;
 
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
 /**
  * Action to add a Maven project to Continuum, either Maven 1 or Maven 2.
  *
@@ -69,11 +69,11 @@
     private boolean scmUseCache;
 
     private int projectGroupId;
-    
+
     private List<BuildDefinitionTemplate> buildDefinitionTemplates;
-    
+
     private int buildDefinitionTemplateId;
-    
+
     public String execute()
         throws ContinuumException, BuildDefinitionServiceException
     {
@@ -194,7 +194,7 @@
 
     // TODO: Remove this method because a default method return SUCCESS instead of INPUT
     public String doDefault()
-    throws BuildDefinitionServiceException
+        throws BuildDefinitionServiceException
     {
         return input();
     }
@@ -231,11 +231,10 @@
         for ( Iterator i = allProjectGroups.iterator(); i.hasNext(); )
         {
             ProjectGroup pg = (ProjectGroup) i.next();
-            //TODO: must implement same functionality using plexus-security
-            //if ( pg.getPermissions().isWrite() )
-            //{
-            projectGroups.add( pg );
-            //}
+            if ( isAuthorizedToAddProjectToGroup( pg.getName() ) )
+            {
+                projectGroups.add( pg );
+            }
         }
 
         initializeProjectGroupName();
@@ -376,5 +375,18 @@
     public void setBuildDefinitionTemplateId( int buildDefinitionTemplateId )
     {
         this.buildDefinitionTemplateId = buildDefinitionTemplateId;
+    }
+
+    private boolean isAuthorizedToAddProjectToGroup( String projectGroupName )
+    {
+        try
+        {
+            checkAddProjectToGroupAuthorization( projectGroupName );
+            return true;
+        }
+        catch ( AuthorizationRequiredException authzE )
+        {
+            return false;
+        }
     }
 }

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?rev=581164&r1=581163&r2=581164&view=diff
==============================================================================
--- 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
Tue Oct  2 02:12:23 2007
@@ -19,11 +19,7 @@
  * under the License.
  */
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
+import com.opensymphony.xwork.Validateable;
 import org.apache.maven.continuum.Continuum;
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.builddefinition.BuildDefinitionServiceException;
@@ -36,7 +32,10 @@
 import org.apache.maven.continuum.web.exception.AuthorizationRequiredException;
 import org.codehaus.plexus.util.StringUtils;
 
-import com.opensymphony.xwork.Validateable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
 
 /**
  * @author Nick Gonzalez
@@ -47,7 +46,6 @@
     extends ContinuumActionSupport
     implements Validateable
 {
-
     private String projectName;
 
     private String projectVersion;
@@ -80,9 +78,9 @@
     private ProfileService profileService;
 
     private int projectGroupId;
-    
+
     private int buildDefintionTemplateId;
-    
+
     private List<BuildDefinitionTemplate> buildDefinitionTemplates;
 
     public void validate()
@@ -97,9 +95,9 @@
             {
                 Project project = projects.next();
                 // CONTINUUM-1445
-                if ( StringUtils.equalsIgnoreCase( project.getName(), projectName )
-                    && StringUtils.equalsIgnoreCase( project.getVersion(), projectVersion
)
-                    && StringUtils.equalsIgnoreCase( project.getScmUrl(), projectScmUrl
) )
+                if ( StringUtils.equalsIgnoreCase( project.getName(), projectName ) &&
+                    StringUtils.equalsIgnoreCase( project.getVersion(), projectVersion )
&&
+                    StringUtils.equalsIgnoreCase( project.getScmUrl(), projectScmUrl ) )
                 {
                     projectNameAlreadyExist = true;
                     break;
@@ -160,7 +158,7 @@
         project.setScmUseCache( projectScmUseCache );
 
         project.setExecutorId( projectType );
-        
+
         getContinuum().addProject( project, projectType, selectedProjectGroup, this.getBuildDefintionTemplateId()
);
 
         if ( this.getSelectedProjectGroup() > 0 )
@@ -200,8 +198,10 @@
         {
             ProjectGroup pg = (ProjectGroup) i.next();
 
-            //TODO: must implement same functionality using plexus-security
-            projectGroups.add( pg );
+            if ( isAuthorizedToAddProjectToGroup( pg.getName() ) )
+            {
+                projectGroups.add( pg );
+            }
         }
 
         if ( !disableGroupSelection )
@@ -387,5 +387,18 @@
     public void setBuildDefinitionTemplates( List<BuildDefinitionTemplate> buildDefinitionTemplates
)
     {
         this.buildDefinitionTemplates = buildDefinitionTemplates;
+    }
+
+    private boolean isAuthorizedToAddProjectToGroup( String projectGroupName )
+    {
+        try
+        {
+            checkAddProjectToGroupAuthorization( projectGroupName );
+            return true;
+        }
+        catch ( AuthorizationRequiredException authzE )
+        {
+            return false;
+        }
     }
 }



Mime
View raw message