]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1362] Add simple 'CRUD' pages for project-level metadata along with a "generic...
authorMaria Odea B. Ching <oching@apache.org>
Fri, 4 Jun 2010 05:50:17 +0000 (05:50 +0000)
committerMaria Odea B. Ching <oching@apache.org>
Fri, 4 Jun 2010 05:50:17 +0000 (05:50 +0000)
o added validation for adding new properties

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@951287 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/resources/struts.xml
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/include/projectMetadata.jspf

index eed67d57171f1f6e163f46ba369b2e890c9f4e2e..373c3eaff8746b0db19ad356d738af0601dce3c2 100644 (file)
@@ -305,9 +305,9 @@ public class ShowArtifactAction
     
     public String addMetadataProperty()
     {
-        ProjectVersionMetadata projectMetadata = getProjectVersionMetadata();
-        String errorMsg = null;      
+        String errorMsg = null;
         
+        ProjectVersionMetadata projectMetadata = getProjectVersionMetadata();
         if( projectMetadata == null )
         {
             addActionError( errorMsg != null ? errorMsg : "Artifact not found" );
@@ -323,6 +323,13 @@ public class ShowArtifactAction
             genericMetadata = projectMetadata.getFacet( GenericMetadataFacet.FACET_ID ).toProperties();
         }
         
+        if( propertyName == null || "".equals( propertyName.trim() ) || propertyValue == null || "".equals( propertyValue.trim() ) )
+        {
+            model = projectMetadata;            
+            addActionError( errorMsg != null ? errorMsg : "Property Name and Property Value are required." );
+            return INPUT;
+        }
+        
         genericMetadata.put( propertyName, propertyValue );
         
         GenericMetadataFacet genericMetadataFacet = new GenericMetadataFacet();
index 1da4912a894ba4b196ad537610a8bf5877d5f07b..4cf08c2cedfe6ab4c053fba279c7c937d9d98dff 100644 (file)
     </action>
 
     <action name="addMetadataProperty" class="showArtifactAction" method="addMetadataProperty">      
-      <result>/WEB-INF/jsp/showArtifact.jsp</result>
+      <result name="input">/WEB-INF/jsp/showArtifact.jsp</result>
+      <result name="success">/WEB-INF/jsp/showArtifact.jsp</result>
     </action>
 
     <action name="deleteMetadataEntry" class="showArtifactAction" method="deleteMetadataEntry">
index 65f3be1f7f63724bcd96adecb13b4c3a23b45336..da2937721b3d659f58a8fc1e97f39fa6ee0069f4 100644 (file)
@@ -23,7 +23,7 @@
 <%@ taglib prefix="archiva"   uri="/WEB-INF/taglib.tld" %>
 
 <div> 
-
   <div>
     <s:form action="addMetadataProperty" namespace="/" method="post" validate="true" theme="simple">    
       <s:hidden name="groupId" value="%{groupId}" />
     </c:if>  
   </div>
   
+  
+  <p>
+    <s:if test="hasActionMessages()">
+      <div id="messages">
+        <s:actionmessage/>
+      </div>
+    </s:if>
+    <s:if test="hasActionErrors()">
+      <div id="messages">
+        <s:actionerror/>
+      </div>
+    </s:if>
+  </p>
+  
   <%-- <archiva:project-metadata object="${projectMetadata}" groupId="${groupId}" artifactId="${artifactId}" version="${version}" /> --%>
 </div>