use of org.olat.fileresource.FileResourceManager in project openolat by klemens.
the class ImsRepositoryResolver method init.
private void init(OLATResourceable fileResource) {
FileResourceManager frm = FileResourceManager.getInstance();
fUnzippedDirRoot = frm.unzipFileResource(fileResource);
sUnzippedDirRel = frm.getUnzippedDirRel(fileResource);
}
use of org.olat.fileresource.FileResourceManager in project openolat by klemens.
the class QTIEditorPackageImpl method unzipPackage.
/**
* Unzip package into temporary directory.
* @return true if successfull, false otherwise
*/
private boolean unzipPackage() {
FileResourceManager frm = FileResourceManager.getInstance();
File fPackageZIP = frm.getFileResource(fileResource);
return ZipUtil.unzip(fPackageZIP, packageDir);
}
use of org.olat.fileresource.FileResourceManager in project openolat by klemens.
the class QTIEditorPackageImpl method savePackageToRepository.
/**
* @return True upon success, false otherwise.
*/
public boolean savePackageToRepository() {
FileResourceManager frm = FileResourceManager.getInstance();
File tmpZipFile = new File(WebappHelper.getTmpDir(), CodeHelper.getUniqueID() + ".zip");
// first save complete ZIP package to repository
if (!savePackageTo(tmpZipFile))
return false;
// move file from temp to repository root and rename
File fRepositoryZip = frm.getFileResource(fileResource);
if (!FileUtils.moveFileToDir(tmpZipFile, frm.getFileResourceRoot(fileResource))) {
tmpZipFile.delete();
return false;
}
fRepositoryZip.delete();
new File(frm.getFileResourceRoot(fileResource), tmpZipFile.getName()).renameTo(fRepositoryZip);
// delete old unzip content. If the repository entry gets called in the meantime,
// the package will get unzipped again.
tmpZipFile.delete();
frm.deleteUnzipContent(fileResource);
// to be prepared for the next start, unzip right now.
return (frm.unzipFileResource(fileResource) != null);
}
use of org.olat.fileresource.FileResourceManager in project OpenOLAT by OpenOLAT.
the class RepositoryEntryResource method replaceFileResource.
private RepositoryEntry replaceFileResource(Identity identity, RepositoryEntry re, File fResource) {
if (re == null)
throw new NullPointerException("RepositoryEntry cannot be null");
FileResourceManager frm = FileResourceManager.getInstance();
File currentResource = frm.getFileResource(re.getOlatResource());
if (currentResource == null || !currentResource.exists()) {
log.debug("Current resource file doesn't exist");
return null;
}
String typeName = re.getOlatResource().getResourceableTypeName();
if (typeName.equals(ImsCPFileResource.TYPE_NAME)) {
if (currentResource.delete()) {
FileUtils.copyFileToFile(fResource, currentResource, false);
String repositoryHome = FolderConfig.getCanonicalRepositoryHome();
String relUnzipDir = frm.getUnzippedDirRel(re.getOlatResource());
File unzipDir = new File(repositoryHome, relUnzipDir);
if (unzipDir != null && unzipDir.exists()) {
FileUtils.deleteDirsAndFiles(unzipDir, true, true);
}
frm.unzipFileResource(re.getOlatResource());
}
log.audit("Resource: " + re.getOlatResource() + " replaced by " + identity.getName());
return re;
}
log.debug("Cannot replace a resource of the type: " + typeName);
return null;
}
use of org.olat.fileresource.FileResourceManager in project OpenOLAT by OpenOLAT.
the class QTI21AssessmentRunController method doShowResults.
private void doShowResults(UserRequest ureq) {
removeAsListenerAndDispose(resultCtrl);
AssessmentTestSession session = null;
if (courseNode instanceof SelfAssessableCourseNode) {
RepositoryEntry courseEntry = userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
session = qtiService.getLastAssessmentTestSessions(courseEntry, courseNode.getIdent(), testEntry, getIdentity());
} else {
AssessmentManager am = userCourseEnv.getCourseEnvironment().getAssessmentManager();
AssessmentEntry assessmentEntry = am.getAssessmentEntry(courseNode, getIdentity());
if (assessmentEntry.getAssessmentId() != null) {
session = qtiService.getAssessmentTestSession(assessmentEntry.getAssessmentId());
} else {
RepositoryEntry courseEntry = userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
session = qtiService.getLastAssessmentTestSessions(courseEntry, courseNode.getIdent(), testEntry, getIdentity());
}
}
if (session == null) {
mainVC.contextPut("showResults", Boolean.FALSE);
} else {
FileResourceManager frm = FileResourceManager.getInstance();
File fUnzippedDirRoot = frm.unzipFileResource(session.getTestEntry().getOlatResource());
URI assessmentObjectUri = qtiService.createAssessmentTestUri(fUnzippedDirRoot);
File submissionDir = qtiService.getAssessmentResultFile(session);
String mapperUri = registerCacheableMapper(ureq, "QTI21CNResults::" + session.getTestEntry().getKey(), new ResourcesMapper(assessmentObjectUri, submissionDir));
resultCtrl = new AssessmentResultController(ureq, getWindowControl(), getIdentity(), true, session, fUnzippedDirRoot, mapperUri, null, getDeliveryOptions().getAssessmentResultsOptions(), false, false, true);
listenTo(resultCtrl);
mainVC.put("resultReport", resultCtrl.getInitialComponent());
mainVC.contextPut("showResults", Boolean.TRUE);
}
saveOpenPanel(ureq, "results", Boolean.TRUE);
}
Aggregations