use of org.osgi.framework.Version in project Lucee by lucee.
the class Admin method doGetBundle.
private void doGetBundle() throws PageException {
String symbolicName = getString("admin", "getBundle", "symbolicName", true);
Version version = OSGiUtil.toVersion(getString("version", null), null);
BundleDefinition bd;
BundleFile bf = null;
Bundle b = OSGiUtil.getBundleLoaded(symbolicName, version, null);
if (b != null) {
bd = new BundleDefinition(b);
} else {
try {
bf = OSGiUtil.getBundleFile(symbolicName, version, null, false);
bd = bf.toBundleDefinition();
b = bd.getLoadedBundle();
} catch (BundleException e) {
throw Caster.toPageException(e);
}
}
CFMLEngine engine = ConfigWebUtil.getEngine(config);
BundleCollection coreBundles = engine.getBundleCollection();
java.util.Collection<BundleDefinition> extBundles = config.getAllExtensionBundleDefintions();
Struct sct = new StructImpl();
pageContext.setVariable(getString("admin", action, "returnVariable"), sct);
sct.set(SYMBOLIC_NAME, bd.getName());
sct.set(KeyConstants._title, bd.getName());
sct.set(KeyConstants._version, bd.getVersionAsString());
sct.set(USED_BY, _usedBy(bd.getName(), bd.getVersion(), coreBundles, extBundles));
try {
if (b != null) {
sct.set(PATH, b.getLocation());
} else {
if (bf == null)
bf = bd.getBundleFile(false);
sct.set(PATH, bf.getFile());
}
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
Map<String, Object> headers = null;
if (b != null) {
sct.set(KeyConstants._version, bd.getVersion().toString());
sct.set(KeyConstants._id, b.getBundleId());
sct.set(KeyConstants._state, OSGiUtil.toState(b.getState(), null));
sct.set(FRAGMENT, OSGiUtil.isFragment(b));
headers = OSGiUtil.getHeaders(b);
} else {
sct.set(KeyConstants._state, "notinstalled");
try {
if (bf == null)
bf = bd.getBundleFile(false);
sct.set(KeyConstants._version, bf.getVersionAsString());
sct.set(FRAGMENT, OSGiUtil.isFragment(bf));
headers = bf.getHeaders();
} catch (BundleException e) {
}
}
if (headers != null) {
Struct h = Caster.toStruct(headers, false);
sct.set(HEADERS, h);
// title
String str = Caster.toString(h.get("Bundle-Title", null), null);
if (StringUtil.isEmpty(str))
str = Caster.toString(h.get("Implementation-Title", null), null);
if (StringUtil.isEmpty(str))
str = Caster.toString(h.get("Specification-Title", null), null);
if (StringUtil.isEmpty(str))
str = Caster.toString(h.get("Bundle-Name", null), null);
if (!StringUtil.isEmpty(str))
sct.set(KeyConstants._title, str);
// description
str = Caster.toString(h.get("Bundle-Description", null), null);
if (StringUtil.isEmpty(str))
str = Caster.toString(h.get("Implementation-Description", null), null);
if (StringUtil.isEmpty(str))
str = Caster.toString(h.get("Specification-Description", null), null);
if (!StringUtil.isEmpty(str))
sct.set(KeyConstants._description, str);
// Vendor
str = Caster.toString(h.get("Bundle-Vendor", null), null);
if (StringUtil.isEmpty(str))
str = Caster.toString(h.get("Implementation-Vendor", null), null);
if (StringUtil.isEmpty(str))
str = Caster.toString(h.get("Specification-Vendor", null), null);
if (!StringUtil.isEmpty(str))
sct.set(VENDOR, str);
}
}
use of org.osgi.framework.Version in project Lucee by lucee.
the class XMLConfigAdmin method installBundle.
/*
* important! returns null when not a bundle!
*/
static BundleFile installBundle(Config config, Resource resJar, String extVersion, boolean convert2bundle) throws IOException, BundleException {
BundleFile bf = new BundleFile(resJar);
// resJar is a bundle
if (bf.isBundle()) {
return installBundle(config, bf);
}
if (!convert2bundle)
return null;
// name
String name = bf.getSymbolicName();
if (StringUtil.isEmpty(name))
name = BundleBuilderFactory.createSymbolicName(resJar);
// version
Version version = bf.getVersion();
if (version == null)
version = OSGiUtil.toVersion(extVersion);
SystemOut.printDate("failed to load [" + resJar + "] as OSGi Bundle");
BundleBuilderFactory bbf = new BundleBuilderFactory(resJar, name);
bbf.setVersion(version);
bbf.setIgnoreExistingManifest(false);
bbf.build();
bf = new BundleFile(resJar);
SystemOut.printDate("converted [" + resJar + "] to an OSGi Bundle");
return installBundle(config, bf);
}
use of org.osgi.framework.Version in project Lucee by lucee.
the class XMLConfigFactory method doNew.
public static UpdateInfo doNew(CFMLEngine engine, Resource contextDir, boolean readOnly) {
lucee.Info info = engine.getInfo();
try {
String strOldVersion;
final Resource resOldVersion = contextDir.getRealResource("version");
String strNewVersion = info.getVersion() + "-" + info.getRealeaseTime();
// fresh install
if (!resOldVersion.exists()) {
if (!readOnly) {
resOldVersion.createNewFile();
IOUtil.write(resOldVersion, strNewVersion, SystemUtil.getCharset(), false);
}
return UpdateInfo.NEW_FRESH;
} else // changed version
if (!(strOldVersion = IOUtil.toString(resOldVersion, SystemUtil.getCharset())).equals(strNewVersion)) {
if (!readOnly)
IOUtil.write(resOldVersion, strNewVersion, SystemUtil.getCharset(), false);
Version oldVersion = OSGiUtil.toVersion(strOldVersion);
return new UpdateInfo(oldVersion, oldVersion.getMajor() < 5 ? NEW_FROM4 : NEW_MINOR);
}
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
return UpdateInfo.NEW_NONE;
}
use of org.osgi.framework.Version in project linuxtools by eclipse.
the class ValgrindRemoteProxyLaunchDelegate method getValgrindVersion.
private Version getValgrindVersion(IProject project) throws CoreException {
Version valgrindVersion;
String verString = whichVersion(project);
if (verString == null || verString.isEmpty()) {
// $NON-NLS-1$
throw new CoreException(new Status(IStatus.ERROR, ValgrindLaunchPlugin.PLUGIN_ID, Messages.getString("ValgrindLaunchPlugin.Couldn't_determine_version")));
}
// $NON-NLS-1$
verString = verString.replace(VERSION_PREFIX, "");
if (verString.indexOf(VERSION_DELIMITER) > 0) {
verString = verString.substring(0, verString.indexOf(VERSION_DELIMITER));
}
if (!verString.isEmpty()) {
valgrindVersion = Version.parseVersion(verString);
} else {
// $NON-NLS-1$
throw new CoreException(new Status(IStatus.ERROR, ValgrindLaunchPlugin.PLUGIN_ID, Messages.getString("ValgrindLaunchPlugin.Couldn't_determine_version")));
}
// check for minimum supported version
if (valgrindVersion.compareTo(MIN_VER) < 0) {
// $NON-NLS-1$
throw new CoreException(new Status(IStatus.ERROR, ValgrindLaunchPlugin.PLUGIN_ID, NLS.bind(Messages.getString("ValgrindLaunchPlugin.Error_min_version"), valgrindVersion.toString(), MIN_VER.toString())));
}
return valgrindVersion;
}
use of org.osgi.framework.Version in project linuxtools by eclipse.
the class LaunchConfigTabTest method testTrackOrigins.
@Test
public void testTrackOrigins() throws Exception {
ILaunchConfigurationWorkingCopy wc = initConfig();
IProject project = CDebugUtils.verifyCProject(config).getProject();
Version ver = ValgrindLaunchPlugin.getDefault().getValgrindVersion(project);
if (ver.compareTo(ValgrindLaunchPlugin.VER_3_4_0) >= 0) {
dynamicTab.getTrackOriginsButton().setSelection(true);
// $NON-NLS-1$
ILaunch launch = saveAndLaunch(wc, "testTrackOrigins");
IProcess[] p = launch.getProcesses();
assertTrue("process array should not be empty", p.length > 0);
String cmd = p[0].getAttribute(IProcess.ATTR_CMDLINE);
assertEquals(0, p[0].getExitValue());
// $NON-NLS-1$
assertTrue(cmd.contains("--track-origins=yes"));
} else {
assertNull(dynamicTab.getTrackOriginsButton());
}
}
Aggregations