]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1362] Add simple 'CRUD' pages for project-level metadata along with a "generic...
authorJevica Arianne B. Zurbano <jzurbano@apache.org>
Fri, 21 May 2010 14:22:15 +0000 (14:22 +0000)
committerJevica Arianne B. Zurbano <jzurbano@apache.org>
Fri, 21 May 2010 14:22:15 +0000 (14:22 +0000)
* modified display of project metadata; added util to format the metadata for display
* modified format of mailing lists in "Mailing List" tab using the previous format of the mailing lists in "Project Metadata"

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@947020 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/main/java/org/apache/maven/archiva/web/util/ProjectMetadataDisplayUtil.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/include/mailingLists.jspf
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/include/projectMetadata.jspf

index f40cd6f08c405b47fff0fdae0eacff5a35096d73..2d3182d8c7ea239991b752cb694a6a3412d8c462 100644 (file)
@@ -29,6 +29,7 @@ import org.apache.archiva.metadata.repository.MetadataRepository;
 import org.apache.archiva.metadata.repository.MetadataResolutionException;
 import org.apache.archiva.metadata.repository.MetadataResolver;
 import org.apache.archiva.metadata.repository.storage.maven2.MavenArtifactFacet;
+import org.apache.maven.archiva.web.util.ProjectMetadataDisplayUtil;
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.archiva.model.ArtifactReference;
 import org.apache.maven.archiva.repository.ManagedRepositoryContent;
@@ -288,6 +289,13 @@ public class ShowArtifactAction
 
         return SUCCESS;
     }
