Search in sources :

Example 26 with OLATResourceManager

use of org.olat.resource.OLATResourceManager in project openolat by klemens.

the class CourseHandler method cleanupOnDelete.

@Override
public boolean cleanupOnDelete(RepositoryEntry entry, OLATResourceable res) {
    // notify all current users of this resource (course) that it will be deleted now.
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new OLATResourceableJustBeforeDeletedEvent(res), res);
    // archiving is done within readyToDelete
    OLATResourceManager rm = OLATResourceManager.getInstance();
    OLATResource resource = rm.findResourceable(res);
    CourseFactory.deleteCourse(entry, resource);
    return true;
}
Also used : OLATResourceableJustBeforeDeletedEvent(org.olat.core.util.resource.OLATResourceableJustBeforeDeletedEvent) OLATResourceManager(org.olat.resource.OLATResourceManager) OLATResource(org.olat.resource.OLATResource)

Example 27 with OLATResourceManager

use of org.olat.resource.OLATResourceManager in project openolat by klemens.

the class RepositoryManagerTest method testRawRepositoryEntryCreate.

/**
 * Test creation of a repository entry.
 */
@Test
public void testRawRepositoryEntryCreate() {
    try {
        OLATResourceable resourceable = OresHelper.createOLATResourceableInstance("RepoMgrTestCourse", CodeHelper.getForeverUniqueID());
        OLATResourceManager rm = OLATResourceManager.getInstance();
        // create course and persist as OLATResourceImpl
        OLATResource r = rm.createOLATResourceInstance(resourceable);
        dbInstance.getCurrentEntityManager().persist(r);
        RepositoryEntry d = repositoryService.create("Florian Gnägi", "Lernen mit OpenOLAT", "JunitTest_RepositoryEntry", "Beschreibung", r);
        dbInstance.commit();
        Assert.assertNotNull(d);
    } catch (Exception ex) {
        ex.printStackTrace();
        fail("No Exception allowed. ex=" + ex.getMessage());
    }
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) OLATResourceManager(org.olat.resource.OLATResourceManager) OLATResource(org.olat.resource.OLATResource) AssertException(org.olat.core.logging.AssertException) LazyInitializationException(org.hibernate.LazyInitializationException) Test(org.junit.Test)

Example 28 with OLATResourceManager

use of org.olat.resource.OLATResourceManager in project openolat by klemens.

the class QTIStatisticsManagerLargeTest method createRepository.

private RepositoryEntry createRepository() {
    OLATResourceManager rm = OLATResourceManager.getInstance();
    // create course and persist as OLATResourceImpl
    OLATResource r = rm.createOLATResourceInstance("QTIStatisticsTest");
    dbInstance.saveObject(r);
    dbInstance.intermediateCommit();
    RepositoryEntry d = repositoryService.create("Kanu Unchou", "QTIStatisticsTest", "QTIStatisticsTest", "Repo entry", r);
    dbInstance.saveObject(d);
    dbInstance.intermediateCommit();
    return d;
}
Also used : OLATResourceManager(org.olat.resource.OLATResourceManager) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 29 with OLATResourceManager

use of org.olat.resource.OLATResourceManager in project openolat by klemens.

the class EfficiencyStatementWebService method putEfficiencyStatement.

/**
 * Create a new efficiency statement.
 *
 * @response.representation.200.doc If the statement was persisted
 * @response.representation.401.doc The roles of the authenticated user are not sufficient
 * @response.representation.404.doc The identity or the resource cannot be found
 * @param identityKey The owner of the certificate
 * @param resourceKey The primary key of the resource of the repository entry of the course.
 * @return Nothing special
 */
