Search in sources :

Example 26 with CatalogEntry

use of org.olat.repository.CatalogEntry in project OpenOLAT by OpenOLAT.

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 27 with CatalogEntry

use of org.olat.repository.CatalogEntry in project OpenOLAT by OpenOLAT.

the class CatalogManager method deleteCatalogEntry.

public void deleteCatalogEntry(RepositoryEntryRef entry, CatalogEntry parent) {
    CatalogEntry ce = getCatalogEntryBy(entry, parent);
    if (ce != null) {
        SecurityGroup owner = ce.getOwnerGroup();
        dbInstance.getCurrentEntityManager().remove(ce);
        if (owner != null) {
            log.debug("deleteCatalogEntry case_1: delete owner-group=" + owner);
            securityManager.deleteSecurityGroup(owner);
        }
    }
}
Also used : CatalogEntry(org.olat.repository.CatalogEntry) SecurityGroup(org.olat.basesecurity.SecurityGroup)

Example 28 with CatalogEntry

use of org.olat.repository.CatalogEntry in project OpenOLAT by OpenOLAT.

the class CatalogManager method moveCatalogEntry.

/**
 * Move the given catalog entry to the new parent
 * @param toBeMovedEntry
 * @param newParentEntry
 * return true: success; false: failure
 */
public boolean moveCatalogEntry(CatalogEntry toBeMovedEntry, CatalogEntry newParentEntry) {
    // reload current item to prevent stale object modification
    toBeMovedEntry = loadCatalogEntry(toBeMovedEntry);
    newParentEntry = loadCatalogEntry(newParentEntry);
    // check that the new parent is not a leaf
    if (newParentEntry.getType() == CatalogEntry.TYPE_LEAF)
        return false;
    // check that the new parent is not a child of the to be moved entry
    CatalogEntry tempEntry = newParentEntry;
    while (tempEntry != null) {
        if (tempEntry.getKey().equals(toBeMovedEntry.getKey())) {
            // ups, the new parent is within the to be moved entry - abort
            return false;
        }
        tempEntry = tempEntry.getParent();
    }
    // set new parent and save
    toBeMovedEntry.setParent(newParentEntry);
    updateCatalogEntry(toBeMovedEntry);
    return true;
}
Also used : CatalogEntry(org.olat.repository.CatalogEntry)

Example 29 with CatalogEntry

use of org.olat.repository.CatalogEntry in project OpenOLAT by OpenOLAT.

the class CatalogManager method afterPropertiesSet.

@Override
public void afterPropertiesSet() throws Exception {
    List<CatalogEntry> roots = getRootCatalogEntries();
    if (roots.isEmpty()) {
        // not initialized yet
        /*
			 * copy a snapshot of olatAdmins into catalogAdmins do not put
			 * secMgr.findSecurityGroupByName(Constants.GROUP_ADMIN) directly into a
			 * CatalogEntry!!
			 */
        SecurityGroup olatAdmins = securityManager.findSecurityGroupByName(Constants.GROUP_ADMIN);
        List<Identity> olatAdminIdents = securityManager.getIdentitiesOfSecurityGroup(olatAdmins);
        SecurityGroup catalogAdmins = securityManager.createAndPersistSecurityGroup();
        for (int i = 0; i < olatAdminIdents.size(); i++) {
            securityManager.addIdentityToSecurityGroup(olatAdminIdents.get(i), catalogAdmins);
        }
        /*
			 * start with something called CATALOGROOT, you can rename it to whatever
			 * name you like later as OLATAdmin
			 */
        // parent == null -> no parent -> I am a root node.
        saveCatEntry(CATALOGROOT, null, CatalogEntry.TYPE_NODE, catalogAdmins, null, null);
        dbInstance.intermediateCommit();
    }
}
Also used : CatalogEntry(org.olat.repository.CatalogEntry) SecurityGroup(org.olat.basesecurity.SecurityGroup) Identity(org.olat.core.id.Identity)

Example 30 with CatalogEntry

use of org.olat.repository.CatalogEntry in project OpenOLAT by OpenOLAT.

the class CatalogManager method deleteUserData.

/**
 * Remove identity as owner of catalog-entry.
 * If there is no other owner, the olat-administrator (define in spring config) will be added as owner.
 *
 * @see org.olat.user.UserDataDeletable#deleteUserData(org.olat.core.id.Identity)
 */
@Override
public void deleteUserData(Identity identity, String newDeletedUserName, File archivePath) {
    // Remove as owner
    List<CatalogEntry> catalogEntries = getCatalogEntriesOwnedBy(identity);
    for (CatalogEntry catalogEntry : catalogEntries) {
        securityManager.removeIdentityFromSecurityGroup(identity, catalogEntry.getOwnerGroup());
        if (securityManager.countIdentitiesOfSecurityGroup(catalogEntry.getOwnerGroup()) == 0) {
            // This group has no owner anymore => add OLAT-Admin as owner
            Identity admin = CoreSpringFactory.getImpl(RepositoryDeletionModule.class).getAdminUserIdentity();
            securityManager.addIdentityToSecurityGroup(admin, catalogEntry.getOwnerGroup());
            log.info("Delete user-data, add Administrator-identity as owner of catalogEntry=" + catalogEntry.getName());
        }
    }
    if (log.isDebug())
        log.debug("All owner entries in catalog deleted for identity=" + identity);
}
Also used : RepositoryDeletionModule(org.olat.repository.RepositoryDeletionModule) CatalogEntry(org.olat.repository.CatalogEntry) Identity(org.olat.core.id.Identity)

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