Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2013-12-16 23:06:00 +0000
committerTom Schindl2013-12-16 23:06:00 +0000
commitab02fe3fc94cda1ab297d12cfe6265ce4d7f5cff (patch)
tree01dce8d09e93df4f9711a985072bbbe43c9d022d /bundles
parent0ee36835de3392b2155f6c377eb957f064e8b650 (diff)
downloadorg.eclipse.efxclipse-ab02fe3fc94cda1ab297d12cfe6265ce4d7f5cff.tar.gz
org.eclipse.efxclipse-ab02fe3fc94cda1ab297d12cfe6265ce4d7f5cff.tar.xz
org.eclipse.efxclipse-ab02fe3fc94cda1ab297d12cfe6265ce4d7f5cff.zip
fixed javadoc and null analysis
Diffstat (limited to 'bundles')
-rw-r--r--bundles/runtime/org.eclipse.fx.core.p2/.settings/org.eclipse.jdt.core.prefs107
-rwxr-xr-xbundles/runtime/org.eclipse.fx.core.p2/build.properties2
-rw-r--r--[-rwxr-xr-x]bundles/runtime/org.eclipse.fx.core.p2/src/org/eclipse/fx/core/p2/Activator.java13
-rwxr-xr-xbundles/runtime/org.eclipse.fx.core.p2/src/org/eclipse/fx/core/p2/UpdateServiceImpl.java400
4 files changed, 327 insertions, 195 deletions
diff --git a/bundles/runtime/org.eclipse.fx.core.p2/.settings/org.eclipse.jdt.core.prefs b/bundles/runtime/org.eclipse.fx.core.p2/.settings/org.eclipse.jdt.core.prefs
index f42de363a..0448c8920 100644
--- a/bundles/runtime/org.eclipse.fx.core.p2/.settings/org.eclipse.jdt.core.prefs
+++ b/bundles/runtime/org.eclipse.fx.core.p2/.settings/org.eclipse.jdt.core.prefs
@@ -1,7 +1,114 @@
eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=enabled
+org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
+org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.doc.comment.support=enabled
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=warning
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
+org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=protected
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
+org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag
+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=protected
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=warning
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
+org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
+org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
+org.eclipse.jdt.core.compiler.problem.nullReference=error
+org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
+org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=warning
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=error
+org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=warning
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=warning
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.7
diff --git a/bundles/runtime/org.eclipse.fx.core.p2/build.properties b/bundles/runtime/org.eclipse.fx.core.p2/build.properties
index dfb3f9f3d..dc141ca5a 100755
--- a/bundles/runtime/org.eclipse.fx.core.p2/build.properties
+++ b/bundles/runtime/org.eclipse.fx.core.p2/build.properties
@@ -4,3 +4,5 @@ bin.includes = META-INF/,\
.,\
OSGI-INF/,\
about.html
+additional.bundles = org.eclipse.jdt.annotation
+jars.extra.classpath = platform:/plugin/org.eclipse.jdt.annotation \ No newline at end of file
diff --git a/bundles/runtime/org.eclipse.fx.core.p2/src/org/eclipse/fx/core/p2/Activator.java b/bundles/runtime/org.eclipse.fx.core.p2/src/org/eclipse/fx/core/p2/Activator.java
index 52a8198bc..c547b4d58 100755..100644
--- a/bundles/runtime/org.eclipse.fx.core.p2/src/org/eclipse/fx/core/p2/Activator.java
+++ b/bundles/runtime/org.eclipse.fx.core.p2/src/org/eclipse/fx/core/p2/Activator.java
@@ -13,6 +13,9 @@ package org.eclipse.fx.core.p2;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
+/**
+ * Activator
+ */
public class Activator implements BundleActivator {
private static BundleContext context;
@@ -21,18 +24,12 @@ public class Activator implements BundleActivator {
return context;
}
- /*
- * (non-Javadoc)
- * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
- */
+ @Override
public void start(BundleContext bundleContext) throws Exception {
Activator.context = bundleContext;
}
- /*
- * (non-Javadoc)
- * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
- */
+ @Override
public void stop(BundleContext bundleContext) throws Exception {
Activator.context = null;
}
diff --git a/bundles/runtime/org.eclipse.fx.core.p2/src/org/eclipse/fx/core/p2/UpdateServiceImpl.java b/bundles/runtime/org.eclipse.fx.core.p2/src/org/eclipse/fx/core/p2/UpdateServiceImpl.java
index 49a55c5db..c94155fe5 100755
--- a/bundles/runtime/org.eclipse.fx.core.p2/src/org/eclipse/fx/core/p2/UpdateServiceImpl.java
+++ b/bundles/runtime/org.eclipse.fx.core.p2/src/org/eclipse/fx/core/p2/UpdateServiceImpl.java
@@ -28,65 +28,92 @@ import org.eclipse.fx.core.log.LoggerFactory;
import org.eclipse.fx.core.update.UpdateService;
import org.osgi.framework.ServiceReference;
import org.eclipse.fx.core.ReturnValue.ReturnValueImpl;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+/**
+ * Implementation of service based upon p2
+ */
public class UpdateServiceImpl implements UpdateService {
private Logger logger;
private LoggerFactory factory;
- static class P2UpdateCheckRV extends ReturnValueImpl<Boolean> implements
- UpdateCheckData {
+ static class P2UpdateCheckRV extends ReturnValueImpl<Boolean> implements UpdateCheckData {
+ @Nullable
public final UpdateOperation updateOperation;
-
- public P2UpdateCheckRV(UpdateOperation updateOperation, State state,
- String message, Boolean value, Throwable throwable) {
+
+ public P2UpdateCheckRV(@Nullable UpdateOperation updateOperation, @NonNull State state, @NonNull String message, @NonNull Boolean value, @Nullable Throwable throwable) {
super(state, message, value, throwable);
this.updateOperation = updateOperation;
}
}
- static class P2UpdateRV extends ReturnValueImpl<Boolean> implements
- UpdateData {
+ static class P2UpdateRV extends ReturnValueImpl<Boolean> implements UpdateData {
- public P2UpdateRV(State state, String message, Boolean value,
- Throwable throwable) {
+ public P2UpdateRV(@NonNull State state, @NonNull String message, @NonNull Boolean value, @Nullable Throwable throwable) {
super(state, message, value, throwable);
}
}
+ /**
+ * Set the factory to create a logger
+ *
+ * @param factory
+ * the factory
+ */
public void setLoggerFactory(LoggerFactory factory) {
this.factory = factory;
- if (logger != null) {
- logger = null;
+ if (this.logger != null) {
+ this.logger = null;
}
}
+ /**
+ * Unset the factory for the logger
+ *
+ * @param factory
+ * the factory
+ */
public void unsetLoggerFactory(LoggerFactory factory) {
- this.factory = null;
- this.logger = null;
+ if (this.factory == factory) {
+ this.factory = null;
+ this.logger = null;
+ }
}
+ @NonNull
private Logger getLogger() {
- if (logger == null) {
- logger = factory.createLogger(getClass().getName());
+ if( this.factory == null ) {
+ throw new IllegalStateException("No logger factory available"); //$NON-NLS-1$
}
- return logger;
+
+ if (this.logger == null ) {
+ this.logger = this.factory.createLogger(getClass().getName());
+ }
+ return this.logger;
}
@Override
public void update(UpdateCheckData data, final Callback<UpdateData> callback) {
- Job job = ((P2UpdateCheckRV) data).updateOperation.getProvisioningJob(new NullProgressMonitor());
- job.addJobChangeListener(new JobChangeAdapter() {
- @Override
- public void done(IJobChangeEvent event) {
- IStatus s = event.getResult();
- State state = fromStatus(s);
- callback.call(new P2UpdateRV(state, s.getMessage(), State.OK == state, s.getException()));
- }
- });
- job.schedule();
+ UpdateOperation updateOperation = ((P2UpdateCheckRV) data).updateOperation;
+ if( updateOperation != null ) {
+ Job job = updateOperation.getProvisioningJob(new NullProgressMonitor());
+ job.addJobChangeListener(new JobChangeAdapter() {
+ @SuppressWarnings("null")
+ @Override
+ public void done(IJobChangeEvent event) {
+ IStatus s = event.getResult();
+ State state = fromStatus(s);
+ callback.call(new P2UpdateRV(state, s.getMessage(), Boolean.valueOf(State.OK == state), s.getException()));
+ }
+ });
+ job.schedule();
+ }
+
}
-
- private State fromStatus(IStatus s) {
+
+ @NonNull
+ static State fromStatus(IStatus s) {
switch (s.getSeverity()) {
case IStatus.CANCEL:
return State.CANCEL;
@@ -99,185 +126,184 @@ public class UpdateServiceImpl implements UpdateService {
}
}
+ @SuppressWarnings("null")
@Override
public void checkUpdate(final Callback<UpdateCheckData> callback) {
try {
IProvisioningAgent agent = getProvisioningAgent();
final ProvisioningSession session = new ProvisioningSession(agent);
- Job o = new Job("Check for Updates") {
-
+ Job o = new Job("Check for Updates") { //$NON-NLS-1$
+
@Override
protected IStatus run(IProgressMonitor monitor) {
UpdateOperation o = new UpdateOperation(session);
IStatus s = o.resolveModal(monitor);
State state = fromStatus(s);
- callback.call(new P2UpdateCheckRV(o, state, s.getMessage(), state == State.OK,s.getException()));
+ callback.call(new P2UpdateCheckRV(o, state, s.getMessage(), Boolean.valueOf(state == State.OK), s.getException()));
return Status.OK_STATUS;
}
};
o.schedule();
} catch (ProvisionException e) {
getLogger().error(e.getMessage(), e);
- callback.call(new P2UpdateCheckRV(null, State.ERROR,"Failure while try to collect updateable units", null, e));
+ callback.call(new P2UpdateCheckRV(null, State.ERROR, "Failure while try to collect updateable units", Boolean.FALSE, e)); //$NON-NLS-1$
}
}
- private IProvisioningAgent getProvisioningAgent() throws ProvisionException {
- ServiceReference<?> reference = Activator.getContext()
- .getServiceReference(IProvisioningAgent.SERVICE_NAME);
- IProvisioningAgent agent = (IProvisioningAgent) Activator.getContext()
- .getService(reference);
+ private static IProvisioningAgent getProvisioningAgent() throws ProvisionException {
+ ServiceReference<?> reference = Activator.getContext().getServiceReference(IProvisioningAgent.SERVICE_NAME);
+ IProvisioningAgent agent = (IProvisioningAgent) Activator.getContext().getService(reference);
return agent;
}
-// TODO enable forced update support in future
-// protected IQueryable<IInstallableUnit> collectUpdateableUnits(
-// IProvisioningAgent agent, final IProgressMonitor monitor)
-// throws ProvisionException {
-// IRepositoryManager<?> manager = (IRepositoryManager<?>) agent
-// .getService(IMetadataRepositoryManager.class.getName());
-//
-// // Get update site uri's from p2.inf.
-//
-// final StringBuffer siteUrlPackage = new StringBuffer();
-//
-// URI[] uris = manager
-// .getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL);
-//
-// if (uris.length == 0) {
-// getLogger().warning("no update repositories found");
-// } else {
-// for (URI uri : uris) {
-// if (siteUrlPackage.length() > 0) {
-// siteUrlPackage.append(",");
-// }
-// // LOGGER.info( "uri found: " + uri.toString() );
-// siteUrlPackage.append(uri.toString());
-// }
-// }
-//
-// if (siteUrlPackage == null || siteUrlPackage.toString().isEmpty()) {
-// throw new IllegalStateException(
-// "No site URL specified. Edit your p2.inf file.");
-// }
-//
-// getLogger().info( "Synch repos: " + siteUrlPackage );
-//
-// String[] siteUrlStrings = siteUrlPackage.toString().split(",");
-// URI[] siteURIs = new URI[siteUrlStrings.length];
-// for (int i = 0; i < siteURIs.length; i++) {
-// try {
-// siteURIs[i] = new URI(siteUrlStrings[i]);
-// } catch (URISyntaxException e) {
-// throw new IllegalStateException(e);
-// }
-// }
-//
-// // Convert URIs into something we can query...
-// IQueryable<IInstallableUnit> allTheIUs = createIUQueryable(siteURIs,
-// agent, monitor);
-// getLogger().debug("query result: " + allTheIUs);
-//
-// return allTheIUs;
-//
-// }
-//
-// public void installUnits(final IProvisioningAgent agent,
-// IQueryable<IInstallableUnit> allTheIUs, IProgressMonitor monitor) {
-// ProvisioningSession session = new ProvisioningSession(agent);
-// /*
-// * Query the metadata repository(ies) for the feature(s) to install.
-// */
-// Collection<IInstallableUnit> toInstall = allTheIUs.query(
-// QueryUtil.createIUGroupQuery(), new NullProgressMonitor())
-// .toUnmodifiableSet();
-// getLogger().info("Everything to synchronize:");
-// logQueryResults(toInstall);
-//
-// SynchronizeOperation operation = new SynchronizeOperation(session,
-// toInstall);
-// IStatus opStatus = operation.resolveModal(monitor);
-// if (opStatus.isOK()) {
-// ProvisioningJob job = operation.getProvisioningJob(null);
-// opStatus = job.runModal(monitor);
-// if (opStatus.getSeverity() == IStatus.CANCEL)
-// throw new OperationCanceledException();
-// }
-// }
-//
-// private void logQueryResults(Collection<IInstallableUnit> toInstall) {
-// if (getLogger().isEnabled(Level.DEBUG)) {
-// StringBuffer iuNames = new StringBuffer("IUs:\n\n ");
-// for (IInstallableUnit iu : toInstall) {
-// iuNames.append(iu.getId() + iu.getVersion() + "\n ");
-// }
-// getLogger().debug(iuNames.toString());
-// }
-// }
-//
-// private IQueryable<IInstallableUnit> createIUQueryable(URI[] p2Sites,
-// IProvisioningAgent agent, IProgressMonitor monitor)
-// throws ProvisionException {
-// IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) agent
-// .getService(IMetadataRepositoryManager.SERVICE_NAME);
-// IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) agent
-// .getService(IArtifactRepositoryManager.SERVICE_NAME);
-//
-// final Collection<IMetadataRepository> metadataReposList = new LinkedList<IMetadataRepository>();
-// for (URI uri : p2Sites) {
-// getLogger().debug("Adding metadata repo at: " + uri.toString());
-// try {
-// IMetadataRepository metadataRepo = metadataManager
-// .loadRepository(uri, monitor);
-// getLogger().debug(
-// "metadata repository loaded: " + uri.toString());
-// try {
-// artifactManager.loadRepository(uri, monitor); // load the
-// // repo:
-// // this
-// // makes it
-// // available
-// // to us
-// metadataReposList.add(metadataRepo);
-// } catch (NullPointerException e) {
-// getLogger()
-// .warning(
-// "Repository " + uri
-// + " not found, will be ignored", e);
-// }
-// } catch (ProvisionException e) {
-// if (e.getStatus().getCode() == ProvisionException.REPOSITORY_NOT_FOUND) {
-// getLogger()
-// .warning(
-// "Repository " + uri
-// + " not found, will be ignored");
-// } else {
-// getLogger()
-// .warning(
-// "ProvisionException code="
-// + e.getStatus().getCode()
-// + ", return none");
-// throw e;
-// }
-// } catch (OperationCanceledException e) {
-// getLogger().warning("OperationCanceledException, return none");
-// throw e;
-// }
-// }
-// if (metadataReposList.isEmpty()) {
-// getLogger().debug("seems to be correct, return NONE");
-// return null;
-// } else {
-// getLogger().debug("seems to be correct, return SOME");
-// return QueryUtil.compoundQueryable(metadataReposList);
-// }
-// }
-// private Collection<IInstallableUnit> getInstalledIUs() {
-// IProfile profile = session.getProfileRegistry().getProfile(profileId);
-// if (profile == null)
-// return CollectionUtils.emptyList();
-// IQuery<IInstallableUnit> query = new UserVisibleRootQuery();
-// IQueryResult<IInstallableUnit> queryResult = profile.query(query, null);
-// return queryResult.toUnmodifiableSet();
-// }
+ // TODO enable forced update support in future
+ // protected IQueryable<IInstallableUnit> collectUpdateableUnits(
+ // IProvisioningAgent agent, final IProgressMonitor monitor)
+ // throws ProvisionException {
+ // IRepositoryManager<?> manager = (IRepositoryManager<?>) agent
+ // .getService(IMetadataRepositoryManager.class.getName());
+ //
+ // // Get update site uri's from p2.inf.
+ //
+ // final StringBuffer siteUrlPackage = new StringBuffer();
+ //
+ // URI[] uris = manager
+ // .getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL);
+ //
+ // if (uris.length == 0) {
+ // getLogger().warning("no update repositories found");
+ // } else {
+ // for (URI uri : uris) {
+ // if (siteUrlPackage.length() > 0) {
+ // siteUrlPackage.append(",");
+ // }
+ // // LOGGER.info( "uri found: " + uri.toString() );
+ // siteUrlPackage.append(uri.toString());
+ // }
+ // }
+ //
+ // if (siteUrlPackage == null || siteUrlPackage.toString().isEmpty()) {
+ // throw new IllegalStateException(
+ // "No site URL specified. Edit your p2.inf file.");
+ // }
+ //
+ // getLogger().info( "Synch repos: " + siteUrlPackage );
+ //
+ // String[] siteUrlStrings = siteUrlPackage.toString().split(",");
+ // URI[] siteURIs = new URI[siteUrlStrings.length];
+ // for (int i = 0; i < siteURIs.length; i++) {
+ // try {
+ // siteURIs[i] = new URI(siteUrlStrings[i]);
+ // } catch (URISyntaxException e) {
+ // throw new IllegalStateException(e);
+ // }
+ // }
+ //
+ // // Convert URIs into something we can query...
+ // IQueryable<IInstallableUnit> allTheIUs = createIUQueryable(siteURIs,
+ // agent, monitor);
+ // getLogger().debug("query result: " + allTheIUs);
+ //
+ // return allTheIUs;
+ //
+ // }
+ //
+ // public void installUnits(final IProvisioningAgent agent,
+ // IQueryable<IInstallableUnit> allTheIUs, IProgressMonitor monitor) {
+ // ProvisioningSession session = new ProvisioningSession(agent);
+ // /*
+ // * Query the metadata repository(ies) for the feature(s) to install.
+ // */
+ // Collection<IInstallableUnit> toInstall = allTheIUs.query(
+ // QueryUtil.createIUGroupQuery(), new NullProgressMonitor())
+ // .toUnmodifiableSet();
+ // getLogger().info("Everything to synchronize:");
+ // logQueryResults(toInstall);
+ //
+ // SynchronizeOperation operation = new SynchronizeOperation(session,
+ // toInstall);
+ // IStatus opStatus = operation.resolveModal(monitor);
+ // if (opStatus.isOK()) {
+ // ProvisioningJob job = operation.getProvisioningJob(null);
+ // opStatus = job.runModal(monitor);
+ // if (opStatus.getSeverity() == IStatus.CANCEL)
+ // throw new OperationCanceledException();
+ // }
+ // }
+ //
+ // private void logQueryResults(Collection<IInstallableUnit> toInstall) {
+ // if (getLogger().isEnabled(Level.DEBUG)) {
+ // StringBuffer iuNames = new StringBuffer("IUs:\n\n ");
+ // for (IInstallableUnit iu : toInstall) {
+ // iuNames.append(iu.getId() + iu.getVersion() + "\n ");
+ // }
+ // getLogger().debug(iuNames.toString());
+ // }
+ // }
+ //
+ // private IQueryable<IInstallableUnit> createIUQueryable(URI[] p2Sites,
+ // IProvisioningAgent agent, IProgressMonitor monitor)
+ // throws ProvisionException {
+ // IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) agent
+ // .getService(IMetadataRepositoryManager.SERVICE_NAME);
+ // IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) agent
+ // .getService(IArtifactRepositoryManager.SERVICE_NAME);
+ //
+ // final Collection<IMetadataRepository> metadataReposList = new LinkedList<IMetadataRepository>();
+ // for (URI uri : p2Sites) {
+ // getLogger().debug("Adding metadata repo at: " + uri.toString());
+ // try {
+ // IMetadataRepository metadataRepo = metadataManager
+ // .loadRepository(uri, monitor);
+ // getLogger().debug(
+ // "metadata repository loaded: " + uri.toString());
+ // try {
+ // artifactManager.loadRepository(uri, monitor); // load the
+ // // repo:
+ // // this
+ // // makes it
+ // // available
+ // // to us
+ // metadataReposList.add(metadataRepo);
+ // } catch (NullPointerException e) {
+ // getLogger()
+ // .warning(
+ // "Repository " + uri
+ // + " not found, will be ignored", e);
+ // }
+ // } catch (ProvisionException e) {
+ // if (e.getStatus().getCode() == ProvisionException.REPOSITORY_NOT_FOUND) {
+ // getLogger()
+ // .warning(
+ // "Repository " + uri
+ // + " not found, will be ignored");
+ // } else {
+ // getLogger()
+ // .warning(
+ // "ProvisionException code="
+ // + e.getStatus().getCode()
+ // + ", return none");
+ // throw e;
+ // }
+ // } catch (OperationCanceledException e) {
+ // getLogger().warning("OperationCanceledException, return none");
+ // throw e;
+ // }
+ // }
+ // if (metadataReposList.isEmpty()) {
+ // getLogger().debug("seems to be correct, return NONE");
+ // return null;
+ // } else {
+ // getLogger().debug("seems to be correct, return SOME");
+ // return QueryUtil.compoundQueryable(metadataReposList);
+ // }
+ // }
+ // private Collection<IInstallableUnit> getInstalledIUs() {
+ // IProfile profile = session.getProfileRegistry().getProfile(profileId);
+ // if (profile == null)
+ // return CollectionUtils.emptyList();
+ // IQuery<IInstallableUnit> query = new UserVisibleRootQuery();
+ // IQueryResult<IInstallableUnit> queryResult = profile.query(query, null);
+ // return queryResult.toUnmodifiableSet();
+ // }
}

Back to the top