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();
 }
 public UserId getLastModifiedBy(ProjectId projectId) {
   String userName = getPropertyValue(projectId, LAST_MODIFIED_BY_PROPERTY_NAME, null);
   if (userName == null) {
     return UserId.getGuest();
   } else {
     return UserId.getUserId(userName);
   }
 }
 /**
  * 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());
 }
 private static ProjectDetails createProjectDetailsFromProjectInstance(
     ProjectInstance projectInstance) {
   final ProjectId projectId = ProjectId.get(projectInstance.getName());
   final String description = projectInstance.getDescription();
   final User projectOwner = projectInstance.getOwner();
   final UserId ownerId =
       projectOwner != null ? UserId.getUserId(projectOwner.getName()) : UserId.getGuest();
   final boolean inTrash = isInTrash(projectInstance);
   final Slot displayNameSlot =
       projectInstance.getProtegeInstance().getKnowledgeBase().getSlot("displayName");
   final String displayName =
       (String) projectInstance.getProtegeInstance().getOwnSlotValue(displayNameSlot);
   return new ProjectDetails(projectId, displayName, description, ownerId, inTrash);
 }
 @Override
 public int hashCode() {
   return "RevisionSummary".hashCode()
       + revisionNumber.hashCode()
       + userId.hashCode()
       + ((int) timestamp)
       + changeCount;
 }
 /**
  * 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;
 }
 public UserData registerUser(String userName, String email, String password)
     throws UserRegistrationException {
   checkNotNull(userName);
   checkNotNull(email);
   checkNotNull(password);
   User existingUser = metaproject.getUser(userName);
   if (existingUser != null) {
     throw new UserNameAlreadyExistsException(userName);
   }
   for (User user : metaproject.getUsers()) {
     if (email.equals(user.getEmail())) {
       throw new UserEmailAlreadyExistsException(email);
     }
   }
   User newUser = metaproject.createUser(userName, password);
   return AuthenticationUtil.createUserData(UserId.getUserId(newUser.getName()));
 }
 public List<ProjectDetails> getListableReadableProjects(UserId userId) {
   Policy policy = metaproject.getPolicy();
   User user = policy.getUserByName(userId.getUserName());
   List<ProjectDetails> result = new ArrayList<ProjectDetails>();
   for (ProjectInstance projectInstance : metaproject.getProjects()) {
     final String name = projectInstance.getName();
     if (name != null && ProjectId.isWelFormedProjectId(name)) {
       final ProjectId projectId = ProjectId.get(name);
       if (isAuthorisedToReadAndList(policy, user, projectInstance)) {
         OWLAPIProjectDocumentStore ds =
             OWLAPIProjectDocumentStore.getProjectDocumentStore(projectId);
         if (ds.exists()) {
           final ProjectDetails projectDetails =
               createProjectDetailsFromProjectInstance(projectInstance);
           result.add(projectDetails);
         }
       }
     }
   }
   return result;
 }
 private UserId getOwner(ProjectId projectId) {
   ProjectInstance pi = getProjectInstance(projectId);
   User owner = pi.getOwner();
   return UserId.getUserId(owner.getName());
 }