use of org.bimserver.models.log.ProjectUndeleted in project BIMserver by opensourceBIM.
the class UndeleteProjectDatabaseAction method execute.
@Override
public Boolean execute() throws UserException, BimserverDatabaseException, BimserverLockConflictException {
User actingUser = getUserByUoid(authorization.getUoid());
final Project project = getProjectByPoid(poid);
if (project == null) {
throw new UserException("No Project with oid " + poid + " found");
}
if (actingUser.getUserType() == UserType.ADMIN || actingUser.getHasRightsOn().contains(project)) {
project.setState(ObjectState.ACTIVE);
final ProjectUndeleted projectUndeleted = getDatabaseSession().create(ProjectUndeleted.class);
projectUndeleted.setAccessMethod(getAccessMethod());
projectUndeleted.setDate(new Date());
projectUndeleted.setExecutor(actingUser);
projectUndeleted.setProject(project);
getDatabaseSession().addPostCommitAction(new PostCommitAction() {
@Override
public void execute() throws UserException {
bimServer.getNotificationsManager().notify(new SConverter().convertToSObject(projectUndeleted));
}
});
getDatabaseSession().store(project);
return true;
} else {
throw new UserException("No rights to undelete this project");
}
}
Aggregations