archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jzurb...@apache.org
Subject svn commit: r948707 - in /archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main: java/org/apache/maven/archiva/web/action/ java/org/apache/maven/archiva/web/tags/ resources/ webapp/WEB-INF/ webapp/WEB-INF/jsp/include/
Date Thu, 27 May 2010 07:45:06 GMT
Author: jzurbano
Date: Thu May 27 07:45:06 2010
New Revision: 948707

URL: http://svn.apache.org/viewvc?rev=948707&view=rev
Log:
[MRM-1362] [MRM-1362] Add simple 'CRUD' pages for project-level metadata along with a "generic
metadata" plugin 
* added delete of mailing list, dependency, and license entries


Modified:
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/ProjectMetadataTag.java
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/resources/struts.xml
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/include/projectMetadata.jspf
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/taglib.tld

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java?rev=948707&r1=948706&r2=948707&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/ShowArtifactAction.java
Thu May 27 07:45:06 2010
@@ -22,6 +22,7 @@ package org.apache.maven.archiva.web.act
 import com.opensymphony.xwork2.Validateable;
 import org.apache.archiva.metadata.model.ArtifactMetadata;
 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.archiva.metadata.model.ProjectVersionReference;
@@ -102,6 +103,10 @@ public class ShowArtifactAction
     private boolean dependencyTree = false;
 
     private ProjectVersionMetadata projectMetadata;
