Search in sources :

Example 1 with RevisionUpdated

use of org.bimserver.models.log.RevisionUpdated in project BIMserver by opensourceBIM.

the class UpdateRevisionDatabaseAction method execute.

@Override
public Void execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
    User actingUser = getUserByUoid(authorization.getUoid());
    final Revision revision = getRevisionByRoid(sRevision.getOid());
    if (revision == null) {
        throw new UserException("Revision with pid " + sRevision.getOid() + " not found");
    }
    Project project = revision.getProject();
    if (!authorization.hasRightsOnProjectOrSuperProjects(actingUser, project)) {
        throw new UserException("User has no rights to update project properties");
    }
    final RevisionUpdated revisionUpdated = getDatabaseSession().create(RevisionUpdated.class);
    revisionUpdated.setRevision(revision);
    revisionUpdated.setDate(new Date());
    revisionUpdated.setExecutor(actingUser);
    revisionUpdated.setAccessMethod(getAccessMethod());
    getDatabaseSession().addPostCommitAction(new PostCommitAction() {

        @Override
        public void execute() throws UserException {
            bimServer.getNotificationsManager().notify(new SConverter().convertToSObject(revisionUpdated));
        }
    });
    revision.setTag(sRevision.getTag());
    getDatabaseSession().store(revision);
    return null;
}
Also used : Project(org.bimserver.models.store.Project) RevisionUpdated(org.bimserver.models.log.RevisionUpdated) User(org.bimserver.models.store.User) SRevision(org.bimserver.interfaces.objects.SRevision) Revision(org.bimserver.models.store.Revision) SConverter(org.bimserver.interfaces.SConverter) PostCommitAction(org.bimserver.database.PostCommitAction) UserException(org.bimserver.shared.exceptions.UserException) Date(java.util.Date)

Aggregations

Date (java.util.Date)1 PostCommitAction (org.bimserver.database.PostCommitAction)1 SConverter (org.bimserver.interfaces.SConverter)1 SRevision (org.bimserver.interfaces.objects.SRevision)1 RevisionUpdated (org.bimserver.models.log.RevisionUpdated)1 Project (org.bimserver.models.store.Project)1 Revision (org.bimserver.models.store.Revision)1 User (org.bimserver.models.store.User)1 UserException (org.bimserver.shared.exceptions.UserException)1