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 )
{
log.warn( "Missing or invalid POM for artifact: " + path + "; creating empty metadata" );
versionMetadata = new ProjectVersionMetadata();
versionMetadata.setId( projectVersion );
+ versionMetadata.setIncomplete( true );
createVersionMetadata = true;
}
}
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 )
{
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.
*/
<%@ 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>
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)
+}
+
private List<Dependency> dependencies = new ArrayList<Dependency>();
+ private boolean incomplete;
+
public String getId()
{
return id;
{
this.dependencies.add( dependency );
}
+
+ public boolean isIncomplete()
+ {
+ return incomplete;
+ }
+
+ public void setIncomplete( boolean incomplete )
+ {
+ this.incomplete = incomplete;
+ }
}
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 )
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() );
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" );
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
{
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();