use of org.bimserver.models.log.ProjectDeleted in project BIMserver by opensourceBIM.
the class DeleteProjectDatabaseAction method execute.
@Override
public Boolean execute() throws UserException, BimserverDatabaseException, BimserverLockConflictException {
User actingUser = getUserByUoid(authorization.getUoid());
final Project project = getProjectByPoid(poid);
if (actingUser.getUserType() == UserType.ADMIN || (actingUser.getHasRightsOn().contains(project) && bimServer.getServerSettingsCache().getServerSettings().isAllowUsersToCreateTopLevelProjects())) {
delete(project);
final ProjectDeleted projectDeleted = getDatabaseSession().create(ProjectDeleted.class);
projectDeleted.setAccessMethod(getAccessMethod());
projectDeleted.setDate(new Date());
projectDeleted.setExecutor(actingUser);
projectDeleted.setProject(project);
getDatabaseSession().addPostCommitAction(new PostCommitAction() {
@Override
public void execute() throws UserException {
bimServer.getNotificationsManager().notify(new SConverter().convertToSObject(projectDeleted));
}
});
getDatabaseSession().store(project);
return true;
} else {
throw new UserException("No rights to delete this project");
}
}
Aggregations