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

OO-4612: remove ZIP as backup and unused offline ZIP of CPs

parent debfa339
No related branches found
No related tags found
No related merge requests found
......@@ -30,7 +30,6 @@ import org.dom4j.tree.DefaultDocument;
import org.dom4j.tree.DefaultElement;
import org.olat.core.id.OLATResourceable;
import org.olat.core.util.vfs.VFSContainer;
import org.olat.core.util.vfs.VFSLeaf;
import org.olat.ims.cp.objects.CPOrganization;
import org.olat.ims.cp.objects.CPResource;
import org.olat.ims.cp.ui.CPPackageConfig;
......@@ -224,14 +223,6 @@ public interface CPManager {
*/
public void writeToFile(ContentPackage cp);
/**
* Writes the cp to a zip file.
*
* @param cp
* @return The VFS zip archive
*/
public VFSLeaf writeToZip(ContentPackage cp);
/**
* this is case-sensitive!
*
......
......@@ -43,7 +43,6 @@ import org.olat.core.logging.OLATRuntimeException;
import org.olat.core.logging.Tracing;
import org.olat.core.util.CodeHelper;
import org.olat.core.util.FileUtils;
import org.olat.core.util.ZipUtil;
import org.olat.core.util.vfs.LocalFolderImpl;
import org.olat.core.util.vfs.VFSContainer;
import org.olat.core.util.vfs.VFSItem;
......@@ -150,7 +149,7 @@ public class CPManagerImpl implements CPManager {
} else {
cp = new ContentPackage(null, directory, ores);
cp.setLastError("Exception reading XML for IMS CP: IMS-Manifest not found in " + directory.getName());
log.error("IMS manifiest xml couldn't be found in dir " + directory.getName() + ". Ores: " + ores.getResourceableId());
log.error("IMS manifiest xml couldn't be found in dir {}. Ores: {}", directory.getName(), ores.getResourceableId());
throw new OLATRuntimeException(CPManagerImpl.class, "The imsmanifest.xml file was not found.", new IOException());
}
return cp;
......@@ -162,8 +161,8 @@ public class CPManagerImpl implements CPManager {
if (copyTemplCP(ores)) {
File cpRoot = FileResourceManager.getInstance().unzipFileResource(ores);
if(log.isDebugEnabled()) {
log.debug("createNewCP: cpRoot=" + cpRoot);
log.debug("createNewCP: cpRoot.getAbsolutePath()=" + cpRoot.getAbsolutePath());
log.debug("createNewCP: cpRoot={}", cpRoot);
log.debug("createNewCP: cpRoot.getAbsolutePath()={}", cpRoot.getAbsolutePath());
}
LocalFolderImpl vfsWrapper = new LocalFolderImpl(cpRoot);
......@@ -186,7 +185,7 @@ public class CPManagerImpl implements CPManager {
return cp;
} else {
log.error("CP couldn't be created. Error when copying template. Ores: " + ores.getResourceableId());
log.error("CP couldn't be created. Error when copying template. Ores: {}", ores.getResourceableId());
throw new OLATRuntimeException("ERROR while creating new empty cp. an error occured while trying to copy template CP", null);
}
}
......@@ -307,28 +306,6 @@ public class CPManagerImpl implements CPManager {
cp.writeToFile();
}
@Override
public VFSLeaf writeToZip(ContentPackage cp) {
OLATResourceable ores = cp.getResourcable();
VFSContainer cpRoot = cp.getRootDir();
VFSContainer oresRoot = FileResourceManager.getInstance().getFileResourceRootImpl(ores);
RepositoryEntry repoEntry = RepositoryManager.getInstance().lookupRepositoryEntry(ores, false);
String zipFileName = "imscp.zip";
if (repoEntry != null) {
String zipName = repoEntry.getResourcename();
if (zipName != null && zipName.endsWith(".zip")) {
zipFileName = zipName;
}
}
// delete old archive and create new one
VFSItem oldArchive = oresRoot.resolve(zipFileName);
if (oldArchive != null) {
oldArchive.deleteSilently();//don't versioned the zip
}
ZipUtil.zip(cpRoot.getItems(), oresRoot.createChildLeaf(zipFileName), true);
return (VFSLeaf) oresRoot.resolve(zipFileName);
}
@Override
public String getPageByItemId(ContentPackage cp, String itemIdentifier) {
return cp.getPageByItemId(itemIdentifier);
......@@ -354,10 +331,10 @@ public class CPManagerImpl implements CPManager {
if (f.exists() && root.exists()) {
FileUtils.copyFileToDir(f, root, "copy imscp template");
} else {
log.error("cp template was not copied. Source: " + url + " Target: " + root.getAbsolutePath());
log.error("cp template was not copied. Source: {} Target: {}", url, root.getAbsolutePath());
}
} catch (URISyntaxException e) {
log.error("Bad url syntax when copying cp template. url: " + url + " Ores:" + ores.getResourceableId());
log.error("Bad url syntax when copying cp template. url: {} Ores: {}", url, ores.getResourceableId());
return false;
}
......
......@@ -128,11 +128,6 @@ public class CPEditMainController extends BasicController implements ToolbarAwar
@Override
protected void doDispose() {
Long oresId = cp.getResourcable().getResourceableId();
logAudit("cp editor closing. oresId: " + oresId);
if (lock.isSuccess() && contentCtr != null) {
// Save CP to zip
cpManager.writeToZip(cp);
}
// In any case, release the lock
CoordinatorManager.getInstance().getCoordinator().getLocker().releaseLock(lock);
logAudit("finished editing cp. ores-id: " + oresId);
......
......@@ -103,27 +103,6 @@ public class CPOfflineReadableManager {
public static CPOfflineReadableManager getInstance() {
return instance;
}
/**
* "exports" the the given CP (specified by its containing _unzipped_ directory) to a
* zipFile.<br />
* The resulting zip contains a "offline-readable" version of the CP.
* including style-sheets, menu-Tree and OpenOLAT branding
*
* @param ores
* the containing directory
* @param targetZip
* the resulting zip-filename
*/
public void makeCPOfflineReadable(File unzippedDir, File targetZip) {
try {
writeOfflineCPStartHTMLFile(unzippedDir);
File cpOfflineMat = new File(WebappHelper.getContextRealPath("/static/" + DIRNAME_CPOFFLINEMENUMAT));
zipOfflineReadableCP(unzippedDir, targetZip, cpOfflineMat);
} catch (IOException e) {
log.error("", e);
}
}
public void makeCPOfflineReadable(String manifest, String indexSrc, ZipOutputStream exportStream) {
try {
......
......@@ -67,7 +67,6 @@ import org.olat.ims.cp.ui.CPEditMainController;
import org.olat.ims.cp.ui.CPPackageConfig;
import org.olat.ims.cp.ui.CPRuntimeController;
import org.olat.modules.cp.CPDisplayController;
import org.olat.modules.cp.CPOfflineReadableManager;
import org.olat.repository.RepositoryEntry;
import org.olat.repository.RepositoryEntryStatusEnum;
import org.olat.repository.RepositoryManager;
......@@ -148,8 +147,6 @@ public class ImsCPHandler extends FileHandler {
File fResourceFileroot = FileResourceManager.getInstance().getFileResourceRoot(resource);
File zipRoot = new File(fResourceFileroot, FileResourceManager.ZIPDIR);
FileResource.copyResource(file, filename, zipRoot);
CPOfflineReadableManager.getInstance().makeCPOfflineReadable(cpResource, displayname);
DBFactory.getInstance().commit();
return re;
}
......@@ -178,8 +175,6 @@ public class ImsCPHandler extends FileHandler {
if(cpConfig != null) {
cpManager.setCPPackageConfig(targetResource, cpConfig);
}
CPOfflineReadableManager.getInstance().makeCPOfflineReadable(targetResource, target.getDisplayname() + ".zip");
return target;
}
......
......@@ -31,14 +31,12 @@ import static org.junit.Assert.assertTrue;
import org.apache.logging.log4j.Logger;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.olat.core.id.OLATResourceable;
import org.olat.core.logging.Tracing;
import org.olat.core.util.resource.OresHelper;
import org.olat.core.util.vfs.VFSItem;
import org.olat.core.util.vfs.VFSLeaf;
import org.olat.ims.cp.CPManager;
import org.olat.ims.cp.ContentPackage;
import org.olat.ims.cp.objects.CPItem;
......@@ -126,11 +124,4 @@ public class CPManagerTest extends OlatTestCase {
public void testWriteToFile() {
cpManager.writeToFile(cp); // Throws exception on failure
}
@Test
public void testWriteToZip() {
VFSLeaf zip = cpManager.writeToZip(cp);
Assert.assertNotNull("The zip file wasn't created properly", zip);
Assert.assertTrue("The zip file cannot be empty", zip.getSize() > 0);
}
}
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