use of org.olat.repository.CatalogEntry in project openolat by klemens.
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 klemens.
the class CatalogManager method saveCatEntry.
private CatalogEntry saveCatEntry(String name, String desc, int type, SecurityGroup ownerGroup, RepositoryEntry repoEntry, CatalogEntry parent) {
CatalogEntry ce = createCatalogEntry();
ce.setName(name);
ce.setDescription(desc);
ce.setOwnerGroup(ownerGroup);
ce.setRepositoryEntry(repoEntry);
ce.setParent(parent);
ce.setType(type);
saveCatalogEntry(ce);
return ce;
}
use of org.olat.repository.CatalogEntry in project openolat by klemens.
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);
}
use of org.olat.repository.CatalogEntry in project openolat by klemens.
the class CatalogSettingsController method doRemove.
private void doRemove(CatalogEntry catEntry) {
List<CatalogEntry> children = catalogManager.getChildrenOf(catEntry);
// find all child element of this level that reference our repo entry
for (CatalogEntry child : children) {
RepositoryEntry childRepoEntry = child.getRepositoryEntry();
if (childRepoEntry != null && childRepoEntry.equalsByPersistableKey(entry)) {
// remove from catalog
catalogManager.deleteCatalogEntry(child);
}
}
// update table
updateTable();
}
use of org.olat.repository.CatalogEntry in project openolat by klemens.
the class CatalogWebService method deleteCatalogEntry.
/**
* Deletes the catalog entry with the path specified in the URL.
* @response.representation.200.qname {http://www.example.com}catalogEntryVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The catalog entry
* @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_CATALOGENTRYVO}
* @response.representation.401.doc Not authorized
* @response.representation.404.doc The path could not be resolved to a valid catalog entry
* @param path The path
* @param httpRquest The HTTP request
* @return The response
*/
@DELETE
@Path("{path:.*}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response deleteCatalogEntry(@PathParam("path") List<PathSegment> path, @Context HttpServletRequest httpRequest) {
Long key = getCatalogEntryKeyFromPath(path);
if (key == null) {
return Response.serverError().status(Status.NOT_ACCEPTABLE).build();
}
CatalogEntry ce = catalogManager.loadCatalogEntry(key);
if (ce == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
if (!canAdminSubTree(ce, httpRequest)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
Identity id = getUserRequest(httpRequest).getIdentity();
LockResult lock = CoordinatorManager.getInstance().getCoordinator().getLocker().acquireLock(lockRes, id, LOCK_TOKEN);
if (!lock.isSuccess()) {
return getLockedResponse(lock, httpRequest);
}
try {
catalogManager.deleteCatalogEntry(ce);
} catch (Exception e) {
throw new WebApplicationException(e);
} finally {
CoordinatorManager.getInstance().getCoordinator().getLocker().releaseLock(lock);
}
return Response.ok().build();
}
Aggregations