You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ev...@apache.org on 2007/02/06 14:03:41 UTC
svn commit: r504120 - in /maven/continuum/trunk:
continuum-api/src/main/java/org/apache/maven/continuum/
continuum-api/src/main/java/org/apache/maven/continuum/store/
continuum-core/src/main/java/org/apache/maven/continuum/
continuum-store/src/main/jav...
Author: evenisse
Date: Tue Feb 6 05:03:39 2007
New Revision: 504120
URL: http://svn.apache.org/viewvc?view=rev&rev=504120
Log:
[CONTINUUM-1153] Add project group level release button
Submitted by: Henry S. Isidro
Modified:
maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml
maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupSummary.jsp
Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java?view=diff&rev=504120&r1=504119&r2=504120
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java (original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java Tue Feb 6 05:03:39 2007
@@ -68,6 +68,9 @@
public Collection getProjectsInGroup( int projectGroupId )
throws ContinuumException;
+ public Collection getProjectsInGroupWithDependencies( int projectGroupId )
+ throws ContinuumException;
+
public void removeProjectGroup( int projectGroupId )
throws ContinuumException;
@@ -192,7 +195,7 @@
/**
* Add a project to the list of building projects (ant, shell,...)
*
- * @param project the project to add
+ * @param project the project to add
* @param executorId the id of an {@link org.apache.maven.continuum.execution.ContinuumBuildExecutor}, eg. <code>ant</code> or <code>shell</code>
* @return id of the project
* @throws ContinuumException
@@ -203,8 +206,8 @@
/**
* Add a project to the list of building projects (ant, shell,...)
*
- * @param project the project to add
- * @param executorId the id of an {@link org.apache.maven.continuum.execution.ContinuumBuildExecutor}, eg. <code>ant</code> or <code>shell</code>
+ * @param project the project to add
+ * @param executorId the id of an {@link org.apache.maven.continuum.execution.ContinuumBuildExecutor}, eg. <code>ant</code> or <code>shell</code>
* @param projectGroupId
* @return id of the project
* @throws ContinuumException
@@ -225,7 +228,7 @@
/**
* Add a Maven 2 project to the list of projects.
*
- * @param metadataUrl url of the pom.xml
+ * @param metadataUrl url of the pom.xml
* @param checkProtocol check if the protocol is allowed, use false if the pom is uploaded
* @return a holder with the projects, project groups and errors occurred during the project adding
* @throws ContinuumException
@@ -236,7 +239,7 @@
/**
* Add a Maven 2 project to the list of projects.
*
- * @param metadataUrl url of the pom.xml
+ * @param metadataUrl url of the pom.xml
* @param projectGroupId id of the project group to use
* @return a holder with the projects, project groups and errors occurred during the project adding
* @throws ContinuumException
@@ -247,9 +250,9 @@
/**
* Add a Maven 2 project to the list of projects.
*
- * @param metadataUrl url of the pom.xml
+ * @param metadataUrl url of the pom.xml
* @param projectGroupId id of the project group to use
- * @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 a holder with the projects, project groups and errors occurred during the project adding
* @throws ContinuumException
*/
@@ -263,42 +266,42 @@
* @return a holder with the projects, project groups and errors occurred during the project adding
* @throws ContinuumException
*/
- ContinuumProjectBuildingResult addMavenOneProject( String metadataUrl )
+ ContinuumProjectBuildingResult addMavenOneProject( String metadataUrl )
throws ContinuumException;
/**
* Add a Maven 1 project to the list of projects.
*
- * @param metadataUrl url of the project.xml
+ * @param metadataUrl url of the project.xml
* @param checkProtocol check if the protocol is allowed, use false if the pom is uploaded
* @return a holder with the projects, project groups and errors occurred during the project adding
* @throws ContinuumException
*/
- ContinuumProjectBuildingResult addMavenOneProject( String metadataUrl, boolean checkProtocol )
+ ContinuumProjectBuildingResult addMavenOneProject( String metadataUrl, boolean checkProtocol )
throws ContinuumException;
/**
* Add a Maven 1 project to the list of projects.
*
- * @param metadataUrl url of the project.xml
+ * @param metadataUrl url of the project.xml
* @param projectGroupId id of the project group to use
* @return a holder with the projects, project groups and errors occurred during the project adding
* @throws ContinuumException
*/
ContinuumProjectBuildingResult addMavenOneProject( String metadataUrl, int projectGroupId )
- throws ContinuumException;
+ throws ContinuumException;
/**
* Add a Maven 1 project to the list of projects.
*
- * @param metadataUrl url of the project.xml
+ * @param metadataUrl url of the project.xml
* @param projectGroupId id of the project group to use
- * @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 a holder with the projects, project groups and errors occurred during the project adding
* @throws ContinuumException
*/
ContinuumProjectBuildingResult addMavenOneProject( String metadataUrl, int projectGroupId, boolean checkProtocol )
- throws ContinuumException;
+ throws ContinuumException;
void updateProject( Project project )
throws ContinuumException;
@@ -376,7 +379,7 @@
/**
* returns the default build definition for the project
- *
+ * <p/>
* 1) if project has default build definition, return that
* 2) otherwise return default build definition for parent project group
*
@@ -410,7 +413,6 @@
BuildDefinition updateBuildDefinitionForProjectGroup( int projectGroupId, BuildDefinition buildDefinition )
throws ContinuumException;
-
// ----------------------------------------------------------------------
// Schedule
Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java?view=diff&rev=504120&r1=504119&r2=504120
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java (original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java Tue Feb 6 05:03:39 2007
@@ -191,6 +191,9 @@
List getProjectsInGroup( int projectGroupId )
throws ContinuumObjectNotFoundException, ContinuumStoreException;
+ List getProjectsInGroupWithDependencies( int projectGroupId )
+ throws ContinuumObjectNotFoundException, ContinuumStoreException;
+
ProjectGroup getProjectGroupWithProjects( int projectGroupId )
throws ContinuumObjectNotFoundException, ContinuumStoreException;
Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?view=diff&rev=504120&r1=504119&r2=504120
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java Tue Feb 6 05:03:39 2007
@@ -2583,6 +2583,23 @@
}
}
+ public Collection getProjectsInGroupWithDependencies( int projectGroupId )
+ throws ContinuumException
+ {
+ try
+ {
+ return store.getProjectsInGroupWithDependencies( projectGroupId );
+ }
+ catch ( ContinuumObjectNotFoundException e )
+ {
+ throw new ContinuumException( "Unable to find the requested project", e );
+ }
+ catch ( ContinuumStoreException e )
+ {
+ throw new ContinuumException( "Error retrieving the requested project", e );
+ }
+ }
+
// ----------------------------------------------------------------------
// Private Utilities
// ----------------------------------------------------------------------
Modified: maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java?view=diff&rev=504120&r1=504119&r2=504120
==============================================================================
--- maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java (original)
+++ maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java Tue Feb 6 05:03:39 2007
@@ -1162,6 +1162,41 @@
Query query = pm.newQuery( extent, "projectGroup.id == " + projectGroupId );
query.setOrdering( "name ascending" );
+
+ pm.getFetchPlan().addGroup( PROJECTGROUP_PROJECTS_FETCH_GROUP );
+
+ List result = (List) query.execute();
+
+ result = (List) pm.detachCopyAll( result );
+
+ tx.commit();
+
+ return result;
+ }
+ finally
+ {
+ rollback( tx );
+ }
+ }
+
+ public List getProjectsInGroupWithDependencies( int projectGroupId )
+ throws ContinuumObjectNotFoundException, ContinuumStoreException
+ {
+ PersistenceManager pm = getPersistenceManager();
+
+ Transaction tx = pm.currentTransaction();
+
+ try
+ {
+ tx.begin();
+
+ Extent extent = pm.getExtent( Project.class, true );
+
+ Query query = pm.newQuery( extent, "projectGroup.id == " + projectGroupId );
+
+ query.setOrdering( "name ascending" );
+
+ pm.getFetchPlan().addGroup( PROJECT_DEPENDENCIES_FETCH_GROUP );
pm.getFetchPlan().addGroup( PROJECTGROUP_PROJECTS_FETCH_GROUP );
Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java?view=diff&rev=504120&r1=504119&r2=504120
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java Tue Feb 6 05:03:39 2007
@@ -21,8 +21,12 @@
import org.apache.maven.continuum.ContinuumException;
import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectDependency;
import org.apache.maven.continuum.model.project.ProjectGroup;
+import org.apache.maven.continuum.project.ContinuumProjectState;
import org.apache.maven.continuum.web.bean.ProjectGroupUserBean;
+import org.codehaus.plexus.rbac.profile.RoleProfileException;
+import org.codehaus.plexus.rbac.profile.RoleProfileManager;
import org.codehaus.plexus.security.rbac.RBACManager;
import org.codehaus.plexus.security.rbac.RbacManagerException;
import org.codehaus.plexus.security.rbac.RbacObjectNotFoundException;
@@ -30,8 +34,6 @@
import org.codehaus.plexus.security.user.User;
import org.codehaus.plexus.security.user.UserManager;
import org.codehaus.plexus.util.StringUtils;
-import org.codehaus.plexus.rbac.profile.RoleProfileManager;
-import org.codehaus.plexus.rbac.profile.RoleProfileException;
import java.util.ArrayList;
import java.util.Collection;
@@ -46,22 +48,21 @@
*
* @author Jesse McConnell <jm...@apache.org>
* @version $Id$
- *
- * @plexus.component
- * role="com.opensymphony.xwork.Action"
- * role-hint="projectGroup"
+ * @plexus.component role="com.opensymphony.xwork.Action"
+ * role-hint="projectGroup"
*/
public class ProjectGroupAction
extends ContinuumConfirmAction
{
private final static Map FILTER_CRITERIA = new HashMap();
+
static
{
FILTER_CRITERIA.put( "username", "Username contains" );
FILTER_CRITERIA.put( "fullName", "Name contains" );
FILTER_CRITERIA.put( "email", "Email contains" );
}
-
+
/**
* @plexus.requirement
*/
@@ -90,21 +91,23 @@
private Map projectGroups = new HashMap();
private boolean confirmed;
-
+
private boolean projectInCOQueue = false;
private Collection projectList;
private List projectGroupUsers;
-
+
private String filterProperty;
-
+
private String filterKey;
-
+
private boolean ascending = true;
-
+
private Collection groupProjects;
+ private int releaseProjectId;
+
public String summary()
throws ContinuumException
{
@@ -117,20 +120,20 @@
throws ContinuumException
{
projectGroup = getContinuum().getProjectGroup( projectGroupId );
-
+
groupProjects = getContinuum().getProjectsInGroup( projectGroupId );
populateProjectGroupUsers( projectGroup );
-
+
return SUCCESS;
}
public Collection getGroupProjects()
throws ContinuumException
{
- return groupProjects;
+ return groupProjects;
}
-
+
public String buildDefinitions()
throws ContinuumException
{
@@ -170,11 +173,11 @@
description = projectGroup.getDescription();
projectList = getContinuum().getProjectsInGroup( projectGroupId );
-
- if( projectList != null )
+
+ if ( projectList != null )
{
Iterator proj = projectList.iterator();
-
+
while ( proj.hasNext() )
{
Project p = (Project) proj.next();
@@ -228,27 +231,27 @@
{
String key = (String) keys.next();
- String [] id = (String []) projects.get( key );
-
+ String[] id = (String[]) projects.get( key );
+
int projectId = Integer.parseInt( key );
Project project = null;
Iterator i = projectGroup.getProjects().iterator();
- while( i.hasNext() )
+ while ( i.hasNext() )
{
project = (Project) i.next();
- if( projectId == project.getId() )
+ if ( projectId == project.getId() )
{
break;
}
}
-
- ProjectGroup newProjectGroup = getProjectGroup( new Integer (id[0]).intValue() );
-
+
+ ProjectGroup newProjectGroup = getProjectGroup( new Integer( id[0] ).intValue() );
+
if ( newProjectGroup.getId() != projectGroup.getId() )
{
- getLogger().info( "Moving project " + project.getName() + " to project group "
- + newProjectGroup.getName() );
+ getLogger().info(
+ "Moving project " + project.getName() + " to project group " + newProjectGroup.getName() );
project.setProjectGroup( newProjectGroup );
getContinuum().updateProject( project );
}
@@ -265,10 +268,90 @@
return SUCCESS;
}
- private void populateProjectGroupUsers( ProjectGroup group )
+ public String release()
+ throws ContinuumException
+ {
+ //get the parent of the group by finding the parent project
+ //i.e., the project that doesn't have a parent, or it's parent is not in the group.
+
+ Project parent = null;
+
+ boolean allBuildsOk = true;
+
+ projectList = getContinuum().getProjectsInGroupWithDependencies( projectGroupId );
+
+ if ( projectList != null )
+ {
+ Iterator proj = projectList.iterator();
+
+ while ( proj.hasNext() )
+ {
+ Project p = (Project) proj.next();
+
+ if ( p.getState() != ContinuumProjectState.OK )
+ {
+ allBuildsOk = false;
+ }
+
+ if ( ( p.getParent() == null ) || ( !isParentInProjectGroup( p.getParent(), projectList ) ) )
+ {
+ if ( parent == null )
+ {
+ parent = p;
+ }
+ else
+ {
+ //currently, we have no provisions for releasing 2 or more parents
+ //at the same time, this will be implemented in the future
+ throw new ContinuumException(
+ "Cannot release two or more parent projects in the same project group at the same time." );
+ }
+ }
+ }
+ }
+
+ releaseProjectId = parent.getId();
+
+ if ( allBuildsOk )
+ {
+ return SUCCESS;
+ }
+ else
+ {
+ throw new ContinuumException(
+ "Cannot release project group: one or more projects in the group were not built successfully." );
+ }
+ }
+
+ private boolean isParentInProjectGroup( ProjectDependency parent, Collection projectsInGroup )
+ throws ContinuumException
+ {
+ boolean result = false;
+
+ Iterator projectsIterator = projectsInGroup.iterator();
+
+ while ( projectsIterator.hasNext() )
+ {
+ Project project = (Project) projectsIterator.next();
+
+ if ( parent != null )
+ {
+ if ( ( project.getArtifactId().equals( parent.getArtifactId() ) ) &&
+ ( project.getGroupId().equals( parent.getGroupId() ) ) &&
+ ( project.getVersion().equals( parent.getVersion() ) ) )
+ {
+ result = true;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ private void populateProjectGroupUsers( ProjectGroup group )
{
List users;
-
+
if ( StringUtils.isEmpty( filterKey ) )
{
users = manager.getUsers( ascending );
@@ -277,33 +360,33 @@
{
users = findUsers( filterProperty, filterKey, ascending );
}
-
+
projectGroupUsers = new ArrayList();
-
+
for ( Iterator i = users.iterator(); i.hasNext(); )
{
ProjectGroupUserBean pgUser = new ProjectGroupUserBean();
-
+
User user = (User) i.next();
-
+
pgUser.setUser( user );
-
+
pgUser.setProjectGroup( group );
-
+
try
{
Collection effectiveRoles = rbac.getEffectivelyAssignedRoles( user.getUsername() );
for ( Iterator j = effectiveRoles.iterator(); j.hasNext(); )
{
Role role = (Role) j.next();
- if( role.getName().indexOf( projectGroup.getName() ) > -1 )
+ if ( role.getName().indexOf( projectGroup.getName() ) > -1 )
{
pgUser.setRoles( effectiveRoles );
projectGroupUsers.add( pgUser );
break;
}
}
-
+
}
catch ( RbacObjectNotFoundException e )
{
@@ -315,11 +398,11 @@
}
}
}
-
+
private List findUsers( String searchProperty, String searchKey, boolean orderAscending )
{
List users = null;
-
+
if ( "username".equals( searchProperty ) )
{
users = manager.findUsersByUsernameKey( searchKey, orderAscending );
@@ -336,10 +419,10 @@
{
users = Collections.EMPTY_LIST;
}
-
+
return users;
}
-
+
public int getProjectGroupId()
{
return projectGroupId;
@@ -430,6 +513,7 @@
{
return projectList;
}
+
public List getProjectGroupUsers()
{
return projectGroupUsers;
@@ -469,5 +553,15 @@
{
return FILTER_CRITERIA;
}
-
+
+ public void setReleaseProjectId( int releaseProjectId )
+ {
+ this.releaseProjectId = releaseProjectId;
+ }
+
+ public int getReleaseProjectId()
+ {
+ return this.releaseProjectId;
+ }
+
}
Modified: maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties?view=diff&rev=504120&r1=504119&r2=504120
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties Tue Feb 6 05:03:39 2007
@@ -32,6 +32,7 @@
edit = Edit
delete = Delete
build = Build
+release = Release
save = Save
add = Add
back = Back
Modified: maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml?view=diff&rev=504120&r1=504119&r2=504120
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/resources/xwork.xml Tue Feb 6 05:03:39 2007
@@ -271,6 +271,13 @@
<param name="actionName">groupSummary</param>
</result>
</action>
+
+ <action name="releaseProjectGroup" class="projectGroup" method="release">
+ <result name="success" type="redirect-action">
+ <param name="actionName">releasePromptGoal</param>
+ <param name="projectId">${releaseProjectId}</param>
+ </result>
+ </action>
<action name="addProjectGroup" class="addProjectGroup">
<result name="input">/WEB-INF/jsp/projectGroupAdd.jsp</result>
Modified: maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupSummary.jsp
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupSummary.jsp?view=diff&rev=504120&r1=504119&r2=504120
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupSummary.jsp (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupSummary.jsp Tue Feb 6 05:03:39 2007
@@ -108,6 +108,14 @@
</pss:ifAuthorized>
</td>
<td>
+ <pss:ifAuthorized permission="continuum-build-group" resource="${projectGroup.name}">
+ <form action="releaseProjectGroup.action" method="post">
+ <input type="hidden" name="projectGroupId" value="<ww:property value="projectGroupId"/>"/>
+ <input type="submit" name="release" value="<ww:text name="release"/>"/>
+ </form>
+ </pss:ifAuthorized>
+ </td>
+ <td>
<pss:ifAnyAuthorized permissions="continuum-add-project-to-group" resource="${projectGroup.name}">
<ww:form name="addNewProject">
<ww:hidden name="disableGroupSelection" value="true"/>