use of org.olat.ims.cp.ui.CPPackageConfig in project OpenOLAT by OpenOLAT.
the class CPManagerImpl method getCPPackageConfig.
@Override
public CPPackageConfig getCPPackageConfig(OLATResourceable ores) {
FileResourceManager frm = FileResourceManager.getInstance();
File reFolder = frm.getFileResourceRoot(ores);
File configXml = new File(reFolder, PACKAGE_CONFIG_FILE_NAME);
CPPackageConfig config;
if (configXml.exists()) {
config = (CPPackageConfig) configXstream.fromXML(configXml);
} else {
// set default config
config = new CPPackageConfig();
config.setDeliveryOptions(DeliveryOptions.defaultWithGlossary());
setCPPackageConfig(ores, config);
}
return config;
}
use of org.olat.ims.cp.ui.CPPackageConfig in project OpenOLAT by OpenOLAT.
the class CPManagerImpl method createNewCP.
/**
* @see org.olat.ims.cp.CPManager#createNewCP(org.olat.core.id.OLATResourceable)
*/
public ContentPackage createNewCP(OLATResourceable ores, String initalPageTitle) {
// copy template cp to new repo-location
if (copyTemplCP(ores)) {
File cpRoot = FileResourceManager.getInstance().unzipFileResource(ores);
logDebug("createNewCP: cpRoot=" + cpRoot);
logDebug("createNewCP: cpRoot.getAbsolutePath()=" + cpRoot.getAbsolutePath());
LocalFolderImpl vfsWrapper = new LocalFolderImpl(cpRoot);
ContentPackage cp = load(vfsWrapper, ores);
// Modify the copy of the template to get a unique identifier
CPOrganization orga = setUniqueOrgaIdentifier(cp);
setOrgaTitleToRepoEntryTitle(ores, orga);
// Also set the translated title of the inital page.
orga.getItems().get(0).setTitle(initalPageTitle);
writeToFile(cp);
// set the default settings for file delivery
DeliveryOptions defOptions = DeliveryOptions.defaultWithGlossary();
CPPackageConfig config = new CPPackageConfig();
config.setDeliveryOptions(defOptions);
setCPPackageConfig(ores, config);
return cp;
} else {
logError("CP couldn't be created. Error when copying template. Ores: " + ores.getResourceableId(), null);
throw new OLATRuntimeException("ERROR while creating new empty cp. an error occured while trying to copy template CP", null);
}
}
use of org.olat.ims.cp.ui.CPPackageConfig 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;
}
use of org.olat.ims.cp.ui.CPPackageConfig in project openolat by klemens.
the class CPRunController method doLaunch.
private void doLaunch(UserRequest ureq) {
DeliveryOptions deliveryOptions = (DeliveryOptions) config.get(CPEditController.CONFIG_DELIVERYOPTIONS);
if (cpRoot == null) {
// it is the first time we start the contentpackaging from this instance
// of this controller.
// need to be strict when launching -> "true"
RepositoryEntry re = CPEditController.getCPReference(config, false);
if (re == null) {
showError(CPEditController.NLS_ERROR_CPREPOENTRYMISSING);
return;
}
cpRoot = FileResourceManager.getInstance().unzipFileResource(re.getOlatResource());
// nodes reference them
if (cpRoot == null) {
showError(CPEditController.NLS_ERROR_CPREPOENTRYMISSING);
return;
}
if (deliveryOptions != null && deliveryOptions.getInherit() != null && deliveryOptions.getInherit().booleanValue()) {
CPPackageConfig packageConfig = CPManager.getInstance().getCPPackageConfig(re.getOlatResource());
if (packageConfig != null && packageConfig.getDeliveryOptions() != null) {
deliveryOptions = packageConfig.getDeliveryOptions();
}
}
}
// else cpRoot is already set (save some db access if the user opens /
// closes / reopens the cp from the same CPRuncontroller instance)
boolean activateFirstPage = true;
if ((nodecmd != null) && !nodecmd.equals("")) {
activateFirstPage = false;
}
boolean showNavigation = !config.getBooleanSafe(NodeEditController.CONFIG_COMPONENT_MENU);
cpDispC = CPUIFactory.getInstance().createContentOnlyCPDisplayController(ureq, getWindowControl(), new LocalFolderImpl(cpRoot), activateFirstPage, showNavigation, deliveryOptions, nodecmd, courseResource, cpNode.getIdent(), preview);
cpDispC.setContentEncoding(deliveryOptions.getContentEncoding());
cpDispC.setJSEncoding(deliveryOptions.getJavascriptEncoding());
cpDispC.addControllerListener(this);
main.setContent(cpDispC.getInitialComponent());
if (isExternalMenuConfigured()) {
treeModel = cpDispC.getTreeModel();
treeNodeClickListener = this;
if (activateFirstPage) {
selNodeId = cpDispC.getInitialSelectedNodeId();
} else {
String uri = nodecmd;
if (uri.startsWith("/")) {
uri = uri.substring(1, uri.length());
}
selNodeId = cpDispC.getNodeByUri(uri);
}
}
}
use of org.olat.ims.cp.ui.CPPackageConfig in project openolat by klemens.
the class ImsCPHandler method createLaunchController.
@Override
public MainLayoutController createLaunchController(RepositoryEntry re, RepositoryEntrySecurity reSecurity, UserRequest ureq, WindowControl wControl) {
OLATResource res = re.getOlatResource();
File cpRoot = FileResourceManager.getInstance().unzipFileResource(res);
final LocalFolderImpl vfsWrapper = new LocalFolderImpl(cpRoot);
CPPackageConfig packageConfig = CPManager.getInstance().getCPPackageConfig(res);
final DeliveryOptions deliveryOptions = (packageConfig == null ? null : packageConfig.getDeliveryOptions());
return new CPRuntimeController(ureq, wControl, re, reSecurity, new RuntimeControllerCreator() {
@Override
public Controller create(UserRequest uureq, WindowControl wwControl, TooledStackedPanel toolbarPanel, RepositoryEntry entry, RepositoryEntrySecurity security, AssessmentMode assessmentMode) {
boolean activateFirstPage = true;
String initialUri = null;
CoreSpringFactory.getImpl(UserCourseInformationsManager.class).updateUserCourseInformations(entry.getOlatResource(), uureq.getIdentity());
CPDisplayController cpCtr = new CPDisplayController(uureq, wwControl, vfsWrapper, true, true, activateFirstPage, true, deliveryOptions, initialUri, entry.getOlatResource(), "", false);
MainLayout3ColumnsController ctr = new LayoutMain3ColsController(uureq, wwControl, cpCtr.getMenuComponent(), cpCtr.getInitialComponent(), vfsWrapper.getName());
ctr.addDisposableChildController(cpCtr);
return ctr;
}
});
}
Aggregations