Search in sources :

Example 31 with IArtifactRepository

use of org.eclipse.equinox.p2.repository.artifact.IArtifactRepository in project tycho by eclipse.

the class VerifierServiceImpl method verifyReferencedArtifactsExist.

private boolean verifyReferencedArtifactsExist(final IMetadataRepository metadata, final IArtifactRepository artifactRepository, MavenLogger logger) {
    final IQueryResult<IInstallableUnit> collector = metadata.query(QueryUtil.ALL_UNITS, monitor);
    boolean valid = true;
    for (Iterator<IInstallableUnit> iterator = collector.iterator(); iterator.hasNext(); ) {
        IInstallableUnit iu = iterator.next();
        final Collection<IArtifactKey> artifacts = iu.getArtifacts();
        for (IArtifactKey key : artifacts) {
            valid &= verifyArtifactExists(key, artifactRepository, logger);
        }
    }
    return valid;
}
Also used : IArtifactKey(org.eclipse.equinox.p2.metadata.IArtifactKey) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 32 with IArtifactRepository

use of org.eclipse.equinox.p2.repository.artifact.IArtifactRepository in project tycho by eclipse.

the class VerifierServiceImpl method verify.

@Override
public boolean verify(URI metadataRepositoryUri, URI artifactRepositoryUri, BuildOutputDirectory tempDirectory) throws FacadeException {
    MavenLogger logger = mavenContext.getLogger();
    logger.debug("Checking metadata from '" + metadataRepositoryUri + "' and artifacts from '" + artifactRepositoryUri + "'");
    IProvisioningAgent agent = Activator.createProvisioningAgent(tempDirectory);
    try {
        try {
            final IMetadataRepository metadata = loadMetadataRepository(metadataRepositoryUri, agent);
            final IArtifactRepository artifactRepository = loadArtifactRepository(artifactRepositoryUri, agent);
            boolean valid = true;
            valid &= verifyReferencedArtifactsExist(metadata, artifactRepository, logger);
            valid &= verifyAllArtifactContent(artifactRepository, logger);
            if (valid) {
                logger.info("The integrity of the metadata repository '" + metadataRepositoryUri + "' and artifact repository '" + artifactRepositoryUri + "' has been verified successfully");
            }
            return valid;
        } catch (ProvisionException e) {
            throw new FacadeException(e);
        }
    } finally {
        agent.stop();
    }
}
Also used : FacadeException(org.eclipse.tycho.p2.tools.FacadeException) MavenLogger(org.eclipse.tycho.core.shared.MavenLogger) ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) IProvisioningAgent(org.eclipse.equinox.p2.core.IProvisioningAgent) IArtifactRepository(org.eclipse.equinox.p2.repository.artifact.IArtifactRepository) IMetadataRepository(org.eclipse.equinox.p2.repository.metadata.IMetadataRepository)

Aggregations

IArtifactRepository (org.eclipse.equinox.p2.repository.artifact.IArtifactRepository)23 Test (org.junit.Test)11 IStatus (org.eclipse.core.runtime.IStatus)7 IArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)6 File (java.io.File)4 OutputStream (java.io.OutputStream)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 Status (org.eclipse.core.runtime.Status)3 IProvisioningAgent (org.eclipse.equinox.p2.core.IProvisioningAgent)3 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)3 IArtifactKey (org.eclipse.equinox.p2.metadata.IArtifactKey)3 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)3 IMetadataRepository (org.eclipse.equinox.p2.repository.metadata.IMetadataRepository)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 IPublisherAction (org.eclipse.equinox.p2.publisher.IPublisherAction)2 IPublisherAdvice (org.eclipse.equinox.p2.publisher.IPublisherAdvice)2 IPublisherInfo (org.eclipse.equinox.p2.publisher.IPublisherInfo)2 Publisher (org.eclipse.equinox.p2.publisher.Publisher)2