Search in sources :

Example 51 with VFSContainer

use of org.olat.core.util.vfs.VFSContainer in project OpenOLAT by OpenOLAT.

the class LinkFileCombiCalloutController method doUnzip.

private VFSContainer doUnzip(VFSLeaf vfsItem, VFSContainer currentContainer) {
    String name = vfsItem.getName();
    // we make a new folder with the same name as the zip file
    String sZipContainer = name.substring(0, name.length() - 4);
    // if zip already exists, create another folder 1,2,3 etc.
    VFSContainer zipContainer = currentContainer.createChildContainer(sZipContainer);
    int i = 1;
    while (zipContainer == null && i < 100) {
        i++;
        sZipContainer = FileUtils.appendNumberAtTheEndOfFilename(sZipContainer, i);
        zipContainer = currentContainer.createChildContainer(sZipContainer);
    }
    if (!ZipUtil.unzip(vfsItem, zipContainer)) {
        // operation failed - rollback
        zipContainer.delete();
        return null;
    } else {
        // check quota
        long quotaLeftKB = VFSManager.getQuotaLeftKB(currentContainer);
        if (quotaLeftKB != Quota.UNLIMITED && quotaLeftKB < 0) {
            // quota exceeded - rollback
            zipContainer.delete();
            getWindowControl().setError(translate("QuotaExceeded"));
            return null;
        }
    }
    return zipContainer;
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer)

Example 52 with VFSContainer

use of org.olat.core.util.vfs.VFSContainer in project OpenOLAT by OpenOLAT.

the class GTACoachController method stepSolution.

@Override
protected Task stepSolution(UserRequest ureq, Task assignedTask) {
    assignedTask = super.stepSolution(ureq, assignedTask);
    if (config.getBooleanSafe(GTACourseNode.GTASK_ASSIGNMENT) || config.getBooleanSafe(GTACourseNode.GTASK_SUBMIT) || config.getBooleanSafe(GTACourseNode.GTASK_REVIEW_AND_CORRECTION) || config.getBooleanSafe(GTACourseNode.GTASK_REVISION_PERIOD)) {
        if (assignedTask == null || assignedTask.getTaskStatus() == TaskProcess.assignment || assignedTask.getTaskStatus() == TaskProcess.submit || assignedTask.getTaskStatus() == TaskProcess.review || assignedTask.getTaskStatus() == TaskProcess.correction || assignedTask.getTaskStatus() == TaskProcess.revision) {
            mainVC.contextPut("solutionCssClass", "");
        } else if (assignedTask.getTaskStatus() == TaskProcess.solution) {
            mainVC.contextPut("solutionCssClass", "o_active");
        } else {
            mainVC.contextPut("solutionCssClass", "o_done");
        }
    } else if (assignedTask == null || assignedTask.getTaskStatus() == TaskProcess.solution) {
        mainVC.contextPut("solutionCssClass", "o_active");
    } else {
        mainVC.contextPut("solutionCssClass", "o_done");
    }
    File documentsDir = gtaManager.getSolutionsDirectory(courseEnv, gtaNode);
    VFSContainer documentsContainer = gtaManager.getSolutionsContainer(courseEnv, gtaNode);
    solutionsCtrl = new DirectoryController(ureq, getWindowControl(), documentsDir, documentsContainer, "run.solutions.description", "bulk.solutions", "solutions");
    listenTo(solutionsCtrl);
    mainVC.put("solutions", solutionsCtrl.getInitialComponent());
    return assignedTask;
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) File(java.io.File)

Example 53 with VFSContainer

use of org.olat.core.util.vfs.VFSContainer in project OpenOLAT by OpenOLAT.

the class GTACoachController method stepSubmit.

@Override
protected Task stepSubmit(UserRequest ureq, Task assignedTask) {
    assignedTask = super.stepSubmit(ureq, assignedTask);
    if (collectSubmissionsLink != null) {
        // clean up
        mainVC.remove(collectSubmissionsLink);
    }
    if (backToSubmissionLink != null) {
        mainVC.remove(backToSubmissionLink);
    }
    // calculate state
    boolean viewSubmittedDocument = false;
    if (config.getBooleanSafe(GTACourseNode.GTASK_ASSIGNMENT)) {
        if (assignedTask == null || assignedTask.getTaskStatus() == TaskProcess.assignment) {
            mainVC.contextPut("submitCssClass", "");
        } else if (assignedTask == null || assignedTask.getTaskStatus() == TaskProcess.submit) {
            mainVC.contextPut("submitCssClass", "o_active");
            collect(assignedTask);
        } else {
            mainVC.contextPut("submitCssClass", "o_done");
            viewSubmittedDocument = true;
        }
    } else if (assignedTask == null || assignedTask.getTaskStatus() == TaskProcess.submit) {
        mainVC.contextPut("submitCssClass", "o_active");
        collect(assignedTask);
    } else {
        mainVC.contextPut("submitCssClass", "o_done");
        viewSubmittedDocument = true;
    }
    if (assignedTask == null || (assignedTask.getTaskStatus() != TaskProcess.submit)) {
        backToSubmission(assignedTask);
    }
    if (viewSubmittedDocument) {
        File documentsDir;
        VFSContainer documentsContainer = null;
        if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
            documentsDir = gtaManager.getSubmitDirectory(courseEnv, gtaNode, assessedGroup);
            documentsContainer = gtaManager.getSubmitContainer(courseEnv, gtaNode, assessedGroup);
        } else {
            documentsDir = gtaManager.getSubmitDirectory(courseEnv, gtaNode, assessedIdentity);
            documentsContainer = gtaManager.getSubmitContainer(courseEnv, gtaNode, assessedIdentity);
        }
        boolean hasDocuments = TaskHelper.hasDocuments(documentsDir);
        if (hasDocuments) {
            submittedDocCtrl = new DirectoryController(ureq, getWindowControl(), documentsDir, documentsContainer, "coach.submitted.documents.description", "bulk.submitted.documents", "submission");
            listenTo(submittedDocCtrl);
            mainVC.put("submittedDocs", submittedDocCtrl.getInitialComponent());
        } else {
            TextFactory.createTextComponentFromI18nKey("submittedDocs", "coach.submitted.nofiles", getTranslator(), null, true, mainVC);
        }
    }
    return assignedTask;
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) File(java.io.File)

