use of org.olat.core.commons.modules.bc.meta.MetaInfo in project OpenOLAT by OpenOLAT.
the class CmdCreateFile method formOK.
@Override
protected void formOK(UserRequest ureq) {
// create the file
fileName = textElement.getValue();
VFSContainer currentContainer = folderComponent.getCurrentContainer();
VFSItem item = currentContainer.createChildLeaf(fileName);
if (item == null) {
status = FolderCommandStatus.STATUS_FAILED;
notifyFinished(ureq);
} else {
if (item instanceof MetaTagged) {
MetaInfo meta = ((MetaTagged) item).getMetaInfo();
meta.setAuthor(ureq.getIdentity());
if (licenseModule.isEnabled(licenseHandler)) {
License license = licenseService.createDefaultLicense(licenseHandler, getIdentity());
meta.setLicenseTypeKey(String.valueOf(license.getLicenseType().getKey()));
meta.setLicenseTypeName(license.getLicenseType().getName());
meta.setLicensor(license.getLicensor());
meta.setLicenseText(LicenseUIFactory.getLicenseText(license));
}
meta.write();
}
// start HTML editor with the folders root folder as base and the file
// path as a relative path from the root directory. But first check if the
// root directory is wirtable at all (e.g. not the case in users personal
// briefcase), and seach for the next higher directory that is writable.
String relFilePath = "/" + fileName;
// add current container path if not at root level
if (!folderComponent.getCurrentContainerPath().equals("/")) {
relFilePath = folderComponent.getCurrentContainerPath() + relFilePath;
}
VFSContainer writableRootContainer = folderComponent.getRootContainer();
ContainerAndFile result = VFSManager.findWritableRootFolderFor(writableRootContainer, relFilePath);
if (result != null) {
writableRootContainer = result.getContainer();
relFilePath = result.getFileName();
} else {
// use fallback that always work: current directory and current file
relFilePath = fileName;
writableRootContainer = folderComponent.getCurrentContainer();
}
if (relFilePath.endsWith(".html") || relFilePath.endsWith(".htm")) {
editorCtr = WysiwygFactory.createWysiwygController(ureq, getWindowControl(), writableRootContainer, relFilePath, true, true);
((HTMLEditorController) editorCtr).setNewFile(true);
} else {
editorCtr = new PlainTextEditorController(ureq, getWindowControl(), (VFSLeaf) writableRootContainer.resolve(relFilePath), "utf-8", true, true, null);
}
listenTo(editorCtr);
initialPanel.setContent(editorCtr.getInitialComponent());
}
}
use of org.olat.core.commons.modules.bc.meta.MetaInfo in project OpenOLAT by OpenOLAT.
the class FolderManager method getFileInfosRecursively.
private static void getFileInfosRecursively(OlatRelPathImpl relPath, List<FileInfo> fileInfos, long newerThan, int basePathlen) {
if (relPath instanceof VFSLeaf) {
// is a file
long lastModified = ((VFSLeaf) relPath).getLastModified();
if (lastModified > newerThan) {
MetaInfo meta = CoreSpringFactory.getImpl(MetaInfoFactory.class).createMetaInfoFor(relPath);
String bcrootPath = relPath.getRelPath();
String bcRelPath = bcrootPath.substring(basePathlen);
fileInfos.add(new FileInfo(bcRelPath, meta, new Date(lastModified)));
}
} else {
// is a folder
OlatRootFolderImpl container = (OlatRootFolderImpl) relPath;
for (VFSItem item : container.getItems(new SystemItemFilter())) {
getFileInfosRecursively((OlatRelPathImpl) item, fileInfos, newerThan, basePathlen);
}
}
}
use of org.olat.core.commons.modules.bc.meta.MetaInfo in project OpenOLAT by OpenOLAT.
the class CmdCreateFolder method formOK.
@Override
protected void formOK(UserRequest ureq) {
// create the folder
String name = textElement.getValue();
VFSContainer currentContainer = folderComponent.getCurrentContainer();
VFSItem item = currentContainer.createChildContainer(name);
if (item instanceof OlatRelPathImpl) {
// update meta data
MetaInfo meta = metaInfoFactory.createMetaInfoFor((OlatRelPathImpl) item);
meta.setAuthor(ureq.getIdentity());
meta.write();
status = FolderCommandStatus.STATUS_FAILED;
fireEvent(ureq, new FolderEvent(FolderEvent.NEW_FOLDER_EVENT, folderName));
fireEvent(ureq, FolderCommand.FOLDERCOMMAND_FINISHED);
} else {
status = FolderCommandStatus.STATUS_FAILED;
fireEvent(ureq, FolderCommand.FOLDERCOMMAND_FINISHED);
}
}
use of org.olat.core.commons.modules.bc.meta.MetaInfo in project OpenOLAT by OpenOLAT.
the class FileCopyController method finishSuccessfullUpload.
private void finishSuccessfullUpload(String fileName, UserRequest ureq) {
VFSContainer currentContainer = folderComponent.getCurrentContainer();
VFSItem item = currentContainer.resolve(fileName);
if (item instanceof OlatRootFileImpl) {
OlatRootFileImpl relPathItem = (OlatRootFileImpl) item;
// create meta data
MetaInfo meta = CoreSpringFactory.getImpl(MetaInfoFactory.class).createMetaInfoFor(relPathItem);
meta.setAuthor(ureq.getIdentity());
// if overwrite an older file
meta.clearThumbnails();
meta.write();
}
ThreadLocalUserActivityLogger.log(FolderLoggingAction.FILE_COPIED, getClass(), CoreLoggingResourceable.wrapUploadFile(fileName));
// Notify listeners about upload
fireEvent(ureq, new FolderEvent(FolderEvent.NEW_FILE_EVENT, newFile.getName()));
fireEvent(ureq, FolderCommand.FOLDERCOMMAND_FINISHED);
}
use of org.olat.core.commons.modules.bc.meta.MetaInfo in project OpenOLAT by OpenOLAT.
the class MetaTaggedComparator method compare.
public int compare(MetaTagged i1, MetaTagged i2) {
MetaInfo m1 = i1.getMetaInfo();
MetaInfo m2 = i2.getMetaInfo();
return comparator.compare(m1, m2);
}
Aggregations