use of org.bimserver.plugins.GitHubPluginRepository in project BIMserver by opensourceBIM.
the class GetAvailablePluginBundles method execute.
@Override
public List<SPluginBundle> execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException, ServerException {
List<SPluginBundle> result = new ArrayList<>();
GitHubPluginRepository repository = new GitHubPluginRepository(bimServer.getMavenPluginRepository(), bimServer.getServerSettingsCache().getServerSettings().getServiceRepositoryUrl());
bimserverVersion = new DefaultArtifactVersion(bimServer.getVersionChecker().getLocalVersion().getFullString());
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(32, 32, 1L, TimeUnit.HOURS, new ArrayBlockingQueue<>(100));
for (PluginLocation<?> pluginLocation : repository.listPluginLocations()) {
PluginBundle pluginBundle = bimServer.getPluginManager().getPluginBundle(pluginLocation.getPluginIdentifier());
// Skipping all plugin bundles that already have an installed version
if (pluginBundle == null) {
threadPoolExecutor.submit(new Runnable() {
@Override
public void run() {
SPluginBundle sPluginBundle = processPluginLocation(pluginLocation, strictVersionChecking, bimserverVersion);
if (sPluginBundle != null) {
result.add(sPluginBundle);
}
}
});
}
}
threadPoolExecutor.shutdown();
try {
threadPoolExecutor.awaitTermination(1, TimeUnit.HOURS);
} catch (InterruptedException e) {
e.printStackTrace();
}
Collections.sort(result, new Comparator<SPluginBundle>() {
@Override
public int compare(SPluginBundle o1, SPluginBundle o2) {
return o1.getName().compareTo(o2.getName());
}
});
return result;
}
use of org.bimserver.plugins.GitHubPluginRepository in project BIMserver by opensourceBIM.
the class GetInstalledPluginBundles method execute.
@Override
public List<SPluginBundle> execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException, ServerException {
List<SPluginBundle> result = new ArrayList<>();
bimserverVersion = new DefaultArtifactVersion(bimServer.getVersionChecker().getLocalVersion().getFullString());
GitHubPluginRepository repository = new GitHubPluginRepository(bimServer.getMavenPluginRepository(), bimServer.getServerSettingsCache().getServerSettings().getServiceRepositoryUrl());
Map<PluginBundleIdentifier, PluginLocation<?>> repositoryKnownLocation = new HashMap<>();
for (PluginLocation<?> pluginLocation : repository.listPluginLocations()) {
repositoryKnownLocation.put(pluginLocation.getPluginIdentifier(), pluginLocation);
}
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(32, 32, 1L, TimeUnit.HOURS, new ArrayBlockingQueue<>(100));
for (PluginBundle pluginBundle : bimServer.getPluginManager().getPluginBundles()) {
SPluginBundleVersion installedVersion = pluginBundle.getPluginBundleVersion();
PluginBundleIdentifier pluginBundleIdentifier = new PluginBundleIdentifier(installedVersion.getGroupId(), installedVersion.getArtifactId());
PluginLocation<?> pluginLocation = repositoryKnownLocation.get(pluginBundleIdentifier);
threadPoolExecutor.submit(new Runnable() {
@Override
public void run() {
SPluginBundle sPluginBundle = processPluginLocation(pluginLocation, strictVersionChecking, bimserverVersion);
if (sPluginBundle == null) {
// No versions found on repository
sPluginBundle = pluginBundle.getPluginBundle();
}
boolean found = false;
for (SPluginBundleVersion sPluginBundleVersion : sPluginBundle.getAvailableVersions()) {
if (sPluginBundleVersion.getVersion().equals(pluginBundle.getPluginBundleVersion().getVersion())) {
found = true;
}
}
if (!found) {
sPluginBundle.getAvailableVersions().add(pluginBundle.getPluginBundleVersion());
}
sPluginBundle.setInstalledVersion(installedVersion);
result.add(sPluginBundle);
}
});
}
threadPoolExecutor.shutdown();
try {
threadPoolExecutor.awaitTermination(1, TimeUnit.HOURS);
} catch (InterruptedException e) {
e.printStackTrace();
}
Collections.sort(result, new Comparator<SPluginBundle>() {
@Override
public int compare(SPluginBundle o1, SPluginBundle o2) {
return o1.getName().compareTo(o2.getName());
}
});
return result;
}
Aggregations