diff options
author | Brett Porter <brett@apache.org> | 2009-12-24 04:02:11 +0000 |
---|---|---|
committer | Brett Porter <brett@apache.org> | 2009-12-24 04:02:11 +0000 |
commit | 1f1252456ab9bbf2b5575f8d22d993e91e7bccb1 (patch) | |
tree | 6ea9c3af1fdfeeb141ba7400eb688c70f211be4a /archiva-modules | |
parent | 79de06cf3e28ff6e0bb6b917e2a6ddcd2cbeef4b (diff) | |
download | archiva-1f1252456ab9bbf2b5575f8d22d993e91e7bccb1.tar.gz archiva-1f1252456ab9bbf2b5575f8d22d993e91e7bccb1.zip |
[MRM-1283] keep track of incomplete metadata so that it can self correct and show a meaningful message to the user
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@893691 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules')
8 files changed, 70 insertions, 5 deletions
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java index ae967dae8..fec93b15e 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-metadata-consumer/src/main/java/org/apache/archiva/consumers/metadata/ArchivaMetadataCreationConsumer.java @@ -166,8 +166,9 @@ public class ArchivaMetadataCreationConsumer ProjectVersionMetadata versionMetadata = null; try { - versionMetadata = storageResolver.getProjectVersion( repository.getId(), artifact.getGroupId(), artifact.getArtifactId(), - projectVersion ); + versionMetadata = + storageResolver.getProjectVersion( repository.getId(), artifact.getGroupId(), artifact.getArtifactId(), + projectVersion ); } catch ( MetadataResolutionException e ) { @@ -180,6 +181,7 @@ public class ArchivaMetadataCreationConsumer log.warn( "Missing or invalid POM for artifact: " + path + "; creating empty metadata" ); versionMetadata = new ProjectVersionMetadata(); versionMetadata.setId( projectVersion ); + versionMetadata.setIncomplete( true ); createVersionMetadata = true; } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java index 9f2502481..523ed0a85 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java @@ -121,7 +121,11 @@ public class ShowArtifactAction } catch ( MetadataResolutionException e ) { - errorMsg = e.getMessage(); + addIncompleteModelWarning(); + + // TODO: need a consistent way to construct this - same in ArchivaMetadataCreationConsumer + versionMetadata = new ProjectVersionMetadata(); + versionMetadata.setId( version ); } if ( versionMetadata != null ) { @@ -161,11 +165,22 @@ public class ShowArtifactAction addActionError( errorMsg != null ? errorMsg : "Artifact not found" ); return ERROR; } + + if ( versionMetadata.isIncomplete() ) + { + addIncompleteModelWarning(); + } + model = versionMetadata; return SUCCESS; } + private void addIncompleteModelWarning() + { + addActionMessage( "The model may be incomplete due to a previous error in resolving information. Refer to the repository problem reports for more information." ); + } + /** * Show the artifact information tab. */ diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/showArtifact.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/showArtifact.jsp index 37df9fb6a..641b6d52d 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/showArtifact.jsp +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/showArtifact.jsp @@ -225,6 +225,12 @@ <%@ include file="/WEB-INF/jsp/include/artifactInfo.jspf" %> </c:otherwise> </c:choose> + + <s:if test="hasActionMessages()"> + <div id="messages"> + <s:actionmessage /> + </div> + </s:if> </div> </div> diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/css/site.css b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/css/site.css index f9c47eb88..ef9c51eac 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/css/site.css +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/css/site.css @@ -338,4 +338,15 @@ div.versions { div.versions a.expand { font-size: 7pt; color: gray; -}
\ No newline at end of file +} + +#messages { + background-color: yellow; + border: 1px solid orange; + margin-top: 2em; +} + +#messages ul { + list-style-image: url(../images/icon_warning_sml.gif) +} + diff --git a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectVersionMetadata.java b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectVersionMetadata.java index e6dcabe84..9973c45c4 100644 --- a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectVersionMetadata.java +++ b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectVersionMetadata.java @@ -51,6 +51,8 @@ public class ProjectVersionMetadata private List<Dependency> dependencies = new ArrayList<Dependency>(); + private boolean incomplete; + public String getId() { return id; @@ -205,4 +207,14 @@ public class ProjectVersionMetadata { this.dependencies.add( dependency ); } + + public boolean isIncomplete() + { + return incomplete; + } + + public void setIncomplete( boolean incomplete ) + { + this.incomplete = incomplete; + } } diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java index 15fd9c485..a0d7d7f90 100644 --- a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java +++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java @@ -68,7 +68,10 @@ public class DefaultMetadataResolver metadataRepository.getProjectVersion( repoId, namespace, projectId, projectVersion ); // TODO: do we want to detect changes as well by comparing timestamps? isProjectVersionNewerThan(updated) // in such cases we might also remove/update stale metadata, including adjusting plugin-based facets - if ( metadata == null ) + // This would also be better than checking for completeness - we can then refresh only when fixed (though + // sometimes this has an additional dependency - such as a parent - requesting the user to force an update + // may then work here and be more efficient than always trying again) + if ( metadata == null || metadata.isIncomplete() ) { metadata = storageResolver.getProjectVersion( repoId, namespace, projectId, projectVersion ); if ( metadata != null ) diff --git a/archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java b/archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java index ac1b03c6e..6011dbca8 100644 --- a/archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java +++ b/archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java @@ -131,6 +131,7 @@ public class FileMetadataRepository setProperty( properties, "name", versionMetadata.getName() ); setProperty( properties, "description", versionMetadata.getDescription() ); setProperty( properties, "url", versionMetadata.getUrl() ); + setProperty( properties, "incomplete", String.valueOf( versionMetadata.isIncomplete() ) ); if ( versionMetadata.getScm() != null ) { setProperty( properties, "scm.connection", versionMetadata.getScm().getConnection() ); @@ -653,6 +654,7 @@ public class FileMetadataRepository versionMetadata.setName( properties.getProperty( "name" ) ); versionMetadata.setDescription( properties.getProperty( "description" ) ); versionMetadata.setUrl( properties.getProperty( "url" ) ); + versionMetadata.setIncomplete( Boolean.valueOf( properties.getProperty( "incomplete", "false" ) ) ); String scmConnection = properties.getProperty( "scm.connection" ); String scmDeveloperConnection = properties.getProperty( "scm.developerConnection" ); diff --git a/archiva-modules/plugins/metadata-repository-file/src/test/java/org/apache/archiva/metadata/repository/file/FileMetadataRepositoryTest.java b/archiva-modules/plugins/metadata-repository-file/src/test/java/org/apache/archiva/metadata/repository/file/FileMetadataRepositoryTest.java index 0cfb2a7ba..915b0190f 100644 --- a/archiva-modules/plugins/metadata-repository-file/src/test/java/org/apache/archiva/metadata/repository/file/FileMetadataRepositoryTest.java +++ b/archiva-modules/plugins/metadata-repository-file/src/test/java/org/apache/archiva/metadata/repository/file/FileMetadataRepositoryTest.java @@ -39,6 +39,9 @@ import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.commons.io.FileUtils; import org.codehaus.plexus.spring.PlexusInSpringTestCase; +/** + * @todo should this be a generic MetadataRepository implementation test? + */ public class FileMetadataRepositoryTest extends PlexusInSpringTestCase { @@ -113,6 +116,17 @@ public class FileMetadataRepositoryTest repository.updateProjectVersion( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata ); } + public void testUpdateProjectVersionMetadataIncomplete() + { + ProjectVersionMetadata metadata = new ProjectVersionMetadata(); + metadata.setId( TEST_PROJECT_VERSION ); + metadata.setIncomplete( true ); + repository.updateProjectVersion( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata ); + + metadata = repository.getProjectVersion( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ); + assertEquals( true, metadata.isIncomplete() ); + } + public void testUpdateProjectVersionMetadataWithExistingFacets() { ProjectVersionMetadata metadata = new ProjectVersionMetadata(); |