mirror of https://github.com/apache/archiva.git
[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
This commit is contained in:
parent
79de06cf3e
commit
1f1252456a
|
@ -166,7 +166,8 @@ public class ArchivaMetadataCreationConsumer
|
|||
ProjectVersionMetadata versionMetadata = null;
|
||||
try
|
||||
{
|
||||
versionMetadata = storageResolver.getProjectVersion( repository.getId(), artifact.getGroupId(), artifact.getArtifactId(),
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -339,3 +339,14 @@ div.versions a.expand {
|
|||
font-size: 7pt;
|
||||
color: gray;
|
||||
}
|
||||
|
||||
#messages {
|
||||
background-color: yellow;
|
||||
border: 1px solid orange;
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
#messages ul {
|
||||
list-style-image: url(../images/icon_warning_sml.gif)
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -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" );
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue