Search in sources :

Example 1 with ProgressOnProjectTopic

use of org.bimserver.notifications.ProgressOnProjectTopic in project BIMserver by opensourceBIM.

the class ServiceImpl method regenerateGeometry.

@Override
public Long regenerateGeometry(Long roid, Long eoid) throws ServerException, UserException {
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        Revision revision = session.get(roid, OldQuery.getDefault());
        SUser user = getCurrentUser();
        ProgressOnProjectTopic progressTopic = getBimServer().getNotificationsManager().createProgressOnProjectTopic(getAuthorization().getUoid(), revision.getProject().getOid(), SProgressTopicType.UPLOAD, "Regenerate geometry");
        RegenerateGeometryDatabaseAction action = new RegenerateGeometryDatabaseAction(getBimServer(), session, getInternalAccessMethod(), revision.getProject().getOid(), roid, getCurrentUser().getOid(), eoid);
        LongGenericAction longAction = new LongGenericAction(progressTopic.getKey().getId(), getBimServer(), user.getUsername(), user.getName(), getAuthorization(), action);
        getBimServer().getLongActionManager().start(longAction);
        return progressTopic.getKey().getId();
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : RegenerateGeometryDatabaseAction(org.bimserver.database.actions.RegenerateGeometryDatabaseAction) ProgressOnProjectTopic(org.bimserver.notifications.ProgressOnProjectTopic) SRevision(org.bimserver.interfaces.objects.SRevision) Revision(org.bimserver.models.store.Revision) CheckinRevision(org.bimserver.models.store.CheckinRevision) SExtendedDataAddedToRevision(org.bimserver.interfaces.objects.SExtendedDataAddedToRevision) DatabaseSession(org.bimserver.database.DatabaseSession) SUser(org.bimserver.interfaces.objects.SUser) 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) LongGenericAction(org.bimserver.longaction.LongGenericAction)

Example 2 with ProgressOnProjectTopic

use of org.bimserver.notifications.ProgressOnProjectTopic in project BIMserver by opensourceBIM.

the class ServiceImpl method initiateCheckin.

@Override
public Long initiateCheckin(Long poid, Long deserializerOid) throws ServerException, UserException {
    requireAuthenticationAndRunningServer();
    final DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        User user = (User) session.get(StorePackage.eINSTANCE.getUser(), getAuthorization().getUoid(), OldQuery.getDefault());
        Project project = session.get(poid, OldQuery.getDefault());
        if (!getAuthorization().hasRightsOnProjectOrSuperProjects(user, project)) {
            throw new UserException("User has no rights to checkin models to this project");
        }
        if (!MailSystem.isValidEmailAddress(user.getUsername())) {
            throw new UserException("Users must have a valid e-mail address to checkin");
        }
        if (project == null) {
            throw new UserException("No project found with poid " + poid);
        }
        ProgressOnProjectTopic progressTopic = getBimServer().getNotificationsManager().createProgressOnProjectTopic(getAuthorization().getUoid(), poid, SProgressTopicType.UPLOAD, "Checkin");
        return progressTopic.getKey().getId();
    } catch (UserException e) {
        throw e;
    } catch (Throwable e) {
        LOGGER.error("", e);
        throw new ServerException(e);
    } finally {
        session.close();
    }
}
Also used : Project(org.bimserver.models.store.Project) SProject(org.bimserver.interfaces.objects.SProject) ProgressOnProjectTopic(org.bimserver.notifications.ProgressOnProjectTopic) SUser(org.bimserver.interfaces.objects.SUser) User(org.bimserver.models.store.User) ServerException(org.bimserver.shared.exceptions.ServerException) DatabaseSession(org.bimserver.database.DatabaseSession) UserException(org.bimserver.shared.exceptions.UserException)

Aggregations

DatabaseSession (org.bimserver.database.DatabaseSession)2 SUser (org.bimserver.interfaces.objects.SUser)2 ProgressOnProjectTopic (org.bimserver.notifications.ProgressOnProjectTopic)2 ServerException (org.bimserver.shared.exceptions.ServerException)2 UserException (org.bimserver.shared.exceptions.UserException)2 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 RegenerateGeometryDatabaseAction (org.bimserver.database.actions.RegenerateGeometryDatabaseAction)1 SExtendedDataAddedToRevision (org.bimserver.interfaces.objects.SExtendedDataAddedToRevision)1 SProject (org.bimserver.interfaces.objects.SProject)1 SRevision (org.bimserver.interfaces.objects.SRevision)1 CannotBeScheduledException (org.bimserver.longaction.CannotBeScheduledException)1 LongGenericAction (org.bimserver.longaction.LongGenericAction)1 CheckinRevision (org.bimserver.models.store.CheckinRevision)1 Project (org.bimserver.models.store.Project)1 Revision (org.bimserver.models.store.Revision)1