Search in sources :

Example 31 with ServerException

use of org.bimserver.shared.exceptions.ServerException in project BIMserver by opensourceBIM.

the class ServiceImpl method getFileMeta.

@Override
public SFile getFileMeta(Long fileId) throws ServerException, UserException {
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        org.bimserver.models.store.File file = (org.bimserver.models.store.File) session.get(StorePackage.eINSTANCE.getFile(), fileId, OldQuery.getDefault());
        file.setData(null);
        return getBimServer().getSConverter().convertToSObject(file);
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : DatabaseSession(org.bimserver.database.DatabaseSession) File(org.bimserver.models.store.File) 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)

Example 32 with ServerException

use of org.bimserver.shared.exceptions.ServerException in project BIMserver by opensourceBIM.

the class ServiceImpl method getAllAuthorizedUsersOfProject.

@Override
public List<SUser> getAllAuthorizedUsersOfProject(Long poid) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        BimDatabaseAction<Set<User>> action = new GetAllAuthorizedUsersOfProjectDatabaseAction(session, getInternalAccessMethod(), poid);
        return new ArrayList<SUser>(getBimServer().getSConverter().convertToSSetUser(session.executeAndCommitAction(action)));
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) DatabaseSession(org.bimserver.database.DatabaseSession) GetAllAuthorizedUsersOfProjectDatabaseAction(org.bimserver.database.actions.GetAllAuthorizedUsersOfProjectDatabaseAction) ArrayList(java.util.ArrayList) 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)

Example 33 with ServerException

use of org.bimserver.shared.exceptions.ServerException in project BIMserver by opensourceBIM.

the class ServiceImpl method getAllProjects.

@Override
public List<SProject> getAllProjects(Boolean onlyTopLevel, Boolean onlyActive) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        BimDatabaseAction<Set<Project>> action = new GetAllProjectsDatabaseAction(session, getInternalAccessMethod(), onlyTopLevel, onlyActive, getAuthorization());
        List<SProject> convertToSListProject = getBimServer().getSConverter().convertToSListProject(session.executeAndCommitAction(action));
        Collections.sort(convertToSListProject, new SProjectComparator());
        return convertToSListProject;
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : SProjectComparator(org.bimserver.webservices.SProjectComparator) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) DatabaseSession(org.bimserver.database.DatabaseSession) GetAllProjectsDatabaseAction(org.bimserver.database.actions.GetAllProjectsDatabaseAction) SProject(org.bimserver.interfaces.objects.SProject) 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)

Example 34 with ServerException

use of org.bimserver.shared.exceptions.ServerException in project BIMserver by opensourceBIM.

the class ServiceImpl method deleteUser.

@Override
public Boolean deleteUser(Long uoid) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        BimDatabaseAction<Boolean> action = new DeleteUserDatabaseAction(session, getInternalAccessMethod(), getAuthorization(), uoid);
        return session.executeAndCommitAction(action);
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : DatabaseSession(org.bimserver.database.DatabaseSession) DeleteUserDatabaseAction(org.bimserver.database.actions.DeleteUserDatabaseAction) 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)

Example 35 with ServerException

use of org.bimserver.shared.exceptions.ServerException in project BIMserver by opensourceBIM.

the class ServiceImpl method getSuggestedDeserializerForExtension.

