I'm trying to do a headless update at startup for my product com.example.product, which contains com.,example.feature which contains com.example.plugin. Here's the error I'm getting in my logs, and the code generating it follows that. It seems to be picking up the update site and the IUs ok, but then can't find the artifact.
The binary folder in my update site contains "com.example.product.executable.win32.win32.x86_1.0.1"
public class P2Util {
private static final Logger logger = Logger.getLogger( P2Util.class );
// XXX Check for updates to this application and return a status.
static IStatus checkForUpdates(IProvisioningAgent agent,
IProgressMonitor monitor) throws OperationCanceledException,
InvocationTargetException {
addUpdateSite(agent);
IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
logRepositories(metadataManager);
IQueryResult<IInstallableUnit> ius = queryIusFromMetadataManager(metadataManager);
ProvisioningSession session = new ProvisioningSession(agent);
UpdateOperation operation = new UpdateOperation(session);
SubMonitor sub = SubMonitor.convert(monitor,
"Checking for application updates...", 200);
IStatus status = operation.resolveModal(sub.newChild(100));
if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) {
return status;
}
if (status.getSeverity() == IStatus.CANCEL)
throw new OperationCanceledException();
if (status.getSeverity() != IStatus.ERROR) {
try {
// More complex status handling might include showing the user what
// updates
// are available if there are multiples, differentiating patches vs.
// updates, etc.
// In this example, we simply update as suggested by the operation.
Update[] updates = operation.getPossibleUpdates();
for( Update u : updates){
}
ProvisioningJob job = operation.getProvisioningJob(null);
if( job == null ){
logger.error( "Provisioning Job is null" );
}
status = job.runModal(sub.newChild(100));
if (status.getSeverity() == IStatus.CANCEL) {
throw new OperationCanceledException();
}
} catch ( Exception e ){
logger.error( "Exception while trying to get updates", e);
}
}
return status;
}
private static void logRepositories(
IMetadataRepositoryManager metadataManager) {
URI[] repos = metadataManager.getKnownRepositories( IMetadataRepositoryManager.REPOSITORIES_ALL);
logger.info( "Found " + repos.length + " repositories in metadata");
logRespositories(repos);
}
private static void logRespositories(URI[] repos) {
for( URI uri : repos ){
}
}
private static IQueryResult<IInstallableUnit> queryIusFromMetadataManager(
IMetadataRepositoryManager metadataManager) {
IQueryResult<IInstallableUnit> ius = metadataManager.query(QueryUtil.createIUGroupQuery(), new NullProgressMonitor());
for( Iterator<IInstallableUnit> y = ius.iterator(); y.hasNext(); ){
IInstallableUnit blah = y.next();
}
return ius;
}
public static void addUpdateSite(IProvisioningAgent provisioningAgent)
throws InvocationTargetException {
// Load repository manager
IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) provisioningAgent
.getService(IMetadataRepositoryManager.SERVICE_NAME);
if (metadataManager == null) {
logger.error( "Metadata manager was null");
Throwable throwable = new
Throwable("Could not load Metadata Repository Manager");
throwable.fillInStackTrace();
throw new InvocationTargetException(throwable);
}
// Load artifact manager
IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) provisioningAgent
.getService(IArtifactRepositoryManager.SERVICE_NAME);
if (artifactManager == null) {
logger.error( "Artifact manager was null");
Throwable throwable = new Throwable(
"Could not load Artifact Repository Manager");
throwable.fillInStackTrace();
throw new InvocationTargetException(throwable);
}
// Load repo
try {
URI repoLocation = new URI(UPDATE_URI);
metadataManager.loadRepository(repoLocation, null);
artifactManager.loadRepository(repoLocation, null);
} catch (ProvisionException pe) {
logger.error( "Caught provisioning exception " + pe.getMessage(), pe);
throw new InvocationTargetException(pe);
} catch (URISyntaxException e) {
logger.error( "Caught URI syntax exception " + e.getMessage(), e);
throw new InvocationTargetException(e);
}
}
}