1 | package org.apache.maven.continuum.core.action; |
2 | |
3 | /* |
4 | * Licensed to the Apache Software Foundation (ASF) under one |
5 | * or more contributor license agreements. See the NOTICE file |
6 | * distributed with this work for additional information |
7 | * regarding copyright ownership. The ASF licenses this file |
8 | * to you under the Apache License, Version 2.0 (the |
9 | * "License"); you may not use this file except in compliance |
10 | * with the License. You may obtain a copy of the License at |
11 | * |
12 | * http://www.apache.org/licenses/LICENSE-2.0 |
13 | * |
14 | * Unless required by applicable law or agreed to in writing, |
15 | * software distributed under the License is distributed on an |
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
17 | * KIND, either express or implied. See the License for the |
18 | * specific language governing permissions and limitations |
19 | * under the License. |
20 | */ |
21 | |
22 | import java.util.List; |
23 | import java.util.Map; |
24 | |
25 | import org.apache.continuum.dao.ProjectDao; |
26 | import org.apache.maven.continuum.ContinuumException; |
27 | import org.apache.maven.continuum.execution.manager.BuildExecutorManager; |
28 | import org.apache.maven.continuum.model.project.Project; |
29 | import org.codehaus.plexus.util.StringUtils; |
30 | |
31 | /** |
32 | * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> |
33 | * @version $Id: ValidateProject.java 771177 2009-05-04 05:02:26Z evenisse $ |
34 | * @plexus.component role="org.codehaus.plexus.action.Action" |
35 | * role-hint="validate-project" |
36 | */ |
37 | public class ValidateProject |
38 | extends AbstractValidationContinuumAction |
39 | { |
40 | /** |
41 | * @plexus.requirement |
42 | */ |
43 | private BuildExecutorManager buildExecutorManager; |
44 | |
45 | /** |
46 | * @plexus.requirement |
47 | */ |
48 | private ProjectDao projectDao; |
49 | |
50 | public void execute( Map context ) |
51 | throws Exception |
52 | { |
53 | Project project = getUnvalidatedProject( context ); |
54 | |
55 | // ---------------------------------------------------------------------- |
56 | // Make sure that the builder id is correct before starting to check |
57 | // stuff out |
58 | // ---------------------------------------------------------------------- |
59 | |
60 | if ( !buildExecutorManager.hasBuildExecutor( project.getExecutorId() ) ) |
61 | { |
62 | throw new ContinuumException( "No such executor with id '" + project.getExecutorId() + "'." ); |
63 | } |
64 | |
65 | List<Project> projects = projectDao.getAllProjectsByName(); |
66 | |
67 | for ( Project storedProject : projects ) |
68 | { |
69 | // CONTINUUM-1445 |
70 | if ( StringUtils.equalsIgnoreCase( project.getName(), storedProject.getName() ) && |
71 | StringUtils.equalsIgnoreCase( project.getVersion(), storedProject.getVersion() ) && |
72 | StringUtils.equalsIgnoreCase( project.getScmUrl(), storedProject.getScmUrl() ) ) |
73 | { |
74 | throw new ContinuumException( "A duplicate project already exist '" + storedProject.getName() + "'." ); |
75 | } |
76 | } |
77 | /* |
78 | if ( store.getProjectByName( project.getName() ) != null ) |
79 | { |
80 | throw new ContinuumException( "A project with the name '" + project.getName() + "' already exist." ); |
81 | } |
82 | */ |
83 | |
84 | // if ( getProjectByScmUrl( scmUrl ) != null ) |
85 | // { |
86 | // throw new ContinuumStoreException( "A project with the scm url '" + scmUrl + "' already exist." ); |
87 | // } |
88 | |
89 | // TODO: Enable |
90 | // assertStringNotEmpty( project.getPath(), "path" ); |
91 | // assertStringNotEmpty( project.getGroupId(), "group id" ); |
92 | // assertStringNotEmpty( project.getArtifactId(), "artifact id" ); |
93 | |
94 | // if ( project.getProjectGroup() == null ) |
95 | // { |
96 | // throw new ContinuumException( "A project has to belong to a project group." ); |
97 | // } |
98 | |
99 | // TODO: validate that the SCM provider id |
100 | } |
101 | } |