use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.
the class CourseElementWebService method attachBlog.
/**
* Attaches an blog building block.
* @response.representation.mediaType application/x-www-form-urlencoded
* @response.representation.doc The assessment node metadatas
* @response.representation.200.qname {http://www.example.com}courseNodeVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The course node metadatas
* @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_COURSENODEVO}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc The course or parentNode not found
* @param courseId The course resourceable's id
* @param parentNodeId The node's id which will be the parent of this assessment
* @param position The node's position relative to its sibling nodes (optional)
* @param shortTitle The node short title
* @param longTitle The node long title
* @param objectives The node learning objectives
* @param visibilityExpertRules The rules to view the node (optional)
* @param accessExpertRules The rules to access the node (optional)
* @param blogResourceableId The softkey of the blog resourceable (optional)
* @param request The HTTP request
* @return
*/
@PUT
@Path("blog")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response attachBlog(@PathParam("courseId") Long courseId, @QueryParam("parentNodeId") String parentNodeId, @QueryParam("position") Integer position, @QueryParam("shortTitle") @DefaultValue("undefined") String shortTitle, @QueryParam("longTitle") @DefaultValue("undefined") String longTitle, @QueryParam("objectives") @DefaultValue("undefined") String objectives, @QueryParam("visibilityExpertRules") String visibilityExpertRules, @QueryParam("accessExpertRules") String accessExpertRules, @QueryParam("repoEntry") Long blogResourceableId, @Context HttpServletRequest request) {
RepositoryManager rm = RepositoryManager.getInstance();
RepositoryEntry blogRepoEntry = rm.lookupRepositoryEntry(blogResourceableId);
if (blogRepoEntry == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
BlogCustomConfig config = new BlogCustomConfig(blogRepoEntry);
return attach(courseId, parentNodeId, "blog", position, shortTitle, longTitle, objectives, visibilityExpertRules, accessExpertRules, config, request);
}
use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.
the class RepositoryEntriesResource method getEntries.
/**
* List all entries in the OLAT repository
* @response.representation.200.qname {http://www.example.com}repositoryEntryVO
* @response.representation.200.mediaType text/plain, text/html, application/xml, application/json
* @response.representation.200.doc List all entries in the repository
* @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_REPOENTRYVOes}
* @param start (optional)
* @param limit (optional)
* @param managed (optional)
* @param externalId External ID (optional)
* @param externalRef External reference number (optional)
* @param resourceType The resource type (CourseModule) (optional)
* @param httpRequest The HTTP request
* @param request The RESt request
* @return
*/
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getEntries(@QueryParam("start") @DefaultValue("0") Integer start, @QueryParam("limit") @DefaultValue("25") Integer limit, @QueryParam("managed") Boolean managed, @QueryParam("externalId") String externalId, @QueryParam("externalRef") String externalRef, @QueryParam("resourceType") String resourceType, @Context HttpServletRequest httpRequest, @Context Request request) {
try {
// list of courses open for everybody
Roles roles = getRoles(httpRequest);
Identity identity = getIdentity(httpRequest);
RepositoryManager rm = RepositoryManager.getInstance();
SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters(identity, roles);
params.setManaged(managed);
if (StringHelper.containsNonWhitespace(externalId)) {
params.setExternalId(externalId);
}
if (StringHelper.containsNonWhitespace(externalRef)) {
params.setExternalRef(externalRef);
}
if (StringHelper.containsNonWhitespace(resourceType)) {
params.setResourceTypes(Collections.singletonList(resourceType));
}
if (MediaTypeVariants.isPaged(httpRequest, request)) {
int totalCount = rm.countGenericANDQueryWithRolesRestriction(params);
List<RepositoryEntry> res = rm.genericANDQueryWithRolesRestriction(params, start, limit, true);
RepositoryEntryVOes voes = new RepositoryEntryVOes();
voes.setRepositoryEntries(toArrayOfVOes(res));
voes.setTotalCount(totalCount);
return Response.ok(voes).build();
} else {
List<RepositoryEntry> res = rm.genericANDQueryWithRolesRestriction(params, 0, -1, false);
RepositoryEntryVO[] voes = toArrayOfVOes(res);
return Response.ok(voes).build();
}
} catch (Exception e) {
throw new WebApplicationException(e);
}
}
use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.
the class RepositoryEntriesResource method getRepositoryEntryResource.
@Path("{repoEntryKey}")
public RepositoryEntryResource getRepositoryEntryResource() {
RepositoryManager rm = RepositoryManager.getInstance();
BaseSecurity securityManager = BaseSecurityManager.getInstance();
RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
return new RepositoryEntryResource(rm, repositoryService, securityManager);
}
use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.
the class OpenOLATStatisticsWebService method getRepositoryStatisticsVO.
private RepositoryStatisticsVO getRepositoryStatisticsVO() {
RepositoryStatisticsVO stats = new RepositoryStatisticsVO();
RepositoryManager repoMgr = CoreSpringFactory.getImpl(RepositoryManager.class);
int allCourses = repoMgr.countByTypeLimitAccess(CourseModule.ORES_TYPE_COURSE, RepositoryEntry.ACC_OWNERS);
int publishedCourses = repoMgr.countByTypeLimitAccess(CourseModule.ORES_TYPE_COURSE, RepositoryEntry.ACC_USERS);
stats.setCoursesCount(allCourses);
stats.setPublishedCoursesCount(publishedCourses);
return stats;
}
use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.
the class ViteroCourseNode method createNodeRunConstructionResult.
@Override
public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) {
updateModuleConfigDefaults(false);
Controller runCtr;
Roles roles = ureq.getUserSession().getRoles();
if (roles.isGuestOnly()) {
Translator trans = Util.createPackageTranslator(ViteroPeekViewController.class, ureq.getLocale());
String title = trans.translate("guestnoaccess.title");
String message = trans.translate("guestnoaccess.message");
runCtr = MessageUIFactory.createInfoMessage(ureq, wControl, title, message);
} else {
// check if user is moderator of the virtual classroom
boolean moderator = roles.isOLATAdmin();
Long key = userCourseEnv.getCourseEnvironment().getCourseResourceableId();
if (!moderator) {
if (roles.isInstitutionalResourceManager() | roles.isAuthor()) {
RepositoryManager rm = RepositoryManager.getInstance();
ICourse course = CourseFactory.loadCourse(key);
RepositoryEntry re = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
if (re != null) {
moderator = rm.isOwnerOfRepositoryEntry(ureq.getIdentity(), re);
if (!moderator) {
moderator = rm.isInstitutionalRessourceManagerFor(ureq.getIdentity(), ureq.getUserSession().getRoles(), re);
}
}
}
}
// create run controller
Long resourceId = userCourseEnv.getCourseEnvironment().getCourseResourceableId();
OLATResourceable ores = OresHelper.createOLATResourceableInstance(CourseModule.class, resourceId);
String courseTitle = userCourseEnv.getCourseEnvironment().getCourseTitle();
runCtr = new ViteroBookingsRunController(ureq, wControl, null, ores, getIdent(), courseTitle, moderator, userCourseEnv.isCourseReadOnly());
}
Controller controller = TitledWrapperHelper.getWrapper(ureq, wControl, runCtr, this, "o_vitero_icon");
return new NodeRunConstructionResult(controller);
}
Aggregations