Package org.apache.maven.continuum.model.project

Examples of org.apache.maven.continuum.model.project.ProjectGroup


                {
                    break;
                }
            }

            ProjectGroup newProjectGroup = getContinuum().getProjectGroupWithProjects( new Integer( id[0] ) );

            if ( newProjectGroup.getId() != projectGroup.getId() && isAuthorized( newProjectGroup.getName() ) )
            {
                logger.info( "Moving project " + project.getName() + " to project group " + newProjectGroup.getName() );
                project.setProjectGroup( newProjectGroup );

                // CONTINUUM-1512
                Collection<BuildResult> results = getContinuum().getBuildResultsForProject( project.getId() );
                for ( BuildResult br : results )
View Full Code Here


        Map<String, Object> context = new HashMap<String, Object>();

        try
        {
            Project project = projectDao.getProject( projectId );
            ProjectGroup projectGroup = project.getProjectGroup();

            List<ProjectScmRoot> scmRoots = projectScmRootDao.getProjectScmRootByProjectGroup( projectGroup.getId() );
            String projectScmUrl = project.getScmUrl();

            for ( ProjectScmRoot projectScmRoot : scmRoots )
            {
                if ( projectScmUrl.startsWith( projectScmRoot.getScmRootAddress() ) )
                {
                    AbstractContinuumAction.setProjectScmRoot( context, projectScmRoot );
                    break;
                }
            }

            AbstractContinuumAction.setProjectGroupId( context, projectGroup.getId() );
            AbstractContinuumAction.setProjectId( context, projectId );
            AbstractContinuumAction.setProject( context, project );

            AbstractContinuumAction.setBuildDefinitionId( context, buildDefinitionId );
            AbstractContinuumAction.setBuildDefinition( context,
View Full Code Here

    private void sendMessage( ProjectScmRoot projectScmRoot, List<ProjectNotifier> notifiers, String subject,
                              String content, MessageContext context )
        throws NotificationException
    {
        ProjectGroup projectGroup = projectScmRoot.getProjectGroup();

        if ( notifiers.size() == 0 )
        {
            // This is a useful message for the users when debugging why they don't
            // receive any mails

            log.info( "No mail notifier for '" + projectGroup.getName() + "'." );

            return;
        }

        String fromMailbox = getFromMailbox( notifiers );

        if ( fromMailbox == null )
        {
            log.warn( projectGroup.getName() +
                ": ProjectGroup is missing nag email and global from mailbox is missing, not sending mail." );

            return;
        }
View Full Code Here

    }

    public void removeProjectGroup( int projectGroupId )
        throws ContinuumException
    {
        ProjectGroup projectGroup = getProjectGroupWithProjects( projectGroupId );

        if ( projectGroup != null )
        {
            List<Project> projects = projectGroup.getProjects();
            int[] projectIds = new int[projects.size()];

            int idx = 0;
            for ( Project project : projects )
            {
                projectIds[idx] = project.getId();
                idx++;
            }

            // check if any project is still being checked out
            // canceling the checkout and proceeding with the delete results to a cannot delete directory error!
            try
            {
                if ( parallelBuildsManager.isAnyProjectCurrentlyBeingCheckedOut( projectIds ) )
                {
                    throw new ContinuumException(
                        "Unable to delete group. At least one project in group is still being checked out." );
                }

                if ( parallelBuildsManager.isAnyProjectCurrentlyBuilding( projectIds ) )
                {
                    throw new ContinuumException(
                        "Unable to delete group. At least one project in group is still building." );
                }

                if ( isAnyProjectsInReleaseStage( projects ) )
                {
                    throw new ContinuumException(
                        "Unable to delete group. At least one project in group is in release stage" );
                }
            }
            catch ( BuildManagerException e )
            {
                throw new ContinuumException( "Unable to delete group.", e );
            }

            for ( int projectId : projectIds )
            {
                removeProject( projectId );
            }

            // check if there are any project scm root left
            List<ProjectScmRoot> scmRoots = getProjectScmRootByProjectGroup( projectGroupId );

            for ( ProjectScmRoot scmRoot : scmRoots )
            {
                removeProjectScmRoot( scmRoot );
            }

            log.info( "Remove project group " + projectGroup.getName() + "(" + projectGroup.getId() + ")" );

            Map<String, Object> context = new HashMap<String, Object>();
            AbstractContinuumAction.setProjectGroupId( context, projectGroup.getId() );
            executeAction( "remove-assignable-roles", context );

            projectGroupDao.removeProjectGroup( projectGroup );
        }
    }
View Full Code Here

    }

    public void addProjectGroup( ProjectGroup projectGroup )
        throws ContinuumException
    {
        ProjectGroup pg = null;

        try
        {
            pg = projectGroupDao.getProjectGroupByGroupId( projectGroup.getGroupId() );
        }
        catch ( ContinuumObjectNotFoundException e )
        {
            //since we want to add a new project group, we should be getting
            //this exception
        }
        catch ( ContinuumStoreException e )
        {
            throw new ContinuumException( "Unable to add the requested project group", e );
        }

        if ( pg == null )
        {
            //CONTINUUM-1502
            projectGroup.setName( projectGroup.getName().trim() );
            try
            {
                ProjectGroup new_pg = projectGroupDao.addProjectGroup( projectGroup );

                buildDefinitionService.addBuildDefinitionTemplateToProjectGroup( new_pg.getId(),
                                                                                 buildDefinitionService.getDefaultMavenTwoBuildDefinitionTemplate() );

                Map<String, Object> context = new HashMap<String, Object>();
                AbstractContinuumAction.setProjectGroupId( context, new_pg.getId() );
                executeAction( "add-assignable-roles", context );

                log.info( "Added new project group: " + new_pg.getName() );
            }
            catch ( BuildDefinitionServiceException e )
            {
                throw new ContinuumException( e.getMessage(), e );
            }
View Full Code Here

    private int executeAddProjectFromScmActivity( Project project, int groupId, int buildDefinitionTemplateId )
        throws ContinuumException
    {
        String executorId = project.getExecutorId();

        ProjectGroup projectGroup = getProjectGroupWithBuildDetails( groupId );

        Map<String, Object> context = new HashMap<String, Object>();

        String scmUrl = project.getScmUrl();

        List<ProjectScmRoot> scmRoots = getProjectScmRootByProjectGroup( groupId );

        boolean found = false;

        for ( ProjectScmRoot scmRoot : scmRoots )
        {
            if ( scmUrl.startsWith( scmRoot.getScmRootAddress() ) )
            {
                found = true;
                break;
            }
        }

        if ( !found )
        {
            createProjectScmRoot( projectGroup, scmUrl );
        }

        // ----------------------------------------------------------------------
        //
        // ----------------------------------------------------------------------

        AbstractContinuumAction.setWorkingDirectory( context, getWorkingDirectory() );

        AbstractContinuumAction.setUnvalidatedProject( context, project );

        AbstractContinuumAction.setUnvalidatedProjectGroup( context, projectGroup );

        AbstractContinuumAction.setProjectGroupId( context, projectGroup.getId() );

        executeAction( "validate-project", context );

        executeAction( "store-project", context );
View Full Code Here

        if ( result.getProjectGroups().size() != 1 )
        {
            throw new ContinuumException( "The project building result has to contain exactly one project group." );
        }

        ProjectGroup projectGroup = result.getProjectGroups().iterator().next();

        boolean projectGroupCreation = false;

        try
        {
            if ( projectGroupId == -1 )
            {
                try
                {
                    projectGroup = projectGroupDao.getProjectGroupByGroupId( projectGroup.getGroupId() );

                    projectGroupId = projectGroup.getId();

                    log.info( "Using existing project group with the group id: '" + projectGroup.getGroupId() + "'." );
                }
                catch ( ContinuumObjectNotFoundException e )
                {
                    log.info( "Creating project group with the group id: '" + projectGroup.getGroupId() + "'." );

                    Map<String, Object> pgContext = new HashMap<String, Object>();

                    AbstractContinuumAction.setWorkingDirectory( pgContext, getWorkingDirectory() );

                    AbstractContinuumAction.setUnvalidatedProjectGroup( pgContext, projectGroup );

                    executeAction( "validate-project-group", pgContext );

                    executeAction( "store-project-group", pgContext );

                    projectGroupId = AbstractContinuumAction.getProjectGroupId( pgContext );

                    projectGroupCreation = true;
                }
            }

            projectGroup = projectGroupDao.getProjectGroupWithBuildDetailsByProjectGroupId( projectGroupId );

            String url = CreateProjectsFromMetadataAction.getUrl( context );

            List<ProjectScmRoot> scmRoots = getProjectScmRootByProjectGroup( projectGroup.getId() );

            boolean found = false;

            for ( ProjectScmRoot scmRoot : scmRoots )
            {
                if ( url.startsWith( scmRoot.getScmRootAddress() ) )
                {
                    found = true;
                    break;
                }
            }

            if ( !found )
            {
                createProjectScmRoot( projectGroup, url );
            }

            /* add the project group loaded from database, which has more info, like id */
            result.getProjectGroups().remove( 0 );
            result.getProjectGroups().add( projectGroup );
        }
        catch ( ContinuumStoreException e )
        {
            throw new ContinuumException( "Error while querying for project group.", e );
        }

        // ----------------------------------------------------------------------
        // Save all the projects if recursive mode asked
        // TODO: Validate all the projects before saving them
        // ----------------------------------------------------------------------

        List<Project> projects = result.getProjects();

        String scmUserName = null;
        String scmPassword = null;

        for ( Project project : projects )
        {
            checkForDuplicateProjectInGroup( projectGroup, project, result );

            if ( result.hasErrors() )
            {
                log.info( result.getErrors().size() + " errors during project add: " );
                log.info( result.getErrorsAsString() );
                return result;
            }

            project.setScmUseCache( useCredentialsCache );

            // values backup for first checkout
            scmUserName = project.getScmUsername();
            scmPassword = project.getScmPassword();
            // CONTINUUM-1792 : we don't store it
            if ( useCredentialsCache )
            {
                project.setScmUsername( null );
                project.setScmPassword( null );
            }

            projectGroup.addProject( project );
        }

        try
        {
            projectGroupDao.updateProjectGroup( projectGroup );

            for ( Project project : projects )
            {
                context = new HashMap<String, Object>();

                // CONTINUUM-1953 olamy : attached buildDefs from template here
                // if no group creation
                if ( !projectGroupCreation && buildDefinitionTemplateId > 0 )
                {
                    buildDefinitionService.addTemplateInProject( buildDefinitionTemplateId,
                                                                 projectDao.getProject( project.getId() ) );
                }

                AbstractContinuumAction.setUnvalidatedProject( context, project );
                //
                //            executeAction( "validate-project", context );
                //
                //            executeAction( "store-project", context );
                //
                AbstractContinuumAction.setProjectId( context, project.getId() );

                if ( !StringUtils.isEmpty( scmUserName ) )
                {
                    project.setScmUsername( scmUserName );
                    CheckoutProjectContinuumAction.setScmUsername( context, scmUserName );
                }
                if ( !StringUtils.isEmpty( scmPassword ) )
                {
                    project.setScmPassword( scmPassword );
                    CheckoutProjectContinuumAction.setScmPassword( context, scmPassword );
                }
                // FIXME
                // olamy  : read again the project to have values because store.updateProjectGroup( projectGroup );
                // remove object data -> we don't display the project name in the build queue
                AbstractContinuumAction.setProject( context, projectDao.getProject( project.getId() ) );

                BuildDefinition defaultBuildDefinition = null;
                if ( projectBuilderId.equals( MavenTwoContinuumProjectBuilder.ID ) )
                {
                    defaultBuildDefinition =
                        (BuildDefinition) buildDefinitionService.getDefaultMavenTwoBuildDefinitionTemplate().getBuildDefinitions().get(
                            0 );
                }
                else if ( projectBuilderId.equals( MavenOneContinuumProjectBuilder.ID ) )
                {
                    defaultBuildDefinition =
                        (BuildDefinition) buildDefinitionService.getDefaultMavenOneBuildDefinitionTemplate().getBuildDefinitions().get(
                            0 );
                }

                // used by BuildManager to determine on which build queue will the project be put
                AbstractContinuumAction.setBuildDefinition( context, defaultBuildDefinition );

                if ( !configurationService.isDistributedBuildEnabled() )
                {
                    executeAction( "add-project-to-checkout-queue", context );
                }

            }
        }
        catch ( BuildDefinitionServiceException e )
        {
            throw new ContinuumException( "Error attaching buildDefintionTemplate to project ", e );
        }
        catch ( ContinuumStoreException e )
        {
            throw new ContinuumException( "Error adding projects from modules", e );
        }

        AbstractContinuumAction.setProjectGroupId( context, projectGroup.getId() );
        // add the relevent security administration roles for this project
        if ( addAssignableRoles )
        {
            executeAction( "add-assignable-roles", context );
        }
View Full Code Here

    }

    public ProjectNotifier getGroupNotifier( int projectGroupId, int notifierId )
        throws ContinuumException
    {
        ProjectGroup projectGroup = getProjectGroupWithBuildDetails( projectGroupId );

        List<ProjectNotifier> notifiers = projectGroup.getNotifiers();

        ProjectNotifier notifier = null;

        for ( ProjectNotifier notif : notifiers )
        {
View Full Code Here

    }

    public ProjectNotifier updateGroupNotifier( int projectGroupId, ProjectNotifier notifier )
        throws ContinuumException
    {
        ProjectGroup projectGroup = getProjectGroupWithBuildDetails( projectGroupId );

        ProjectNotifier notif = getGroupNotifier( projectGroupId, notifier.getId() );

        // I remove notifier then add it instead of update it due to a ClassCastException in jpox
        projectGroup.removeNotifier( notif );

        try
        {
            projectGroupDao.updateProjectGroup( projectGroup );
        }
View Full Code Here

        notif.setType( notifier.getType() );

        notif.setFrom( ProjectNotifier.FROM_USER );

        ProjectGroup projectGroup = getProjectGroupWithBuildDetails( projectGroupId );

        projectGroup.addNotifier( notif );
        try
        {
            projectGroupDao.updateProjectGroup( projectGroup );
        }
        catch ( ContinuumStoreException cse )
View Full Code Here

TOP

Related Classes of org.apache.maven.continuum.model.project.ProjectGroup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.