Example 54 with VFSContainer

use of org.olat.core.util.vfs.VFSContainer in project OpenOLAT by OpenOLAT.

the class GTACoachController method setUploadCorrections.

private void setUploadCorrections(UserRequest ureq, Task task) {
    File documentsDir;
    VFSContainer documentsContainer;
    if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
        documentsDir = gtaManager.getCorrectionDirectory(courseEnv, gtaNode, assessedGroup);
        documentsContainer = gtaManager.getCorrectionContainer(courseEnv, gtaNode, assessedGroup);
    } else {
        documentsDir = gtaManager.getCorrectionDirectory(courseEnv, gtaNode, assessedIdentity);
        documentsContainer = gtaManager.getCorrectionContainer(courseEnv, gtaNode, assessedIdentity);
    }
    submitCorrectionsCtrl = new SubmitDocumentsController(ureq, getWindowControl(), task, documentsDir, documentsContainer, -1, gtaNode, courseEnv, coachCourseEnv.isCourseReadOnly(), null, "coach.document");
    listenTo(submitCorrectionsCtrl);
    mainVC.put("corrections", submitCorrectionsCtrl.getInitialComponent());
    reviewedButton.setVisible(!coachCourseEnv.isCourseReadOnly());
    if (config.getBooleanSafe(GTACourseNode.GTASK_REVISION_PERIOD)) {
        needRevisionsButton.setVisible(!coachCourseEnv.isCourseReadOnly());
    }
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) File(java.io.File)

Example 55 with VFSContainer

use of org.olat.core.util.vfs.VFSContainer in project OpenOLAT by OpenOLAT.

the class GTACoachController method setCorrections.

private void setCorrections(UserRequest ureq, boolean hasRevisions) {
    File documentsDir;
    VFSContainer documentsContainer;
    if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
        documentsDir = gtaManager.getCorrectionDirectory(courseEnv, gtaNode, assessedGroup);
        documentsContainer = gtaManager.getCorrectionContainer(courseEnv, gtaNode, assessedGroup);
    } else {
        documentsDir = gtaManager.getCorrectionDirectory(courseEnv, gtaNode, assessedIdentity);
        documentsContainer = gtaManager.getCorrectionContainer(courseEnv, gtaNode, assessedIdentity);
    }
    boolean hasDocuments = TaskHelper.hasDocuments(documentsDir);
    if (hasDocuments) {
        correctionsCtrl = new DirectoryController(ureq, getWindowControl(), documentsDir, documentsContainer, "coach.corrections.description", "bulk.review", "review");
        listenTo(correctionsCtrl);
        mainVC.put("corrections", correctionsCtrl.getInitialComponent());
    } else if (hasRevisions) {
        String msg = "<i class='o_icon o_icon_warn'> </i> " + translate("coach.corrections.rejected");
        TextFactory.createTextComponentFromString("corrections", msg, null, true, mainVC);
    } else {
        String msg = "<i class='o_icon o_icon_ok'> </i> " + translate("coach.corrections.closed");
        TextFactory.createTextComponentFromString("corrections", msg, null, true, mainVC);
    }
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) File(java.io.File)

Aggregations

VFSContainer (org.olat.core.util.vfs.VFSContainer)962 VFSItem (org.olat.core.util.vfs.VFSItem)364 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)338 File (java.io.File)170 Test (org.junit.Test)136 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)86 Identity (org.olat.core.id.Identity)86 LocalFolderImpl (org.olat.core.util.vfs.LocalFolderImpl)76 RepositoryEntry (org.olat.repository.RepositoryEntry)76 IOException (java.io.IOException)74 InputStream (java.io.InputStream)64 ArrayList (java.util.ArrayList)64 Date (java.util.Date)60 URI (java.net.URI)56 MetaInfo (org.olat.core.commons.modules.bc.meta.MetaInfo)42 OutputStream (java.io.OutputStream)40 HttpResponse (org.apache.http.HttpResponse)38 MetaTagged (org.olat.core.commons.modules.bc.meta.tagged.MetaTagged)34 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)34 BlogFileResource (org.olat.fileresource.types.BlogFileResource)34