/**
  * 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);
 }
 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);
 }
 private static boolean isInTrash(ProjectInstance projectInstance) {
   Instance protegeInstance = projectInstance.getProtegeInstance();
   KnowledgeBase kb = protegeInstance.getKnowledgeBase();
   Slot inTrashSlot = getInTrashSlot(kb);
   Object ownSlotValue = protegeInstance.getOwnSlotValue(inTrashSlot);
   return ownSlotValue != null && ownSlotValue.equals(Boolean.TRUE);
 }
 private boolean isAuthorisedToReadAndList(
     Policy policy, User user, ProjectInstance projectInstance) {
   User owner = projectInstance.getOwner();
   if (isUserOwner(user, owner)) {
     return true;
   }
   return isAuthorisedToDisplayInList(policy, user, projectInstance)
       && isAuthorisedToRead(policy, user, projectInstance);
 }
 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 boolean isWorldAllowedOperation(ProjectInstance projectInstance, Operation operation) {
   for (GroupOperation groupOperation : projectInstance.getAllowedGroupOperations()) {
     Group group = groupOperation.getAllowedGroup();
     String groupName = group.getName();
     if (MetaProjectConstants.USER_WORLD.equals(groupName)) {
       Set<Operation> operations = groupOperation.getAllowedOperations();
       if (operations.contains(operation)) {
         return true;
       }
     }
   }
   return false;
 }