Package org.olat.catalog

Examples of org.olat.catalog.CatalogEntry


  public List<AjaxTreeNode> getChildrenFor(String nodeId) {
    List<AjaxTreeNode> childNodes = new ArrayList<AjaxTreeNode>();
    CatalogManager cm = CatalogManager.getInstance();
    // load node with given id
    Long entryKey = Long.parseLong(nodeId);
    CatalogEntry entry = cm.loadCatalogEntry(entryKey);
    // load children of node and add them to the list
    List<CatalogEntry> childEntries = cm.getChildrenOf(entry);
    for (CatalogEntry childEntry : childEntries) {
      // don't add the to be moved child itself!
      if (toBeMovedEntry != null && toBeMovedEntry.getKey().equals(childEntry.getKey())) {
View Full Code Here


        } else {
          getWindowControl().setWarning(translate("warn.cantlaunch"));
        }
      } else if (polyLink.getLinkType().equals(InstitutionPortlet.TYPE_CATALOG)) {
        try {
          CatalogEntry ce = CatalogManager.getInstance().loadCatalogEntry(resultIDForUser != null ? resultIDForUser : defaultID);
          DTabs dts = (DTabs) getWindowControl().getWindowBackOffice().getWindow().getAttribute("DTabs");
          dts.activateStatic(ureq, RepositorySite.class.getName(), "search.catalog:" + ce.getKey());
        } catch (Exception e) {
          Tracing.createLoggerFor(InstitutionPortletRunController.class).error(e.getMessage());
          getWindowControl().setWarning(translate("warn.cantlaunch"));
        }
      }
View Full Code Here

    cat.appendChild(root);
   
    CatalogManager cm = CatalogManager.getInstance();                            // instanciate catalog manager
    List ces = cm.getRootCatalogEntries();
    for (Iterator it = ces.iterator(); it.hasNext();) {                          // for every root entry (currently only one)
      CatalogEntry ce = (CatalogEntry) it.next();
      getCatalogSubStructure(doc, root, cm, ce);                                // scan this entry
    }
   
    TransformerFactory tranFac = TransformerFactory.newInstance();              // init transfromer to write XML to file
    Transformer t;
View Full Code Here

  private void getCatalogSubStructure(Document doc, Element parent, CatalogManager cm, CatalogEntry ce) {
    Element cur = null;                                                          // tmp. element
    List l = cm.getChildrenOf(ce);                                              // get catalog children
    // all nodes
    for (Iterator it = l.iterator(); it.hasNext();) {                            // scan for node entries
      CatalogEntry c = (CatalogEntry) it.next();
      if (c.getType() == CatalogEntry.TYPE_NODE) {                              // it's a node
       
        Element node = doc.createElement(XML_NODE);                              // node element
        node.setAttribute("name", c.getName());
        parent.appendChild(node);
       
        cur = doc.createElement(XML_DESCR);                                      // description element
        cur.appendChild(doc.createTextNode(c.getDescription()));
        node.appendChild(cur);

        if (cm.getChildrenOf(c).size() > 0) {                                    // children element containing all subentries
          cur = doc.createElement(XML_CHILDREN);
          node.appendChild(cur);
          getCatalogSubStructure(doc, cur, cm, c);                              // recursive scan
        }
       
        cur = doc.createElement(XML_CUSTOM);
        /*
         * Insert custom info here!
         */
        node.appendChild(cur);
       
      }
    }
    // all leafes
    for (Iterator it = l.iterator(); it.hasNext();) {                            // scan for leaf entries
      CatalogEntry c = (CatalogEntry) it.next();
      if (c.getType() == CatalogEntry.TYPE_LEAF) {
        RepositoryEntry re = c.getRepositoryEntry();                            // get repo entry
        if (re.getAccess() > RepositoryEntry.ACC_OWNERS_AUTHORS) {              // just show entries visible for registered users
          Element leaf = doc.createElement(XML_LEAF);                            // leaf element
          leaf.setAttribute("name", c.getName());
          parent.appendChild(leaf);
         
          cur = doc.createElement(XML_DESCR);                                    // description element
          cur.appendChild(doc.createTextNode(c.getDescription()));
          leaf.appendChild(cur);
         
          cur = doc.createElement(XML_TYPE);
          String typeName = re.getOlatResource().getResourceableTypeName();      // add the resource type
          StringOutput typeDisplayText = new StringOutput(100);
View Full Code Here

    super(ureq, wControl, Util.createPackageTranslator(RepositoryManager.class, ureq.getLocale()));
   
    cm = CatalogManager.getInstance();

    List<CatalogEntry> rootNodes = cm.getRootCatalogEntries();
    CatalogEntry rootce;
    if (rootNodes.isEmpty()) throw new AssertException("No RootNodes found for Catalog! failed module init? corrupt DB?");
    rootce = (CatalogEntry) cm.getRootCatalogEntries().get(0);

    // Check AccessRights
    isAuthor = ureq.getUserSession().getRoles().isAuthor();
View Full Code Here

      // - 'navigation path' history
      // - link selectionfires a leaf event
      //
      if (command.startsWith(CATENTRY_CHILD)) { // child clicked
        int pos = Integer.parseInt(command.substring(CATENTRY_CHILD.length()));
        CatalogEntry cur = (CatalogEntry) childCe.get(pos);
        // put new as trail on stack
        historyStack.add(cur);
        updateToolAccessRights(ureq, cur, historyStack.indexOf(cur));
        updateContent(ureq.getIdentity(), cur, historyStack.indexOf(cur));
        fireEvent(ureq, Event.CHANGED_EVENT);
       
      } else if (command.startsWith(CATCMD_HISTORY)) { // history clicked
        int pos = Integer.parseInt(command.substring(CATCMD_HISTORY.length()));
        CatalogEntry cur = historyStack.get(pos);
        historyStack = historyStack.subList(0, pos + 1);
        updateToolAccessRights(ureq, cur, historyStack.indexOf(cur));
        updateContent(ureq.getIdentity(), cur, historyStack.indexOf(cur));
        fireEvent(ureq, Event.CHANGED_EVENT);
       
      } else if (command.startsWith(CATENTRY_LEAF)) { // link clicked
        int pos = Integer.parseInt(command.substring(CATENTRY_LEAF.length()));
        CatalogEntry cur = (CatalogEntry) childCe.get(pos);
        RepositoryEntry repoEntry = cur.getRepositoryEntry();
        if (repoEntry == null) throw new AssertException("a leaf did not have a repositoryentry! catalogEntry = key:" + cur.getKey()
            + ", title " + cur.getName());
        // launch entry if launchable, otherwise offer it as download / launch
        // it as non-html in browser
        String displayName = cur.getName();
        RepositoryHandler handler = RepositoryHandlerFactory.getInstance().getRepositoryHandler(repoEntry);
        OLATResource ores = repoEntry.getOlatResource();
        if (ores == null) throw new AssertException("repoEntry had no olatresource, repoKey = " + repoEntry.getKey());
        if (repoEntry.getCanLaunch()) {
          // we can create a controller and launch
          // it in OLAT, e.g. if it is a
          // content-packacking or a course

          //was brasato:: DTabs dts = getWindowControl().getDTabs();
          DTabs dts = (DTabs)Windows.getWindows(ureq).getWindow(ureq).getAttribute("DTabs");
          DTab dt = dts.getDTab(ores);
          if (dt == null) {
            // does not yet exist -> create and add
            dt = dts.createDTab(ores, displayName);
            if (dt == null) return;
            Controller launchController = ControllerFactory.createLaunchController(ores, null, ureq, dt.getWindowControl(), true);
            dt.setController(launchController);
            dts.addDTab(dt);
          }
          dts.activate(ureq, dt, null); // null: start with main entry point of controller
        } else if (repoEntry.getCanDownload()) {
          // else not launchable in olat, but downloadable -> send the document
          // directly to browser but "downloadable" (pdf, word, excel)
          MediaResource mr = handler.getAsMediaResource(ores);
          RepositoryManager.getInstance().incrementDownloadCounter(repoEntry);
          ureq.getDispatchResult().setResultingMediaResource(mr);
          return;
        } else { // neither launchable nor downloadable -> show details         
          //REVIEW:pb:replace EntryChangedEvent with a more specific event
          fireEvent(ureq, new EntryChangedEvent(repoEntry, EntryChangedEvent.MODIFIED));
          return;
        }

      } else if (command.startsWith(CATCMD_MOVE)) {
        String s = command.substring(CATCMD_MOVE.length());
        if (s.startsWith(CATENTRY_LEAF)) {
          // move a resource in the catalog - moving of catalog leves is triggered by a toolbox action
          int pos = Integer.parseInt(s.substring(CATENTRY_LEAF.length()));
          linkMarkedToBeEdited = (CatalogEntry) childCe.get(pos);
          removeAsListenerAndDispose(catEntryMoveController);
          boolean ajax = getWindowControl().getWindowBackOffice().getWindowManager().isAjaxEnabled();
          if (ajax) {
            // fancy ajax tree
            catEntryMoveController= new CatalogAjaxMoveController(ureq, getWindowControl(), linkMarkedToBeEdited);
          } else {
            // old-school selection tree
            catEntryMoveController= new CatalogEntryMoveController(getWindowControl(), ureq, linkMarkedToBeEdited, getTranslator());
          }
          listenTo(catEntryMoveController);
          removeAsListenerAndDispose(cmc);
          cmc = new CloseableModalController(getWindowControl(), "close", catEntryMoveController.getInitialComponent());
          listenTo(cmc);
          cmc.activate();
        }
      } else if (command.startsWith(CATCMD_REMOVE)) {
        String s = command.substring(CATCMD_REMOVE.length());
        if (s.startsWith(CATENTRY_LEAF)) {
          int pos = Integer.parseInt(s.substring(CATENTRY_LEAF.length()));
          linkMarkedToBeDeleted = (CatalogEntry) childCe.get(pos);
          // create modal dialog
          String[] trnslP = { linkMarkedToBeDeleted.getName() };
          dialogDeleteLink = activateYesNoDialog(ureq, null, getTranslator().translate(NLS_DIALOG_MODAL_LEAF_DELETE_TEXT, trnslP), dialogDeleteLink);
          return;
        }
      } else if (command.startsWith(CATCMD_EDIT)) {
        String s = command.substring(CATCMD_EDIT.length());
        if (s.startsWith(CATENTRY_LEAF)) {
          int pos = Integer.parseInt(s.substring(CATENTRY_LEAF.length()));
          linkMarkedToBeEdited = (CatalogEntry) childCe.get(pos);
          repositoryEditDescriptionController = new RepositoryEditDescriptionController(ureq, getWindowControl(), linkMarkedToBeEdited.getRepositoryEntry(), false);
          repositoryEditDescriptionController.addControllerListener(this);
          // open form in dialog
          removeAsListenerAndDispose(cmc);
          cmc = new CloseableModalController(getWindowControl(), "close", repositoryEditDescriptionController.getInitialComponent(), true, translate("tools.edit.catalog.category"));
          listenTo(cmc);
          cmc.activate();         
        }
      } else if (command.startsWith(CATCMD_DETAIL)) {
        String s = command.substring(CATCMD_DETAIL.length());
        if (s.startsWith(CATENTRY_LEAF)) {
          int pos = Integer.parseInt(s.substring(CATENTRY_LEAF.length()));
          CatalogEntry showDetailForLink = (CatalogEntry) childCe.get(pos);
          RepositoryEntry repoEnt = showDetailForLink.getRepositoryEntry();         
          fireEvent(ureq, new EntryChangedEvent(repoEnt, EntryChangedEvent.MODIFIED));
          //TODO [ingkr]
          //getWindowControl().getDTabs().activateStatic(ureq, RepositorySite.class.getName(), RepositoryMainController.JUMPFROMEXTERN+RepositoryMainController.JUMPFROMCATALOG+repoEnt.getKey().toString());
          return;
        }
      }
    }
    /*
     * login link clicked
     */   
    else if (source == loginLink){
      DispatcherAction.redirectToDefaultDispatcher(ureq.getHttpResp());
    }
    /*
     * add/edit node
     */
    else if (source == addEntryForm) {
      // remove modal dialog
      cmc.deactivate();
      if (event == Form.EVNT_VALIDATION_OK) {
        CatalogEntry ce = cm.createCatalogEntry();
        addEntryForm.fillEntry(ce);
        ce.setOwnerGroup(ManagerFactory.getManager().createAndPersistSecurityGroup());
        ce.setRepositoryEntry(null);
        ce.setParent(currentCatalogEntry);
        // optimistic save: might fail in case the parent has been deleted in the meantime
        cm.saveCatalogEntry(ce);
      } else if (event == Form.EVNT_FORM_CANCELLED) {
        // nothing to do
      }
      CatalogEntry reloaded = cm.loadCatalogEntry(currentCatalogEntry);
      currentCatalogEntry = reloaded;// FIXME:pb:
      updateContent(ureq.getIdentity(), currentCatalogEntry, currentCatalogEntryLevel);
      updateToolAccessRights(ureq, currentCatalogEntry, currentCatalogEntryLevel);
      // in any case, remove the lock
      if (catModificationLock != null && catModificationLock.isSuccess()) {
        CoordinatorManager.getCoordinator().getLocker().releaseLock(catModificationLock);
        catModificationLock = null;
      }
      fireEvent(ureq, Event.CHANGED_EVENT);
     
    } else if (source == editEntryForm) {
      // remove modal dialog
      cmc.deactivate();
      // optimistic save: might fail in case the current entry has been deleted
      // in the meantime by someone else
      CatalogEntry reloaded = (CatalogEntry) DBFactory.getInstance().loadObject(currentCatalogEntry);
      currentCatalogEntry = reloaded;// FIXME:pb
      if (event == Form.EVNT_VALIDATION_OK) {
        editEntryForm.fillEntry(currentCatalogEntry);
        cm.updateCatalogEntry(currentCatalogEntry);
        // update the changed name in the history path
        historyStack.remove(historyStack.size() - 1);
        historyStack.add(currentCatalogEntry);
      } else if (event == Form.EVNT_FORM_CANCELLED) {
        // nothing to do
      }
      // in any case, remove the lock
      if (catModificationLock != null && catModificationLock.isSuccess()) {
        CoordinatorManager.getCoordinator().getLocker().releaseLock(catModificationLock);
        catModificationLock = null;
      }
      updateContent(ureq.getIdentity(), currentCatalogEntry, currentCatalogEntryLevel);
    }
    /*
     * admin submitted a new structure
     */
    else if (source == addStructureForm) {
      // remove modal dialog first
      cmc.deactivate();
      if (event == Form.EVNT_VALIDATION_OK) {
        importStructure();
      }
      CatalogEntry newRoot = (CatalogEntry) cm.getRootCatalogEntries().get(0);
      historyStack = new ArrayList<CatalogEntry>();
      historyStack.add(newRoot);
      updateContent(ureq.getIdentity(), newRoot, 0);
      updateToolAccessRights(ureq, currentCatalogEntry, currentCatalogEntryLevel);
      fireEvent(ureq, Event.CHANGED_EVENT);
View Full Code Here

       */
      else if (event.getCommand().equals(ACTION_EDIT_CTLGCATOWNER)) {
        // add ownership management
        SecurityGroup secGroup = currentCatalogEntry.getOwnerGroup();
        if (secGroup == null) {
          CatalogEntry reloaded = cm.loadCatalogEntry(currentCatalogEntry);
          currentCatalogEntry = reloaded;// FIXME:pb:?
          secGroup = ManagerFactory.getManager().createAndPersistSecurityGroup();
          currentCatalogEntry.setOwnerGroup(secGroup);
          cm.saveCatalogEntry(currentCatalogEntry);
        }
        boolean keepAtLeastOne = currentCatalogEntryLevel == 0;
        removeAsListenerAndDispose(groupController);
        groupController = new GroupController(ureq, getWindowControl(), true, keepAtLeastOne, false, secGroup);
        listenTo(groupController);
        // open form in dialog
        removeAsListenerAndDispose(cmc);
        cmc = new CloseableModalController(getWindowControl(), "close", groupController.getInitialComponent(), true, translate("tools.edit.catalog.category.ownergroup"));
        listenTo(cmc);
        cmc.activate();         
      }
      /*
       * delete category (subtree)
       */
      else if (event.getCommand().equals(ACTION_DELETE_CTLGCATEGORY)) {
        catModificationLock = CoordinatorManager.getCoordinator().getLocker().acquireLock(OresHelper.createOLATResourceableType(CatalogController.class), ureq.getIdentity(), LOCK_TOKEN);
        if ( ! catModificationLock.isSuccess()) {
          showError("catalog.locked.by", catModificationLock.getOwner().getName());
          return;
        }
        String[] trnslP = { currentCatalogEntry.getName() };
        dialogDeleteSubtree = activateYesNoDialog(ureq, null, getTranslator().translate(NLS_DIALOG_MODAL_SUBTREE_DELETE_TEXT, trnslP), dialogDeleteSubtree);
        return;
      }
      /*
       * contact caretaker, request subcategory, request deletion of an entry,
       * etc.
       */
      else if (event.getCommand().equals(ACTION_NEW_CTGREQUEST)) {
        /*
         * find the first caretaker, looking from the leaf towards the root,
         * following the selected branch.
         */
        Manager mngr = ManagerFactory.getManager();
        ContactList caretaker = new ContactList(translate(NLS_CONTACT_TO_GROUPNAME_CARETAKER));
        final List emptyList = new ArrayList();
        List tmpIdent = new ArrayList();
        for (int i = historyStack.size() - 1; i >= 0 && tmpIdent.isEmpty(); i--) {
          // start at the selected category, the root category is asserted to
          // have the OLATAdministrator
          // so we end up having always at least one identity as receiver for a
          // request ;-)
          CatalogEntry tmp = historyStack.get(i);
          SecurityGroup tmpOwn = tmp.getOwnerGroup();
          if (tmpOwn != null) tmpIdent = mngr.getIdentitiesOfSecurityGroup(tmpOwn);
          else tmpIdent = emptyList;
        }
        for (int i = tmpIdent.size() - 1; i >= 0; i--) {
          caretaker.add((Identity) tmpIdent.get(i));
        }
       
        //create e-mail Message
        ContactMessage cmsg = new ContactMessage(ureq.getIdentity());
        cmsg.addEmailTo(caretaker);
        removeAsListenerAndDispose(cfc);
        cfc = new ContactFormController(ureq, getWindowControl(), false, true, false, false, cmsg);
        listenTo(cfc);
        // open form in dialog
        removeAsListenerAndDispose(cmc);
        cmc = new CloseableModalController(getWindowControl(), "close", cfc.getInitialComponent(), true, translate("contact.caretaker"));
        listenTo(cmc);
        cmc.activate();         
      }
      /*
       * add a structure
       */
      else if (event.getCommand().equals(ACTION_ADD_STRUCTURE)) {
        addStructureForm = new EntryForm("ADDSTRUCTURE", getTranslator(), false);
        addStructureForm.addListener(this);
        cmc = new CloseableModalController(getWindowControl(), "close", addStructureForm, true, translate("contact.caretaker"));
        listenTo(cmc);
        cmc.activate();         
      }
     
      /*
       * add bookmark
       */
     
      else if (event.getCommand().equals(ACTION_ADD_BOOKMARK)){
        removeAsListenerAndDispose(bookmarkController);
        CatalogManager cm = CatalogManager.getInstance();
        OLATResourceable ores = cm.createOLATResouceableFor(currentCatalogEntry);
        bookmarkController = new AddAndEditBookmarkController(ureq, getWindowControl(), currentCatalogEntry.getName(), "", ores, CatalogManager.CATALOGENTRY);           
        listenTo(bookmarkController);
        removeAsListenerAndDispose(cmc);
        cmc = new CloseableModalController(getWindowControl(), "close", bookmarkController.getInitialComponent());
        listenTo(cmc);
        cmc.activate();
      }
      /*
       * move catalogentry
       */
      else if(event.getCommand().equals(ACTION_MOVE_ENTRY)){       
        // Move catalog level - moving of resources in the catalog (leafs) is triggered by a velocity command
        // so, reset stale link to the current resource first (OLAT-4253), the linkMarkedToBeEdited will be reset
        // when an edit or move operation on the resource is done
        linkMarkedToBeEdited = null;
        //
        catModificationLock = CoordinatorManager.getCoordinator().getLocker().acquireLock(OresHelper.createOLATResourceableType(CatalogController.class), ureq.getIdentity(), LOCK_TOKEN);
        if ( ! catModificationLock.isSuccess()) {
          showError("catalog.locked.by", catModificationLock.getOwner().getName());
          return;
        }
        // check if user surfs in ajax mode
        removeAsListenerAndDispose(catEntryMoveController);
        boolean ajax = getWindowControl().getWindowBackOffice().getWindowManager().isAjaxEnabled();
        if (ajax) {
          // fancy ajax tree
          catEntryMoveController= new CatalogAjaxMoveController(ureq, getWindowControl(), currentCatalogEntry);
        } else {
          // old-school selection tree
          catEntryMoveController= new CatalogEntryMoveController(getWindowControl(), ureq, currentCatalogEntry, getTranslator());         
        }
        listenTo(catEntryMoveController);
        removeAsListenerAndDispose(cmc);
        cmc = new CloseableModalController(getWindowControl(), "close", catEntryMoveController.getInitialComponent());
        listenTo(cmc);
        cmc.activate();
      }
    }
    /*
     * from the repository search, a entry was selected to add
     */
    else if (source == rsc) {
      // remove modal dialog
      cmc.deactivate();
      if (event.getCommand().equals(RepositoryTableModel.TABLE_ACTION_SELECT_LINK)) {
        /*
         * succesfully selected a repository entry which will be a link within
         * the current Category
         */
        RepositoryEntry re = rsc.getSelectedEntry();
        /*
         * create, but do not persist a new catalog entry
         */
        newLinkNotPersistedYet = cm.createCatalogEntry();
        newLinkNotPersistedYet.setName(re.getDisplayname());
        newLinkNotPersistedYet.setDescription(re.getDescription());
        newLinkNotPersistedYet.setRepositoryEntry(re);
        newLinkNotPersistedYet.setType(CatalogEntry.TYPE_LEAF);
        /*
         * open the confirm form, which allows to change the link-title,
         * link-description.
         */
        newLinkNotPersistedYet.setOwnerGroup(ManagerFactory.getManager().createAndPersistSecurityGroup());
        cm.addCatalogEntry(currentCatalogEntry, newLinkNotPersistedYet);
        newLinkNotPersistedYet = null;
        updateContent(ureq.getIdentity(), currentCatalogEntry, currentCatalogEntryLevel);
        updateToolAccessRights(ureq, currentCatalogEntry, currentCatalogEntryLevel);
        fireEvent(ureq, Event.CHANGED_EVENT);
      } else if (event == Event.CANCELLED_EVENT) {
        updateContent(ureq.getIdentity(), currentCatalogEntry, currentCatalogEntryLevel);
        updateToolAccessRights(ureq, currentCatalogEntry, currentCatalogEntryLevel);
        fireEvent(ureq, Event.CHANGED_EVENT);

      }
    }
    /*
     * from remove subtree dialog -> yes or no
     */
    else if (source == dialogDeleteSubtree) {
      if (DialogBoxUIFactory.isYesEvent(event)) {
        // remember the parent of the subtree being deleted
        CatalogEntry parent = currentCatalogEntry.getParent();
        // delete the subtree!!!
        cm.deleteCatalogEntry(currentCatalogEntry);
        // display the parent
        historyStack.remove(historyStack.size() - 1);
        updateContent(ureq.getIdentity(), parent, historyStack.indexOf(parent));
View Full Code Here

    myContent.contextPut("canRemoveAllLinks", new Boolean(canRemoveAllLinks));
    myContent.contextPut("currentCatalogEntry", currentCatalogEntry);
    childCe = cm.getChildrenOf(ce);
    myContent.contextPut("children", childCe);
    for ( Object leaf : childCe ) {
      CatalogEntry entry = (CatalogEntry)leaf;
      if(entry.getType() == CatalogEntry.TYPE_NODE) continue;
      String name = "image" + childCe.indexOf(leaf);
      ImageComponent ic = RepositoryEntryImageController.getImageComponentForRepositoryEntry(name, entry.getRepositoryEntry());
      if(ic == null) {
        myContent.remove(myContent.getComponent(name));
        continue;
      }
      ic.setMaxWithAndHeightToFitWithin(200, 100);
View Full Code Here

  /**
   * Helper to imports simple tree structure, for simplicity
   */
  private void importStructure() {
    CatalogEntry oldRoot = (CatalogEntry) cm.getRootCatalogEntries().get(0);
    SecurityGroup rootOwners = oldRoot.getOwnerGroup();
    Manager secMgr = ManagerFactory.getManager();
    List olatAdminIdents = secMgr.getIdentitiesOfSecurityGroup(rootOwners);
    SecurityGroup catalogAdmins = secMgr.createAndPersistSecurityGroup();
    for (int i = 0; i < olatAdminIdents.size(); i++) {
      secMgr.addIdentityToSecurityGroup((Identity) olatAdminIdents.get(i), catalogAdmins);
    }
    cm.deleteCatalogEntry(oldRoot);

    CatalogEntry dummy = cm.createCatalogEntry();
    addStructureForm.fillEntry(dummy);
    String structure = dummy.getDescription();
    String[] lines = structure.split("\n");
    Stack<CatalogEntry> treeStack = new Stack<CatalogEntry>();
    //
    CatalogEntry newRoot = cm.createCatalogEntry();
    newRoot.setParent(null);
    newRoot.setType(CatalogEntry.TYPE_NODE);
    newRoot.setDescription("fill it");
    newRoot.setName(lines[0]);
    newRoot.setOwnerGroup(catalogAdmins);
    cm.saveCatalogEntry(newRoot);
    treeStack.push(newRoot);
    for (int i = 1; i < lines.length; i++) {
      int level = 0;
      int pos = 0;
      while ("".equals(lines[i].substring(pos, pos + 2).trim())) {
        level++;
        pos += 3;
      }
      CatalogEntry tmp = cm.createCatalogEntry();
      tmp.setType(CatalogEntry.TYPE_NODE);
      tmp.setDescription("fill it");
      tmp.setName(lines[i].trim());
      if (treeStack.size() == level) {
        tmp.setParent(treeStack.lastElement());
        treeStack.push(tmp);
      } else if (treeStack.size() > level) {
        // moving towards root
        for (int ii = treeStack.size() - 1; ii >= level; ii--) {
          treeStack.pop();
        }
        tmp.setParent(treeStack.lastElement());
        treeStack.push(tmp);
      }
      cm.saveCatalogEntry(tmp);
    }
  }
View Full Code Here

   * @param ce The current catalog category element from the given level
   * @param pos The current level in the catalog
   */
  private void updateToolAccessRights(UserRequest ureq, CatalogEntry ce, int pos) {
    // 1) check if user has already a bookmark for this level
    final CatalogEntry tmp=ce;
    OLATResourceable catEntryOres = CatalogManager.getInstance().createOLATResouceableFor(ce);
    if (tmp != null && BookmarkManager.getInstance().isResourceableBookmarked(ureq.getIdentity(), catEntryOres)){
      canBookmark = false;
      if(catalogToolC != null){
        catalogToolC.setEnabled(TOOL_BOOKMARK, canBookmark);
View Full Code Here

TOP

Related Classes of org.olat.catalog.CatalogEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.