@Override
public SDeserializerPluginConfiguration getSuggestedDeserializerForExtension(String extension, Long poid) throws ServerException, UserException {
    // Token authenticated users should also be able to call this method
    try {
        requireAuthenticationAndRunningServer();
        DatabaseSession session = getBimServer().getDatabase().createSession();
        List<DeserializerPluginConfiguration> list = new ArrayList<>();
        try {
            Project project = session.get(poid, OldQuery.getDefault());
            UserSettings userSettings = getUserSettings(session);
            for (DeserializerPluginConfiguration deserializer : userSettings.getDeserializers()) {
                Plugin plugin = getBimServer().getPluginManager().getPlugin(deserializer.getPluginDescriptor().getIdentifier(), true);
                if (plugin instanceof DeserializerPlugin) {
                    DeserializerPlugin deserializerPlugin = (DeserializerPlugin) plugin;
                    if (deserializerPlugin.getSupportedSchemas().contains(Schema.valueOf(project.getSchema().toUpperCase()))) {
                        if (deserializerPlugin.canHandleExtension(extension)) {
                            list.add(deserializer);
                        }
                    }
                } else if (plugin instanceof StreamingDeserializerPlugin) {
                    StreamingDeserializerPlugin streamingDeserializerPlugin = (StreamingDeserializerPlugin) plugin;
                    if (streamingDeserializerPlugin.getSupportedSchemas().contains(Schema.valueOf(project.getSchema().toUpperCase()))) {
                        if (streamingDeserializerPlugin.canHandleExtension(extension)) {
                            list.add(deserializer);
                        }
                    }
                }
            }
        } finally {
            session.close();
        }
        if (list.size() == 1) {
            return getBimServer().getSConverter().convertToSObject(list.get(0));
        } else if (list.size() > 1) {
            for (DeserializerPluginConfiguration deserializerPluginConfiguration : list) {
                Plugin plugin = getBimServer().getPluginManager().getPlugin(deserializerPluginConfiguration.getPluginDescriptor().getIdentifier(), true);
                // Prefer the streaming version
                if (plugin instanceof StreamingDeserializerPlugin) {
                    return getBimServer().getSConverter().convertToSObject(deserializerPluginConfiguration);
                }
            }
            // Just return the first one
            return getBimServer().getSConverter().convertToSObject(list.get(0));
        }
    } catch (Exception e) {
        return handleException(e);
    }
    return null;
}
Also used : Project(org.bimserver.models.store.Project) SProject(org.bimserver.interfaces.objects.SProject) DatabaseSession(org.bimserver.database.DatabaseSession) UserSettings(org.bimserver.models.store.UserSettings) SUserSettings(org.bimserver.interfaces.objects.SUserSettings) StreamingDeserializerPlugin(org.bimserver.plugins.deserializers.StreamingDeserializerPlugin) ArrayList(java.util.ArrayList) StreamingDeserializerPlugin(org.bimserver.plugins.deserializers.StreamingDeserializerPlugin) DeserializerPlugin(org.bimserver.plugins.deserializers.DeserializerPlugin) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) DeserializerPluginConfiguration(org.bimserver.models.store.DeserializerPluginConfiguration) 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) StreamingSerializerPlugin(org.bimserver.plugins.serializers.StreamingSerializerPlugin) QueryEnginePlugin(org.bimserver.plugins.queryengine.QueryEnginePlugin) MessagingSerializerPlugin(org.bimserver.plugins.serializers.MessagingSerializerPlugin) StreamingDeserializerPlugin(org.bimserver.plugins.deserializers.StreamingDeserializerPlugin) DeserializerPlugin(org.bimserver.plugins.deserializers.DeserializerPlugin) MessagingStreamingSerializerPlugin(org.bimserver.plugins.serializers.MessagingStreamingSerializerPlugin) SerializerPlugin(org.bimserver.plugins.serializers.SerializerPlugin) Plugin(org.bimserver.plugins.Plugin)

Aggregations

ServerException (org.bimserver.shared.exceptions.ServerException)253 UserException (org.bimserver.shared.exceptions.UserException)250 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)224 DatabaseSession (org.bimserver.database.DatabaseSession)215 IOException (java.io.IOException)212 SerializerException (org.bimserver.plugins.serializers.SerializerException)111 DeserializeException (org.bimserver.plugins.deserializers.DeserializeException)110 MalformedURLException (java.net.MalformedURLException)109 BcfException (org.opensourcebim.bcf.BcfException)109 UnsupportedEncodingException (java.io.UnsupportedEncodingException)108 MessagingException (javax.mail.MessagingException)108 AddressException (javax.mail.internet.AddressException)108 CannotBeScheduledException (org.bimserver.longaction.CannotBeScheduledException)108 ArrayList (java.util.ArrayList)29 SProject (org.bimserver.interfaces.objects.SProject)26 User (org.bimserver.models.store.User)23 Project (org.bimserver.models.store.Project)20 SUser (org.bimserver.interfaces.objects.SUser)19 UserSettings (org.bimserver.models.store.UserSettings)18 PublicInterfaceNotFoundException (org.bimserver.shared.exceptions.PublicInterfaceNotFoundException)18