Search in sources :

Example 41 with CatalogEntry

use of org.olat.repository.CatalogEntry in project openolat by klemens.

the class CatalogManagerController method activate.

@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
    if (entries == null || entries.isEmpty())
        return;
    ContextEntry entry = entries.get(0);
    String type = entry.getOLATResourceable().getResourceableTypeName();
    if ("CatalogEntry".equalsIgnoreCase(type)) {
        Long entryKey = entry.getOLATResourceable().getResourceableId();
        if (entryKey != null && entryKey.longValue() > 0) {
            List<ContextEntry> parentLine = new ArrayList<>();
            for (CatalogEntry node = catalogManager.getCatalogEntryByKey(entryKey); node != null && node.getParent() != null; node = node.getParent()) {
                OLATResourceable nodeRes = OresHelper.createOLATResourceableInstance("Node", node.getKey());
                ContextEntry ctxEntry = BusinessControlFactory.getInstance().createContextEntry(nodeRes);
                ctxEntry.setTransientState(new CatalogStateEntry(node));
                parentLine.add(ctxEntry);
            }
            Collections.reverse(parentLine);
            toolbarPanel.popUpToRootController(ureq);
            catalogCtrl.activate(ureq, parentLine, null);
        }
    }
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) ArrayList(java.util.ArrayList) CatalogEntry(org.olat.repository.CatalogEntry) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 42 with CatalogEntry

use of org.olat.repository.CatalogEntry in project openolat by klemens.

the class CatalogNodeController method event.

@Override
public void event(UserRequest ureq, Component source, Event event) {
    if (source instanceof Link) {
        Link link = (Link) source;
        if ("select_node".equals(link.getCommand())) {
            Long categoryNodeKey = (Long) link.getUserObject();
            CatalogEntry entry = catalogManager.getCatalogNodeByKey(categoryNodeKey);
            selectCatalogEntry(ureq, entry);
        }
    } else if ("img_select".equals(event.getCommand())) {
        String node = ureq.getParameter("node");
        if (StringHelper.isLong(node)) {
            try {
                Long categoryNodeKey = new Long(node);
                CatalogEntry entry = catalogManager.getCatalogNodeByKey(categoryNodeKey);
                selectCatalogEntry(ureq, entry);
            } catch (NumberFormatException e) {
                logWarn("Not a valid long: " + node, e);
            }
        }
    }
}
Also used : CatalogEntry(org.olat.repository.CatalogEntry) Link(org.olat.core.gui.components.link.Link)

Example 43 with CatalogEntry

use of org.olat.repository.CatalogEntry in project openolat by klemens.

the class CatalogNodeController method activate.

@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
    if (entries == null || entries.isEmpty()) {
        return;
    }
    ContextEntry entry = entries.get(0);
    String type = entry.getOLATResourceable().getResourceableTypeName();
    if ("CatalogEntry".equalsIgnoreCase(type)) {
        Long entryKey = entry.getOLATResourceable().getResourceableId();
        if (entryKey != null && entryKey.longValue() > 0) {
            activateRoot(ureq, entryKey);
        }
    } else if ("Node".equalsIgnoreCase(type)) {
        // the "Node" is only for internal usage
        StateEntry stateEntry = entry.getTransientState();
        if (stateEntry instanceof CatalogStateEntry) {
            CatalogEntry catalogEntry = ((CatalogStateEntry) stateEntry).getEntry();
            CatalogNodeController nextCtrl = selectCatalogEntry(ureq, catalogEntry);
            if (nextCtrl != null && entries.size() > 1) {
                nextCtrl.activate(ureq, entries.subList(1, entries.size()), null);
            }
        }
    }
}
Also used : StateEntry(org.olat.core.id.context.StateEntry) CatalogEntry(org.olat.repository.CatalogEntry) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 44 with CatalogEntry

use of org.olat.repository.CatalogEntry in project openolat by klemens.

the class CatalogNodeManagerController method doAddResource.

private void doAddResource(UserRequest ureq, RepositoryEntry selectedEntry) {
    CatalogEntry newLinkNotPersistedYet = catalogManager.createCatalogEntry();
    newLinkNotPersistedYet.setName(selectedEntry.getDisplayname());
    newLinkNotPersistedYet.setDescription(selectedEntry.getDescription());
    newLinkNotPersistedYet.setRepositoryEntry(selectedEntry);
    newLinkNotPersistedYet.setType(CatalogEntry.TYPE_LEAF);
    newLinkNotPersistedYet.setOwnerGroup(securityManager.createAndPersistSecurityGroup());
    catalogManager.addCatalogEntry(catalogEntry, newLinkNotPersistedYet);
    loadResources(ureq);
}
Also used : CatalogEntry(org.olat.repository.CatalogEntry)

Example 45 with CatalogEntry

use of org.olat.repository.CatalogEntry in project openolat by klemens.

the class CatalogNodeManagerController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (addEntryCtrl == source) {
        if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            loadNodesChildren();
        }
        cmc.deactivate();
        cleanUp();
        fireEvent(ureq, Event.CHANGED_EVENT);
    } else if (editEntryCtrl == source) {
        if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            catalogEntry = editEntryCtrl.getEditedCatalogEntry();
            loadEntryInfos();
        }
        cmc.deactivate();
        cleanUp();
        fireEvent(ureq, Event.CHANGED_EVENT);
    } else if (categoryMoveCtrl == source) {
        cmc.deactivate();
        CatalogEntry moveMe = null;
        if (event.equals(Event.DONE_EVENT)) {
            showInfo("tools.move.catalog.entry.success", catalogEntry.getName());
            moveMe = categoryMoveCtrl.getMoveMe();
        } else if (event.equals(Event.FAILED_EVENT)) {
            showError("tools.move.catalog.entry.failed");
            loadNodesChildren();
        }
        cleanUp();
        // in any case, remove the lock
        if (catModificationLock != null && catModificationLock.isSuccess()) {
            CoordinatorManager.getInstance().getCoordinator().getLocker().releaseLock(catModificationLock);
            catModificationLock = null;
        }
        // only after jump to the moved entry
        if (moveMe != null) {
            launchCatalogEntry(ureq, moveMe);
        }
    } else if (dialogDeleteSubtree == source) {
        // from remove subtree dialog -> yes or no
        if (DialogBoxUIFactory.isYesEvent(event)) {
            catalogManager.deleteCatalogEntry(catalogEntry);
            fireEvent(ureq, Event.BACK_EVENT);
        }
        // in any case, remove the lock
        if (catModificationLock != null && catModificationLock.isSuccess()) {
            CoordinatorManager.getInstance().getCoordinator().getLocker().releaseLock(catModificationLock);
            catModificationLock = null;
        }
    } else if (childNodeCtrl == source) {
        if (event == Event.BACK_EVENT) {
            toolbarPanel.popUpToController(this);
            removeAsListenerAndDispose(childNodeCtrl);
            childNodeCtrl = null;
            loadNodesChildren();
        }
    } else if (entrySearchCtrl == source) {
        if (event.getCommand().equals(RepositoryTableModel.TABLE_ACTION_SELECT_LINK)) {
            // successfully selected a repository entry which will be a link within
            // the current Category
            RepositoryEntry selectedEntry = entrySearchCtrl.getSelectedEntry();
            doAddResource(ureq, selectedEntry);
            fireEvent(ureq, Event.CHANGED_EVENT);
        }
        cmc.deactivate();
        cleanUp();
    } else if (groupCtrl == source) {
        if (event instanceof IdentitiesAddEvent || event instanceof IdentitiesRemoveEvent) {
            doAddRemoveOwners(event);
        }
    } else if (contactCtrl == source) {
        cmc.deactivate();
        cleanUp();
    } else if (dialogDeleteLink == source) {
        if (DialogBoxUIFactory.isYesEvent(event)) {
            CatalogEntryRow row = (CatalogEntryRow) dialogDeleteLink.getUserObject();
            catalogManager.deleteCatalogEntry(row, catalogEntry);
            loadResources(ureq);
        }
    } else if (entryResourceMoveCtrl == source) {
        if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            CatalogEntry moveMe = entryResourceMoveCtrl.getMoveMe();
            showInfo("tools.move.catalog.entry.success", moveMe.getName());
            loadResources(ureq);
        }
        cmc.deactivate();
        cleanUp();
    } else if (cmc == source) {
        cleanUp();
    }
    super.event(ureq, source, event);
}
Also used : IdentitiesRemoveEvent(org.olat.admin.securitygroup.gui.IdentitiesRemoveEvent) CatalogEntry(org.olat.repository.CatalogEntry) IdentitiesAddEvent(org.olat.admin.securitygroup.gui.IdentitiesAddEvent) RepositoryEntry(org.olat.repository.RepositoryEntry)

Aggregations

CatalogEntry (org.olat.repository.CatalogEntry)122 Test (org.junit.Test)30 CatalogEntryVO (org.olat.restapi.support.vo.CatalogEntryVO)30 URI (java.net.URI)28 HttpResponse (org.apache.http.HttpResponse)28 Identity (org.olat.core.id.Identity)28 ArrayList (java.util.ArrayList)20 Path (javax.ws.rs.Path)18 SecurityGroup (org.olat.basesecurity.SecurityGroup)18 RepositoryEntry (org.olat.repository.RepositoryEntry)18 Produces (javax.ws.rs.Produces)14 HttpPut (org.apache.http.client.methods.HttpPut)12 GET (javax.ws.rs.GET)10 WebApplicationException (javax.ws.rs.WebApplicationException)10 HttpPost (org.apache.http.client.methods.HttpPost)10 OLATResourceable (org.olat.core.id.OLATResourceable)10 ContextEntry (org.olat.core.id.context.ContextEntry)10 LockResult (org.olat.core.util.coordinate.LockResult)10 CatalogManager (org.olat.repository.manager.CatalogManager)8 Link (org.olat.core.gui.components.link.Link)6