Skip to content
Snippets Groups Projects
Commit cb8808d7 authored by srosse's avatar srosse
Browse files

no-jira: remove unused details in repository handler

parent a7b4eacc
No related branches found
No related tags found
No related merge requests found
Showing
with 2 additions and 215 deletions
/**
* OLAT - Online Learning and Training<br>
* http://www.olat.org
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br>
* University of Zurich, Switzerland.
* <hr>
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* This file has been modified by the OpenOLAT community. Changes are licensed
* under the Apache 2.0 license as the original file.
*/
package org.olat.fileresource;
import java.io.File;
import java.text.DateFormat;
import java.util.Date;
import java.util.List;
import org.dom4j.Document;
import org.dom4j.Element;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.form.flexible.FormItemContainer;
import org.olat.core.gui.components.form.flexible.impl.FormBasicController;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.id.OLATResourceable;
import org.olat.core.util.vfs.LocalFileImpl;
import org.olat.core.util.vfs.LocalFolderImpl;
import org.olat.core.util.vfs.VFSContainer;
import org.olat.core.util.vfs.VFSItem;
import org.olat.fileresource.types.ImsCPFileResource;
import org.olat.fileresource.types.ScormCPFileResource;
import org.olat.ims.qti.fileresource.SurveyFileResource;
import org.olat.ims.qti.fileresource.TestFileResource;
import org.olat.ims.qti.process.QTIHelper;
/**
* Initial Date: Apr 19, 2004
*
* @author Mike Stock
*
*/
public class FileDetailsForm extends FormBasicController {
private OLATResourceable res;
private File file;
/**
* Create details form with values from resourceable res.
* @param name
* @param locale
* @param res
*/
public FileDetailsForm(UserRequest ureq, WindowControl wControl, OLATResourceable res) {
super(ureq, wControl);
this.res = res;
file = FileResourceManager.getInstance().getFileResource(res);
initForm (ureq);
}
@Override
protected void formOK(UserRequest ureq) {
//
}
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
uifactory.addStaticTextElement("size", "fr.size", new Long(file.length() / 1024).toString() + " KB", formLayout);
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, getLocale());
uifactory.addStaticTextElement("last", "fr.last", df.format(new Date(file.lastModified())), formLayout);
String resType = res.getResourceableTypeName();
if (resType.equals(TestFileResource.TYPE_NAME) || resType.equals(SurveyFileResource.TYPE_NAME)) {
FileResourceManager frm = FileResourceManager.getInstance();
File unzippedRoot = frm.unzipFileResource(res);
//with VFS FIXME:pb:c: remove casts to LocalFileImpl and LocalFolderImpl if no longer needed.
VFSContainer vfsUnzippedRoot = new LocalFolderImpl(unzippedRoot);
VFSItem vfsQTI = vfsUnzippedRoot.resolve("qti.xml");
//getDocument(..) ensures that InputStream is closed in every case.
Document doc = QTIHelper.getDocument((LocalFileImpl) vfsQTI);
//if doc is null an error loading the document occured (IOException, qti.xml does not exist)
if (doc != null) {
// extract title
Element el_assess = (Element)doc.selectSingleNode("questestinterop/assessment");
String title = el_assess.attributeValue("title");
uifactory.addStaticTextElement("title", "qti.title", title==null?"-":title, formLayout);
// extract objectives
//HTMLTextAreaElement htmlTA = new HTMLTextAreaElement("qti.objectives", 10, 60);
//htmlTA.setReadOnly(true);
String obj = "-";
Element el_objectives = (Element)doc.selectSingleNode("//questestinterop/assessment/objectives");
if (el_objectives != null) {
Element el_mat = (Element)el_objectives.selectSingleNode("material/mattext");
if (el_mat != null) {
obj = el_mat.getTextTrim();
}
}
uifactory.addStaticTextElement("obj", "qti.objectives", obj, formLayout);
// extract num of questions
List items = doc.selectNodes("//item");
uifactory.addStaticTextElement("qti.questions", "qti.questions", items.size()>0?""+items.size():"-", formLayout);
// extract time limit
String tl = "-";
Element el_duration = (Element)el_assess.selectSingleNode("duration");
if (el_duration != null) {
long dur = QTIHelper.parseISODuration(el_duration.getTextTrim());
long min = dur / 1024 / 60;
long sec = (dur - (min * 60 * 1024)) / 1024;
tl = "" + min + "' " + sec + "''";
}
uifactory.addStaticTextElement("qti.timelimit", "qti.timelimit", tl, formLayout);
}
} else if (resType.equals(ImsCPFileResource.TYPE_NAME) || resType.equals(ScormCPFileResource.TYPE_NAME)) {
//
}
flc.setEnabled(false);
}
@Override
protected void doDispose() {
//
}
}
......@@ -29,9 +29,6 @@ import java.io.File;
import org.olat.core.commons.modules.bc.FolderConfig;
import org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.media.MediaResource;
import org.olat.core.id.OLATResourceable;
import org.olat.core.logging.OLATRuntimeException;
......@@ -265,14 +262,6 @@ public class FileResourceManager extends BasicManager {
return FileUtils.deleteDirsAndFiles(zipTargetDir, true, true);
}
/**
* @param res
* @return FormBasicController
*/
public Controller getDetailsForm(UserRequest ureq, WindowControl wControl, OLATResourceable res) {
return new FileDetailsForm(ureq, wControl, res);
}
private FileResource getAsGenericFileResource(OLATResourceable res) {
FileResource fr = new FileResource();
fr.overrideResourceableId(res.getResourceableId());
......
......@@ -158,11 +158,6 @@ public class BlogHandler implements RepositoryHandler {
.getFileResourceMedia(repoEntry.getOlatResource());
}
@Override
public Controller createDetailsForm(UserRequest ureq, WindowControl wControl, OLATResourceable res) {
return FileResourceManager.getInstance().getDetailsForm(ureq, wControl, res);
}
@Override
public Controller createEditorController(RepositoryEntry re, UserRequest ureq, WindowControl control, TooledStackedPanel toolbar) {
return null;
......
......@@ -494,11 +494,6 @@ public class CourseHandler implements RepositoryHandler {
return ccSMRC;
}
@Override
public Controller createDetailsForm(UserRequest ureq, WindowControl wControl, OLATResourceable res) {
return null;
}
@Override
public boolean cleanupOnDelete(OLATResourceable res) {
// notify all current users of this resource (course) that it will be deleted now.
......
......@@ -28,9 +28,6 @@ package org.olat.repository.handlers;
import java.io.File;
import java.util.Locale;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.media.MediaResource;
import org.olat.core.gui.translator.Translator;
import org.olat.core.id.Identity;
......@@ -62,11 +59,6 @@ public abstract class FileHandler implements RepositoryHandler {
public MediaResource getAsMediaResource(OLATResourceable res, boolean backwardsCompatible) {
return FileResourceManager.getInstance().getAsDownloadeableMediaResource(res);
}
@Override
public Controller createDetailsForm(UserRequest ureq, WindowControl wControl, OLATResourceable res) {
return FileResourceManager.getInstance().getDetailsForm(ureq, wControl, res);
}
@Override
public VFSContainer getMediaContainer(RepositoryEntry repoEntry) {
......
......@@ -223,11 +223,6 @@ public class GlossaryHandler implements RepositoryHandler {
return layoutCtr;
}
@Override
public Controller createDetailsForm(UserRequest ureq, WindowControl wControl, OLATResourceable res) {
return null;
}
@Override
public boolean cleanupOnDelete(OLATResourceable res) {
// FIXME fg
......
......@@ -158,11 +158,6 @@ public class PodcastHandler implements RepositoryHandler {
return manager.getFeedArchiveMediaResource(res);
}
@Override
public Controller createDetailsForm(UserRequest ureq, WindowControl wControl, OLATResourceable res) {
return FileResourceManager.getInstance().getDetailsForm(ureq, wControl, res);
}
@Override
public Controller createEditorController(RepositoryEntry re, UserRequest ureq, WindowControl control, TooledStackedPanel toolbar) {
return null;
......
......@@ -226,11 +226,6 @@ public class PortfolioHandler implements RepositoryHandler {
return mr;
}
@Override
public Controller createDetailsForm(UserRequest ureq, WindowControl wControl, OLATResourceable res) {
return null;
}
@Override
public Controller createEditorController(RepositoryEntry re, UserRequest ureq, WindowControl control, TooledStackedPanel toolbar) {
return null;
......
......@@ -189,23 +189,13 @@ public interface RepositoryHandler {
* this method returns false, the entry will not be deleted.
* @param res
* @param identity
* @param roles TODO
* @param locale TODO
* @param roles
* @param locale
* @param errors
* @return true if ressource is ready to delete, false if not.
*/
public boolean readyToDelete(OLATResourceable res, Identity identity, Roles roles, Locale locale, ErrorList errors);
/**
* If a handler likes to provied any details on a resourceable in the repository's details
* view, he may do so by providing a component that renders the details.
*
* @param ureq
* @param wControl
* @param res
* @return Controller displaying details or null, if no details are available.
*/
public Controller createDetailsForm(UserRequest ureq, WindowControl wControl, OLATResourceable res);
public String archive(Identity archiveOnBehalfOf, String archivFilePath, RepositoryEntry repoEntry);
......
......@@ -204,11 +204,6 @@ public class SharedFolderHandler implements RepositoryHandler {
return layoutCtr;
}
@Override
public Controller createDetailsForm(UserRequest ureq, WindowControl wControl, OLATResourceable res) {
return null;
}
@Override
public boolean cleanupOnDelete(OLATResourceable res) {
// do not need to notify all current users of this resource, since the only
......
......@@ -299,11 +299,6 @@ public class WikiHandler implements RepositoryHandler {
return true;
}
@Override
public Controller createDetailsForm( UserRequest ureq, WindowControl wControl, OLATResourceable res) {
return FileResourceManager.getInstance().getDetailsForm(ureq, wControl, res);
}
@Override
public String archive(Identity archiveOnBehalfOf, String archivFilePath, RepositoryEntry repoEntry) {
VFSContainer rootContainer = FileResourceManager.getInstance().getFileResourceRootImpl(repoEntry.getOlatResource());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment