<packaging>war</packaging>
<name>Archiva Web :: Application</name>
<dependencies>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>generic-metadata-support</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>npanday-support</artifactId>
*/
import com.opensymphony.xwork2.Validateable;
+
+import org.apache.archiva.metadata.generic.GenericMetadataFacet;
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.model.Dependency;
import org.apache.archiva.metadata.model.License;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
+import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.TreeMap;
/**
* Browse the repository.
private String deleteItem;
private String itemValue;
+
+ private Map<String, String> genericMetadata;
+
+ private String propertyName;
+
+ private String propertyValue;
+
/**
* Show the versioned project information tab.
* TODO: Change name to 'project' - we are showing project versions here, not specific artifact information (though
{
ProjectVersionMetadata versionMetadata = null;
artifacts = new LinkedHashMap<String, List<ArtifactDownloadInfo>>();
-
+
List<String> repos = getObservableRepos();
for ( String repoId : repos )
public String projectMetadata()
{
- projectMetadata = getProjectVersionMetadata();
- String errorMsg = null;
+ String result = artifact();
+
+ if( model.getFacet( GenericMetadataFacet.FACET_ID ) != null )
+ {
+ genericMetadata = model.getFacet( GenericMetadataFacet.FACET_ID ).toProperties();
+ }
+
+ if( genericMetadata == null )
+ {
+ genericMetadata = new HashMap<String, String>();
+ }
- if ( projectMetadata == null )
+ return result;
+ }
+
+ public String addMetadataProperty()
+ {
+ ProjectVersionMetadata projectMetadata = getProjectVersionMetadata();
+ String errorMsg = null;
+
+ if( projectMetadata == null )
{
addActionError( errorMsg != null ? errorMsg : "Artifact not found" );
return ERROR;
}
-
- if ( projectMetadata.isIncomplete() )
+
+ if( projectMetadata.getFacet( GenericMetadataFacet.FACET_ID ) == null )
{
- addIncompleteModelWarning();
+ genericMetadata = new HashMap<String, String>();
}
-
+ else
+ {
+ genericMetadata = projectMetadata.getFacet( GenericMetadataFacet.FACET_ID ).toProperties();
+ }
+
+ genericMetadata.put( propertyName, propertyValue );
+
+ GenericMetadataFacet genericMetadataFacet = new GenericMetadataFacet();
+ genericMetadataFacet.fromProperties( genericMetadata );
+
+ // add updated facet
+ projectMetadata.addFacet( genericMetadataFacet );
+
+ metadataRepository.updateProjectVersion( repositoryId, groupId, artifactId, projectMetadata );
+
+ projectMetadata = getProjectVersionMetadata();
+
+ genericMetadata = projectMetadata.getFacet( GenericMetadataFacet.FACET_ID ).toProperties();
+
+ model = projectMetadata;
+
+ propertyName = "";
+ propertyValue = "";
+
return SUCCESS;
}
{
this.itemValue = itemValue;
}
+
+ public Map<String, String> getGenericMetadata()
+ {
+ return genericMetadata;
+ }
+
+ public void setGenericMetadata( Map<String, String> genericMetadata )
+ {
+ this.genericMetadata = genericMetadata;
+ }
+
+ public String getPropertyName()
+ {
+ return propertyName;
+ }
+
+ public void setPropertyName( String propertyName )
+ {
+ this.propertyName = propertyName;
+ }
+
+ public String getPropertyValue()
+ {
+ return propertyValue;
+ }
+
+ public void setPropertyValue( String propertyValue )
+ {
+ this.propertyValue = propertyValue;
+ }
// TODO: move this into the artifact metadata itself via facets where necessary
{
return path;
}
-
-
}
}
<result>/WEB-INF/jsp/showArtifact.jsp</result>
</action>
+ <action name="addMetadataProperty" class="showArtifactAction" method="addMetadataProperty">
+ <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>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="archiva" uri="/WEB-INF/taglib.tld" %>
-<p>
- <archiva:groupIdLink var="${groupId}" includeTop="true" />
+<div>
- <c:set var="url">
- <s:url action="browseArtifact" namespace="/">
- <s:param name="groupId" value="%{#attr.groupId}"/>
- <s:param name="artifactId" value="%{#attr.artifactId}"/>
- </s:url>
- </c:set>
- <a href="${url}">${artifactId}</a> /
- <strong>${version}</strong>
-</p>
-
-<div>
- <archiva:project-metadata object="${projectMetadata}" groupId="${groupId}" artifactId="${artifactId}" version="${version}" />
+ <div>
+ <s:form action="addMetadataProperty" namespace="/" method="post" validate="true" theme="simple">
+ <s:hidden name="groupId" value="%{groupId}" />
+ <s:hidden name="artifactId" value="%{artifactId}" />
+ <s:hidden name="version" value="%{version}" />
+ <s:hidden name="repositoryId" value="%{repositoryId}" />
+ <table>
+ <tr>
+ <td align="center"><strong>Property Name</strong></td>
+ <td align="center"><strong>Property Value</strong></td>
+ <td/>
+ </tr>
+ <tr>
+ <td>
+ <s:textfield name="propertyName" size="30" required="true"/>
+ </td>
+ <td>
+ <s:textfield name="propertyValue" size="30" required="true"/>
+ </td>
+ <td align="right">
+ <s:submit value="Add"/>
+ </td>
+ </tr>
+ </table>
+ </s:form>
+ </div>
+
+ <div>
+ <c:if test="${empty genericMetadata}">
+ <p>
+ <strong>No metadata content.</strong>
+ </p>
+ </c:if>
+
+ <c:if test="${!empty genericMetadata}">
+ <ul>
+ <c:forEach var="prop" items="${genericMetadata}">
+ <li>${prop.key}=${prop.value}</li>
+ </c:forEach>
+ </ul>
+ </c:if>
+ </div>
+
+ <%-- <archiva:project-metadata object="${projectMetadata}" groupId="${groupId}" artifactId="${artifactId}" version="${version}" /> --%>
</div>
<%-- TODO: panels? this is ugly as is --%>
<div id="tabArea">
<c:choose>
- <c:when test="${projectMetadata != null}">
+ <c:when test="${genericMetadata != null}">
<%@ include file="/WEB-INF/jsp/include/projectMetadata.jspf" %>
</c:when>
<c:when test="${dependencies != null}">
</s:if>
</div>
</div>
-
</body>
</html>
* under the License.
*/
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import org.apache.archiva.metadata.generic.GenericMetadataFacet;
import org.apache.archiva.metadata.model.CiManagement;
import org.apache.archiva.metadata.model.IssueManagement;
import org.apache.archiva.metadata.model.License;
protected static final String TEST_SCM_DEV_CONNECTION = "scmDevConnection";
protected static final String TEST_SCM_URL = "scmUrl";
-
+
+ protected static final String TEST_GENERIC_METADATA_PROPERTY_NAME = "rating";
+
+ protected static final String TEST_GENERIC_METADATA_PROPERTY_VALUE = "5 stars";
+
protected void setObservableRepos( List<String> repoIds )
{
UserRepositoriesStub repos = (UserRepositoriesStub) lookup( UserRepositories.class );
parent.setVersion( TEST_PARENT_VERSION );
mavenProjectFacet.setParent( parent );
model.addFacet( mavenProjectFacet );
+
+ GenericMetadataFacet genericMetadataFacet = new GenericMetadataFacet();
+ Map<String, String> props = new HashMap<String,String>();
+ props.put( TEST_GENERIC_METADATA_PROPERTY_NAME, TEST_GENERIC_METADATA_PROPERTY_VALUE );
+ genericMetadataFacet.setAdditionalProperties( props );
+ model.addFacet( genericMetadataFacet );
+
return model;
}
}
*/
import com.opensymphony.xwork2.Action;
+
+import org.apache.archiva.metadata.generic.GenericMetadataFacet;
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.model.Dependency;
import org.apache.archiva.metadata.model.MailingList;
public void testGetProjectMetadata()
{
ProjectVersionMetadata versionMetadata = createProjectModel( TEST_VERSION );
- Dependency dependency1 = createDependencyBasic( "artifactId1" );
- Dependency dependency2 = createDependencyExtended( "artifactId2" );
- versionMetadata.setDependencies( Arrays.asList( dependency1, dependency2 ) );
-
- MailingList ml1 = createMailingList( "Users List", "users" );
- MailingList ml2 = createMailingList( "Developers List", "dev" );
- versionMetadata.setMailingLists( Arrays.asList( ml1, ml2 ) );
-
+
metadataResolver.setProjectVersion( TEST_REPO, TEST_GROUP_ID, TEST_ARTIFACT_ID, versionMetadata );
setActionParameters();
assertActionSuccess( action, result );
assertActionParameters( action );
- ProjectVersionMetadata projectMetadata = action.getProjectMetadata();
- assertDefaultModel( projectMetadata );
-
- assertNotNull( projectMetadata.getDependencies() );
- assertDependencyBasic( projectMetadata.getDependencies().get( 0 ), "artifactId1" );
- assertDependencyExtended( projectMetadata.getDependencies().get( 1 ), "artifactId2" );
-
+
+ Map<String, String> genericMetadata = action.getGenericMetadata();
+ assertNotNull( genericMetadata.get( TEST_GENERIC_METADATA_PROPERTY_NAME ) );
+ assertEquals( genericMetadata.get( TEST_GENERIC_METADATA_PROPERTY_NAME ), TEST_GENERIC_METADATA_PROPERTY_VALUE );
+
assertEquals( TEST_REPO, action.getRepositoryId() );
- assertNull( action.getModel() );
+ assertNotNull( action.getModel() );
assertNull( action.getDependees() );
assertNull( action.getDependencies() );
assertNull( action.getMailingLists() );
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>plugins</artifactId>
+ <groupId>org.apache.archiva</groupId>
+ <version>1.4-SNAPSHOT</version>
+ </parent>
+ <artifactId>generic-metadata-support</artifactId>
+ <name>Generic Metadata Support</name>
+ <url>http://maven.apache.org</url>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>metadata-model</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+package org.apache.archiva.metadata.generic;
+
+/*
+ * 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 java.util.HashMap;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.apache.archiva.metadata.model.MetadataFacet;
+
+public class GenericMetadataFacet
+ implements MetadataFacet
+{
+ private Map<String, String> additionalProperties;
+
+ public static final String FACET_ID = "org.apache.archiva.metadata.generic";
+
+ public String getFacetId()
+ {
+ return FACET_ID;
+ }
+
+ public String getName()
+ {
+ return "";
+ }
+
+ public void fromProperties( Map<String, String> properties )
+ {
+ if( additionalProperties == null )
+ {
+ additionalProperties = new TreeMap<String, String>();
+ }
+
+ for( String key : properties.keySet() )
+ {
+ additionalProperties.put( key, properties.get( key ) );
+ }
+ }
+
+ public Map<String, String> toProperties()
+ {
+ Map<String, String> properties = new TreeMap<String, String>();
+
+ if( additionalProperties != null )
+ {
+ for( String key : additionalProperties.keySet() )
+ {
+ properties.put( key, additionalProperties.get( key ) );
+ }
+ }
+
+ return properties;
+ }
+
+ public Map<String, String> getAdditionalProperties()
+ {
+ return additionalProperties;
+ }
+
+ public void setAdditionalProperties( Map<String, String> additionalProperties )
+ {
+ this.additionalProperties = additionalProperties;
+ }
+
+}
--- /dev/null
+package org.apache.archiva.metadata.generic;
+
+/*
+ * 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.MetadataFacet;
+import org.apache.archiva.metadata.model.MetadataFacetFactory;
+
+/**
+ * @plexus.component role="org.apache.archiva.metadata.model.MetadataFacetFactory" role-hint="org.apache.archiva.metadata.generic"
+ */
+public class GenericMetadataFacetFactory
+ implements MetadataFacetFactory
+{
+
+ public MetadataFacet createMetadataFacet()
+ {
+ return new GenericMetadataFacet();
+ }
+
+ public MetadataFacet createMetadataFacet( String repositoryId, String name )
+ {
+ throw new UnsupportedOperationException( "There is no valid name for project version facets" );
+ }
+
+}
private String join( Collection<String> ids )
{
- if ( !ids.isEmpty() )
+ if ( ids != null && !ids.isEmpty() )
{
StringBuilder s = new StringBuilder();
for ( String id : ids )
<!-- TODO: eventually not a core plugin, needs to be moved to a separate tree, with it's own Selenium tests -->
<module>npanday-support</module>
<module>maven1-repository</module>
+ <module>generic-metadata-support</module>
</modules>
</project>
\ No newline at end of file
<artifactId>maven2-repository</artifactId>
<version>1.4-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>generic-metadata-support</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-applet</artifactId>