import org.apache.archiva.metadata.model.ProjectVersionMetadata;
import org.apache.archiva.rest.api.model.Artifact;
import org.apache.archiva.rest.api.model.BrowseResult;
+import org.apache.archiva.rest.api.model.Entry;
import org.apache.archiva.rest.api.model.TreeEntry;
import org.apache.archiva.rest.api.model.VersionsList;
import org.codehaus.plexus.redback.authorization.RedbackAuthorization;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import java.util.List;
-import java.util.Map;
/**
* @author Olivier Lamy
@GET
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
@RedbackAuthorization( noPermission = true, noRestriction = true )
- Map<String, String> getMetadatas( @PathParam( "g" ) String groupId, @PathParam( "a" ) String artifactId,
- @PathParam( "v" ) String version,
- @QueryParam( "repositoryId" ) String repositoryId )
+ List<Entry> getMetadatas( @PathParam( "g" ) String groupId, @PathParam( "a" ) String artifactId,
+ @PathParam( "v" ) String version, @QueryParam( "repositoryId" ) String repositoryId )
throws ArchivaRestServiceException;
@Path( "metadata/{g}/{a}/{v}/{key}/{value}" )
import org.apache.archiva.rest.api.model.Artifact;
import org.apache.archiva.rest.api.model.BrowseResult;
import org.apache.archiva.rest.api.model.BrowseResultEntry;
+import org.apache.archiva.rest.api.model.Entry;
import org.apache.archiva.rest.api.model.TreeEntry;
import org.apache.archiva.rest.api.model.VersionsList;
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
return artifacts;
}
- public Map<String, String> getMetadatas( String groupId, String artifactId, String version, String repositoryId )
+ public List<Entry> getMetadatas( String groupId, String artifactId, String version, String repositoryId )
throws ArchivaRestServiceException
{
ProjectVersionMetadata projectVersionMetadata =
getProjectMetadata( groupId, artifactId, version, repositoryId );
if ( projectVersionMetadata == null )
{
- return Collections.emptyMap();
+ return Collections.emptyList();
}
MetadataFacet metadataFacet = projectVersionMetadata.getFacet( GenericMetadataFacet.FACET_ID );
if ( metadataFacet == null )
{
- return Collections.emptyMap();
+ return Collections.emptyList();
}
+ Map<String, String> map = metadataFacet.toProperties();
+ List<Entry> entries = new ArrayList<Entry>( map.size() );
- return metadataFacet.toProperties();
+ for ( Map.Entry<String, String> entry : map.entrySet() )
+ {
+ entries.add( new Entry( entry.getKey(), entry.getValue() ) );
+ }
+
+ return entries;
}
public Boolean addMetadata( String groupId, String artifactId, String version, String key, String value,
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
import org.apache.archiva.rest.api.model.BrowseResult;
import org.apache.archiva.rest.api.model.BrowseResultEntry;
+import org.apache.archiva.rest.api.model.Entry;
import org.apache.archiva.rest.api.model.VersionsList;
import org.apache.archiva.rest.api.services.BrowseService;
import org.fest.assertions.MapAssert;
import org.junit.Test;
+import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import static org.fest.assertions.Assertions.assertThat;
public class BrowseServiceTest
extends AbstractArchivaRestTest
{
+
+ Map<String, String> toMap( List<Entry> entries )
+ {
+ Map<String, String> map = new HashMap<String, String>( entries.size() );
+
+ for ( Entry entry : entries )
+ {
+ map.put( entry.getKey(), entry.getValue() );
+ }
+
+ return map;
+ }
+
@Test
public void metadatagetthenadd()
throws Exception
BrowseService browseService = getBrowseService( authorizationHeader, false );
- Map<String, String> metadatas = browseService.getMetadatas( "commons-cli", "commons-cli", "1.0", testRepoId );
+ Map<String, String> metadatas =
+ toMap( browseService.getMetadatas( "commons-cli", "commons-cli", "1.0", testRepoId ) );
assertThat( metadatas ).isNotNull().isEmpty();
browseService.addMetadata( "commons-cli", "commons-cli", "1.0", "wine", "bordeaux", testRepoId );
- metadatas = browseService.getMetadatas( "commons-cli", "commons-cli", "1.0", testRepoId );
+ metadatas = toMap( browseService.getMetadatas( "commons-cli", "commons-cli", "1.0", testRepoId ) );
assertThat( metadatas ).isNotNull().isNotEmpty().includes( MapAssert.entry( "wine", "bordeaux" ) );
BrowseService browseService = getBrowseService( authorizationHeader, false );
- Map<String, String> metadatas = browseService.getMetadatas( "commons-cli", "commons-cli", "1.0", testRepoId );
+ Map<String, String> metadatas =
+ toMap( browseService.getMetadatas( "commons-cli", "commons-cli", "1.0", testRepoId ) );
assertThat( metadatas ).isNotNull().isEmpty();
browseService.addMetadata( "commons-cli", "commons-cli", "1.0", "wine", "bordeaux", testRepoId );
- metadatas = browseService.getMetadatas( "commons-cli", "commons-cli", "1.0", testRepoId );
+ metadatas = toMap( browseService.getMetadatas( "commons-cli", "commons-cli", "1.0", testRepoId ) );
assertThat( metadatas ).isNotNull().isNotEmpty().includes( MapAssert.entry( "wine", "bordeaux" ) );
browseService.deleteMetadata( "commons-cli", "commons-cli", "1.0", "wine", testRepoId );
- metadatas = browseService.getMetadatas( "commons-cli", "commons-cli", "1.0", testRepoId );
+ metadatas = toMap( browseService.getMetadatas( "commons-cli", "commons-cli", "1.0", testRepoId ) );
assertThat( metadatas ).isNotNull().isEmpty();