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);
}
}
}
}
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);
}
}
}
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;
}
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();
}
}
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);
}
Aggregations