public void setTarget(OWLEntity target) { currentTarget = target; UserId userId = Application.get().getUserId(); view.setPostNewTopicEnabled(currentTarget != null && !userId.isGuest()); view.setPostNewTopicHandler(new PostNewTopicHandlerImpl(Optional.fromNullable(currentTarget))); reload(); }
/** * Gets the userId for the signed in client that is associated with the current thread local * request. local request does not have a signed in user associated with it. * * @return The {@link UserId} of the signed in user associated with the thread local request. * @throws NotSignedInException if there is not a signed in user associated with the thread local * request. */ public UserId getUserInSessionAndEnsureSignedIn() throws NotSignedInException { UserId userId = getUserInSession(); if (userId.isGuest()) { throw new NotSignedInException(); } else { return userId; } }
/** * Detemines if the signed in user is the owner of the specified project * * @param projectId The project id * @return <code>true</code> if the project exists AND there is a user signed in AND the signed in * user is the owner of the project, otherwise <code>false</code>. */ protected boolean isSignedInUserProjectOwner(ProjectId projectId) { UserId userId = getUserInSession(); if (userId.isGuest()) { return false; } MetaProjectManager mpm = getMetaProjectManager(); MetaProject metaProject = mpm.getMetaProject(); ProjectInstance project = metaProject.getProject(projectId.getId()); if (project == null) { return false; } User owner = project.getOwner(); return owner != null && userId.getUserName().equals(owner.getName()); }
/** * Determines if the signed in user is an admin. * * @return <code>true</code> if there is a user signed in AND the signed in user corresponds to a * user which exists where that user is an admin, otherwise <code>false</code> */ protected boolean isSignedInUserAdmin() { UserId userId = getUserInSession(); if (userId.isGuest()) { return false; } MetaProjectManager mpm = getMetaProjectManager(); MetaProject metaProject = mpm.getMetaProject(); User user = metaProject.getUser(userId.getUserName()); if (user == null) { return false; } for (Group group : user.getGroups()) { if (OntologyShareAccessConstants.ADMIN_GROUP.equals(group.getName())) { return true; } } return false; }