+    
+    public String getMetadataOutput()
+    {
+        ProjectMetadataDisplayUtil metadataDisplayUtil = new ProjectMetadataDisplayUtil();
+        
+        return metadataDisplayUtil.formatProjectMetadata( projectMetadata );
+    }
 
     public String updateProjectMetadata()
     {
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/util/ProjectMetadataDisplayUtil.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/util/ProjectMetadataDisplayUtil.java
new file mode 100644 (file)
index 0000000..af3ba7e
--- /dev/null
@@ -0,0 +1,199 @@
+package org.apache.maven.archiva.web.util;
+
+/*
+ * 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.archiva.metadata.model.Dependency;
+import org.apache.archiva.metadata.model.License;
+import org.apache.archiva.metadata.model.MailingList;
+import org.apache.archiva.metadata.model.ProjectVersionMetadata;
+import org.apache.commons.lang.StringUtils;
+
+import java.util.List;
+
+/**
+ * ProjectMetadataDisplayUtil
+ *
+ */
+
+public class ProjectMetadataDisplayUtil
+{
+    private StringBuilder metadataEntries;
+    
+    public String formatProjectMetadata( ProjectVersionMetadata projectMetadata )
+    {
+        metadataEntries = new StringBuilder();
+        
+        startList();
+        
+        addListItem( "project.metadata.id=", projectMetadata.getId() );
+        addListItem( "project.url=", projectMetadata.getUrl() );
+        addListItem( "project.name=", projectMetadata.getName() );
+        addListItem( "project.description=", projectMetadata.getDescription() );
+        
+        startListItem( "organization" );
+        if ( projectMetadata.getOrganization() != null )
+        {
+            startList();
+            addListItem( "organization.name=", projectMetadata.getOrganization().getName() );
+            addListItem( "organization.url=", projectMetadata.getOrganization().getUrl() );
+            endList();
+        }
+        endListItem();
+         
+        startListItem( "issueManagement" );
+        if ( projectMetadata.getIssueManagement() != null )
+        {
+            startList();
+            addListItem( "issueManagement.system=", projectMetadata.getIssueManagement().getSystem() );
+            addListItem( "issueManagement.url=", projectMetadata.getIssueManagement().getUrl() );
+            endList();
+        }
+        endListItem();
+        
+        startListItem( "scm" );
+        if ( projectMetadata.getScm() != null )
+        {
+            startList();
+            addListItem( "scm.url=", projectMetadata.getScm().getUrl() );
+            addListItem( "scm.connection=", projectMetadata.getScm().getConnection() );
+            addListItem( "scm.developer.connection=", projectMetadata.getScm().getDeveloperConnection() );
+            endList();
+        }
+        endListItem();
+        
+        startListItem( "ciManagement" );
+        if ( projectMetadata.getCiManagement() != null )
+        {
+            startList();
+            addListItem( "ciManagement.system=", projectMetadata.getCiManagement().getSystem() );
+            addListItem( "ciManagement.url=", projectMetadata.getCiManagement().getUrl() );
+            endList();
+        }
+        endListItem();
+        
+        startListItem( "licenses" );
+        if ( projectMetadata.getLicenses() != null )
+        {
+            List<License> licenses = projectMetadata.getLicenses();
+            int ctr = 0;
+            startList();
+            for ( License license : licenses )
+            {
+                addListItem( "licenses." + ctr + ".name=", license.getName() );
+                addListItem( "licenses." + ctr + ".url=", license.getUrl() );
+                ctr++;
+            }
+            endList();
+        }
+        endListItem();
+         
+        startListItem( "mailingLists" );
+        if ( projectMetadata.getMailingLists() != null )
+        {
+            List<MailingList> lists = projectMetadata.getMailingLists();
+            List<String> otherArchives;
+            int ctr = 0;
+            int archiveCtr = 0;
+            
+            startList();
+            for ( MailingList list : lists )
+            {
+                addListItem( "mailingLists." + ctr + ".name=", list.getName() );
+                addListItem( "mailingLists." + ctr + ".archive.url=", list.getMainArchiveUrl() );
+                addListItem( "mailingLists." + ctr + ".post=", list.getPostAddress() );
+                addListItem( "mailingLists." + ctr + ".subscribe=", list.getSubscribeAddress() );
+                addListItem( "mailingLists." + ctr + ".unsubscribe=", list.getUnsubscribeAddress() );
+                startListItem( "mailingLists." + ctr + ".otherArchives" );
+                
+                if ( list.getOtherArchives() != null && list.getOtherArchives().size() > 0 )
+                {
+                    archiveCtr = 0;
+                    otherArchives = list.getOtherArchives();
+                    
+                    startList();
+                    for ( String archive : otherArchives )
+                    {
+                        addListItem( "mailingLists." + ctr + ".otherArchives." + archiveCtr + "=", archive );
+                        metadataEntries.append( archive );
+                        archiveCtr++;
+                    }
+                    endList();
+                }
+                endListItem();
+                ctr++;
+            }
+            endList();
+        }
+        endListItem();
+        
+        startListItem( "dependencies" );
+        if ( projectMetadata.getDependencies() != null )
+        {
+            List<Dependency> dependencies = projectMetadata.getDependencies();
+            int ctr = 0;
+            
+            startList();
+            for ( Dependency dependency : dependencies )
+            {
+                addListItem( "dependency." + ctr + ".group.id=", dependency.getGroupId() );
+                addListItem( "dependency." + ctr + ".artifact.id=", dependency.getArtifactId() );
+                addListItem( "dependency." + ctr + ".version=", dependency.getVersion() );
+                addListItem( "dependency." + ctr + ".classifier=", dependency.getClassifier() );
+                addListItem( "dependency." + ctr + ".type=", dependency.getType() );
+                addListItem( "dependency." + ctr + ".scope=", dependency.getScope() );
+                addListItem( "dependency." + ctr + ".system.path=", dependency.getSystemPath() );
+                ctr++;
+            }
+            endList();
+        }
+        endListItem();
+        
+        endList();
+        
+        return metadataEntries.toString();
+    }
+    
+    private void startList()
+    {
+        metadataEntries.append( "\n<ul>" );
+    }
+     
+    private void endList()
+    {
+        metadataEntries.append( "\n</ul>" );
+    }
+    
+    private void addListItem( String label, String value )
+    {
+        String newValue = StringUtils.isEmpty( value ) ? "" : value;
+        metadataEntries.append( "\n<li>" ).append( label ).append( newValue ).append( "</li>" );
+    }
+    
+    private void startListItem( String value )
+    {
+        metadataEntries.append( "\n<li>" ).append( value );
+    }
+    
+    private void endListItem()
+    {
+        metadataEntries.append( "\n</li>" );
+    }
+}
+
index 21d140d5dddab60a3d86537afef24d72efcf8b3b..027cfe849796a846f8266045d892c8eeee59105f 100644 (file)
 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 <%@ taglib prefix="my" tagdir="/WEB-INF/tags" %>
 
-<c:forEach items="${mailingLists}" var="mailingList">
-  <h3>
-      ${mailingList.name}
-  </h3>
-  <%-- TODO: description
-    <p>
-      Description blah blah blah
-    </p>
-  --%>
-  <ul>
-    <c:if test="${!empty (mailingList.subscribeAddress)}">
-      <li>
-        <b>Subscribe:</b>
-        <a href="mailto:${mailingList.subscribeAddress}">${mailingList.subscribeAddress}</a>
-      </li>
-    </c:if>
-    <c:if test="${!empty (mailingList.postAddress)}">
-      <li>
-        <b>Post:</b>
-        <a href="mailto:${mailingList.postAddress}">${mailingList.postAddress}</a>
-      </li>
-    </c:if>
-    <c:if test="${!empty (mailingList.unsubscribeAddress)}">
-      <li>
-        <b>Unsubscribe:</b>
-        <a href="mailto:${mailingList.unsubscribeAddress}">${mailingList.unsubscribeAddress}</a>
-      </li>
-    </c:if>
-      <%-- TODO: not in the POM yet
-          <li>
-            <b>List owner:</b>
-            <a href="mailto:${mailingList.owner}">${mailingList.owner}</a>
-          </li>
-      --%>
-    <c:if test="${!empty (mailingList.mainArchiveUrl)}">
-      <li>
-        <b>Archive:</b>
-        <ul>
-          <li>
-            <a href="${mailingList.mainArchiveUrl}">${mailingList.mainArchiveUrl}</a>
-          </li>
-        </ul>
-      </li>
-    </c:if>
-    <%-- <c:if test="${!empty (mailingList.otherArchives)}">
-      <li>
-        <b>Other Archives:</b>
-        <ul>
-          <c:forEach items="${mailingList.otherArchives}" var="archive">
-            <li>
-              <a href="${archive}">${archive}</a>
-            </li>
-          </c:forEach>
-        </ul>
-      </li>
-    </c:if> --%>
-  </ul>
-</c:forEach>
-<c:if test="${empty (mailingLists)}">
-  <strong>No mailing lists</strong>
-</c:if>
+<script type="text/javascript">
+  $(function() {
+    $("#accordion2").accordion();
+  });
+</script>
+
+<table class="infoTable">
+  <tr>
+    <td>
+      <div id="accordion2">
+
+        <c:forEach items="${mailingLists}" var="mailingList">
+          <h2>
+              <a href="#">${mailingList.name}</a>
+          </h2>
+          <%-- TODO: description
+            <p>
+              Description blah blah blah
+            </p>
+          --%>
+          <ul>
+            <c:if test="${!empty (mailingList.subscribeAddress)}">
+              <li>
+                <b>Subscribe:</b>
+                <a href="mailto:${mailingList.subscribeAddress}">${mailingList.subscribeAddress}</a>
+              </li>
+            </c:if>
+            <c:if test="${!empty (mailingList.postAddress)}">
+              <li>
+                <b>Post:</b>
+                <a href="mailto:${mailingList.postAddress}">${mailingList.postAddress}</a>
+              </li>
+            </c:if>
+            <c:if test="${!empty (mailingList.unsubscribeAddress)}">
+              <li>
+                <b>Unsubscribe:</b>
+                <a href="mailto:${mailingList.unsubscribeAddress}">${mailingList.unsubscribeAddress}</a>
+              </li>
+            </c:if>
+              <%-- TODO: not in the POM yet
+                  <li>
+                    <b>List owner:</b>
+                    <a href="mailto:${mailingList.owner}">${mailingList.owner}</a>
+                  </li>
+              --%>
+            <c:if test="${!empty (mailingList.mainArchiveUrl)}">
+              <li>
+                <b>Archive:</b>
+                <ul>
+                  <li>
+                    <a href="${mailingList.mainArchiveUrl}">${mailingList.mainArchiveUrl}</a>
+                  </li>
+                </ul>
+              </li>
+            </c:if>
+            <%-- <c:if test="${!empty (mailingList.otherArchives)}">
+              <li>
+                <b>Other Archives:</b>
+                <ul>
+                  <c:forEach items="${mailingList.otherArchives}" var="archive">
+                    <li>
+                      <a href="${archive}">${archive}</a>
+                    </li>
+                  </c:forEach>
+                </ul>
+              </li>
+            </c:if> --%>
+          </ul>
+        </c:forEach>
+      </div>
+
+      <c:if test="${empty (mailingLists)}">
+        <strong>No mailing lists</strong>
+      </c:if>
+
+    </td>
+  </tr>
+</table>
index 78104df50b488cdd4165a52669de7a300c7235f5..452050aac59df700b591c5da943b0d9234ad33ae 100644 (file)
 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 <%@ taglib prefix="archiva"   uri="/WEB-INF/taglib.tld" %>
 
-<script type="text/javascript">
-  $(function() {
-    $("#accordion2").accordion();
-  });
-</script>
-
 <p>
   <archiva:groupIdLink var="${groupId}" includeTop="true" />
 
   <strong>${version}</strong>
 </p>
 
-<c:if test="${!empty (projectMetadata.description)}">
-  <blockquote>${projectMetadata.description}</blockquote>
-</c:if>
-
-<table class="infoTable">
-  <tr>
-    <th>Project Metadata ID</th>
-    <td>${projectMetadata.id}</td>
-  </tr>
-  <tr>
-    <th>URL</th>
-    <td>${projectMetadata.url}</td>
-  </tr>
-  <tr>
-    <th>Name</th>
-    <td>${projectMetadata.name}</td>
-  </tr>
-  <tr>
-    <th>Description</th>
-    <td>${projectMetadata.description}</td>
-  </tr>
-</table>
-
-<c:if test="${projectMetadata.organization != null || !empty (projectMetadata.licenses)
-    || projectMetadata.issueManagement != null || projectMetadata.ciManagement != null }">
-
-  <h2>Other Details</h2>
-  <table class="infoTable">
-    <c:if test="${projectMetadata.organization != null}">
-      <tr>
-        <th>Organisation</th>
-        <td>
-          <c:choose>
-            <c:when test="${projectMetadata.organization.url != null}">
-              <a href="${projectMetadata.organization.url}">${projectMetadata.organization.name}</a>
-            </c:when>
-            <c:otherwise>
-              ${projectMetadata.organization.name}
-            </c:otherwise>
-          </c:choose>
-        </td>
-      </tr>
-    </c:if>
-    <c:if test="${!empty (projectMetadata.licenses)}">
-      <c:forEach items="${projectMetadata.licenses}" var="license">
-        <tr>
-          <th>License</th>
-          <td>
-            <c:choose>
-              <c:when test="${!empty (license.url)}">
-                <a href="${license.url}">${license.name}</a>
-              </c:when>
-              <c:otherwise>
-                ${license.name}
-              </c:otherwise>
-            </c:choose>
-          </td>
-        </tr>
-      </c:forEach>
-    </c:if>
-    <c:if test="${projectMetadata.issueManagement != null}">
-      <tr>
-        <th>Issue Tracker</th>
-        <td>
-          <c:choose>
-            <c:when test="${!empty (projectMetadata.issueManagement.url)}">
-              <a href="${projectMetadata.issueManagement.url}">${projectMetadata.issueManagement.system}</a>
-            </c:when>
-            <c:otherwise>
-              ${projectMetadata.issueManagement.system}
-            </c:otherwise>
-          </c:choose>
-        </td>
-      </tr>
-    </c:if>
-    <c:if test="${projectMetadata.ciManagement != null}">
-      <tr>
-        <th>Continuous Integration</th>
-        <td>
-          <c:choose>
-            <c:when test="${!empty (projectMetadata.ciManagement.url)}">
-              <a href="${projectMetadata.ciManagement.url}">${projectMetadata.ciManagement.system}</a>
-            </c:when>
-            <c:otherwise>
-              ${projectMetadata.ciManagement.system}
-            </c:otherwise>
-          </c:choose>
-        </td>
-      </tr>
-    </c:if>
-  </table>
-</c:if>
-
-<c:if test="${projectMetadata.scm != null}">
-  <h2>SCM</h2>
-  <table class="infoTable">
-    <c:if test="${!empty (projectMetadata.scm.connection)}">
-      <tr>
-        <th>Connection</th>
-        <td>
-          <code>${projectMetadata.scm.connection}</code>
-        </td>
-      </tr>
-    </c:if>
-    <c:if test="${!empty (projectMetadata.scm.developerConnection)}">
-      <tr>
-        <th>Dev. Connection</th>
-        <td>
-          <code>${projectMetadata.scm.developerConnection}</code>
-        </td>
-      </tr>
-    </c:if>
-    <c:if test="${!empty (projectMetadata.scm.url)}">
-      <tr>
-        <th>Viewer</th>
-        <td>
-          <a href="${projectMetadata.scm.url}">${projectMetadata.scm.url}</a>
-        </td>
-      </tr>
-    </c:if>
-  </table>
-</c:if>
-
-
-<c:if test="${projectMetadata.mailingLists != null || projectMetadata.dependencies != null}">
- <div id="accordion2">
-    <c:if test="${!empty (projectMetadata.mailingLists)}">
-    <h2><a href="#">Mailing Lists</a></h2>
-    <div>
-       <c:forEach items="${projectMetadata.mailingLists}" var="mailingList">
-         <h3>${mailingList.name}</h3>
-         <table class="infoTable">
-           <c:if test="${!empty (mailingList.subscribeAddress)}">
-             <tr>
-               <th>Subscribe</th>
-               <td>
-                 <code>${mailingList.subscribeAddress}</code>
-               </td>
-             </tr>
-           </c:if>
-           <c:if test="${!empty (mailingList.postAddress)}">
-             <tr>
-               <th>Post</th>
-               <td>
-                 <code>${mailingList.postAddress}</code>
-               </td>
-             </tr>
-           </c:if>
-           <c:if test="${!empty (mailingList.unsubscribeAddress)}">
-             <tr>
-               <th>Unsubscribe</th>
-               <td>
-                 <code>${mailingList.unsubscribeAddress}</code>
-               </td>
-             </tr>
-           </c:if>
-           <c:if test="${!empty (mailingList.mainArchiveUrl)}">
-             <tr>
-               <th>Archive</th>
-               <td>
-                 <code>${mailingList.mainArchiveUrl}</code>
-               </td>
-             </tr>
-           </c:if>
-         </table>
-       </c:forEach>
-    </div>
-    </c:if>
-
-    <c:if test="${!empty (projectMetadata.dependencies)}">
-    <h2><a href="#">Dependencies</a></h2>
-    <div>
-        <c:forEach items="${projectMetadata.dependencies}" var="dependency">
-         <h3>Dependency</h3>
-         <table class="infoTable">
-           <c:if test="${!empty (dependency.groupId)}">
-             <tr>
-               <th>Group ID</th>
-               <td>
-                 <code>${dependency.groupId}</code>
-               </td>
-             </tr>
-           </c:if>
-           <c:if test="${!empty (dependency.artifactId)}">
-             <tr>
-               <th>Artifact ID</th>
-               <td>
-                 <code>${dependency.artifactId}</code>
-               </td>
-             </tr>
-           </c:if>
-           <c:if test="${!empty (dependency.version)}">
-             <tr>
-               <th>Version</th>
-               <td>
-                 <code>${dependency.version}</code>
-               </td>
-             </tr>
-           </c:if>
-           <c:if test="${!empty (dependency.classifier)}">
-             <tr>
-               <th>Classifier</th>
-               <td>
-                 <code>${dependency.classifier}</code>
-               </td>
-             </tr>
-           </c:if>
-           <c:if test="${!empty (dependency.type)}">
-             <tr>
-               <th>Type</th>
-               <td>
-                 <code>${dependency.type}</code>
-               </td>
-             </tr>
-           </c:if>
-           <c:if test="${!empty (dependency.scope)}">
-             <tr>
-               <th>Scope</th>
-               <td>
-                 <code>${dependency.scope}</code>
-               </td>
-             </tr>
-           </c:if>
-           <c:if test="${!empty (dependency.systemPath)}">
-             <tr>
-               <th>System Path</th>
-               <td>
-                 <code>${dependency.systemPath}</code>
-               </td>
-             </tr>
-           </c:if>
-         </table>
-       </c:forEach>
-      </div>
-    </c:if>
- </div>
-</c:if>
+<div>
+  ${metadataOutput}
+</div>