use of org.osgi.framework.Version in project bnd by bndtools.
the class Activator method getReportWriter.
private Writer getReportWriter(File reportDir, Bundle bundle) throws IOException {
if (reportDir.isDirectory()) {
Version v = bundle.getVersion();
File f = new File(reportDir, "TEST-" + bundle.getSymbolicName() + "-" + v.getMajor() + "." + v.getMinor() + "." + v.getMicro() + ".xml");
Writer writer = new OutputStreamWriter(Files.newOutputStream(f.toPath()), UTF_8);
writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
return writer;
}
return null;
}
use of org.osgi.framework.Version in project bnd by bndtools.
the class ArtifactRepository method parse.
void parse() throws Exception {
final Map<String, String> properties = getProperties("repository/properties/property");
properties.put("repoUrl", base.resolve("").toString());
final Domain parent = new Domain() {
@Override
public Map<String, String> getMap() {
return properties;
}
@Override
public Domain getParent() {
return null;
}
};
rules = getRules();
NodeList artifactNodes = getNodes("repository/artifacts/artifact");
for (int i = 0; i < artifactNodes.getLength(); i++) {
final Node artifactNode = artifactNodes.item(i).cloneNode(true);
final XMLArtifact xmlArtifact = getFromType(artifactNode, XMLArtifact.class);
final Map<String, String> map = Converter.cnv(new TypeReference<Map<String, String>>() {
}, xmlArtifact);
if ("osgi.bundle".equals(xmlArtifact.classifier)) {
Domain domain = new Domain() {
@Override
public Map<String, String> getMap() {
return map;
}
@Override
public Domain getParent() {
return parent;
}
};
ReplacerAdapter ra = new ReplacerAdapter(domain);
for (Rule r : rules) {
if (r.matches(map)) {
String s = ra.process(r.output);
URI uri = new URI(s).normalize();
Artifact artifact = new Artifact();
artifact.uri = uri;
artifact.id = xmlArtifact.id;
artifact.version = new Version(xmlArtifact.version);
artifact.md5 = getProperties(artifactNode, "properties/property").get("download.md5");
artifacts.add(artifact);
break;
}
}
}
}
}
use of org.osgi.framework.Version in project Lucee by lucee.
the class OSGiUtil method toPackageDefinition.
private static PackageDefinition toPackageDefinition(String str, String filterPackageName, List<VersionDefinition> versionDefinitions) {
// first part is the package
StringList list = ListUtil.toList(str, ';');
PackageDefinition pd = null;
String token;
Version v;
while (list.hasNext()) {
token = list.next().trim();
if (pd == null) {
if (!token.equals(filterPackageName))
return null;
pd = new PackageDefinition(token);
} else // only intressted in version
{
StringList entry = ListUtil.toList(token, '=');
if (entry.size() == 2 && entry.next().trim().equalsIgnoreCase("version")) {
String version = StringUtil.unwrap(entry.next().trim());
if (!version.equals("0.0.0")) {
v = OSGiUtil.toVersion(version, null);
if (v != null) {
if (versionDefinitions != null) {
Iterator<VersionDefinition> it = versionDefinitions.iterator();
while (it.hasNext()) {
if (!it.next().matches(v)) {
return null;
}
}
}
pd.setVersion(v);
}
}
}
}
}
return pd;
}
use of org.osgi.framework.Version in project Lucee by lucee.
the class OSGiUtil method toVersion.
public static Version toVersion(String version, Version defaultValue) {
if (StringUtil.isEmpty(version))
return defaultValue;
// String[] arr = ListUtil.listToStringArray(version, '.');
String[] arr;
try {
arr = ListUtil.toStringArrayTrim(ListUtil.listToArray(version.trim(), '.'));
} catch (PageException e) {
// should not happen
return defaultValue;
}
Integer major, minor, micro;
String qualifier;
if (arr.length == 1) {
major = Caster.toInteger(arr[0], null);
minor = 0;
micro = 0;
qualifier = null;
} else if (arr.length == 2) {
major = Caster.toInteger(arr[0], null);
minor = Caster.toInteger(arr[1], null);
micro = 0;
qualifier = null;
} else if (arr.length == 3) {
major = Caster.toInteger(arr[0], null);
minor = Caster.toInteger(arr[1], null);
micro = Caster.toInteger(arr[2], null);
qualifier = null;
} else {
major = Caster.toInteger(arr[0], null);
minor = Caster.toInteger(arr[1], null);
micro = Caster.toInteger(arr[2], null);
qualifier = arr[3];
}
if (major == null || minor == null || micro == null)
return defaultValue;
if (qualifier == null)
return new Version(major, minor, micro);
return new Version(major, minor, micro, qualifier);
}
use of org.osgi.framework.Version in project Lucee by lucee.
the class Admin method doChangeVersionTo.
private void doChangeVersionTo() throws PageException {
try {
Version version = OSGiUtil.toVersion(getString("admin", "changeVersionTo", "version"));
admin.changeVersionTo(version, password, // ,pageContext.getConfig().getLog("Application")
pageContext.getConfig().getIdentification());
adminSync.broadcast(attributes, config);
} catch (BundleException e) {
throw Caster.toPageException(e);
}
}
Aggregations