+    
+    private String deleteItem;
+    
+    private String itemValue;
    
     /**
      * Show the versioned project information tab.
@@ -295,7 +300,90 @@ public class ShowArtifactAction
 
         return SUCCESS;
     }
-
+    
+    public String deleteMetadataEntry()
+    {   
+        projectMetadata = getProjectVersionMetadata();
+        
+        if ( !StringUtils.isEmpty( deleteItem ) && !StringUtils.isEmpty( itemValue
) )
+        {
+            if ( "dependency".equals( deleteItem ) )
+            {
+                removeDependency();
+            }
+            else if ( "mailingList".equals( deleteItem ) )
+            {
+                removeMailingList();
+            }
+            else if ( "license".equals( deleteItem ) )
+            {
+                removeLicense();
+            }
+            
+            deleteItem = "";
+            itemValue = "";
+        }
+        
+        return updateProjectMetadata();
+    }
+    
+    private void removeDependency()
+    {
+        List<Dependency> dependencies = projectMetadata.getDependencies();
+        List<Dependency> newDependencies = new ArrayList<Dependency>();
+        
+        if ( dependencies != null )
+        {
+            for ( Dependency dependency : dependencies )
+            {
+                if ( !StringUtils.equals( itemValue, dependency.getArtifactId() ) )
+                {
+                    newDependencies.add( dependency );
+                }
+            }
+        }
+        
+        projectMetadata.setDependencies( newDependencies );
+    }
+    
+    private void removeMailingList()
+    {
+        List<MailingList> mailingLists = projectMetadata.getMailingLists();
+        List<MailingList> newMailingLists = new ArrayList<MailingList>();
+        
+        if ( mailingLists != null )
+        {
+            for ( MailingList mailingList : mailingLists )
+            {
+                if ( !StringUtils.equals( itemValue, mailingList.getName() ) )
+                {
+                    newMailingLists.add( mailingList );
+                }
+            }
+        }
+        
+        projectMetadata.setMailingLists( newMailingLists );
+    }
+    
+    private void removeLicense()
+    {
+        List<License> licenses = projectMetadata.getLicenses();
+        List<License> newLicenses = new ArrayList<License>();
+        
+        if ( licenses != null )
+        {
+            for ( License license : licenses )
+            {
+                if ( !StringUtils.equals( itemValue, license.getName() ) )
+                {
+                    newLicenses.add( license );
+                }
+            }
+        }
+        
+        projectMetadata.setLicenses( newLicenses );
+    }
+    
     @Override
     public void validate()
     {
@@ -410,6 +498,16 @@ public class ShowArtifactAction
         this.projectMetadata = projectMetadata;
     }
 
+    public void setDeleteItem( String deleteItem )
+    {
+        this.deleteItem = deleteItem; 
+    }
+    
+    public void setItemValue( String itemValue )
+    {
+        this.itemValue = itemValue;
+    }
+
     // TODO: move this into the artifact metadata itself via facets where necessary
 
     public class ArtifactDownloadInfo

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/ProjectMetadataTag.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/ProjectMetadataTag.java?rev=948707&r1=948706&r2=948707&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/ProjectMetadataTag.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/tags/ProjectMetadataTag.java
Thu May 27 07:45:06 2010
@@ -45,6 +45,12 @@ public class ProjectMetadataTag
     private Logger log = LoggerFactory.getLogger( ProjectMetadataTag.class );
 
     private Object object;
+    
+    private String groupId;
+
+    private String artifactId;
+
+    private String version;
 
     @Override
     public void release()
@@ -152,8 +158,12 @@ public class ProjectMetadataTag
             startList( metadataEntries );
             for ( License license : licenses )
             {
+                createDeleteLink( "license", license.getName(), metadataEntries );
+                startList( metadataEntries );
                 addListItem( "licenses." + ctr + ".name=", license.getName(), metadataEntries
);
                 addListItem( "licenses." + ctr + ".url=", license.getUrl(), metadataEntries
);
+                endList( metadataEntries );
+                endListItem( metadataEntries );
                 ctr++;
             }
             endList( metadataEntries );
@@ -171,6 +181,8 @@ public class ProjectMetadataTag
             startList( metadataEntries );
             for ( MailingList list : lists )
             {
+                createDeleteLink( "mailingList", list.getName(), metadataEntries );
+                startList( metadataEntries );
                 addListItem( "mailingLists." + ctr + ".name=", list.getName(), metadataEntries
);
                 addListItem( "mailingLists." + ctr + ".archive.url=", list.getMainArchiveUrl(),
metadataEntries );
                 addListItem( "mailingLists." + ctr + ".post=", list.getPostAddress(), metadataEntries
);
@@ -194,6 +206,8 @@ public class ProjectMetadataTag
                     endList( metadataEntries );
                 }
                 endListItem( metadataEntries );
+                endList( metadataEntries );
+                endListItem( metadataEntries );
                 ctr++;
             }
             endList( metadataEntries );
@@ -207,8 +221,11 @@ public class ProjectMetadataTag
             int ctr = 0;
 
             startList( metadataEntries );
+            
             for ( Dependency dependency : dependencies )
             {
+                createDeleteLink( "dependency", dependency.getArtifactId(), metadataEntries
);
+                startList( metadataEntries );
                 addListItem( "dependency." + ctr + ".group.id=", dependency.getGroupId(),
metadataEntries );
                 addListItem( "dependency." + ctr + ".artifact.id=", dependency.getArtifactId(),
metadataEntries );
                 addListItem( "dependency." + ctr + ".version=", dependency.getVersion(),
metadataEntries );
@@ -216,9 +233,12 @@ public class ProjectMetadataTag
                 addListItem( "dependency." + ctr + ".type=", dependency.getType(), metadataEntries
);
                 addListItem( "dependency." + ctr + ".scope=", dependency.getScope(), metadataEntries
);
                 addListItem( "dependency." + ctr + ".system.path=", dependency.getSystemPath(),
metadataEntries );
+                endList( metadataEntries );
+                endListItem( metadataEntries );
                 ctr++;
             }
             endList( metadataEntries );
+            
             endListItem( metadataEntries );
         }
 
@@ -250,9 +270,36 @@ public class ProjectMetadataTag
     {
         metadataEntries.append( "\n</li>" );
     }
+    
+    private void createDeleteLink( String name, String value, StringBuffer metadataEntries
)
+    {
+        metadataEntries.append( "\n<li>" ).append( value )
+                       .append( "\n<a href=\"showProjectMetadata!deleteMetadataEntry.action?"
)
+                       .append( "groupId=" ).append( groupId )
+                       .append( "&artifactId=" ).append( artifactId )
+                       .append( "&version=" ).append( version )
+                       .append( "&deleteItem=" ).append( name )
+                       .append( "&itemValue=").append( value ).append( "\" >" )
+                       .append( "<img src=\"images/icons/delete.gif\"/>" ).append(
"</a>" );
+    }
 
     public void setObject( Object object )
     {
         this.object = object;
     }
+
+    public void setGroupId( String groupId )
+    {
+        this.groupId = groupId;
+    }
+
+    public void setArtifactId( String artifactId )
+    {
+        this.artifactId = artifactId;
+    }
+
+    public void setVersion( String version )
+    {
+        this.version = version;
+    }
 }

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/resources/struts.xml
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/resources/struts.xml?rev=948707&r1=948706&r2=948707&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/resources/struts.xml
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/resources/struts.xml
Thu May 27 07:45:06 2010
@@ -222,6 +222,13 @@
       <result>/WEB-INF/jsp/showArtifact.jsp</result>
     </action>
 
+    <action name="deleteMetadataEntry" class="showArtifactAction" method="deleteMetadataEntry">
+      <result name="success" type="redirect-action">
+        <param name="actionName">showProjectMetadata</param>
+        <param name="namespace">/</param>
+      </result>
+    </action>
+
   </package>
 
   <package name="components" namespace="/components" extends="struts-default">

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/include/projectMetadata.jspf
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/include/projectMetadata.jspf?rev=948707&r1=948706&r2=948707&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/include/projectMetadata.jspf
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/include/projectMetadata.jspf
Thu May 27 07:45:06 2010
@@ -36,5 +36,5 @@
 </p>
 
 <div>
-  <archiva:project-metadata object="${projectMetadata}" />
+  <archiva:project-metadata object="${projectMetadata}" groupId="${groupId}" artifactId="${artifactId}"
version="${version}" />
 </div>

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/taglib.tld
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/taglib.tld?rev=948707&r1=948706&r2=948707&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/taglib.tld
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/taglib.tld
Thu May 27 07:45:06 2010
@@ -124,7 +124,31 @@
         
         <description><![CDATA[The Object to Render]]></description>
       </attribute>
+
+      <attribute>
+        <name>groupId</name>
+        <required>true</required>
+        <rtexprvalue>true</rtexprvalue>
+        
+        <description><![CDATA[The groupId]]></description>
+      </attribute>
+      
+      <attribute>
+        <name>artifactId</name>
+        <required>true</required>
+        <rtexprvalue>true</rtexprvalue>
+        
+        <description><![CDATA[The artifactId]]></description>
+      </attribute>
+
+      <attribute>
+        <name>version</name>
+        <required>true</required>
+        <rtexprvalue>true</rtexprvalue>
+        
+        <description><![CDATA[The version]]></description>
+      </attribute>
    
    </tag>
    
-</taglib>
\ No newline at end of file
+</taglib>



Mime
View raw message