Search in sources :

Example 56 with RepositoryService

use of org.olat.repository.RepositoryService in project OpenOLAT by OpenOLAT.

the class BinderTemplateHandler method createResource.

@Override
public RepositoryEntry createResource(Identity initialAuthor, String displayname, String description, Object createObject, Locale locale) {
    RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
    PortfolioService portfolioService = CoreSpringFactory.getImpl(PortfolioService.class);
    OLATResource resource = portfolioService.createBinderTemplateResource();
    RepositoryEntry re = repositoryService.create(initialAuthor, null, "", displayname, description, resource, RepositoryEntry.ACC_OWNERS);
    portfolioService.createAndPersistBinderTemplate(initialAuthor, re, locale);
    DBFactory.getInstance().commit();
    return re;
}
Also used : PortfolioService(org.olat.modules.portfolio.PortfolioService) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryService(org.olat.repository.RepositoryService)

Example 57 with RepositoryService

use of org.olat.repository.RepositoryService in project OpenOLAT by OpenOLAT.

the class ModifyCourseEvent method createHelpCourseLaunchController.

/**
 * Create a user locale dependent help-course run controller
 *
 * @param ureq The user request
 * @param wControl The current window controller
 * @return The help-course run controller
 */
public static Controller createHelpCourseLaunchController(UserRequest ureq, WindowControl wControl) {
    // Find repository entry for this course
    String helpCourseSoftKey = CoreSpringFactory.getImpl(CourseModule.class).getHelpCourseSoftKey();
    RepositoryManager rm = RepositoryManager.getInstance();
    RepositoryService rs = CoreSpringFactory.getImpl(RepositoryService.class);
    RepositoryEntry entry = null;
    if (StringHelper.containsNonWhitespace(helpCourseSoftKey)) {
        entry = rm.lookupRepositoryEntryBySoftkey(helpCourseSoftKey, false);
    }
    if (entry == null) {
        Translator translator = Util.createPackageTranslator(CourseFactory.class, ureq.getLocale());
        wControl.setError(translator.translate("error.helpcourse.not.configured"));
        // create empty main controller
        LayoutMain3ColsController emptyCtr = new LayoutMain3ColsController(ureq, wControl, null, null, null);
        return emptyCtr;
    } else {
        // Increment launch counter
        rs.incrementLaunchCounter(entry);
        ICourse course = loadCourse(entry);
        ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(entry);
        WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ce, wControl);
        RepositoryEntrySecurity reSecurity = new RepositoryEntrySecurity(false, false, false, false, false, false, false, true, false);
        RunMainController launchC = new RunMainController(ureq, bwControl, null, course, entry, reSecurity, null);
        return launchC;
    }
}
Also used : Translator(org.olat.core.gui.translator.Translator) RepositoryEntrySecurity(org.olat.repository.model.RepositoryEntrySecurity) LayoutMain3ColsController(org.olat.core.commons.fullWebApp.LayoutMain3ColsController) RunMainController(org.olat.course.run.RunMainController) RepositoryManager(org.olat.repository.RepositoryManager) RepositoryEntry(org.olat.repository.RepositoryEntry) WindowControl(org.olat.core.gui.control.WindowControl) ContextEntry(org.olat.core.id.context.ContextEntry) RepositoryService(org.olat.repository.RepositoryService)

Example 58 with RepositoryService

use of org.olat.repository.RepositoryService in project OpenOLAT by OpenOLAT.

the class ScoreAccountingHelper method loadUsers.

/**
 * Load all users from all known learning groups into a list
 *
 * @param courseEnv
 * @return The list of identities from this course
 */
public static List<Identity> loadUsers(CourseEnvironment courseEnv) {
    CourseGroupManager gm = courseEnv.getCourseGroupManager();
    List<BusinessGroup> groups = gm.getAllBusinessGroups();
    BusinessGroupService businessGroupService = CoreSpringFactory.getImpl(BusinessGroupService.class);
    Set<Identity> userSet = new HashSet<>(businessGroupService.getMembers(groups, GroupRoles.participant.name()));
    RepositoryEntry re = gm.getCourseEntry();
    if (re != null) {
        RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
        userSet.addAll(repositoryService.getMembers(re, GroupRoles.participant.name()));
    }
    List<Identity> assessedList = courseEnv.getCoursePropertyManager().getAllIdentitiesWithCourseAssessmentData(userSet);
    if (!assessedList.isEmpty()) {
        userSet.addAll(assessedList);
    }
    return new ArrayList<>(userSet);
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) BusinessGroup(org.olat.group.BusinessGroup) BusinessGroupService(org.olat.group.BusinessGroupService) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) HashSet(java.util.HashSet) RepositoryService(org.olat.repository.RepositoryService)

