Search in sources :

Example 11 with OLATResourceManager

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

the class WikiManager method createWiki.

// ---- end controller factory -----
/**
 * @return the new created resource
 */
public WikiResource createWiki() {
    WikiResource resource = new WikiResource();
    createFolders(resource);
    OLATResourceManager rm = getResourceManager();
    OLATResource ores = rm.createOLATResourceInstance(resource);
    rm.saveOLATResource(ores);
    return resource;
}
Also used : WikiResource(org.olat.fileresource.types.WikiResource) OLATResourceManager(org.olat.resource.OLATResourceManager) OLATResource(org.olat.resource.OLATResource)

Example 12 with OLATResourceManager

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

the class CertificationWebService method postCertificate.

/**
 * Upload a new certificate.
 *
 * @response.representation.200.doc if the certificate was uploaded
 * @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.
 * @param request The request
 * @return Nothing special
 */
@POST
@Path("{identityKey}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response postCertificate(@PathParam("identityKey") Long identityKey, @PathParam("resourceKey") Long resourceKey, @Context HttpServletRequest request) {
    if (!isAdmin(request)) {
        return Response.serverError().status(Status.UNAUTHORIZED).build();
    }
    MultipartReader partsReader = null;
    try {
        partsReader = new MultipartReader(request);
        File tmpFile = partsReader.getFile();
        String courseTitle = partsReader.getValue("courseTitle");
        String creationDateStr = partsReader.getValue("creationDate");
        Date creationDate = null;
        if (StringHelper.containsNonWhitespace(creationDateStr)) {
            creationDate = ObjectFactory.parseDate(creationDateStr);
        }
        CertificatesManager certificatesManager = CoreSpringFactory.getImpl(CertificatesManager.class);
        BaseSecurity baseSecurity = CoreSpringFactory.getImpl(BaseSecurity.class);
        Identity assessedIdentity = baseSecurity.loadIdentityByKey(identityKey);
        if (assessedIdentity == null) {
            return Response.serverError().status(Response.Status.NOT_FOUND).build();
        }
        OLATResourceManager resourceManager = CoreSpringFactory.getImpl(OLATResourceManager.class);
        OLATResource resource = resourceManager.findResourceById(resourceKey);
        if (resource == null) {
            certificatesManager.uploadStandaloneCertificate(assessedIdentity, creationDate, courseTitle, resourceKey, tmpFile);
        } else {
            certificatesManager.uploadCertificate(assessedIdentity, creationDate, resource, tmpFile);
        }
        return Response.ok().build();
    } catch (Throwable e) {
        throw new WebApplicationException(e);
    } finally {
        MultipartReader.closeQuietly(partsReader);
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) CertificatesManager(org.olat.course.certificate.CertificatesManager) OLATResourceManager(org.olat.resource.OLATResourceManager) OLATResource(org.olat.resource.OLATResource) Identity(org.olat.core.id.Identity) File(java.io.File) MultipartReader(org.olat.restapi.support.MultipartReader) Date(java.util.Date) BaseSecurity(org.olat.basesecurity.BaseSecurity) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes)

Example 13 with OLATResourceManager

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

the class GlossaryManagerImpl method createGlossary.

/**
 * Creates a glossary resource and creates the necessary folders on disk. The
 * glossary will be placed in the resources _unizipped dir to make import /
 * export easier
 *
 * @return
 */
@Override
public GlossaryResource createGlossary() {
    GlossaryResource resource = new GlossaryResource();
    VFSContainer rootContainer = FileResourceManager.getInstance().getFileResourceRootImpl(resource);
    if (rootContainer == null)
        return null;
    if (rootContainer.createChildContainer(INTERNAL_FOLDER_NAME) == null)
        return null;
    OLATResourceManager rm = OLATResourceManager.getInstance();
    OLATResource ores = rm.createOLATResourceInstance(resource);
    rm.saveOLATResource(ores);
    return resource;
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) OLATResourceManager(org.olat.resource.OLATResourceManager) OLATResource(org.olat.resource.OLATResource) GlossaryResource(org.olat.fileresource.types.GlossaryResource)

Example 14 with OLATResourceManager

use of org.olat.resource.OLATResourceManager in project OpenOLAT by OpenOLAT.

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 15 with OLATResourceManager

use of org.olat.resource.OLATResourceManager in project OpenOLAT by OpenOLAT.

the class WikiManager method createWiki.

// ---- end controller factory -----
/**
 * @return the new created resource
 */
public WikiResource createWiki() {
    WikiResource resource = new WikiResource();
    createFolders(resource);
    OLATResourceManager rm = getResourceManager();
    OLATResource ores = rm.createOLATResourceInstance(resource);
    rm.saveOLATResource(ores);
    return resource;
}
Also used : WikiResource(org.olat.fileresource.types.WikiResource) OLATResourceManager(org.olat.resource.OLATResourceManager) OLATResource(org.olat.resource.OLATResource)

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