use of org.olat.ims.cp.CPManager in project OpenOLAT by OpenOLAT.
the class CPTreeController method copyPage.
/**
* copies the page with given nodeID
*
* @param nodeID
*/
private String copyPage(CPPage page) {
String newIdentifier = null;
if (page != null) {
CPManager cpMgm = CPManager.getInstance();
newIdentifier = cpMgm.copyElement(cp, page.getIdentifier());
cpMgm.writeToFile(cp);
updateTree();
}
return newIdentifier;
}
use of org.olat.ims.cp.CPManager in project OpenOLAT by OpenOLAT.
the class CPTreeController method getCurrentPageInfoStringHTML.
/**
* Builds an html-info string about the current page and its linked resources
*
* @return HTML-String
*/
private String getCurrentPageInfoStringHTML() {
// test if currentPage links to resource, which is used (linked) somewhere
// else in the manifest
CPManager cpMgm = CPManager.getInstance();
DefaultElement ele = cpMgm.getElementByIdentifier(cp, currentPage.getIdRef());
boolean single = false;
if (ele instanceof CPResource) {
CPResource res = (CPResource) ele;
single = cpMgm.isSingleUsedResource(res, cp);
}
StringBuilder b = new StringBuilder();
b.append("<br /><ul>");
b.append("<li><b>" + translate("cptreecontroller.pagetitle") + "</b> " + currentPage.getTitle() + "</li>");
if (single) {
b.append("<li><b>" + translate("cptreecontroller.file") + "</b> " + currentPage.getFileName() + "</li>");
}
b.append("</ul>");
return b.toString();
}
use of org.olat.ims.cp.CPManager in project OpenOLAT by OpenOLAT.
the class CPTreeController method deletePage.
/**
* deletes a page from the manifest
*
* @param nodeID
*/
private void deletePage(String identifier, boolean deleteResource) {
if (identifier.equals("")) {
// no page selected
} else {
CPManager cpMgm = CPManager.getInstance();
treeModel.removePath();
cpMgm.removeElement(cp, identifier, deleteResource);
cpMgm.writeToFile(cp);
updateTree();
}
}
use of org.olat.ims.cp.CPManager in project OpenOLAT by OpenOLAT.
the class CPTreeController method addPage.
/**
* Adds a page to the CP
*
* @return
*/
protected String addPage(CPPage page) {
CPManager cpMgm = CPManager.getInstance();
String newNodeID = "";
if (currentPage.getIdentifier().equals("")) {
newNodeID = cpMgm.addBlankPage(cp, page.getTitle());
} else {
// adds new page as child of currentPage
newNodeID = cpMgm.addBlankPage(cp, page.getTitle(), currentPage.getIdentifier());
}
setCurrentPage(new CPPage(newNodeID, cp));
cpMgm.writeToFile(cp);
updateTree();
return newNodeID;
}
use of org.olat.ims.cp.CPManager in project OpenOLAT by OpenOLAT.
the class ImsCPHandler method copy.
@Override
public RepositoryEntry copy(Identity author, RepositoryEntry source, RepositoryEntry target) {
final CPManager cpManager = CPManager.getInstance();
OLATResource sourceResource = source.getOlatResource();
OLATResource targetResource = target.getOlatResource();
File sourceFileroot = FileResourceManager.getInstance().getFileResourceRootImpl(sourceResource).getBasefile();
File zipRoot = new File(sourceFileroot, FileResourceManager.ZIPDIR);
File targetFileroot = FileResourceManager.getInstance().getFileResourceRootImpl(targetResource).getBasefile();
FileUtils.copyFileToDir(zipRoot, targetFileroot, "add file resource");
// copy packaging info
CPPackageConfig cpConfig = cpManager.getCPPackageConfig(sourceResource);
if (cpConfig != null) {
cpManager.setCPPackageConfig(targetResource, cpConfig);
}
CPOfflineReadableManager.getInstance().makeCPOfflineReadable(targetResource, target.getDisplayname() + ".zip");
return target;
}
Aggregations