Example 59 with RepositoryService

use of org.olat.repository.RepositoryService in project OpenOLAT by OpenOLAT.

the class JunitTestHelper method createAndPersistRepositoryEntry.

public static final RepositoryEntry createAndPersistRepositoryEntry(String initialAuthor, OLATResource r, boolean membersOnly) {
    RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
    RepositoryEntry re = repositoryService.create(initialAuthor, "Lernen mit OLAT", r.getResourceableTypeName(), null, r);
    if (membersOnly) {
        re.setAccess(RepositoryEntry.ACC_OWNERS);
        re.setMembersOnly(true);
    } else {
        re.setAccess(RepositoryEntry.ACC_USERS);
    }
    repositoryService.update(re);
    return re;
}
Also used : RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryService(org.olat.repository.RepositoryService)

Example 60 with RepositoryService

use of org.olat.repository.RepositoryService in project openolat by klemens.

the class CoursesWebService method createEmptyCourse.

/**
 * Create an empty course with some settings
 * @param initialAuthor
 * @param shortTitle
 * @param longTitle
 * @param softKey
 * @param externalId
 * @param externalRef
 * @param managedFlags
 * @param courseConfigVO
 * @return
 */
public static ICourse createEmptyCourse(Identity initialAuthor, String shortTitle, String longTitle, String reDisplayName, String description, String softKey, int access, boolean membersOnly, String authors, String location, String externalId, String externalRef, String managedFlags, CourseConfigVO courseConfigVO) {
    if (!StringHelper.containsNonWhitespace(reDisplayName)) {
        reDisplayName = shortTitle;
    }
    try {
        // create a repository entry
        RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
        OLATResource resource = OLATResourceManager.getInstance().createOLATResourceInstance(CourseModule.class);
        RepositoryEntry addedEntry = repositoryService.create(initialAuthor, null, "-", reDisplayName, null, resource, 0);
        if (StringHelper.containsNonWhitespace(softKey) && softKey.length() <= 30) {
            addedEntry.setSoftkey(softKey);
        }
        addedEntry.setLocation(location);
        addedEntry.setAuthors(authors);
        addedEntry.setExternalId(externalId);
        addedEntry.setExternalRef(externalRef);
        addedEntry.setManagedFlagsString(managedFlags);
        addedEntry.setDescription(description);
        if (RepositoryEntryManagedFlag.isManaged(addedEntry, RepositoryEntryManagedFlag.membersmanagement)) {
            addedEntry.setAllowToLeaveOption(RepositoryEntryAllowToLeaveOptions.never);
        } else {
            // default
            addedEntry.setAllowToLeaveOption(RepositoryEntryAllowToLeaveOptions.atAnyTime);
        }
        if (membersOnly) {
            addedEntry.setMembersOnly(true);
            addedEntry.setAccess(RepositoryEntry.ACC_OWNERS);
        } else {
            addedEntry.setAccess(access);
        }
        addedEntry = repositoryService.update(addedEntry);
        // create an empty course
        CourseFactory.createCourse(addedEntry, shortTitle, longTitle, "");
        return prepareCourse(addedEntry, shortTitle, longTitle, courseConfigVO);
    } catch (Exception e) {
        throw new WebApplicationException(e);
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) WebApplicationException(javax.ws.rs.WebApplicationException) RepositoryService(org.olat.repository.RepositoryService)

Aggregations

RepositoryService (org.olat.repository.RepositoryService)76 RepositoryEntry (org.olat.repository.RepositoryEntry)72 OLATResource (org.olat.resource.OLATResource)32 Identity (org.olat.core.id.Identity)20 Produces (javax.ws.rs.Produces)18 Path (javax.ws.rs.Path)16 RestSecurityHelper.getIdentity (org.olat.restapi.security.RestSecurityHelper.getIdentity)14 File (java.io.File)12 OLATResourceable (org.olat.core.id.OLATResourceable)12 GET (javax.ws.rs.GET)10 UserRequest (org.olat.core.gui.UserRequest)8 WindowControl (org.olat.core.gui.control.WindowControl)8 ICourse (org.olat.course.ICourse)8 RepositoryHandler (org.olat.repository.handlers.RepositoryHandler)8 UserVO (org.olat.user.restapi.UserVO)7 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)6 Before (org.junit.Before)6 VFSContainer (org.olat.core.util.vfs.VFSContainer)6 GlossaryResource (org.olat.fileresource.types.GlossaryResource)6