To know all the possible options, you can refer to the javadoc of SearchRequest class.
+* Browse Service
+
+ Get a Browse Service Client :
+
+%{snippet|id=cxf-browseservice-creation|ignoreDownloadError=true|url=https://raw.githubusercontent.com/apache/archiva/master/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java}
+
+ Get artifacts based on project version metadata, generic metadata added previously in Archiva :
+
+%{snippet|id=get-artifacts-by-project-version-metadata|ignoreDownloadError=true|url=https://raw.githubusercontent.com/apache/archiva/master/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/BrowseServiceTest.java}
+
+ Get artifacts based on the artifact properties :
+
+%{snippet|id=get-artifacts-by-metadata|ignoreDownloadError=true|url=https://raw.githubusercontent.com/apache/archiva/master/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/BrowseServiceTest.java}
+
+
+ Get artifacts based on the project properties from POM :
+
+%{snippet|id=get-artifacts-by-property|ignoreDownloadError=true|url=https://raw.githubusercontent.com/apache/archiva/master/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/BrowseServiceTest.java}
+
+
+ Searching by properties and metadata :
+
+%{snippet|id=search-artifacts-by-field|ignoreDownloadError=true|url=https://raw.githubusercontent.com/apache/archiva/master/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/BrowseServiceTest.java}
+
+%{snippet|id=search-artifacts|ignoreDownloadError=true|url=https://raw.githubusercontent.com/apache/archiva/master/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/BrowseServiceTest.java}
+
+
+
+ Get Search
+
+%{snippet|id=quick-search|ignoreDownloadError=true|url=https://raw.githubusercontent.com/apache/archiva/master/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/SearchServiceTest.java}
+
+
Dependencies to add in order to use those REST Services
%{snippet|id=rest-dependencies|ignoreDownloadError=true|url=https://raw.githubusercontent.com/apache/archiva/master/pom.xml}
@RedbackAuthorization(noPermission = true, noRestriction = true)
List<Artifact> getArtifacts( @PathParam("r") String repositoryId )
throws ArchivaRestServiceException;
+
+ /**
+ * Return List of artifacts from this repository with project version level metadata key matching value. If
+ * repository is not provided the search runs in all repositories.
+ *
+ * @param key
+ * @param value
+ * @param repositoryId
+ * @return
+ * @throws ArchivaRestServiceException
+ * @since 2.2
+ */
+ @Path( "artifactsByProjectVersionMetadata/{key}/{value}" )
+ @GET
+ @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+ @RedbackAuthorization( noPermission = true, noRestriction = true )
+ List<Artifact> getArtifactsByProjectVersionMetadata( @PathParam( "key" ) String key, @PathParam( "value" ) String value,
+ @QueryParam("repositoryId") String repositoryId )
+ throws ArchivaRestServiceException;
+
+ /**
+ * Return List of artifacts from this repository with artifact metadata key matching value.
+ * If repository is not provided the search runs in all repositories.
+ *
+ * @param key
+ * @param value
+ * @param repositoryId
+ * @return
+ * @throws ArchivaRestServiceException
+ * @since 2.2
+ */
+ @Path( "artifactsByMetadata/{key}/{value}" )
+ @GET
+ @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+ @RedbackAuthorization( noPermission = true, noRestriction = true )
+ List<Artifact> getArtifactsByMetadata( @PathParam( "key" ) String key, @PathParam( "value" ) String value,
+ @QueryParam("repositoryId") String repositoryId )
+ throws ArchivaRestServiceException;
+
+ /**
+ * Return List of artifacts from this repository with property key matching value.
+ * If repository is not provided the search runs in all repositories.
+ *
+ * @param key
+ * @param value
+ * @param repositoryId
+ * @return
+ * @throws ArchivaRestServiceException
+ * @since 2.2
+ */
+ @Path( "artifactsByProperty/{key}/{value}" )
+ @GET
+ @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+ @RedbackAuthorization( noPermission = true, noRestriction = true )
+ List<Artifact> getArtifactsByProperty( @PathParam( "key" ) String key, @PathParam( "value" ) String value,
+ @QueryParam("repositoryId") String repositoryId )
+ throws ArchivaRestServiceException;
+
+ /**
+ * Search artifacts with any property matching text. If repository is not provided the search runs in all
+ * repositories. If exact is true only the artifacts whose property match exactly are returned.
+ *
+ * @param text
+ * @param repositoryId
+ * @param exact
+ * @return
+ * @throws ArchivaRestServiceException
+ * @since 2.2
+ */
+ @Path( "searchArtifacts/{text}" )
+ @GET
+ @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+ @RedbackAuthorization( noPermission = true, noRestriction = true )
+ List<Artifact> searchArtifacts( @PathParam( "text" ) String text,
+ @QueryParam( "repositoryId" ) String repositoryId,
+ @QueryParam( "exact" ) Boolean exact )
+ throws ArchivaRestServiceException;
+
+ /**
+ * Search artifacts with the property specified by key matching text. If repository is not provided the search runs
+ * in all repositories. If exact is true only the artifacts whose property match exactly are returned.
+ *
+ * @param key
+ * @param text
+ * @param repositoryId
+ * @param exact
+ * @return
+ * @throws ArchivaRestServiceException
+ * @since 2.2
+ */
+ @Path( "searchArtifacts/{key}/{text}" )
+ @GET
+ @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+ @RedbackAuthorization( noPermission = true, noRestriction = true )
+ List<Artifact> searchArtifacts( @PathParam( "key" ) String key, @PathParam( "text" ) String text,
+ @QueryParam( "repositoryId" ) String repositoryId,
+ @QueryParam( "exact" ) Boolean exact )
+ throws ArchivaRestServiceException;
}
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
for ( ArtifactMetadata artifact : artifactMetadatas )
{
+ String repoId = repositoryId != null ? repositoryId : artifact.getRepositoryId();
+ if ( repoId == null ) {
+ throw new IllegalStateException( "Repository Id is null" );
+ }
+
ArtifactBuilder builder =
new ArtifactBuilder().forArtifactMetadata( artifact ).withManagedRepositoryContent(
- repositoryContentFactory.getManagedRepositoryContent( repositoryId ) );
+ repositoryContentFactory.getManagedRepositoryContent( repoId ) );
Artifact art = builder.build();
art.setUrl( getArtifactUrl( art, repositoryId ) );
artifacts.add( art );
}
}
+ @Override
+ public List<Artifact> getArtifactsByProjectVersionMetadata( String key, String value, String repositoryId )
+ throws ArchivaRestServiceException
+ {
+ RepositorySession repositorySession = repositorySessionFactory.createSession();
+ try
+ {
+ List<ArtifactMetadata> artifactMetadatas = repositorySession.getRepository().getArtifactsByProjectVersionMetadata( key, value, repositoryId );
+ return buildArtifacts( artifactMetadatas, repositoryId );
+ }
+ catch ( MetadataRepositoryException e )
+ {
+ throw new ArchivaRestServiceException( e.getMessage(), e );
+ }
+ finally
+ {
+ repositorySession.close();
+ }
+ }
+
+ @Override
+ public List<Artifact> getArtifactsByMetadata( String key, String value, String repositoryId )
+ throws ArchivaRestServiceException
+ {
+ RepositorySession repositorySession = repositorySessionFactory.createSession();
+ try
+ {
+ List<ArtifactMetadata> artifactMetadatas = repositorySession.getRepository().getArtifactsByMetadata( key, value, repositoryId );
+ return buildArtifacts( artifactMetadatas, repositoryId );
+ }
+ catch ( MetadataRepositoryException e )
+ {
+ throw new ArchivaRestServiceException( e.getMessage(), e );
+ }
+ finally
+ {
+ repositorySession.close();
+ }
+ }
+
+ @Override
+ public List<Artifact> getArtifactsByProperty( String key, String value, String repositoryId )
+ throws ArchivaRestServiceException
+ {
+ RepositorySession repositorySession = repositorySessionFactory.createSession();
+ try
+ {
+ List<ArtifactMetadata> artifactMetadatas = repositorySession.getRepository().getArtifactsByProperty( key, value, repositoryId );
+ return buildArtifacts( artifactMetadatas, repositoryId );
+ }
+ catch ( MetadataRepositoryException e )
+ {
+ throw new ArchivaRestServiceException( e.getMessage(), e );
+ }
+ finally
+ {
+ repositorySession.close();
+ }
+ }
+
@Override
public Boolean importMetadata( MetadataAddRequest metadataAddRequest, String repositoryId )
throws ArchivaRestServiceException
return result;
}
+ @Override
+ public List<Artifact> searchArtifacts( String text, String repositoryId, Boolean exact )
+ throws ArchivaRestServiceException
+ {
+ RepositorySession repositorySession = repositorySessionFactory.createSession();
+ try
+ {
+ List<ArtifactMetadata> artifactMetadatas =
+ repositorySession.getRepository().searchArtifacts( text, repositoryId, exact == null ? false : exact );
+ return buildArtifacts( artifactMetadatas, repositoryId );
+ }
+ catch ( MetadataRepositoryException e )
+ {
+ throw new ArchivaRestServiceException( e.getMessage(), e );
+ }
+ finally
+ {
+ repositorySession.close();
+ }
+ }
+
+ @Override
+ public List<Artifact> searchArtifacts( String key, String text, String repositoryId, Boolean exact )
+ throws ArchivaRestServiceException
+ {
+ RepositorySession repositorySession = repositorySessionFactory.createSession();
+ try
+ {
+ List<ArtifactMetadata> artifactMetadatas =
+ repositorySession.getRepository().searchArtifacts( key, text, repositoryId, exact == null ? false : exact );
+ return buildArtifacts( artifactMetadatas, repositoryId );
+ }
+ catch ( MetadataRepositoryException e )
+ {
+ throw new ArchivaRestServiceException( e.getMessage(), e );
+ }
+ finally
+ {
+ repositorySession.close();
+ }
+ }
+
//---------------------------
// internals
//---------------------------
protected BrowseService getBrowseService( String authzHeader, boolean useXml )
{
+ // START SNIPPET: cxf-browseservice-creation
BrowseService service =
JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/",
BrowseService.class,
WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE );
}
return service;
+ // END SNIPPET: cxf-browseservice-creation
}
}
+ @Test
+ public void getArtifactsByMetadata()
+ throws Exception
+ {
+ // START SNIPPET: get-artifacts-by-metadata
+ BrowseService browseService = getBrowseService( authorizationHeader, true );
+
+ List<Artifact> artifactDownloadInfos = browseService.getArtifactsByMetadata( "type", "pom", TEST_REPO_ID );
+
+ assertThat( artifactDownloadInfos ).isNotNull().isNotEmpty().hasSize( 11 );
+ // END SNIPPET: get-artifacts-by-metadata
+ }
+
+
+ @Test
+ public void getArtifactsByProjectVersionMetadata()
+ throws Exception
+ {
+ // START SNIPPET: get-artifacts-by-project-version-metadata
+ BrowseService browseService = getBrowseService( authorizationHeader, true );
+
+ browseService.addMetadata( "commons-cli", "commons-cli", "1.0", "wine", "bordeaux", TEST_REPO_ID );
+
+ List<Artifact> artifactDownloadInfos = browseService.getArtifactsByProjectVersionMetadata( "wine", "bordeaux", TEST_REPO_ID );
+
+ assertThat( artifactDownloadInfos ).isNotNull().isNotEmpty().hasSize( 3 );
+ // END SNIPPET: get-artifacts-by-project-version-metadata
+ }
+
+
+ @Test
+ public void getArtifactsByProjectVersionMetadataWithNoRepository()
+ throws Exception
+ {
+ BrowseService browseService = getBrowseService( authorizationHeader, true );
+
+ browseService.addMetadata( "commons-cli", "commons-cli", "1.0", "wine", "bordeaux", TEST_REPO_ID );
+
+ List<Artifact> artifactDownloadInfos = browseService.getArtifactsByProjectVersionMetadata( "wine", "bordeaux", null );
+
+ assertThat( artifactDownloadInfos ).isNotNull().isNotEmpty().hasSize( 3 );
+ }
+
+
+ @Test
+ public void getArtifactsByProperty()
+ throws Exception
+ {
+ // START SNIPPET: get-artifacts-by-property
+ BrowseService browseService = getBrowseService( authorizationHeader, true );
+
+ List<Artifact> artifactDownloadInfos = browseService.getArtifactsByProperty( "org.name", "The Apache Software Foundation", TEST_REPO_ID );
+
+ assertThat( artifactDownloadInfos ).isNotNull().isNotEmpty().hasSize( 7 );
+ // END SNIPPET: get-artifacts-by-property
+ }
+
+
+ @Test
+ public void searchArtifacts()
+ throws Exception
+ {
+ // START SNIPPET: search-artifacts
+ BrowseService browseService = getBrowseService( authorizationHeader, true );
+
+ List<Artifact> artifactDownloadInfos = browseService.searchArtifacts( "The Apache Software Foundation", TEST_REPO_ID, true );
+
+ assertThat( artifactDownloadInfos ).isNotNull().isNotEmpty().hasSize( 7 );
+ // END SNIPPET: search-artifacts
+ }
+
+
+ @Test
+ public void searchArtifactsByField()
+ throws Exception
+ {
+ // START SNIPPET: search-artifacts-by-field
+ BrowseService browseService = getBrowseService( authorizationHeader, true );
+
+ List<Artifact> artifactDownloadInfos = browseService.searchArtifacts( "org.name", "The Apache Software Foundation", TEST_REPO_ID, true );
+
+ assertThat( artifactDownloadInfos ).isNotNull().isNotEmpty().hasSize( 7 );
+ // END SNIPPET: search-artifacts-by-field
+ }
+
+
@Test
public void readArtifactContentText()
throws Exception
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>generic-metadata-support</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
throw new UnsupportedOperationException();
}
+ @Override
+ public List<ArtifactMetadata> getArtifactsByProjectVersionMetadata( String key , String value , String repositoryId )
+ throws MetadataRepositoryException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public List<ArtifactMetadata> getArtifactsByMetadata( String key , String value , String repositoryId )
+ throws MetadataRepositoryException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public List<ArtifactMetadata> getArtifactsByProperty( String key, String value, String repositoryId )
+ throws MetadataRepositoryException
+ {
+ throw new UnsupportedOperationException();
+ }
+
@Override
public void removeArtifact( String repositoryId, String namespace, String project, String version, String id )
throws MetadataRepositoryException
throw new UnsupportedOperationException();
}
+ @Override
+ public List<ArtifactMetadata> searchArtifacts( String text, String repositoryId, boolean exact )
+ throws MetadataRepositoryException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public List<ArtifactMetadata> searchArtifacts( String key, String text, String repositoryId, boolean exact )
+ throws MetadataRepositoryException
+ {
+ throw new UnsupportedOperationException();
+ }
+
}
Collection<ArtifactMetadata> getArtifactsByChecksum( String repositoryId, String checksum )
throws MetadataRepositoryException;
+ /**
+ * Get artifacts with a project version metadata key that matches the passed value.
+ *
+ * @param key
+ * @param value
+ * @param repositoryId can be null, meaning search in all repositories
+ * @return a list of artifacts
+ * @throws MetadataRepositoryException
+ */
+ List<ArtifactMetadata> getArtifactsByProjectVersionMetadata( String key, String value, String repositoryId )
+ throws MetadataRepositoryException;
+
+ /**
+ * Get artifacts with an artifact metadata key that matches the passed value.
+ *
+ * @param key
+ * @param value
+ * @param repositoryId can be null, meaning search in all repositories
+ * @return a list of artifacts
+ * @throws MetadataRepositoryException
+ */
+ List<ArtifactMetadata> getArtifactsByMetadata( String key, String value, String repositoryId )
+ throws MetadataRepositoryException;
+
+ /**
+ * Get artifacts with a property key that matches the passed value.
+ * Possible keys are 'scm.url', 'org.name', 'url', 'mailingList.0.name', 'license.0.name',...
+ *
+ * @param key
+ * @param value
+ * @param repositoryId can be null, meaning search in all repositories
+ * @return a list of artifacts
+ * @throws MetadataRepositoryException
+ */
+ List<ArtifactMetadata> getArtifactsByProperty( String key, String value, String repositoryId )
+ throws MetadataRepositoryException;
+
void removeArtifact( String repositoryId, String namespace, String project, String version, String id )
throws MetadataRepositoryException;
<T> T obtainAccess( Class<T> aClass )
throws MetadataRepositoryException;
+
+ /**
+ * Full text artifacts search.
+ *
+ * @param text
+ * @param repositoryId can be null to search in all repositories
+ * @param exact running an exact search, the value must exactly match the text.
+ * @return a list of artifacts
+ * @throws MetadataRepositoryException
+ */
+ List<ArtifactMetadata> searchArtifacts( String text, String repositoryId, boolean exact )
+ throws MetadataRepositoryException;
+
+ /**
+ * Full text artifacts search inside the specified key.
+ *
+ * @param key search only inside this key
+ * @param text
+ * @param repositoryId can be null to search in all repositories
+ * @param exact running an exact search, the value must exactly match the text.
+ * @return a list of artifacts
+ * @throws MetadataRepositoryException
+ */
+ List<ArtifactMetadata> searchArtifacts( String key, String text, String repositoryId, boolean exact )
+ throws MetadataRepositoryException;
+
}
* under the License.
*/
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+
import junit.framework.TestCase;
+
+import org.apache.archiva.metadata.generic.GenericMetadataFacet;
+import org.apache.archiva.metadata.generic.GenericMetadataFacetFactory;
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.model.CiManagement;
import org.apache.archiva.metadata.model.Dependency;
import org.slf4j.LoggerFactory;
import org.springframework.test.context.ContextConfiguration;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.TimeZone;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
@RunWith( ArchivaSpringJUnit4ClassRunner.class )
@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
public abstract class AbstractMetadataRepositoryTest
private static final String TEST_PROJECT_VERSION_2_0 = "2.0";
+ private static final String TEST_URL = "http://archiva.apache.org";
+
+ private static final Organization TEST_ORGANIZATION = new Organization( "Apache", "http://apache.org" );
+
private static final String TEST_FACET_ID = "test-facet-id";
private static final String TEST_NAME = "test/name";
private static final String TEST_SHA1 = "2e5daf0201ddeb068a62d5e08da18657ab2c6be9";
- private static final String TEST_METADATA_VALUE = "test-metadata";
+ private static final String TEST_METADATA_KEY = "testkey";
+
+ private static final String TEST_METADATA_VALUE = "testmetadata";
protected Logger log = LoggerFactory.getLogger( getClass() );
return new TestMetadataFacet( "", TEST_VALUE );
}
} );
+
+ // for the getArtifactsByProjectVersionMetadata tests
+ factories.put( GenericMetadataFacet.FACET_ID, new GenericMetadataFacetFactory() );
+
return factories;
}
tracker.setUrl( "issue tracker url" );
metadata.setIssueManagement( tracker );
- Organization org = new Organization();
- org.setName( "org name" );
- org.setUrl( "url" );
- metadata.setOrganization( org );
+ metadata.setOrganization( TEST_ORGANIZATION );
License l = new License();
l.setName( "license name" );
assertEquals( "system", metadata.getIssueManagement().getSystem() );
assertEquals( "issue tracker url", metadata.getIssueManagement().getUrl() );
- assertEquals( "org name", metadata.getOrganization().getName() );
- assertEquals( "url", metadata.getOrganization().getUrl() );
+ assertEquals( TEST_ORGANIZATION.getName(), metadata.getOrganization().getName() );
+ assertEquals( TEST_ORGANIZATION.getUrl(), metadata.getOrganization().getUrl() );
assertEquals( 1, metadata.getMailingLists().size() );
MailingList retrievedMailingList = metadata.getMailingLists().get( 0 );
assertThat( artifactsByChecksum ).isNotNull().isEmpty();
}
+ @Test
+ public void testGetArtifactsByProjectVersionMetadata()
+ throws Exception
+ {
+ createArtifactWithGenericMetadataFacet( 10 );
+ Collection<ArtifactMetadata> artifactsByMetadata =
+ repository.getArtifactsByProjectVersionMetadata( TEST_METADATA_KEY, TEST_METADATA_VALUE, TEST_REPO_ID );
+ assertThat( artifactsByMetadata ).hasSize( 1 );
+ ArtifactMetadata artifactMetadata = artifactsByMetadata.iterator().next();
+ assertThat( artifactMetadata.getId() ).isEqualTo( "projectId-1.0.jar" );
+ assertThat( artifactMetadata.getSha1() ).isEqualTo( TEST_SHA1 );
+ assertThat( artifactMetadata.getRepositoryId() ).isEqualTo( TEST_REPO_ID );
+ }
+
+ @Test
+ public void testGetArtifactsByProjectVersionMetadataNoRepository()
+ throws Exception
+ {
+ createArtifactWithGenericMetadataFacet();
+ Collection<ArtifactMetadata> artifactsByMetadata =
+ repository.getArtifactsByProjectVersionMetadata( TEST_METADATA_KEY, TEST_METADATA_VALUE, null );
+ assertThat( artifactsByMetadata ).hasSize( 1 );
+ assertThat( artifactsByMetadata.iterator().next().getRepositoryId() ).isNotNull().isNotEmpty();
+ }
+
+ @Test
+ public void testGetArtifactsByProjectVersionMetadataAllRepositories()
+ throws Exception
+ {
+ createArtifactWithGenericMetadataFacet();
+ Collection<ArtifactMetadata> artifactsByMetadata =
+ repository.getArtifactsByProjectVersionMetadata( TEST_METADATA_KEY, TEST_METADATA_VALUE, null );
+ assertThat( artifactsByMetadata ).hasSize( 1 );
+ }
+
+ @Test
+ public void testGetArtifactsByMetadataAllRepositories()
+ throws Exception
+ {
+ createArtifactWithMavenArtifactFacet();
+ Collection<ArtifactMetadata> artifactsByMetadata =
+ repository.getArtifactsByMetadata( "foo", TEST_METADATA_VALUE, null );
+ assertThat( artifactsByMetadata ).hasSize( 1 );
+ ArtifactMetadata artifactMetadata = artifactsByMetadata.iterator().next();
+ assertThat( artifactMetadata.getId() ).isEqualTo( "projectId-1.0.jar" );
+ assertThat( artifactMetadata.getSha1() ).isEqualTo( TEST_SHA1 );
+ assertThat( artifactMetadata.getRepositoryId() ).isEqualTo( TEST_REPO_ID );
+ MetadataFacet facet = artifactMetadata.getFacet( TEST_FACET_ID );
+ assertThat( facet ).isNotNull();
+ assertThat( facet.toProperties() ).isEqualTo( Collections.singletonMap( "foo", TEST_METADATA_VALUE ) );
+ }
+
+ @Test
+ public void testGetArtifactsByPropertySingleResult()
+ throws Exception
+ {
+ createArtifactWithData();
+ // only works on JCR implementation
+ // Collection<ArtifactMetadata> artifactsByProperty = repository.getArtifactsByProperty( "org.name", TEST_ORGANIZATION.getName(), TEST_REPO_ID );
+ Collection<ArtifactMetadata> artifactsByProperty = repository.getArtifactsByProperty( "url", TEST_URL, TEST_REPO_ID );
+ assertThat( artifactsByProperty ).hasSize( 1 );
+ ArtifactMetadata artifactMetadata = artifactsByProperty.iterator().next();
+ assertThat( artifactMetadata.getId() ).isEqualTo( "projectId-1.0.jar" );
+ assertThat( artifactMetadata.getSha1() ).isEqualTo( TEST_SHA1 );
+ assertThat( artifactMetadata.getRepositoryId() ).isEqualTo( TEST_REPO_ID );
+ }
@Test
public void testDeleteRepository()
}
+ @Test
+ public void testSearchArtifactsByKey()
+ throws Exception
+ {
+ createArtifactWithData();
+ Collection<ArtifactMetadata> artifactsByProperty = repository.searchArtifacts( "url", TEST_URL, TEST_REPO_ID, false );
+ assertThat( artifactsByProperty ).isNotNull().isNotEmpty();
+ }
+
+ @Test
+ public void testSearchArtifactsByKeyExact()
+ throws Exception
+ {
+ createArtifactWithData();
+ Collection<ArtifactMetadata> artifactsByProperty = repository.searchArtifacts( "url", TEST_URL, TEST_REPO_ID, true );
+ assertThat( artifactsByProperty ).isNotNull().isNotEmpty();
+ artifactsByProperty = repository.searchArtifacts( "org.name", "pache", TEST_REPO_ID, true );
+ assertThat( artifactsByProperty ).isNotNull().isEmpty();
+ }
+
+ @Test
+ public void testSearchArtifactsByFacetKey()
+ throws Exception
+ {
+ createArtifactWithGenericMetadataFacet();
+ Collection<ArtifactMetadata> artifactsByProperty = repository.searchArtifacts( TEST_METADATA_KEY, TEST_METADATA_VALUE, TEST_REPO_ID, false );
+ assertThat( artifactsByProperty ).isNotNull().isNotEmpty();
+ }
+
+ @Test
+ public void testSearchArtifactsByFacetKeyAllRepos()
+ throws Exception
+ {
+ createArtifactWithGenericMetadataFacet();
+ Collection<ArtifactMetadata> artifactsByProperty = repository.searchArtifacts( TEST_METADATA_KEY, TEST_METADATA_VALUE, null, false );
+ assertThat( artifactsByProperty ).isNotNull().isNotEmpty();
+ }
+
+ @Test
+ public void testSearchArtifactsFullText()
+ throws Exception
+ {
+ createArtifactWithGenericMetadataFacet();
+ // only works in JCR
+ // Collection<ArtifactMetadata> artifactsByProperty = repository.searchArtifacts( TEST_URL, TEST_REPO_ID, false );
+ Collection<ArtifactMetadata> artifactsByProperty =
+ repository.searchArtifacts( TEST_METADATA_VALUE, TEST_REPO_ID, false );
+ assertThat( artifactsByProperty ).isNotNull().isNotEmpty();
+ }
+
+ @Test
+ public void testSearchArtifactsFullTextExact()
+ throws Exception
+ {
+ createArtifactWithGenericMetadataFacet();
+ // only works in JCR
+ // Collection<ArtifactMetadata> artifactsByProperty = repository.searchArtifacts( TEST_URL, TEST_REPO_ID, true );
+ Collection<ArtifactMetadata> artifactsByProperty =
+ repository.searchArtifacts( TEST_METADATA_VALUE, TEST_REPO_ID, true );
+ assertThat( artifactsByProperty ).isNotNull().isNotEmpty();
+ artifactsByProperty = repository.searchArtifacts( TEST_METADATA_VALUE.substring( 2 ), TEST_REPO_ID, true );
+ assertThat( artifactsByProperty ).isNotNull().isEmpty();
+ }
+
+ @Test
+ public void testSearchArtifactsFullTextByFacet()
+ throws Exception
+ {
+ createArtifactWithGenericMetadataFacet();
+ Collection<ArtifactMetadata> artifactsByProperty = repository.searchArtifacts( TEST_METADATA_VALUE, TEST_REPO_ID, false );
+ assertThat( artifactsByProperty ).isNotNull().isNotEmpty();
+ }
private static ProjectMetadata createProject()
{
return project;
}
+ private void createArtifactWithGenericMetadataFacet()
+ throws MetadataRepositoryException, MetadataResolutionException
+ {
+ createArtifactWithGenericMetadataFacet( 1 );
+ }
+
+ private void createArtifactWithGenericMetadataFacet( int artifacts )
+ throws MetadataRepositoryException, MetadataResolutionException
+ {
+ MetadataFacet metadataFacet = new GenericMetadataFacet();
+ Map<String, String> properties = new HashMap<>();
+ properties.put( TEST_METADATA_KEY, TEST_METADATA_VALUE );
+ metadataFacet.fromProperties( properties );
+ createArtifactWithFacet( artifacts, null, metadataFacet );
+ }
+
+ private void createArtifactWithMavenArtifactFacet()
+ throws MetadataRepositoryException, MetadataResolutionException
+ {
+ createArtifactWithMavenArtifactFacet( 1 );
+ }
+
+ private void createArtifactWithMavenArtifactFacet( int artifacts )
+ throws MetadataRepositoryException, MetadataResolutionException
+ {
+ TestMetadataFacet facet = new TestMetadataFacet( TEST_METADATA_VALUE );
+ createArtifactWithFacet( artifacts, facet, null );
+ }
+
+ private void createArtifactWithFacet( int artifacts, MetadataFacet artifactFacet,
+ MetadataFacet projectVersionMetadataFacet )
+ throws MetadataRepositoryException, MetadataResolutionException
+ {
+ for ( int i = 0; i < artifacts; i++ )
+ {
+ ArtifactMetadata artifact = createArtifact();
+ if ( artifactFacet != null )
+ {
+ artifact.addFacet( artifactFacet );
+ }
+ repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
+ }
+ if ( projectVersionMetadataFacet != null )
+ {
+ ProjectVersionMetadata metadata =
+ repository.getProjectVersion( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
+ metadata.addFacet( projectVersionMetadataFacet );
+ metadata.setOrganization( TEST_ORGANIZATION );
+ metadata.setUrl( TEST_URL );
+ repository.updateProjectVersion( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata );
+ }
+ repository.save();
+ }
+
+ private void createArtifactWithData()
+ throws MetadataRepositoryException, MetadataResolutionException
+ {
+ ArtifactMetadata artifact = createArtifact();
+ repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
+ ProjectVersionMetadata metadata =
+ repository.getProjectVersion( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION );
+ metadata.setOrganization( TEST_ORGANIZATION );
+ metadata.setUrl( TEST_URL );
+
+ repository.updateProjectVersion( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, metadata );
+ repository.save();
+ }
+
private static ArtifactMetadata createArtifact()
{
return createArtifact( "jar" );
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>generic-metadata-support</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
+
import me.prettyprint.cassandra.serializers.LongSerializer;
import me.prettyprint.cassandra.serializers.StringSerializer;
import me.prettyprint.cassandra.service.template.ColumnFamilyResult;
import me.prettyprint.hector.api.mutation.Mutator;
import me.prettyprint.hector.api.query.QueryResult;
import me.prettyprint.hector.api.query.RangeSlicesQuery;
+
import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.metadata.model.ArtifactMetadata;
import org.apache.archiva.metadata.model.CiManagement;
import org.slf4j.LoggerFactory;
import javax.persistence.PersistenceException;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
return artifactMetadataMap.values();
}
+ @Override
+ public List<ArtifactMetadata> getArtifactsByProjectVersionMetadata( String key, String value, String repositoryId )
+ throws MetadataRepositoryException
+ {
+ throw new UnsupportedOperationException( "not yet implemented in Cassandra backend" );
+ }
+
+ @Override
+ public List<ArtifactMetadata> getArtifactsByMetadata( String key, String value, String repositoryId )
+ throws MetadataRepositoryException
+ {
+ throw new UnsupportedOperationException( "not yet implemented in Cassandra backend" );
+ }
+
+ @Override
+ public List<ArtifactMetadata> getArtifactsByProperty( String key, String value, String repositoryId )
+ throws MetadataRepositoryException
+ {
+ throw new UnsupportedOperationException( "getArtifactsByProperty not yet implemented in Cassandra backend" );
+ }
@Override
public void removeArtifact( final String repositoryId, final String namespace, final String project,
{
return ModelMapperHolder.MODEL_MAPPER;
}
+
+ @Override
+ public List<ArtifactMetadata> searchArtifacts( String text, String repositoryId, boolean exact )
+ throws MetadataRepositoryException
+ {
+ throw new UnsupportedOperationException( "searchArtifacts not yet implemented in Cassandra backend" );
+ }
+
+ @Override
+ public List<ArtifactMetadata> searchArtifacts( String key, String text, String repositoryId, boolean exact )
+ throws MetadataRepositoryException
+ {
+ throw new UnsupportedOperationException( "searchArtifacts not yet implemented in Cassandra backend" );
+ }
}
* under the License.
*/
-import org.apache.archiva.metadata.model.MailingList;
import org.apache.archiva.metadata.model.MetadataFacetFactory;
import org.apache.archiva.metadata.repository.AbstractMetadataRepositoryTest;
import org.apache.archiva.metadata.repository.cassandra.model.ProjectVersionMetadataModel;
import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import javax.inject.Named;
+
import java.io.File;
-import java.util.List;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
public class CassandraMetadataRepositoryTest
extends AbstractMetadataRepositoryTest
{
- private Logger logger = LoggerFactory.getLogger( getClass() );
-
@Inject
@Named(value = "archivaEntityManagerFactory#cassandra")
CassandraArchivaManager cassandraArchivaManager;
clearReposAndNamespace( cassandraArchivaManager );
}
+ @Override
+ @Ignore
+ public void testGetArtifactsByProjectVersionMetadata()
+ throws Exception
+ {
+ // TODO not implemented
+ }
+
+ @Override
+ @Ignore
+ public void testGetArtifactsByProjectVersionMetadataNoRepository()
+ throws Exception
+ {
+ // TODO not implemented
+ }
+
+ @Override
+ @Ignore
+ public void testGetArtifactsByProjectVersionMetadataAllRepositories()
+ throws Exception
+ {
+ // TODO not implemented
+ }
+
+ @Override
+ @Ignore
+ public void testGetArtifactsByMetadataAllRepositories()
+ throws Exception
+ {
+ // TODO not implemented
+ }
+
+ @Override
+ @Ignore
+ public void testGetArtifactsByPropertySingleResult()
+ throws Exception
+ {
+ // TODO not implemented
+ }
+
+ @Override
+ @Ignore
+ public void testSearchArtifactsByKey()
+ throws Exception
+ {
+ // TODO not implemented
+ }
+
+ @Override
+ @Ignore
+ public void testSearchArtifactsByKeyExact()
+ throws Exception
+ {
+ // TODO not implemented
+ }
+
+ @Override
+ @Ignore
+ public void testSearchArtifactsFullText()
+ throws Exception
+ {
+ // TODO not implemented
+ }
+
+ @Override
+ @Ignore
+ public void testSearchArtifactsFullTextExact()
+ throws Exception
+ {
+ // TODO not implemented
+ }
+
+ @Override
+ @Ignore
+ public void testSearchArtifactsByFacetKeyAllRepos()
+ throws Exception
+ {
+ // TODO not implemented
+ }
+
+ @Override
+ @Ignore
+ public void testSearchArtifactsByFacetKey()
+ throws Exception
+ {
+ // TODO not implemented
+ }
+
+ @Override
+ @Ignore
+ public void testSearchArtifactsFullTextByFacet()
+ throws Exception
+ {
+ // TODO not implemented
+ }
+
+
/**
* ensure all dependant tables are cleaned up (mailinglist, license, dependencies)
*
<version>${project.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>generic-metadata-support</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jcl</artifactId>
}
}
+ @Override
+ public List<ArtifactMetadata> getArtifactsByProjectVersionMetadata( String key, String value, String repositoryId )
+ throws MetadataRepositoryException
+ {
+ throw new UnsupportedOperationException( "not yet implemented in File backend" );
+ }
+
+ @Override
+ public List<ArtifactMetadata> getArtifactsByMetadata( String key, String value, String repositoryId )
+ throws MetadataRepositoryException
+ {
+ throw new UnsupportedOperationException( "not yet implemented in File backend" );
+ }
+
+ @Override
+ public List<ArtifactMetadata> getArtifactsByProperty( String key, String value, String repositoryId )
+ throws MetadataRepositoryException
+ {
+ throw new UnsupportedOperationException( "getArtifactsByProperty not yet implemented in File backend" );
+ }
+
private File getMetadataDirectory( String repoId, String facetId )
{
return new File( getBaseDirectory( repoId ), "facets/" + facetId );
}
}
}
+
+ @Override
+ public List<ArtifactMetadata> searchArtifacts( String text, String repositoryId, boolean exact )
+ throws MetadataRepositoryException
+ {
+ throw new UnsupportedOperationException( "searchArtifacts not yet implemented in File backend" );
+ }
+
+ @Override
+ public List<ArtifactMetadata> searchArtifacts( String key, String text, String repositoryId, boolean exact )
+ throws MetadataRepositoryException
+ {
+ throw new UnsupportedOperationException( "searchArtifacts not yet implemented in File backend" );
+ }
}
import org.apache.archiva.configuration.Configuration;
import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
import org.junit.Before;
+import org.junit.Ignore;
import java.io.File;
import java.util.Map;
this.repository = new FileMetadataRepository( factories, config );
}
+ @Override
+ @Ignore
+ public void testGetArtifactsByProjectVersionMetadata()
+ throws Exception
+ {
+ // TODO not implemented
+ }
+
+ @Override
+ @Ignore
+ public void testGetArtifactsByProjectVersionMetadataNoRepository()
+ throws Exception
+ {
+ // TODO not implemented
+ }
+
+ @Override
+ @Ignore
+ public void testGetArtifactsByProjectVersionMetadataAllRepositories()
+ throws Exception
+ {
+ // TODO not implemented
+ }
+
+ @Override
+ @Ignore
+ public void testGetArtifactsByMetadataAllRepositories()
+ throws Exception
+ {
+ // TODO not implemented
+ }
+
+ @Override
+ @Ignore
+ public void testGetArtifactsByPropertySingleResult()
+ throws Exception
+ {
+ // TODO not implemented
+ }
+
+ @Override
+ @Ignore
+ public void testSearchArtifactsByKey()
+ throws Exception
+ {
+ // TODO not implemented
+ }
+
+ @Override
+ @Ignore
+ public void testSearchArtifactsByKeyExact()
+ throws Exception
+ {
+ // TODO not implemented
+ }
+
+ @Override
+ @Ignore
+ public void testSearchArtifactsFullText()
+ throws Exception
+ {
+ // TODO not implemented
+ }
+
+ @Override
+ @Ignore
+ public void testSearchArtifactsFullTextExact()
+ throws Exception
+ {
+ // TODO not implemented
+ }
+
+ @Override
+ @Ignore
+ public void testSearchArtifactsByFacetKeyAllRepos()
+ throws Exception
+ {
+ // TODO not implemented
+ }
+
+ @Override
+ @Ignore
+ public void testSearchArtifactsByFacetKey()
+ throws Exception
+ {
+ // TODO not implemented
+ }
+
+ @Override
+ @Ignore
+ public void testSearchArtifactsFullTextByFacet()
+ throws Exception
+ {
+ // TODO not implemented
+ }
+
protected static ArchivaConfiguration createTestConfiguration( File directory )
{
ArchivaConfiguration config = mock( ArchivaConfiguration.class );
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>generic-metadata-support</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>maven2-repository</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.collect.ImmutableMap;
+
import javax.jcr.NamespaceRegistry;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.nodetype.NodeTypeTemplate;
import javax.jcr.query.Query;
import javax.jcr.query.QueryResult;
+import javax.jcr.query.Row;
+import javax.jcr.query.RowIterator;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
/**
return artifacts;
}
+ private List<ArtifactMetadata> runJcrQuery( String repositoryId, String q, Map<String, String> bindings )
+ throws MetadataRepositoryException
+ {
+ List<ArtifactMetadata> artifacts;
+ if ( repositoryId != null )
+ {
+ q += " AND ISDESCENDANTNODE(artifact,'/" + getRepositoryContentPath( repositoryId ) + "')";
+ }
+
+ log.info( "Running JCR Query: {}", q );
+
+ try
+ {
+ Query query = getJcrSession().getWorkspace().getQueryManager().createQuery( q, Query.JCR_SQL2 );
+ ValueFactory valueFactory = getJcrSession().getValueFactory();
+ for ( Entry<String, String> entry : bindings.entrySet() )
+ {
+ query.bindValue( entry.getKey(), valueFactory.createValue( entry.getValue() ) );
+ }
+ long start = Calendar.getInstance().getTimeInMillis();
+ QueryResult result = query.execute();
+ long end = Calendar.getInstance().getTimeInMillis();
+ log.info( "JCR Query ran in {} milliseconds: {}", end - start , q );
+
+ artifacts = new ArrayList<>();
+ RowIterator rows = result.getRows();
+ while ( rows.hasNext() )
+ {
+ Row row = rows.nextRow();
+ Node node = row.getNode( "artifact" );
+ artifacts.add( getArtifactFromNode( repositoryId, node ) );
+ }
+ }
+ catch ( RepositoryException e )
+ {
+ throw new MetadataRepositoryException( e.getMessage(), e );
+ }
+ return artifacts;
+ }
+
+ @Override
+ public List<ArtifactMetadata> getArtifactsByProjectVersionMetadata( String key, String value, String repositoryId )
+ throws MetadataRepositoryException
+ {
+ String q =
+ "SELECT * FROM [" + PROJECT_VERSION_NODE_TYPE + "] AS projectVersion INNER JOIN [" + ARTIFACT_NODE_TYPE
+ + "] AS artifact ON ISCHILDNODE(artifact, projectVersion) INNER JOIN [" + FACET_NODE_TYPE
+ + "] AS facet ON ISCHILDNODE(facet, projectVersion) WHERE ([facet].[" + key + "] = $value)";
+
+ return runJcrQuery( repositoryId, q, ImmutableMap.of( "value", value ) );
+ }
+
+
+ @Override
+ public List<ArtifactMetadata> getArtifactsByMetadata( String key, String value, String repositoryId )
+ throws MetadataRepositoryException
+ {
+ String q =
+ "SELECT * FROM [" + ARTIFACT_NODE_TYPE + "] AS artifact INNER JOIN [" + FACET_NODE_TYPE
+ + "] AS facet ON ISCHILDNODE(facet, artifact) WHERE ([facet].[" + key + "] = $value)";
+
+ return runJcrQuery( repositoryId, q, ImmutableMap.of( "value", value ) );
+ }
+
+
+ @Override
+ public List<ArtifactMetadata> getArtifactsByProperty( String key, String value, String repositoryId )
+ throws MetadataRepositoryException
+ {
+ String q =
+ "SELECT * FROM [" + PROJECT_VERSION_NODE_TYPE + "] AS projectVersion INNER JOIN [" + ARTIFACT_NODE_TYPE
+ + "] AS artifact ON ISCHILDNODE(artifact, projectVersion) WHERE ([projectVersion].[" + key
+ + "] = $value)";
+
+ return runJcrQuery( repositoryId, q, ImmutableMap.of( "value", value ) );
+ }
+
@Override
public void removeRepository( String repositoryId )
}
}
+
+ @Override
+ public List<ArtifactMetadata> searchArtifacts( String text, String repositoryId, boolean exact )
+ throws MetadataRepositoryException
+ {
+ return searchArtifacts( null, text, repositoryId, exact );
+ }
+
+ @Override
+ public List<ArtifactMetadata> searchArtifacts( String key, String text, String repositoryId, boolean exact )
+ throws MetadataRepositoryException
+ {
+ // we can't do exact search in any property (*), we need a key
+ boolean e = exact && key != null;
+ String theKey = key == null ? "*" : "[" + key + "]";
+ String projectVersionCondition =
+ e ? "(projectVersion." + theKey + " = $value)" : "contains([projectVersion]." + theKey + ", $value)";
+ String facetCondition = e ? "(facet." + theKey + " = $value)" : "contains([facet]." + theKey + ", $value)";
+ String q =
+ "SELECT * FROM [" + PROJECT_VERSION_NODE_TYPE + "] AS projectVersion LEFT OUTER JOIN ["
+ + ARTIFACT_NODE_TYPE + "] AS artifact ON ISCHILDNODE(artifact, projectVersion) LEFT OUTER JOIN ["
+ + FACET_NODE_TYPE + "] AS facet ON ISCHILDNODE(facet, projectVersion) WHERE ("
+ + projectVersionCondition + " OR " + facetCondition + ")";
+
+ return runJcrQuery( repositoryId, q, ImmutableMap.of( "value", text ) );
+ }
+
private ArtifactMetadata getArtifactFromNode( String repositoryId, Node artifactNode )
throws RepositoryException
{
ArtifactMetadata artifact = new ArtifactMetadata();
artifact.setId( id );
- artifact.setRepositoryId( repositoryId );
+ artifact.setRepositoryId( repositoryId == null ? artifactNode.getAncestor(2).getName() : repositoryId );
Node projectVersionNode = artifactNode.getParent();
Node projectNode = projectVersionNode.getParent();