Search in sources :

Example 1 with InstallPluginBundleFromBytes

use of org.bimserver.database.actions.InstallPluginBundleFromBytes in project BIMserver by opensourceBIM.

the class PluginServiceImpl method installPluginBundleFromUrl.

public void installPluginBundleFromUrl(String url, Boolean installAllPluginsForAllUsers, Boolean installAllPluginsForNewUsers) throws UserException, ServerException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.POSSIBLY_WRITE);
    try {
        byte[] data = NetUtils.getContentAsBytes(new URL(url), 5000);
        session.executeAndCommitAction(new InstallPluginBundleFromBytes(session, getInternalAccessMethod(), getBimServer(), data, installAllPluginsForAllUsers, installAllPluginsForNewUsers));
    } catch (Exception e) {
        handleException(e);
    } finally {
        session.close();
    }
}
Also used : DatabaseSession(org.bimserver.database.DatabaseSession) URL(java.net.URL) InstallPluginBundleFromBytes(org.bimserver.database.actions.InstallPluginBundleFromBytes) UserException(org.bimserver.shared.exceptions.UserException) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException)

Example 2 with InstallPluginBundleFromBytes

use of org.bimserver.database.actions.InstallPluginBundleFromBytes in project BIMserver by opensourceBIM.

the class PluginServiceImpl method installPluginBundleFromFile.

public void installPluginBundleFromFile(DataHandler file, Boolean installAllPluginsForAllUsers, Boolean installAllPluginsForNewUsers) throws UserException, ServerException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.POSSIBLY_WRITE);
    try {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        IOUtils.copy(file.getInputStream(), byteArrayOutputStream);
        session.executeAndCommitAction(new InstallPluginBundleFromBytes(session, getInternalAccessMethod(), getBimServer(), byteArrayOutputStream.toByteArray(), installAllPluginsForAllUsers, installAllPluginsForNewUsers));
    } catch (Exception e) {
        handleException(e);
    } finally {
        session.close();
    }
}
Also used : DatabaseSession(org.bimserver.database.DatabaseSession) ByteArrayOutputStream(java.io.ByteArrayOutputStream) InstallPluginBundleFromBytes(org.bimserver.database.actions.InstallPluginBundleFromBytes) UserException(org.bimserver.shared.exceptions.UserException) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException)

Aggregations

IOException (java.io.IOException)2 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)2 DatabaseSession (org.bimserver.database.DatabaseSession)2 InstallPluginBundleFromBytes (org.bimserver.database.actions.InstallPluginBundleFromBytes)2 ServerException (org.bimserver.shared.exceptions.ServerException)2 UserException (org.bimserver.shared.exceptions.UserException)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 URL (java.net.URL)1