use of org.olat.repository.CatalogEntry in project OpenOLAT by OpenOLAT.
the class CatalogWebService method removeOwner.
/**
* Remove an owner of the local sub tree
* @response.representation.200.qname {http://www.example.com}userVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The catalog entry
* @response.representation.200.example {@link org.olat.user.restapi.Examples#SAMPLE_USERVOes}
* @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 identityKey The id of the user
* @param httpRquest The HTTP request
* @return The response
*/
@DELETE
@Path("{path:.*}/owners/{identityKey}")
public Response removeOwner(@PathParam("path") List<PathSegment> path, @PathParam("identityKey") Long identityKey, @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 (!isAuthor(httpRequest) && !canAdminSubTree(ce, httpRequest)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
BaseSecurity securityManager = BaseSecurityManager.getInstance();
Identity identity = securityManager.loadIdentityByKey(identityKey, false);
if (identity == null) {
return Response.ok().build();
}
SecurityGroup sg = ce.getOwnerGroup();
if (sg == null) {
return Response.ok().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 {
securityManager.removeIdentityFromSecurityGroup(identity, ce.getOwnerGroup());
} catch (Exception e) {
throw new WebApplicationException(e);
} finally {
CoordinatorManager.getInstance().getCoordinator().getLocker().releaseLock(lock);
}
return Response.ok().build();
}
use of org.olat.repository.CatalogEntry in project OpenOLAT by OpenOLAT.
the class CatalogNodeManagerController method doMoveCategory.
private void doMoveCategory(UserRequest ureq, CatalogEntryRow row) {
removeAsListenerAndDispose(cmc);
removeAsListenerAndDispose(entryResourceMoveCtrl);
CatalogEntry moveMe = catalogManager.getCatalogEntryBy(row, catalogEntry);
if (moveMe != null) {
entryResourceMoveCtrl = new CatalogEntryMoveController(getWindowControl(), ureq, moveMe, getTranslator());
listenTo(entryResourceMoveCtrl);
cmc = new CloseableModalController(getWindowControl(), "close", entryResourceMoveCtrl.getInitialComponent(), true, translate("tools.move.catalog.entry"));
listenTo(cmc);
cmc.activate();
}
}
use of org.olat.repository.CatalogEntry in project OpenOLAT by OpenOLAT.
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);
}
use of org.olat.repository.CatalogEntry in project OpenOLAT by OpenOLAT.
the class CatalogNodeManagerController 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 catEntry = ((CatalogStateEntry) stateEntry).getEntry();
CatalogNodeManagerController nextCtrl = selectCatalogEntry(ureq, catEntry);
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 CatalogNodeManagerController method doAddCategory.
private void doAddCategory(UserRequest ureq) {
removeAsListenerAndDispose(addEntryCtrl);
removeAsListenerAndDispose(cmc);
catModificationLock = CoordinatorManager.getInstance().getCoordinator().getLocker().acquireLock(lockRes, getIdentity(), LOCK_TOKEN);
if (catModificationLock.isSuccess()) {
CatalogEntry ce = catalogManager.createCatalogEntry();
addEntryCtrl = new CatalogEntryEditController(ureq, getWindowControl(), ce, catalogEntry);
addEntryCtrl.setElementCssClass("o_sel_catalog_add_category_popup");
listenTo(addEntryCtrl);
cmc = new CloseableModalController(getWindowControl(), "close", addEntryCtrl.getInitialComponent(), true, translate("tools.add.catalog.category"));
listenTo(cmc);
cmc.activate();
} else {
String ownerName = userManager.getUserDisplayName(catModificationLock.getOwner());
showError("catalog.locked.by", ownerName);
}
}
Aggregations