From ef8f63a5acce6605fcba3c7af75cdfca4aa44f0f Mon Sep 17 00:00:00 2001 From: "Jevica Arianne B. Zurbano" Date: Fri, 21 May 2010 14:22:15 +0000 Subject: [PATCH] [MRM-1362] Add simple 'CRUD' pages for project-level metadata along with a "generic metadata" plugin * 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 --- .../web/action/ShowArtifactAction.java | 8 + .../web/util/ProjectMetadataDisplayUtil.java | 199 ++++++++++++++ .../WEB-INF/jsp/include/mailingLists.jspf | 139 +++++----- .../WEB-INF/jsp/include/projectMetadata.jspf | 246 +----------------- 4 files changed, 288 insertions(+), 304 deletions(-) create mode 100644 archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/util/ProjectMetadataDisplayUtil.java 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 f40cd6f08..2d3182d8c 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 @@ -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 index 000000000..af3ba7ed0 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/util/ProjectMetadataDisplayUtil.java @@ -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 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 lists = projectMetadata.getMailingLists(); + List 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 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
    " ); + } + + private void endList() + { + metadataEntries.append( "\n
" ); + } + + private void addListItem( String label, String value ) + { + String newValue = StringUtils.isEmpty( value ) ? "" : value; + metadataEntries.append( "\n
  • " ).append( label ).append( newValue ).append( "
  • " ); + } + + private void startListItem( String value ) + { + metadataEntries.append( "\n
  • " ).append( value ); + } + + private void endListItem() + { + metadataEntries.append( "\n
  • " ); + } +} + diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/include/mailingLists.jspf b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/include/mailingLists.jspf index 21d140d5d..027cfe849 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/include/mailingLists.jspf +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/include/mailingLists.jspf @@ -22,64 +22,81 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="my" tagdir="/WEB-INF/tags" %> - -

    - ${mailingList.name} -

    - <%-- TODO: description -

    - Description blah blah blah -

    - --%> - -
    - - No mailing lists - + + + + + + +
    +
    + + +

    + ${mailingList.name} +

    + <%-- TODO: description +

    + Description blah blah blah +

    + --%> + +
    +
    + + + No mailing lists + + +
    diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/include/projectMetadata.jspf b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/include/projectMetadata.jspf index 78104df50..452050aac 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/include/projectMetadata.jspf +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/include/projectMetadata.jspf @@ -22,12 +22,6 @@ <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="archiva" uri="/WEB-INF/taglib.tld" %> - -

    @@ -41,240 +35,6 @@ ${version}

    - -
    ${projectMetadata.description}
    -
    - - - - - - - - - - - - - - - - - - -
    Project Metadata ID${projectMetadata.id}
    URL${projectMetadata.url}
    Name${projectMetadata.name}
    Description${projectMetadata.description}
    - - - -

    Other Details

    - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Organisation - - - ${projectMetadata.organization.name} - - - ${projectMetadata.organization.name} - - -
    License - - - ${license.name} - - - ${license.name} - - -
    Issue Tracker - - - ${projectMetadata.issueManagement.system} - - - ${projectMetadata.issueManagement.system} - - -
    Continuous Integration - - - ${projectMetadata.ciManagement.system} - - - ${projectMetadata.ciManagement.system} - - -
    -
    - - -

    SCM

    - - - - - - - - - - - - - - - - - - - -
    Connection - ${projectMetadata.scm.connection} -
    Dev. Connection - ${projectMetadata.scm.developerConnection} -
    Viewer - ${projectMetadata.scm.url} -
    -
    - - - -
    - -

    Mailing Lists

    -
    - -

    ${mailingList.name}

    - - - - - - - - - - - - - - - - - - - - - - - - - -
    Subscribe - ${mailingList.subscribeAddress} -
    Post - ${mailingList.postAddress} -
    Unsubscribe - ${mailingList.unsubscribeAddress} -
    Archive - ${mailingList.mainArchiveUrl} -
    -
    -
    -
    - - -

    Dependencies

    -
    - -

    Dependency

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Group ID - ${dependency.groupId} -
    Artifact ID - ${dependency.artifactId} -
    Version - ${dependency.version} -
    Classifier - ${dependency.classifier} -
    Type - ${dependency.type} -
    Scope - ${dependency.scope} -
    System Path - ${dependency.systemPath} -
    -
    -
    -
    -
    -
    +
    + ${metadataOutput} +
    -- 2.39.5