コード例 #1
0
 /**
  * Adds a new project to the metaproject. This sets up the name of the project and the description
  * of the project in the metaproject. (Location is not set/used by this implementation - not all
  * implementations use pprj files anymore).
  *
  * @param newProjectSettings The info about the new project
  */
 private void addProjectToMetaProject(ProjectId projectId, NewProjectSettings newProjectSettings) {
   MetaProject mp = getMetaProject();
   ProjectInstance pi = mp.createProject(projectId.getId());
   pi.setDescription(newProjectSettings.getProjectDescription());
   final Instance protegeInstance = pi.getProtegeInstance();
   final KnowledgeBase kb = protegeInstance.getKnowledgeBase();
   final Slot displayNameSlot = kb.getSlot("displayName");
   protegeInstance.setOwnSlotValue(displayNameSlot, newProjectSettings.getDisplayName());
   User user = mp.getUser(newProjectSettings.getProjectOwner().getUserName());
   pi.setOwner(user);
   OWLAPIMetaProjectStore.getStore().saveMetaProject(this);
 }
コード例 #2
0
 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()));
 }
コード例 #3
0
 /**
  * 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;
 }