diff options
author | Brett Porter <brett@apache.org> | 2007-08-03 16:02:00 +0000 |
---|---|---|
committer | Brett Porter <brett@apache.org> | 2007-08-03 16:02:00 +0000 |
commit | 0dc2c29c92ed68ccf1e7a266166a02908d06c699 (patch) | |
tree | e3babf1c220be5a6f47b51ac7632adafbfe42adb | |
parent | 83dfd74838cc58cdb8a9de6d1883f1969b811552 (diff) | |
download | archiva-0dc2c29c92ed68ccf1e7a266166a02908d06c699.tar.gz archiva-0dc2c29c92ed68ccf1e7a266166a02908d06c699.zip |
[MRM-329] revised reporting actions
Submitted by: Teodoro Cue
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@562511 13f79535-47bb-0310-9956-ffa450edef68
22 files changed, 734 insertions, 659 deletions
diff --git a/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/RepositoryProblemReport.java b/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/RepositoryProblemReport.java index 22e190790..15519d1b1 100644 --- a/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/RepositoryProblemReport.java +++ b/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/RepositoryProblemReport.java @@ -21,11 +21,12 @@ package org.apache.maven.archiva.model; /** * RepositoryProblemReport - * + * * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a> * @version $Id$ */ -public class RepositoryProblemReport extends RepositoryProblem +public class RepositoryProblemReport + extends RepositoryProblem { private static final long serialVersionUID = 4990893576717148324L; @@ -53,7 +54,7 @@ public class RepositoryProblemReport extends RepositoryProblem public String getGroupURL() { - return groupURL; + return groupURL; } public void setArtifactURL( String artifactURL ) @@ -63,7 +64,7 @@ public class RepositoryProblemReport extends RepositoryProblem public String getArtifactURL() { - return artifactURL; + return artifactURL; } public void setVersionURL( String versionURL ) @@ -73,6 +74,6 @@ public class RepositoryProblemReport extends RepositoryProblem public String getVersionURL() { - return versionURL; + return versionURL; } } diff --git a/archiva-database/src/main/java/org/apache/maven/archiva/database/DeclarativeConstraint.java b/archiva-database/src/main/java/org/apache/maven/archiva/database/DeclarativeConstraint.java index c87df33ab..15fa14e2b 100644 --- a/archiva-database/src/main/java/org/apache/maven/archiva/database/DeclarativeConstraint.java +++ b/archiva-database/src/main/java/org/apache/maven/archiva/database/DeclarativeConstraint.java @@ -20,84 +20,85 @@ package org.apache.maven.archiva.database; */ /** - * DeclarativeConstraint + * DeclarativeConstraint * * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a> * @version $Id$ */ -public interface DeclarativeConstraint extends Constraint +public interface DeclarativeConstraint + extends Constraint { /** * Get the declared imports used for this query. (optional) - * + * <p/> * NOTE: This is DAO implementation specific. - * + * * @return the imports. (can be null) */ public abstract String[] getDeclaredImports(); /** * Get the declared parameters used for this query. (optional) - * + * <p/> * NOTE: This is DAO implementation specific. - * + * * @return the parameters. (can be null) */ public abstract String[] getDeclaredParameters(); - + /** * The JDOQL filter to apply to the query. (optional) - * + * <p/> * NOTE: This is DAO implementation specific. - * + * * @return the filter to apply. (can be null) */ public abstract String getFilter(); /** * Get the parameters used for this query. (required if using {@link #getDeclaredParameters()} ) - * + * <p/> * NOTE: This is DAO implementation specific. - * + * * @return the parameters. (can be null) */ public abstract Object[] getParameters(); /** * Get the sort direction name. - * + * * @return the sort direction name. ("ASC" or "DESC") (only valid if {@link #getSortColumn()} is specified.) */ public abstract String getSortDirection(); /** * Get the sort column name. - * + * * @return the sort column name. (can be null) */ public abstract String getSortColumn(); - + /** * Get the variables used within the query. - * + * <p/> * NOTE: This is DAO implementation specific. - * + * * @return the variables used within the query. */ public abstract String[] getVariables(); /** * Get the SELECT WHERE (condition) value for the constraint. - * + * * @return the equivalent of the SELECT WHERE (condition) value for this constraint. (can be null) */ public abstract String getWhereCondition(); /** * Get the declared range used for this query. (optional) - * + * <p/> * NOTE: This is DAO implementation specific. - * + * * @return the range. (can be null) */ public abstract int[] getRange(); diff --git a/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RangeConstraint.java b/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RangeConstraint.java index 9fb821d28..3eead3323 100644 --- a/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RangeConstraint.java +++ b/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RangeConstraint.java @@ -22,15 +22,20 @@ package org.apache.maven.archiva.database.constraints; import org.apache.maven.archiva.database.Constraint; /** - * RangeConstraint + * RangeConstraint */ public class RangeConstraint extends AbstractDeclarativeConstraint implements Constraint { + public RangeConstraint() + { + this.range = null; + } + public RangeConstraint( int[] range ) { - this.range = range; + this.range = range; } public String getSortColumn() diff --git a/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByGroupIdConstraint.java b/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByGroupIdConstraint.java index fbeff0932..1a0971acb 100644 --- a/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByGroupIdConstraint.java +++ b/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByGroupIdConstraint.java @@ -24,16 +24,29 @@ import org.apache.maven.archiva.database.Constraint; /** * RepositoryProblemByGroupIdConstraint */ -public class RepositoryProblemByGroupIdConstraint extends RangeConstraint implements Constraint +public class RepositoryProblemByGroupIdConstraint + extends RangeConstraint + implements Constraint { private String whereClause; + private void createWhereClause( String desiredGroupId ) + { + whereClause = "groupId == desiredGroupId"; + declParams = new String[]{"String desiredGroupId"}; + params = new Object[]{desiredGroupId}; + } + + public RepositoryProblemByGroupIdConstraint( String desiredGroupId ) + { + super(); + createWhereClause( desiredGroupId ); + } + public RepositoryProblemByGroupIdConstraint( int[] range, String desiredGroupId ) { super( range ); - whereClause = "groupId == desiredGroupId"; - declParams = new String[] { "String desiredGroupId" }; - params = new Object[] { desiredGroupId }; + createWhereClause( desiredGroupId ); } public String getSortColumn() diff --git a/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByRepositoryIdConstraint.java b/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByRepositoryIdConstraint.java index 08b024b27..d1b5de7d8 100644 --- a/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByRepositoryIdConstraint.java +++ b/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByRepositoryIdConstraint.java @@ -24,16 +24,29 @@ import org.apache.maven.archiva.database.Constraint; /** * RepositoryProblemByRepositoryIdConstraint */ -public class RepositoryProblemByRepositoryIdConstraint extends RangeConstraint implements Constraint +public class RepositoryProblemByRepositoryIdConstraint + extends RangeConstraint + implements Constraint { private String whereClause; + private void createWhereClause( String desiredRepositoryId ) + { + whereClause = "repositoryId == desiredRepositoryId"; + declParams = new String[]{"String desiredRepositoryId"}; + params = new Object[]{desiredRepositoryId}; + } + + public RepositoryProblemByRepositoryIdConstraint( String desiredRepositoryId ) + { + super(); + createWhereClause( desiredRepositoryId ); + } + public RepositoryProblemByRepositoryIdConstraint( int[] range, String desiredRepositoryId ) { super( range ); - whereClause = "repositoryId == desiredRepositoryId"; - declParams = new String[] { "String desiredRepositoryId" }; - params = new Object[] { desiredRepositoryId }; + createWhereClause( desiredRepositoryId ); } public String getSortColumn() diff --git a/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByArtifactIdConstraint.java b/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemConstraint.java index a94aed873..3c2c997ac 100644 --- a/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByArtifactIdConstraint.java +++ b/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/RepositoryProblemConstraint.java @@ -22,23 +22,36 @@ package org.apache.maven.archiva.database.constraints; import org.apache.maven.archiva.database.Constraint; /** - * RepositoryProblemByArtifactIdConstraint + * RepositoryProblemConstraint */ -public class RepositoryProblemByArtifactIdConstraint extends RangeConstraint implements Constraint +public class RepositoryProblemConstraint + extends RangeConstraint + implements Constraint { private String whereClause; - public RepositoryProblemByArtifactIdConstraint( int[] range, String desiredArtifactId ) + private void createWhereClause( String desiredGroupId, String desiredRepositoryId ) + { + whereClause = "groupId == desiredGroupId && repositoryId == desiredRepositoryId"; + declParams = new String[]{"String desiredGroupId", "String desiredRepositoryId"}; + params = new Object[]{desiredGroupId, desiredRepositoryId}; + } + + public RepositoryProblemConstraint( String desiredGroupId, String desiredRepositoryId ) + { + super(); + createWhereClause( desiredGroupId, desiredRepositoryId ); + } + + public RepositoryProblemConstraint( int[] range, String desiredGroupId, String desiredRepositoryId ) { super( range ); - whereClause = "artifactId == desiredArtifactId"; - declParams = new String[] { "String desiredArtifactId" }; - params = new Object[] { desiredArtifactId }; + createWhereClause( desiredGroupId, desiredRepositoryId ); } public String getSortColumn() { - return "groupId"; + return "artifactId"; } public String getWhereCondition() diff --git a/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueFieldConstraint.java b/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueFieldConstraint.java new file mode 100644 index 000000000..8e22ac255 --- /dev/null +++ b/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/UniqueFieldConstraint.java @@ -0,0 +1,57 @@ +package org.apache.maven.archiva.database.constraints; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.archiva.database.Constraint; + +/** + * UniqueFieldConstraint + */ +public class UniqueFieldConstraint + extends AbstractSimpleConstraint + implements Constraint +{ + private String sql; + + public UniqueFieldConstraint( String className, String fieldName ) + { + sql = "SELECT " + fieldName + " FROM " + className + " GROUP BY " + fieldName + " ORDER BY " + fieldName + + " ASCENDING"; + } + + public UniqueFieldConstraint( String className, String fieldName, String fieldNamePrefix ) + { + sql = "SELECT " + fieldName + " FROM " + className + " WHERE " + fieldName + + ".startsWith( fieldPrefix ) PARAMETERS String fieldPrefix GROUP BY " + fieldName + " ORDER BY " + + fieldName + " ASCENDING"; + + super.params = new Object[]{fieldNamePrefix}; + } + + public Class getResultClass() + { + return String.class; + } + + public String getSelectSql() + { + return sql; + } +} diff --git a/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RangeConstraintTest.java b/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RangeConstraintTest.java new file mode 100644 index 000000000..aa0618955 --- /dev/null +++ b/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RangeConstraintTest.java @@ -0,0 +1,88 @@ +package org.apache.maven.archiva.database.constraints; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase; +import org.apache.maven.archiva.database.ArchivaDAO; +import org.apache.maven.archiva.database.Constraint; +import org.apache.maven.archiva.database.RepositoryProblemDAO; +import org.apache.maven.archiva.model.RepositoryProblem; + +import java.util.List; + +/** + * RangeConstraintTest + */ +public class RangeConstraintTest + extends AbstractArchivaDatabaseTestCase +{ + private RepositoryProblemDAO repoProblemDao; + + protected void setUp() + throws Exception + { + super.setUp(); + + ArchivaDAO dao = (ArchivaDAO) lookup( ArchivaDAO.ROLE, "jdo" ); + repoProblemDao = dao.getRepositoryProblemDAO(); + } + + public RepositoryProblem createRepoProblem() + { + RepositoryProblem repoProblem = new RepositoryProblem(); + + repoProblem.setGroupId( "groupId" ); + repoProblem.setArtifactId( "artifactId" ); + repoProblem.setMessage( "message" ); + repoProblem.setOrigin( "origin" ); + repoProblem.setPath( "path" ); + repoProblem.setRepositoryId( "repositoryId" ); + repoProblem.setType( "type" ); + repoProblem.setVersion( "version" ); + + return repoProblem; + } + + public void testConstraint() + throws Exception + { + repoProblemDao.saveRepositoryProblem( createRepoProblem() ); + repoProblemDao.saveRepositoryProblem( createRepoProblem() ); + repoProblemDao.saveRepositoryProblem( createRepoProblem() ); + repoProblemDao.saveRepositoryProblem( createRepoProblem() ); + repoProblemDao.saveRepositoryProblem( createRepoProblem() ); + + assertConstraint( 0, new RangeConstraint( new int[]{5, 10} ) ); + assertConstraint( 1, new RangeConstraint( new int[]{0, 1} ) ); + assertConstraint( 2, new RangeConstraint( new int[]{0, 2} ) ); + assertConstraint( 3, new RangeConstraint( new int[]{0, 3} ) ); + assertConstraint( 4, new RangeConstraint( new int[]{0, 4} ) ); + assertConstraint( 5, new RangeConstraint( new int[]{0, 5} ) ); + assertConstraint( 5, new RangeConstraint() ); + } + + private void assertConstraint( int expectedHits, Constraint constraint ) + throws Exception + { + List results = repoProblemDao.queryRepositoryProblems( constraint ); + assertNotNull( "Range Constraint: Not Null", results ); + assertEquals( "Range Constraint: Results.size", expectedHits, results.size() ); + } +} diff --git a/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByGroupIdConstraintTest.java b/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByGroupIdConstraintTest.java new file mode 100644 index 000000000..49d4713e0 --- /dev/null +++ b/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByGroupIdConstraintTest.java @@ -0,0 +1,93 @@ +package org.apache.maven.archiva.database.constraints; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase; +import org.apache.maven.archiva.database.ArchivaDAO; +import org.apache.maven.archiva.database.Constraint; +import org.apache.maven.archiva.database.RepositoryProblemDAO; +import org.apache.maven.archiva.model.RepositoryProblem; + +import java.util.List; + +/** + * RepositoryProblemByGroupIdConstraintTest + */ +public class RepositoryProblemByGroupIdConstraintTest + extends AbstractArchivaDatabaseTestCase +{ + private static final String GROUP_ID_1 = "org.apache.maven.archiva.test.1"; + + private static final String GROUP_ID_2 = "org.apache.maven.archiva.test.2"; + + private static final String GROUP_ID_3 = "org.apache.maven.archiva.test.3"; + + private RepositoryProblemDAO repoProblemDao; + + protected void setUp() + throws Exception + { + super.setUp(); + + ArchivaDAO dao = (ArchivaDAO) lookup( ArchivaDAO.ROLE, "jdo" ); + repoProblemDao = dao.getRepositoryProblemDAO(); + } + + public RepositoryProblem createRepoProblem( String groupId ) + { + RepositoryProblem repoProblem = new RepositoryProblem(); + + repoProblem.setGroupId( groupId ); + repoProblem.setArtifactId( "artifactId" ); + repoProblem.setMessage( "message" ); + repoProblem.setOrigin( "origin" ); + repoProblem.setPath( "path" ); + repoProblem.setRepositoryId( "repositoryId" ); + repoProblem.setType( "type" ); + repoProblem.setVersion( "version" ); + + return repoProblem; + } + + public void testConstraint() + throws Exception + { + repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_1 ) ); + + repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_2 ) ); + repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_2 ) ); + + repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_3 ) ); + repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_3 ) ); + repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_3 ) ); + + assertConstraint( 1, new RepositoryProblemByGroupIdConstraint( GROUP_ID_1 ) ); + assertConstraint( 2, new RepositoryProblemByGroupIdConstraint( GROUP_ID_2 ) ); + assertConstraint( 3, new RepositoryProblemByGroupIdConstraint( GROUP_ID_3 ) ); + } + + private void assertConstraint( int expectedHits, Constraint constraint ) + throws Exception + { + List results = repoProblemDao.queryRepositoryProblems( constraint ); + assertNotNull( "Repository Problems by Group Id: Not Null", results ); + assertEquals( "Repository Problems by Group Id: Results.size", expectedHits, results.size() ); + } +} diff --git a/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByRepositoryIdConstraintTest.java b/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByRepositoryIdConstraintTest.java new file mode 100644 index 000000000..425fc0e8d --- /dev/null +++ b/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemByRepositoryIdConstraintTest.java @@ -0,0 +1,93 @@ +package org.apache.maven.archiva.database.constraints; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase; +import org.apache.maven.archiva.database.ArchivaDAO; +import org.apache.maven.archiva.database.Constraint; +import org.apache.maven.archiva.database.RepositoryProblemDAO; +import org.apache.maven.archiva.model.RepositoryProblem; + +import java.util.List; + +/** + * RepositoryProblemByRepositoryIdConstraintTest + */ +public class RepositoryProblemByRepositoryIdConstraintTest + extends AbstractArchivaDatabaseTestCase +{ + private static final String REPO_ID_1 = "test-repo-1"; + + private static final String REPO_ID_2 = "test-repo-2"; + + private static final String REPO_ID_3 = "test-repo-3"; + + private RepositoryProblemDAO repoProblemDao; + + protected void setUp() + throws Exception + { + super.setUp(); + + ArchivaDAO dao = (ArchivaDAO) lookup( ArchivaDAO.ROLE, "jdo" ); + repoProblemDao = dao.getRepositoryProblemDAO(); + } + + public RepositoryProblem createRepoProblem( String repoId ) + { + RepositoryProblem repoProblem = new RepositoryProblem(); + + repoProblem.setGroupId( "groupId" ); + repoProblem.setArtifactId( "artifactId" ); + repoProblem.setMessage( "message" ); + repoProblem.setOrigin( "origin" ); + repoProblem.setPath( "path" ); + repoProblem.setRepositoryId( repoId ); + repoProblem.setType( "type" ); + repoProblem.setVersion( "version" ); + + return repoProblem; + } + + public void testConstraint() + throws Exception + { + repoProblemDao.saveRepositoryProblem( createRepoProblem( REPO_ID_1 ) ); + + repoProblemDao.saveRepositoryProblem( createRepoProblem( REPO_ID_2 ) ); + repoProblemDao.saveRepositoryProblem( createRepoProblem( REPO_ID_2 ) ); + + repoProblemDao.saveRepositoryProblem( createRepoProblem( REPO_ID_3 ) ); + repoProblemDao.saveRepositoryProblem( createRepoProblem( REPO_ID_3 ) ); + repoProblemDao.saveRepositoryProblem( createRepoProblem( REPO_ID_3 ) ); + + assertConstraint( 1, new RepositoryProblemByRepositoryIdConstraint( REPO_ID_1 ) ); + assertConstraint( 2, new RepositoryProblemByRepositoryIdConstraint( REPO_ID_2 ) ); + assertConstraint( 3, new RepositoryProblemByRepositoryIdConstraint( REPO_ID_3 ) ); + } + + private void assertConstraint( int expectedHits, Constraint constraint ) + throws Exception + { + List results = repoProblemDao.queryRepositoryProblems( constraint ); + assertNotNull( "Repository Problems by Repository Id: Not Null", results ); + assertEquals( "Repository Problems by Repository Id: Results.size", expectedHits, results.size() ); + } +} diff --git a/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemConstraintTest.java b/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemConstraintTest.java new file mode 100644 index 000000000..e0d77b31a --- /dev/null +++ b/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/RepositoryProblemConstraintTest.java @@ -0,0 +1,122 @@ +package org.apache.maven.archiva.database.constraints; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase; +import org.apache.maven.archiva.database.ArchivaDAO; +import org.apache.maven.archiva.database.Constraint; +import org.apache.maven.archiva.database.RepositoryProblemDAO; +import org.apache.maven.archiva.model.RepositoryProblem; + +import java.util.List; + +/** + * RepositoryProblemConstraintTest + */ +public class RepositoryProblemConstraintTest + extends AbstractArchivaDatabaseTestCase +{ + private static final String GROUP_ID_1 = "org.apache.maven.archiva.test.1"; + + private static final String GROUP_ID_2 = "org.apache.maven.archiva.test.2"; + + private static final String GROUP_ID_3 = "org.apache.maven.archiva.test.3"; + + private static final String GROUP_ID_4 = "org.apache.maven.archiva.test.4"; + + private static final String REPO_ID_1 = "test-repo-1"; + + private static final String REPO_ID_2 = "test-repo-2"; + + private static final String REPO_ID_3 = "test-repo-3"; + + private static final String REPO_ID_4 = "test-repo-4"; + + private RepositoryProblemDAO repoProblemDao; + + protected void setUp() + throws Exception + { + super.setUp(); + + ArchivaDAO dao = (ArchivaDAO) lookup( ArchivaDAO.ROLE, "jdo" ); + repoProblemDao = dao.getRepositoryProblemDAO(); + } + + public RepositoryProblem createRepoProblem( String groupId, String repoId ) + { + RepositoryProblem repoProblem = new RepositoryProblem(); + + repoProblem.setGroupId( groupId ); + repoProblem.setArtifactId( "artifactId" ); + repoProblem.setMessage( "message" ); + repoProblem.setOrigin( "origin" ); + repoProblem.setPath( "path" ); + repoProblem.setRepositoryId( repoId ); + repoProblem.setType( "type" ); + repoProblem.setVersion( "version" ); + + return repoProblem; + } + + public void testGroupIdConstraint() + throws Exception + { + repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_1, REPO_ID_1 ) ); + + repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_2, REPO_ID_1 ) ); + repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_2, REPO_ID_1 ) ); + + repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_3, REPO_ID_1 ) ); + repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_3, REPO_ID_1 ) ); + repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_3, REPO_ID_1 ) ); + + assertConstraint( 1, new RepositoryProblemConstraint( GROUP_ID_1, REPO_ID_1 ) ); + assertConstraint( 2, new RepositoryProblemConstraint( GROUP_ID_2, REPO_ID_1 ) ); + assertConstraint( 3, new RepositoryProblemConstraint( GROUP_ID_3, REPO_ID_1 ) ); + assertConstraint( 0, new RepositoryProblemConstraint( GROUP_ID_4, REPO_ID_1 ) ); + } + + public void testRepoIdConstraint() + throws Exception + { + repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_1, REPO_ID_1 ) ); + + repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_1, REPO_ID_2 ) ); + repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_1, REPO_ID_2 ) ); + + repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_1, REPO_ID_3 ) ); + repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_1, REPO_ID_3 ) ); + repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_1, REPO_ID_3 ) ); + + assertConstraint( 1, new RepositoryProblemConstraint( GROUP_ID_1, REPO_ID_1 ) ); + assertConstraint( 2, new RepositoryProblemConstraint( GROUP_ID_1, REPO_ID_2 ) ); + assertConstraint( 3, new RepositoryProblemConstraint( GROUP_ID_1, REPO_ID_3 ) ); + assertConstraint( 0, new RepositoryProblemConstraint( GROUP_ID_1, REPO_ID_4 ) ); + } + + private void assertConstraint( int expectedHits, Constraint constraint ) + throws Exception + { + List results = repoProblemDao.queryRepositoryProblems( constraint ); + assertNotNull( "Repository Problems: Not Null", results ); + assertEquals( "Repository Problems: Results.size", expectedHits, results.size() ); + } +} diff --git a/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueFieldConstraintTest.java b/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueFieldConstraintTest.java new file mode 100644 index 000000000..b453281fa --- /dev/null +++ b/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/UniqueFieldConstraintTest.java @@ -0,0 +1,117 @@ +package org.apache.maven.archiva.database.constraints; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase; +import org.apache.maven.archiva.database.ArchivaDAO; +import org.apache.maven.archiva.database.ArtifactDAO; +import org.apache.maven.archiva.database.RepositoryProblemDAO; +import org.apache.maven.archiva.database.SimpleConstraint; +import org.apache.maven.archiva.model.ArchivaArtifact; +import org.apache.maven.archiva.model.ArchivaArtifactModel; +import org.apache.maven.archiva.model.RepositoryProblem; + +import java.util.Date; +import java.util.List; + +/** + * UniqueFieldConstraintTest + */ +public class UniqueFieldConstraintTest + extends AbstractArchivaDatabaseTestCase +{ + private static final String GROUP_ID_1 = "org.apache.maven.archiva.test.1"; + + private static final String GROUP_ID_2 = "org.apache.maven.archiva.test.2"; + + private static final String GROUP_ID_3 = "org.apache.maven.archiva.test.3"; + + private ArchivaDAO archivaDao; + + private ArtifactDAO artifactDao; + + private RepositoryProblemDAO repoProblemDao; + + protected void setUp() + throws Exception + { + super.setUp(); + + archivaDao = (ArchivaDAO) lookup( ArchivaDAO.ROLE, "jdo" ); + artifactDao = archivaDao.getArtifactDAO(); + repoProblemDao = archivaDao.getRepositoryProblemDAO(); + } + + public ArchivaArtifact createArtifact( String groupId ) + { + ArchivaArtifact artifact = artifactDao.createArtifact( groupId, "artifactId", "version", "classifier", "jar" ); + + artifact.getModel().setLastModified( new Date() ); + artifact.getModel().setRepositoryId( "repoId" ); + + return artifact; + } + + public RepositoryProblem createRepoProblem( String groupId ) + { + RepositoryProblem repoProblem = new RepositoryProblem(); + + repoProblem.setGroupId( groupId ); + repoProblem.setArtifactId( "artifactId" ); + repoProblem.setMessage( "message" ); + repoProblem.setOrigin( "origin" ); + repoProblem.setPath( "path" ); + repoProblem.setRepositoryId( "repoId" ); + repoProblem.setType( "type" ); + repoProblem.setVersion( "version" ); + + return repoProblem; + } + + public void testArtifact() + throws Exception + { + artifactDao.saveArtifact( createArtifact( GROUP_ID_1 ) ); + artifactDao.saveArtifact( createArtifact( GROUP_ID_2 ) ); + artifactDao.saveArtifact( createArtifact( GROUP_ID_3 ) ); + + assertConstraint( 1, new UniqueFieldConstraint( ArchivaArtifactModel.class.getName(), "artifactId" ) ); + assertConstraint( 3, new UniqueFieldConstraint( ArchivaArtifactModel.class.getName(), "groupId" ) ); + } + + public void testRepoProblem() + throws Exception + { + repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_1 ) ); + repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_2 ) ); + repoProblemDao.saveRepositoryProblem( createRepoProblem( GROUP_ID_3 ) ); + + assertConstraint( 1, new UniqueFieldConstraint( RepositoryProblem.class.getName(), "artifactId" ) ); + assertConstraint( 3, new UniqueFieldConstraint( RepositoryProblem.class.getName(), "groupId" ) ); + } + + private void assertConstraint( int expectedHits, SimpleConstraint constraint ) + throws Exception + { + List results = archivaDao.query( constraint ); + assertNotNull( "Repository Problems: Not Null", results ); + assertEquals( "Repository Problems: Results.size", expectedHits, results.size() ); + } +} diff --git a/archiva-web/archiva-webapp/src/main/jasperreports/report.jrxml b/archiva-web/archiva-webapp/src/main/jasperreports/report.jrxml deleted file mode 100644 index 3f61ec29f..000000000 --- a/archiva-web/archiva-webapp/src/main/jasperreports/report.jrxml +++ /dev/null @@ -1,238 +0,0 @@ -<?xml version="1.0"?> -<!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> -<jasperReport name="ArchivaReport" - pageWidth="1800"> - <field name="groupId" class="java.lang.String"/> - <field name="artifactId" class="java.lang.String"/> - <field name="version" class="java.lang.String"/> - <field name="message" class="java.lang.String"/> - <field name="origin" class="java.lang.String"/> - <field name="path" class="java.lang.String"/> - <field name="type" class="java.lang.String"/> - <field name="groupURL" class="java.lang.String"/> - <field name="artifactURL" class="java.lang.String"/> - <field name="versionURL" class="java.lang.String"/> - <field name="prev" class="java.lang.String"/> - <field name="next" class="java.lang.String"/> - <field name="page" class="java.lang.Integer"/> - <field name="isLastPage" class="java.lang.Boolean"/> - <title> - <band height="50"> - <staticText> - <reportElement x="0" y="0" width="2240" height="50"/> - <textElement textAlignment="Center"> - <font size="14" isBold="true"/> - </textElement> - <text><![CDATA[All Problematic Artifacts]]></text> - </staticText> - </band> - </title> - <pageHeader> - <band></band> - </pageHeader> - <columnHeader> - <band height="20"> - <staticText> - <reportElement x="0" y="0" width="300" height="20"/> - <box leftBorder="Thin" - leftPadding="10" - rightBorder="Thin" - rightPadding="10" - topBorder="Thin" - bottomBorder="Thin"/> - <textElement textAlignment="Center"> - <font size="12"/> - </textElement> - <text><![CDATA[Group Id]]></text> - </staticText> - <staticText> - <reportElement x="300" y="0" width="300" height="20"/> - <box leftPadding="10" - rightBorder="Thin" - rightPadding="10" - topBorder="Thin" - bottomBorder="Thin"/> - <textElement textAlignment="Center"> - <font size="12"/> - </textElement> - <text><![CDATA[Artifact Id]]></text> - </staticText> - <staticText> - <reportElement x="600" y="0" width="300" height="20"/> - <box leftPadding="10" - rightBorder="Thin" - rightPadding="10" - topBorder="Thin" - bottomBorder="Thin"/> - <textElement textAlignment="Center"> - <font size="12"/> - </textElement> - <text><![CDATA[Version]]></text> - </staticText> - <staticText> - <reportElement x="900" y="0" width="300" height="20"/> - <box leftPadding="10" - rightBorder="Thin" - rightPadding="10" - topBorder="Thin" - bottomBorder="Thin"/> - <textElement textAlignment="Center"> - <font size="12"/> - </textElement> - <text><![CDATA[Message]]></text> - </staticText> - <staticText> - <reportElement x="1200" y="0" width="300" height="20"/> - <box leftPadding="10" - rightBorder="Thin" - rightPadding="10" - topBorder="Thin" - bottomBorder="Thin"/> - <textElement textAlignment="Center"> - <font size="12"/> - </textElement> - <text><![CDATA[Origin]]></text> - </staticText> - <staticText> - <reportElement x="1500" y="0" width="300" height="20"/> - <box leftPadding="10" - rightBorder="Thin" - rightPadding="10" - topBorder="Thin" - bottomBorder="Thin"/> - <textElement textAlignment="Center"> - <font size="12"/> - </textElement> - <text><![CDATA[Repository Path]]></text> - </staticText> - <staticText> - <reportElement x="1800" y="0" width="300" height="20"/> - <box leftPadding="10" - rightBorder="Thin" - rightPadding="10" - topBorder="Thin" - bottomBorder="Thin"/> - <textElement textAlignment="Center"> - <font size="12"/> - </textElement> - <text><![CDATA[Type]]></text> - </staticText> - </band> - </columnHeader> - <detail> - <band height="20"> - <textField isBlankWhenNull="true" hyperlinkType="Reference" hyperlinkTarget="Self"> - <reportElement x="0" y="0" width="300" height="15"/> - <box leftBorder="Thin" - leftPadding="10" - rightBorder="Thin" - rightPadding="10" - bottomBorder="Thin"/> - <textFieldExpression> - <![CDATA[$F{groupId}]]> - </textFieldExpression> - <hyperlinkReferenceExpression><![CDATA[$F{groupURL}]]></hyperlinkReferenceExpression> - </textField> - <textField isBlankWhenNull="true" hyperlinkType="Reference" hyperlinkTarget="Self"> - <reportElement x="300" y="0" width="300" height="15"/> - <box leftPadding="10" - rightBorder="Thin" - rightPadding="10" - bottomBorder="Thin"/> - <textFieldExpression> - <![CDATA[$F{artifactId}]]> - </textFieldExpression> - <hyperlinkReferenceExpression><![CDATA[$F{artifactURL}]]></hyperlinkReferenceExpression> - </textField> - <textField isBlankWhenNull="true" hyperlinkType="Reference" hyperlinkTarget="Self"> - <reportElement x="600" y="0" width="300" height="15"/> - <box leftPadding="10" - rightBorder="Thin" - rightPadding="10" - bottomBorder="Thin"/> - <textFieldExpression> - <![CDATA[$F{version}]]> - </textFieldExpression> - <hyperlinkReferenceExpression><![CDATA[$F{versionURL}]]></hyperlinkReferenceExpression> - </textField> - <textField isBlankWhenNull="true" isStretchWithOverflow="true"> - <reportElement x="900" y="0" width="300" height="15"/> - <box leftPadding="10" - rightBorder="Thin" - rightPadding="10" - bottomBorder="Thin"/> - <textFieldExpression> - <![CDATA[$F{message}]]> - </textFieldExpression> - </textField> - <textField isBlankWhenNull="true"> - <reportElement x="1200" y="0" width="300" height="15"/> - <box leftPadding="10" - rightBorder="Thin" - rightPadding="10" - bottomBorder="Thin"/> - <textFieldExpression> - <![CDATA[$F{origin}]]> - </textFieldExpression> - </textField> - <textField isBlankWhenNull="true" isStretchWithOverflow="true"> - <reportElement x="1500" y="0" width="300" height="15"/> - <box leftPadding="10" - rightBorder="Thin" - rightPadding="10" - bottomBorder="Thin"/> - <textFieldExpression> - <![CDATA[$F{path}]]> - </textFieldExpression> - </textField> - <textField isBlankWhenNull="true"> - <reportElement x="1800" y="0" width="300" height="15"/> - <box leftPadding="10" - rightBorder="Thin" - rightPadding="10" - bottomBorder="Thin"/> - <textFieldExpression> - <![CDATA[$F{type}]]> - </textFieldExpression> - </textField> - </band> - </detail> - <columnFooter> - <band></band> - </columnFooter> - <pageFooter> - <band height="15"> - <textField> - <reportElement x="0" y="0" width="50" height="15"/> - <textFieldExpression> - <![CDATA["Page: " + $F{page}]]> - </textFieldExpression> - </textField> - <textField hyperlinkType="Reference" hyperlinkTarget="Self"> - <reportElement x="50" y="0" width="50" height="15"> - <printWhenExpression> - <![CDATA[$F{page}.intValue() != 1]]> - </printWhenExpression> - </reportElement> - <textFieldExpression> - <![CDATA["prev"]]> - </textFieldExpression> - <hyperlinkReferenceExpression><![CDATA[$F{prev}]]></hyperlinkReferenceExpression> - </textField> - <textField hyperlinkType="Reference" hyperlinkTarget="Self"> - <reportElement x="100" y="0" width="50" height="15"> - <printWhenExpression> - <![CDATA[$F{isLastPage} != true]]> - </printWhenExpression> - </reportElement> - <textFieldExpression> - <![CDATA["next"]]> - </textFieldExpression> - <hyperlinkReferenceExpression><![CDATA[$F{next}]]></hyperlinkReferenceExpression> - </textField> - </band> - </pageFooter> - <summary> - <band></band> - </summary> -</jasperReport> diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/AllProblematicArtifactsAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/AllProblematicArtifactsAction.java deleted file mode 100644 index ba530760f..000000000 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/AllProblematicArtifactsAction.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.apache.maven.archiva.web.action.reports; - -import org.apache.maven.archiva.database.constraints.RangeConstraint; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * All problematic artifacts reporting. - * - * @plexus.component role="com.opensymphony.xwork.Action" role-hint="allProblematicArtifactsAction" - */ -public class AllProblematicArtifactsAction extends AbstractReportAction -{ - protected void configureConstraint() - { - this.constraint = new RangeConstraint( range ); - } -} diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/AbstractReportAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java index 6f9d52a48..570d3b0a4 100644 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/AbstractReportAction.java +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/GenerateReportAction.java @@ -19,13 +19,13 @@ package org.apache.maven.archiva.web.action.reports; * under the License. */ -import java.util.ArrayList; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; - +import com.opensymphony.webwork.interceptor.ServletRequestAware; import org.apache.maven.archiva.database.ArchivaDAO; import org.apache.maven.archiva.database.Constraint; +import org.apache.maven.archiva.database.constraints.RangeConstraint; +import org.apache.maven.archiva.database.constraints.RepositoryProblemByGroupIdConstraint; +import org.apache.maven.archiva.database.constraints.RepositoryProblemByRepositoryIdConstraint; +import org.apache.maven.archiva.database.constraints.RepositoryProblemConstraint; import org.apache.maven.archiva.model.RepositoryProblem; import org.apache.maven.archiva.model.RepositoryProblemReport; import org.apache.maven.archiva.security.ArchivaRoleConstants; @@ -35,12 +35,16 @@ import org.codehaus.plexus.redback.xwork.interceptor.SecureActionBundle; import org.codehaus.plexus.redback.xwork.interceptor.SecureActionException; import org.codehaus.plexus.xwork.action.PlexusActionSupport; -import com.opensymphony.webwork.interceptor.ServletRequestAware; +import javax.servlet.http.HttpServletRequest; +import java.util.ArrayList; +import java.util.List; /** - * Abstract reporting. + * @plexus.component role="com.opensymphony.xwork.Action" role-hint="generateReportAction" */ -public abstract class AbstractReportAction extends PlexusActionSupport implements SecureAction, ServletRequestAware +public class GenerateReportAction + extends PlexusActionSupport + implements SecureAction, ServletRequestAware { /** * @plexus.requirement role-hint="jdo" @@ -53,6 +57,10 @@ public abstract class AbstractReportAction extends PlexusActionSupport implement protected List reports = new ArrayList(); + protected String groupId; + + protected String repositoryId; + protected String prev; protected String next; @@ -67,13 +75,10 @@ public abstract class AbstractReportAction extends PlexusActionSupport implement public static final String BLANK = "blank"; - public String execute() throws Exception + public String execute() + throws Exception { - range[0] = ( page - 1 ) * rowCount; - range[1] = ( page * rowCount ) + 1; // Add 1 to check if it's the last page or not. - - configureConstraint(); - List problemArtifacts = dao.getRepositoryProblemDAO().queryRepositoryProblems( constraint ); + List problemArtifacts = dao.getRepositoryProblemDAO().queryRepositoryProblems( configureConstraint() ); String contextPath = request.getRequestURL().substring( 0, request.getRequestURL().indexOf( request.getRequestURI() ) ); @@ -85,10 +90,8 @@ public abstract class AbstractReportAction extends PlexusActionSupport implement problemArtifactReport = new RepositoryProblemReport( problemArtifact ); problemArtifactReport.setGroupURL( contextPath + "/browse/" + problemArtifact.getGroupId() ); - problemArtifactReport.setArtifactURL( contextPath + "/browse/" + problemArtifact.getGroupId() + "/" - + problemArtifact.getArtifactId() ); - problemArtifactReport.setVersionURL( contextPath + "/browse/" + problemArtifact.getGroupId() + "/" - + problemArtifact.getArtifactId() + "/" + problemArtifact.getVersion() ); + problemArtifactReport.setArtifactURL( + contextPath + "/browse/" + problemArtifact.getGroupId() + "/" + problemArtifact.getArtifactId() ); reports.add( problemArtifactReport ); } @@ -102,8 +105,10 @@ public abstract class AbstractReportAction extends PlexusActionSupport implement reports.remove( rowCount ); } - prev = request.getRequestURL() + "?page=" + ( page - 1 ) + "&rowCount=" + rowCount; - next = request.getRequestURL() + "?page=" + ( page + 1 ) + "&rowCount=" + rowCount; + prev = request.getRequestURL() + "?page=" + ( page - 1 ) + "&rowCount=" + rowCount + "&groupId=" + groupId + + "&repositoryId=" + repositoryId; + next = request.getRequestURL() + "?page=" + ( page + 1 ) + "&rowCount=" + rowCount + "&groupId=" + groupId + + "&repositoryId=" + repositoryId; if ( reports.size() == 0 && page == 1 ) { @@ -115,10 +120,35 @@ public abstract class AbstractReportAction extends PlexusActionSupport implement } } - /** - * To be implemented by sub-reports to configure specific constraints. - */ - abstract protected void configureConstraint(); + private Constraint configureConstraint() + { + Constraint constraint; + + range[0] = ( page - 1 ) * rowCount; + range[1] = ( page * rowCount ) + 1; // Add 1 to check if it's the last page or not. + + if ( groupId != null && ( !groupId.equals( "" ) ) ) + { + if ( repositoryId != null && ( !repositoryId.equals( "" ) ) ) + { + constraint = new RepositoryProblemConstraint( range, groupId, repositoryId ); + } + else + { + constraint = new RepositoryProblemByGroupIdConstraint( range, groupId ); + } + } + else if ( repositoryId != null && ( !repositoryId.equals( "" ) ) ) + { + constraint = new RepositoryProblemByRepositoryIdConstraint( range, repositoryId ); + } + else + { + constraint = new RangeConstraint( range ); + } + + return constraint; + } public void setServletRequest( HttpServletRequest request ) { @@ -130,6 +160,26 @@ public abstract class AbstractReportAction extends PlexusActionSupport implement return reports; } + public String getGroupId() + { + return groupId; + } + + public void setGroupId( String groupId ) + { + this.groupId = groupId; + } + + public String getRepositoryId() + { + return repositoryId; + } + + public void setRepositoryId( String repositoryId ) + { + this.repositoryId = repositoryId; + } + public String getPrev() { return prev; @@ -165,7 +215,8 @@ public abstract class AbstractReportAction extends PlexusActionSupport implement return isLastPage; } - public SecureActionBundle getSecureActionBundle() throws SecureActionException + public SecureActionBundle getSecureActionBundle() + throws SecureActionException { SecureActionBundle bundle = new SecureActionBundle(); diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ReportsByArtifactIdAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ReportsByArtifactIdAction.java deleted file mode 100644 index 760081990..000000000 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ReportsByArtifactIdAction.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.apache.maven.archiva.web.action.reports; - -import org.apache.maven.archiva.database.constraints.RepositoryProblemByArtifactIdConstraint; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * By artifact id reporting. - * - * @plexus.component role="com.opensymphony.xwork.Action" role-hint="reportsByArtifactIdAction" - */ -public class ReportsByArtifactIdAction extends AbstractReportAction -{ - private String artifactId; - - protected void configureConstraint() - { - this.constraint = new RepositoryProblemByArtifactIdConstraint( range, artifactId ); - } - - public void setArtifactId( String artifactId ) - { - this.artifactId = artifactId; - } -} diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ReportsByGroupIdAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ReportsByGroupIdAction.java deleted file mode 100644 index ec5308273..000000000 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ReportsByGroupIdAction.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.apache.maven.archiva.web.action.reports; - -import org.apache.maven.archiva.database.constraints.RangeConstraint; -import org.apache.maven.archiva.database.constraints.RepositoryProblemByGroupIdConstraint; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * By group id reporting. - * - * @plexus.component role="com.opensymphony.xwork.Action" role-hint="reportsByGroupIdAction" - */ -public class ReportsByGroupIdAction extends AbstractReportAction -{ - private String groupId; - - protected void configureConstraint() - { - this.constraint = new RepositoryProblemByGroupIdConstraint( range, groupId ); - } - - public void setGroupId( String groupId ) - { - this.groupId = groupId; - } -} diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ReportsByRepositoryIdAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ReportsByRepositoryIdAction.java deleted file mode 100644 index 9c8e8d3a2..000000000 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ReportsByRepositoryIdAction.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.apache.maven.archiva.web.action.reports; - -import org.apache.maven.archiva.database.constraints.RepositoryProblemByRepositoryIdConstraint; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * By repository id reporting. - * - * @plexus.component role="com.opensymphony.xwork.Action" role-hint="reportsByRepositoryIdAction" - */ -public class ReportsByRepositoryIdAction extends AbstractReportAction -{ - private String repositoryId; - - protected void configureConstraint() - { - this.constraint = new RepositoryProblemByRepositoryIdConstraint( range, repositoryId ); - } - - public void setRepositoryId( String repositoryId ) - { - this.repositoryId = repositoryId; - } -} diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ShowReportsAction.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ShowReportsAction.java deleted file mode 100644 index c59b968ea..000000000 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ShowReportsAction.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.apache.maven.archiva.web.action.reports; - -import java.util.Collection; - -import org.apache.maven.archiva.database.ArchivaDAO; -import org.codehaus.plexus.xwork.action.PlexusActionSupport; - -/** - * Show reports. - * - * @plexus.component role="com.opensymphony.xwork.Action" role-hint="showReportsAction" - */ -public class ShowReportsAction extends PlexusActionSupport -{ - /** - * @plexus.requirement role-hint="jdo" - */ - protected ArchivaDAO dao; - - private Collection groupIds; - - private Collection artifactIds; - - private Collection repositoryIds; - - public String execute() throws Exception - { - /* - * TODO Use combo box for groupIds, artifactIds and repositoryIds instead of a text field. - */ - - return SUCCESS; - } - - public Collection getGroupIds() - { - return groupIds; - } - - public Collection getArtifactIds() - { - return artifactIds; - } - - public Collection getRepositoryIds() - { - return repositoryIds; - } -} diff --git a/archiva-web/archiva-webapp/src/main/resources/xwork.xml b/archiva-web/archiva-webapp/src/main/resources/xwork.xml index 126ae7780..8ac578ef7 100644 --- a/archiva-web/archiva-webapp/src/main/resources/xwork.xml +++ b/archiva-web/archiva-webapp/src/main/resources/xwork.xml @@ -395,34 +395,7 @@ <result>/WEB-INF/jsp/reports/showReports.jsp</result> </action> - <action name="allProblematicArtifacts" class="allProblematicArtifactsAction"> - <result name="success" type="jasper"> - <param name="location">/WEB-INF/jasperreports/report.jasper</param> - <param name="dataSource">reports</param> - <param name="format">HTML</param> - </result> - <result name="blank">/WEB-INF/jsp/reports/blankReport.jsp</result> - </action> - - <action name="byGroupId" class="reportsByGroupIdAction"> - <result name="success" type="jasper"> - <param name="location">/WEB-INF/jasperreports/report.jasper</param> - <param name="dataSource">reports</param> - <param name="format">HTML</param> - </result> - <result name="blank">/WEB-INF/jsp/reports/blankReport.jsp</result> - </action> - - <action name="byArtifactId" class="reportsByArtifactIdAction"> - <result name="success" type="jasper"> - <param name="location">/WEB-INF/jasperreports/report.jasper</param> - <param name="dataSource">reports</param> - <param name="format">HTML</param> - </result> - <result name="blank">/WEB-INF/jsp/reports/blankReport.jsp</result> - </action> - - <action name="byRepositoryId" class="reportsByRepositoryIdAction"> + <action name="generateReportAction" class="generateReportAction"> <result name="success" type="jasper"> <param name="location">/WEB-INF/jasperreports/report.jasper</param> <param name="dataSource">reports</param> diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/blankReport.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/blankReport.jsp deleted file mode 100644 index 321b896a7..000000000 --- a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/blankReport.jsp +++ /dev/null @@ -1,36 +0,0 @@ -<%-- - ~ Licensed to the Apache Software Foundation (ASF) under one - ~ or more contributor license agreements. See the NOTICE file - ~ distributed with this work for additional information - ~ regarding copyright ownership. The ASF licenses this file - ~ to you under the Apache License, Version 2.0 (the - ~ "License"); you may not use this file except in compliance - ~ with the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, - ~ software distributed under the License is distributed on an - ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~ KIND, either express or implied. See the License for the - ~ specific language governing permissions and limitations - ~ under the License. - --%> - -<%@ taglib prefix="ww" uri="/webwork" %> - -<html> -<head> - <title>Reports</title> - <ww:head/> -</head> - -<body> -<h1>Reports</h1> -<div id="contentArea"> - - <ww:text name="The operation generated an empty report."/> - -</div> -</body> -</html> diff --git a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/showReports.jsp b/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/showReports.jsp deleted file mode 100644 index 826449388..000000000 --- a/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/showReports.jsp +++ /dev/null @@ -1,80 +0,0 @@ -<%-- - ~ Licensed to the Apache Software Foundation (ASF) under one - ~ or more contributor license agreements. See the NOTICE file - ~ distributed with this work for additional information - ~ regarding copyright ownership. The ASF licenses this file - ~ to you under the Apache License, Version 2.0 (the - ~ "License"); you may not use this file except in compliance - ~ with the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, - ~ software distributed under the License is distributed on an - ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~ KIND, either express or implied. See the License for the - ~ specific language governing permissions and limitations - ~ under the License. - --%> - -<%@ taglib prefix="ww" uri="/webwork" %> - -<html> -<head> - <title>Reports</title> - <ww:head/> -</head> - -<body> -<script> - function getRowCount() - { - document.getElementById("rowCount1_id").value = document.getElementById("rowCountSource_id").value; - document.getElementById("rowCount2_id").value = document.getElementById("rowCountSource_id").value; - document.getElementById("rowCount3_id").value = document.getElementById("rowCountSource_id").value; - document.getElementById("rowCount4_id").value = document.getElementById("rowCountSource_id").value; - } -</script> - -<h1>Reports</h1> - -<div id="contentArea"> - - <h2>Global Settings</h2> - <ww:textfield id="rowCountSource_id" label="Row Count" value="100"/> - <br><br> - - <h2>All Problematic Artifacts</h2> - <ww:form onsubmit="getRowCount();" action="allProblematicArtifacts" namespace="/report"> - <ww:hidden id="rowCount1_id" name="rowCount"/> - <ww:submit value="Show All Problematic Artifacts"/> - </ww:form> - <br> - - <h2>Problematic Artifacts by Group Id</h2> - <ww:form action="byGroupId" namespace="/report"> - <ww:hidden id="rowCount2_id" name="rowCount"/> - <ww:textfield name="groupId"/> - <ww:submit value="Problematic Artifacts by Group Id"/> - </ww:form> - <br> - - <h2>Problematic Artifacts by Artifact Id</h2> - <ww:form action="byArtifactId" namespace="/report"> - <ww:hidden id="rowCount3_id" name="rowCount"/> - <ww:textfield name="artifactId"/> - <ww:submit value="Problematic Artifacts by Artifact Id"/> - </ww:form> - <br> - - <h2>Problematic Artifacts by Repository Id</h2> - <ww:form action="byRepositoryId" namespace="/report"> - <ww:hidden id="rowCount4_id" name="rowCount"/> - <ww:textfield name="repositoryId"/> - <ww:submit value="Problematic Artifacts by Repository Id"/> - </ww:form> - -</div> - -</body> -</html> |