@PUT
@Path("{identityKey}")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response putEfficiencyStatement(@PathParam("identityKey") Long identityKey, @PathParam("resourceKey") Long resourceKey, EfficiencyStatementVO efficiencyStatementVO, @Context HttpServletRequest request) {
    if (!isAdmin(request)) {
        return Response.serverError().status(Status.UNAUTHORIZED).build();
    }
    BaseSecurity baseSecurity = CoreSpringFactory.getImpl(BaseSecurity.class);
    Identity assessedIdentity = baseSecurity.loadIdentityByKey(identityKey);
    if (assessedIdentity == null) {
        return Response.serverError().status(Response.Status.NOT_FOUND).build();
    }
    EfficiencyStatementManager efficiencyStatementManager = CoreSpringFactory.getImpl(EfficiencyStatementManager.class);
    EfficiencyStatement efficiencyStatement = efficiencyStatementManager.getUserEfficiencyStatementByResourceKey(resourceKey, assessedIdentity);
    if (efficiencyStatement != null) {
        return Response.serverError().status(Response.Status.CONFLICT).build();
    }
    Date creationDate = efficiencyStatementVO.getCreationDate();
    Float score = efficiencyStatementVO.getScore();
    Boolean passed = efficiencyStatementVO.getPassed();
    OLATResourceManager resourceManager = CoreSpringFactory.getImpl(OLATResourceManager.class);
    OLATResource resource = resourceManager.findResourceById(resourceKey);
    if (resource == null) {
        String courseTitle = efficiencyStatementVO.getCourseTitle();
        efficiencyStatementManager.createStandAloneUserEfficiencyStatement(creationDate, score, passed, assessedIdentity, resourceKey, courseTitle);
    } else {
        efficiencyStatementManager.createUserEfficiencyStatement(creationDate, score, passed, assessedIdentity, resource);
    }
    return Response.ok().build();
}
Also used : EfficiencyStatementManager(org.olat.course.assessment.manager.EfficiencyStatementManager) OLATResourceManager(org.olat.resource.OLATResourceManager) OLATResource(org.olat.resource.OLATResource) Identity(org.olat.core.id.Identity) EfficiencyStatement(org.olat.course.assessment.EfficiencyStatement) UserEfficiencyStatement(org.olat.course.assessment.UserEfficiencyStatement) Date(java.util.Date) BaseSecurity(org.olat.basesecurity.BaseSecurity) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Example 30 with OLATResourceManager

use of org.olat.resource.OLATResourceManager in project openolat by klemens.

the class CertificationWebService method getCertificateInfo.

@HEAD
@Path("{identityKey}")
@Produces({ "application/pdf" })
public Response getCertificateInfo(@PathParam("identityKey") Long identityKey, @PathParam("resourceKey") Long resourceKey, @Context HttpServletRequest request) {
    if (!isAdmin(request)) {
        return Response.serverError().status(Status.UNAUTHORIZED).build();
    }
    CertificatesManager certificatesManager = CoreSpringFactory.getImpl(CertificatesManager.class);
    BaseSecurity baseSecurity = CoreSpringFactory.getImpl(BaseSecurity.class);
    Identity identity = baseSecurity.loadIdentityByKey(identityKey);
    if (identity == null) {
        return Response.serverError().status(Response.Status.NOT_FOUND).build();
    }
    OLATResourceable courseOres = OresHelper.createOLATResourceableInstance("CourseModule", resourceKey);
    OLATResourceManager resourceManager = CoreSpringFactory.getImpl(OLATResourceManager.class);
    OLATResource resource = resourceManager.findResourceable(courseOres);
    if (resource == null) {
        resource = resourceManager.findResourceById(resourceKey);
    }
    if (resource == null) {
        return Response.serverError().status(Response.Status.NOT_FOUND).build();
    }
    Certificate certificate = certificatesManager.getLastCertificate(identity, resource.getKey());
    if (certificate == null) {
        return Response.serverError().status(Response.Status.NOT_FOUND).build();
    }
    VFSLeaf certificateFile = certificatesManager.getCertificateLeaf(certificate);
    if (certificateFile == null || !certificateFile.exists()) {
        return Response.serverError().status(Response.Status.NOT_FOUND).build();
    }
    return Response.ok().build();
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) OLATResourceable(org.olat.core.id.OLATResourceable) CertificatesManager(org.olat.course.certificate.CertificatesManager) OLATResourceManager(org.olat.resource.OLATResourceManager) OLATResource(org.olat.resource.OLATResource) Identity(org.olat.core.id.Identity) BaseSecurity(org.olat.basesecurity.BaseSecurity) Certificate(org.olat.course.certificate.Certificate) Path(javax.ws.rs.Path) HEAD(javax.ws.rs.HEAD) Produces(javax.ws.rs.Produces)

Aggregations

OLATResourceManager (org.olat.resource.OLATResourceManager)32 OLATResource (org.olat.resource.OLATResource)30 OLATResourceable (org.olat.core.id.OLATResourceable)14 Identity (org.olat.core.id.Identity)12 RepositoryEntry (org.olat.repository.RepositoryEntry)12 Path (javax.ws.rs.Path)10 BaseSecurity (org.olat.basesecurity.BaseSecurity)10 CertificatesManager (org.olat.course.certificate.CertificatesManager)8 Date (java.util.Date)6 VFSContainer (org.olat.core.util.vfs.VFSContainer)6 Certificate (org.olat.course.certificate.Certificate)6 File (java.io.File)4 IOException (java.io.IOException)4 Consumes (javax.ws.rs.Consumes)4 PUT (javax.ws.rs.PUT)4 Produces (javax.ws.rs.Produces)4 Before (org.junit.Before)4 CollaborationTools (org.olat.collaboration.CollaborationTools)4 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)4 Forum (org.olat.modules.fo.Forum)4