use of org.olat.repository.CatalogEntry in project OpenOLAT by OpenOLAT.
the class CatalogWebService method getOwners.
/**
* Get the owners 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 httpRquest The HTTP request
* @return The response
*/
@GET
@Path("{path:.*}/owners")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getOwners(@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 (!isAuthor(httpRequest) && !canAdminSubTree(ce, httpRequest)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
SecurityGroup sg = ce.getOwnerGroup();
if (sg == null) {
return Response.ok(new UserVO[0]).build();
}
List<Identity> ids = BaseSecurityManager.getInstance().getIdentitiesOfSecurityGroup(sg);
int count = 0;
UserVO[] voes = new UserVO[ids.size()];
for (Identity id : ids) {
voes[count++] = UserVOFactory.get(id);
}
return Response.ok(voes).build();
}
use of org.olat.repository.CatalogEntry in project OpenOLAT by OpenOLAT.
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();
}
use of org.olat.repository.CatalogEntry in project OpenOLAT by OpenOLAT.
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);
}
}
}
use of org.olat.repository.CatalogEntry in project OpenOLAT by OpenOLAT.
the class CatalogNodeManagerController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
// one mapper for all users
flc.contextPut("mapperThumbnailUrl", mapperThumbnailKey.getUrl());
int level = 0;
CatalogEntry parent = catalogEntry.getParent();
while (parent != null) {
level++;
parent = parent.getParent();
}
flc.contextPut("catalogLevel", level);
String url = Settings.getServerContextPathURI() + "/url/CatalogEntry/" + catalogEntry.getKey();
if (loginModule.isGuestLoginLinksEnabled()) {
flc.contextPut("guestExtLink", url + "?guest=true&lang=" + getLocale().getLanguage());
}
if (!isGuest) {
flc.contextPut("extLink", url);
}
FlexiTableColumnModel entriesColumnsModel = getCatalogFlexiTableColumnModel("opened-");
entriesModel = new CatalogEntryRowModel(entriesColumnsModel);
entriesEl = uifactory.addTableElement(getWindowControl(), "entries", entriesModel, getTranslator(), formLayout);
FlexiTableColumnModel closedEntriesColumnsModel = getCatalogFlexiTableColumnModel("closed-");
closedEntriesModel = new CatalogEntryRowModel(closedEntriesColumnsModel);
closedEntriesEl = uifactory.addTableElement(getWindowControl(), "closedEntries", closedEntriesModel, getTranslator(), formLayout);
}
use of org.olat.repository.CatalogEntry in project OpenOLAT by OpenOLAT.
the class CatalogNodeManagerController method event.
@Override
public void event(UserRequest ureq, Component source, Event event) {
if (editLink == source) {
doEditCategory(ureq);
} else if (nominateLink == source) {
doEditOwners(ureq);
} else if (contactLink == source) {
doContact(ureq);
} else if (deleteLink == source) {
doConfirmDelete(ureq);
} else if (moveLink == source) {
doMoveCategory(ureq);
} else if (addCategoryLink == source) {
doAddCategory(ureq);
} else if (addResourceLink == source) {
doAddResource(ureq);
} else 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);
}
}
}
super.event(ureq, source, event);
}
Aggregations