use of org.bimserver.plugins.MavenPluginVersion in project BIMserver by opensourceBIM.
the class PluginBundleDatabaseAction method processMavenPluginLocation.
public SPluginBundle processMavenPluginLocation(MavenPluginLocation mavenPluginLocation, boolean strictVersionChecking, ArtifactVersion bimserverVersion) {
SPluginBundle pluginBundle = new SPluginBundle();
boolean usefulBundle = false;
for (PluginVersion pluginVersion : mavenPluginLocation.getAllVersions()) {
if (pluginVersion instanceof MavenPluginVersion) {
SPluginBundleVersion sPluginBundleVersion = new SPluginBundleVersion();
boolean useful = true;
MavenPluginVersion mavenPluginVersion = (MavenPluginVersion) pluginVersion;
for (MavenDependency mavenDependency : mavenPluginVersion.getDependencies()) {
if (mavenDependency.getArtifact().getGroupId().equals("org.opensourcebim")) {
String artifactId = mavenDependency.getArtifact().getArtifactId();
// for the plugin, it's version has to be ok
if (artifactId.equals("shared") || artifactId.equals("pluginbase")) {
VersionRange versionRange = VersionRange.createFromVersion(mavenDependency.getArtifact().getVersion());
if (bimserverVersion != null && versionRange.containsVersion(bimserverVersion)) {
} else {
sPluginBundleVersion.setMismatch(true);
if (strictVersionChecking) {
useful = false;
LOGGER.info("Skipping version " + mavenPluginVersion.getArtifact().getVersion() + " or artifact " + mavenPluginVersion.getArtifact().getArtifactId());
}
}
}
}
}
if (useful) {
usefulBundle = true;
sPluginBundleVersion.setName(mavenPluginVersion.getModel().getName());
sPluginBundleVersion.setOrganization(mavenPluginVersion.getModel().getOrganization().getName());
sPluginBundleVersion.setArtifactId(mavenPluginLocation.getArtifactId());
sPluginBundleVersion.setGroupId(mavenPluginLocation.getGroupId());
try {
sPluginBundleVersion.setRepository(mavenPluginLocation.getRepository(mavenPluginVersion.getVersion().toString()));
} catch (ArtifactResolutionException e) {
LOGGER.error("", e);
}
sPluginBundleVersion.setType(SPluginBundleType.MAVEN);
sPluginBundleVersion.setVersion(mavenPluginVersion.getVersion().toString());
sPluginBundleVersion.setDescription(mavenPluginVersion.getModel().getDescription());
pluginBundle.setName(mavenPluginVersion.getModel().getName());
pluginBundle.setOrganization(mavenPluginVersion.getModel().getOrganization().getName());
pluginBundle.setLatestVersion(sPluginBundleVersion);
pluginBundle.getAvailableVersions().add(sPluginBundleVersion);
try {
sPluginBundleVersion.setIcon(mavenPluginLocation.getVersionIcon(mavenPluginVersion.getVersion().toString()));
} catch (ArtifactResolutionException e) {
// This is not important
} catch (IOException e) {
LOGGER.error("", e);
}
try {
GregorianCalendar date = mavenPluginLocation.getVersionDate(mavenPluginVersion.getVersion().toString());
if (date != null) {
sPluginBundleVersion.setDate(date.getTime());
}
// byte[] bytes = Files.readAllBytes(date);
// Properties properties = new Properties();
// properties.load(new ByteArrayInputStream(bytes));
// String buildDateString = properties.getProperty("build.date");
//
// DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
// try {
// } catch (ParseException e) {
// LOGGER.error("Invalid date format for plugin " + mavenPluginVersion.getModel().getName() + ": '" + buildDateString + "'");
// }
} catch (ArtifactResolutionException e) {
// Not a problem
} catch (Exception e) {
LOGGER.error("", e);
}
}
}
}
if (usefulBundle) {
return pluginBundle;
}
return null;
}
Aggregations