]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1283] handle missing Maven facet
authorBrett Porter <brett@apache.org>
Wed, 25 Nov 2009 15:33:40 +0000 (15:33 +0000)
committerBrett Porter <brett@apache.org>
Wed, 25 Nov 2009 15:33:40 +0000 (15:33 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@884147 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/ShowArtifactActionTest.java

index 4d87e7203820ad074aba0febdfa4d53846d71905..d44348934a6a9c974584895c361d21d0844ae63f 100644 (file)
@@ -150,16 +150,19 @@ public class ShowArtifactAction
         // TODO: eventually, move to just use the metadata directly, with minimal JSP changes, mostly for Maven specifics
         model = new ArchivaProjectModel();
         MavenProjectFacet projectFacet = (MavenProjectFacet) versionMetadata.getFacet( MavenProjectFacet.FACET_ID );
-        model.setGroupId( projectFacet.getGroupId() );
-        model.setArtifactId( projectFacet.getArtifactId() );
-        model.setPackaging( projectFacet.getPackaging() );
-        if ( projectFacet.getParent() != null )
+        if ( projectFacet != null )
         {
-            VersionedReference parent = new VersionedReference();
-            parent.setGroupId( projectFacet.getParent().getGroupId() );
-            parent.setArtifactId( projectFacet.getParent().getArtifactId() );
-            parent.setVersion( projectFacet.getParent().getVersion() );
-            model.setParentProject( parent );
+            model.setGroupId( projectFacet.getGroupId() );
+            model.setArtifactId( projectFacet.getArtifactId() );
+            model.setPackaging( projectFacet.getPackaging() );
+            if ( projectFacet.getParent() != null )
+            {
+                VersionedReference parent = new VersionedReference();
+                parent.setGroupId( projectFacet.getParent().getGroupId() );
+                parent.setArtifactId( projectFacet.getParent().getArtifactId() );
+                parent.setVersion( projectFacet.getParent().getVersion() );
+                model.setParentProject( parent );
+            }
         }
 
         model.setVersion( versionMetadata.getId() );
index 5d4ab0853cc193d96a19c816e04b1341deeb5f5e..82ef07e0c81466bc7ecb1bbed5b796e9b66d4f1b 100644 (file)
@@ -308,6 +308,37 @@ public class ShowArtifactActionTest
         assertTrue( action.getSnapshotVersions().isEmpty() );
     }
 
+    public void testGetArtifactNoMavenFacet()
+    {
+        ProjectVersionMetadata versionMetadata = new ProjectVersionMetadata();
+        versionMetadata.setId( TEST_VERSION );
+        versionMetadata.setUrl( TEST_URL );
+        versionMetadata.setName( TEST_NAME );
+        versionMetadata.setDescription( TEST_DESCRIPTION );
+
+        metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );
+
+        setActionParameters();
+
+        String result = action.artifact();
+
+        assertActionSuccess( action, result );
+
+        assertActionParameters( action );
+        ArchivaProjectModel model = action.getModel();
+        assertEquals( TEST_VERSION, model.getVersion() );
+        assertEquals( TEST_URL, model.getUrl() );
+        assertEquals( TEST_NAME, model.getName() );
+        assertEquals( TEST_DESCRIPTION, model.getDescription() );
+
+        assertEquals( TEST_REPO, action.getRepositoryId() );
+
+        assertNull( action.getDependees() );
+        assertNull( action.getDependencies() );
+        assertNull( action.getMailingLists() );
+        assertTrue( action.getSnapshotVersions().isEmpty() );
+    }
+
     private void assertNoOutputFields()
     {
         assertNull( action.getModel() );