Search in sources :

Example 1 with UploadFileDatabaseAction

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

the class ServiceImpl method uploadFile.

@Override
public Long uploadFile(SFile file) throws ServerException, UserException {
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        File convertFromSObject = getBimServer().getSConverter().convertFromSObject(file, session.create(File.class), session);
        UploadFileDatabaseAction action = new UploadFileDatabaseAction(session, getInternalAccessMethod(), convertFromSObject);
        return session.executeAndCommitAction(action);
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : DatabaseSession(org.bimserver.database.DatabaseSession) File(org.bimserver.models.store.File) SFile(org.bimserver.interfaces.objects.SFile) BcfFile(org.opensourcebim.bcf.BcfFile) IOException(java.io.IOException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) SerializerException(org.bimserver.plugins.serializers.SerializerException) BcfException(org.opensourcebim.bcf.BcfException) UserException(org.bimserver.shared.exceptions.UserException) CannotBeScheduledException(org.bimserver.longaction.CannotBeScheduledException) DeserializeException(org.bimserver.plugins.deserializers.DeserializeException) ServerException(org.bimserver.shared.exceptions.ServerException) MessagingException(javax.mail.MessagingException) AddressException(javax.mail.internet.AddressException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException) UploadFileDatabaseAction(org.bimserver.database.actions.UploadFileDatabaseAction)

Aggregations

IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MalformedURLException (java.net.MalformedURLException)1 MessagingException (javax.mail.MessagingException)1 AddressException (javax.mail.internet.AddressException)1 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)1 DatabaseSession (org.bimserver.database.DatabaseSession)1 UploadFileDatabaseAction (org.bimserver.database.actions.UploadFileDatabaseAction)1 SFile (org.bimserver.interfaces.objects.SFile)1 CannotBeScheduledException (org.bimserver.longaction.CannotBeScheduledException)1 File (org.bimserver.models.store.File)1 DeserializeException (org.bimserver.plugins.deserializers.DeserializeException)1 SerializerException (org.bimserver.plugins.serializers.SerializerException)1 ServerException (org.bimserver.shared.exceptions.ServerException)1 UserException (org.bimserver.shared.exceptions.UserException)1 BcfException (org.opensourcebim.bcf.BcfException)1 BcfFile (org.opensourcebim.bcf.BcfFile)1