Search in sources :

Example 1 with MavenPluginLocation

use of org.bimserver.plugins.MavenPluginLocation in project BIMserver by opensourceBIM.

the class GetPluginBundle method execute.

@Override
public SPluginBundle execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException, ServerException {
    if (bimServer.getVersionChecker() != null && bimServer.getVersionChecker().getLocalVersion() != null) {
        bimserverVersion = new DefaultArtifactVersion(bimServer.getVersionChecker().getLocalVersion().getFullString());
    }
    MavenPluginLocation pluginLocation = bimServer.getMavenPluginRepository().getPluginLocation(repository, groupId, artifactId);
    PluginBundle pluginBundle = bimServer.getPluginManager().getPluginBundle(pluginLocation.getPluginIdentifier());
    // Skipping all plugin bundles that already have an installed version
    if (pluginBundle == null) {
        SPluginBundle sPluginBundle = processPluginLocation(pluginLocation, false, bimserverVersion);
        if (sPluginBundle != null) {
            return sPluginBundle;
        }
    }
    throw new UserException("Plugin bundle already installed " + groupId + "." + artifactId);
}
Also used : PluginBundle(org.bimserver.plugins.PluginBundle) SPluginBundle(org.bimserver.interfaces.objects.SPluginBundle) MavenPluginLocation(org.bimserver.plugins.MavenPluginLocation) DefaultArtifactVersion(org.apache.maven.artifact.versioning.DefaultArtifactVersion) SPluginBundle(org.bimserver.interfaces.objects.SPluginBundle) UserException(org.bimserver.shared.exceptions.UserException)

Example 2 with MavenPluginLocation

use of org.bimserver.plugins.MavenPluginLocation in project BIMserver by opensourceBIM.

the class InstallPluginBundle method execute.

@Override
public Void execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException, ServerException {
    LOGGER.info("Installing plugin " + repository + " " + groupId + "." + artifactId + "." + version);
    MavenPluginLocation mavenPluginLocation = bimServer.getMavenPluginRepository().getPluginLocation(repository, groupId, artifactId);
    if (version == null) {
        String latestVersion = mavenPluginLocation.getLatestVersionString();
        LOGGER.info("Using version " + latestVersion + " because no version given");
        version = latestVersion;
    }
    try {
        LOGGER.info(mavenPluginLocation.getRepository(version));
    } catch (Exception e1) {
        e1.printStackTrace();
    }
    MavenPluginBundle mavenPluginBundle = mavenPluginLocation.getMavenPluginBundle(version);
    LOGGER.info(mavenPluginBundle.getVersion());
    try {
        bimServer.getPluginManager().install(mavenPluginBundle, plugins, false);
    } catch (Exception e) {
        LOGGER.error("", e);
        throw new UserException(e);
    }
    return null;
}
Also used : MavenPluginLocation(org.bimserver.plugins.MavenPluginLocation) MavenPluginBundle(org.bimserver.plugins.MavenPluginBundle) UserException(org.bimserver.shared.exceptions.UserException) BimserverLockConflictException(org.bimserver.database.BimserverLockConflictException) UserException(org.bimserver.shared.exceptions.UserException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException)

Example 3 with MavenPluginLocation

use of org.bimserver.plugins.MavenPluginLocation in project BIMserver by opensourceBIM.

the class UpdatePluginBundle method execute.

@Override
public Void execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException, ServerException {
    MavenPluginLocation mavenPluginLocation = bimServer.getMavenPluginRepository().getPluginLocation(repository, groupId, artifactId);
    try {
        Path jarFile = mavenPluginLocation.getVersionJar(version);
        Path pomFile = mavenPluginLocation.getVersionPom(version);
        try {
            List<SPluginInformation> plugins = null;
            try {
                plugins = bimServer.getPluginManager().getPluginInformationFromPluginFile(new ByteArrayInputStream(mavenPluginLocation.getVersionPluginXml(version)));
            } catch (ArtifactResolutionException e) {
                plugins = bimServer.getPluginManager().getPluginInformationFromJar(jarFile);
            }
            // IfcModelInterface allOfType = getDatabaseSession().getAllOfType(StorePackage.eINSTANCE.getPluginDescriptor(), OldQuery.getDefault());
            // for (SPluginInformation sPluginInformation : plugins) {
            // update plugin information with data from potentially existing plugins
            // }
            bimServer.getPluginManager().update(mavenPluginLocation.getPluginVersionIdentifier(version), mavenPluginLocation.getPluginBundle(version), mavenPluginLocation.getPluginBundleVersion(version), jarFile, pomFile, plugins);
        } catch (Exception e) {
            throw new UserException(e);
        }
    } catch (Exception e) {
        LOGGER.error("", e);
        throw new UserException(e);
    }
    return null;
}
Also used : Path(java.nio.file.Path) ArtifactResolutionException(org.eclipse.aether.resolution.ArtifactResolutionException) MavenPluginLocation(org.bimserver.plugins.MavenPluginLocation) ByteArrayInputStream(java.io.ByteArrayInputStream) SPluginInformation(org.bimserver.interfaces.objects.SPluginInformation) UserException(org.bimserver.shared.exceptions.UserException) BimserverLockConflictException(org.bimserver.database.BimserverLockConflictException) UserException(org.bimserver.shared.exceptions.UserException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) ArtifactResolutionException(org.eclipse.aether.resolution.ArtifactResolutionException)

Aggregations

MavenPluginLocation (org.bimserver.plugins.MavenPluginLocation)3 UserException (org.bimserver.shared.exceptions.UserException)3 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)2 BimserverLockConflictException (org.bimserver.database.BimserverLockConflictException)2 ServerException (org.bimserver.shared.exceptions.ServerException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Path (java.nio.file.Path)1 DefaultArtifactVersion (org.apache.maven.artifact.versioning.DefaultArtifactVersion)1 SPluginBundle (org.bimserver.interfaces.objects.SPluginBundle)1 SPluginInformation (org.bimserver.interfaces.objects.SPluginInformation)1 MavenPluginBundle (org.bimserver.plugins.MavenPluginBundle)1 PluginBundle (org.bimserver.plugins.PluginBundle)1 ArtifactResolutionException (org.eclipse.aether.resolution.ArtifactResolutionException)1