Search in sources :

Example 1 with FileNameSuffixFilter

use of org.olat.core.util.FileNameSuffixFilter in project OpenOLAT by OpenOLAT.

the class ProjectBrokerCourseNode method postImport.

@Override
public void postImport(File importDirectory, ICourse course, CourseEnvironmentMapper envMapper, Processing processType) {
    // initialize managers
    if (processType == Processing.editor && importDirectory != null) {
        ProjectBrokerManager projectBrokerManager = CoreSpringFactory.getImpl(ProjectBrokerManager.class);
        CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
        // create a new projectBroker
        ProjectBroker projectBroker = projectBrokerManager.createAndSaveProjectBroker();
        projectBrokerManager.saveProjectBrokerId(projectBroker.getKey(), cpm, this);
        // get the node folder inside of the importDirectory
        File folderNodeData = new File(importDirectory, getIdent());
        // for the broker prefs
        File projectBrokerFile = new File(folderNodeData, "projectbroker.xml");
        if (projectBrokerFile.exists()) {
            XStream xstream = XStreamHelper.createXStreamInstance();
            ProjectGroupManager projectGroupManager = CoreSpringFactory.getImpl(ProjectGroupManager.class);
            ProjectBrokerConfig brokerConfig = (ProjectBrokerConfig) XStreamHelper.readObject(xstream, projectBrokerFile);
            if (brokerConfig != null && brokerConfig.getAccountGroupKey() != null) {
                Long accountGroupKey = envMapper.toGroupKeyFromOriginalKey(brokerConfig.getAccountGroupKey());
                if (accountGroupKey != null) {
                    projectGroupManager.saveAccountManagerGroupKey(accountGroupKey, cpm, this);
                }
            }
        }
        // loop through the project directories
        if (folderNodeData.exists()) {
            for (File projectDir : folderNodeData.listFiles(DirectoryFilter.DIRECTORY_FILTER)) {
                for (File projectFile : projectDir.listFiles(new FileNameSuffixFilter("xml"))) {
                    importProject(projectDir, projectFile, projectBroker, course, envMapper);
                }
            }
        }
    }
    super.postImport(importDirectory, course, envMapper, processType);
}
Also used : ProjectGroupManager(org.olat.course.nodes.projectbroker.service.ProjectGroupManager) FileNameSuffixFilter(org.olat.core.util.FileNameSuffixFilter) ProjectBroker(org.olat.course.nodes.projectbroker.datamodel.ProjectBroker) XStream(com.thoughtworks.xstream.XStream) ProjectBrokerManager(org.olat.course.nodes.projectbroker.service.ProjectBrokerManager) File(java.io.File) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager) PersistingCoursePropertyManager(org.olat.course.properties.PersistingCoursePropertyManager)

Example 2 with FileNameSuffixFilter

use of org.olat.core.util.FileNameSuffixFilter in project openolat by klemens.

the class ProjectBrokerCourseNode method postImport.

@Override
public void postImport(File importDirectory, ICourse course, CourseEnvironmentMapper envMapper, Processing processType) {
    // initialize managers
    if (processType == Processing.editor && importDirectory != null) {
        ProjectBrokerManager projectBrokerManager = CoreSpringFactory.getImpl(ProjectBrokerManager.class);
        CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
        // create a new projectBroker
        ProjectBroker projectBroker = projectBrokerManager.createAndSaveProjectBroker();
        projectBrokerManager.saveProjectBrokerId(projectBroker.getKey(), cpm, this);
        // get the node folder inside of the importDirectory
        File folderNodeData = new File(importDirectory, getIdent());
        // for the broker prefs
        File projectBrokerFile = new File(folderNodeData, "projectbroker.xml");
        if (projectBrokerFile.exists()) {
            XStream xstream = XStreamHelper.createXStreamInstance();
            ProjectGroupManager projectGroupManager = CoreSpringFactory.getImpl(ProjectGroupManager.class);
            ProjectBrokerConfig brokerConfig = (ProjectBrokerConfig) XStreamHelper.readObject(xstream, projectBrokerFile);
            if (brokerConfig != null && brokerConfig.getAccountGroupKey() != null) {
                Long accountGroupKey = envMapper.toGroupKeyFromOriginalKey(brokerConfig.getAccountGroupKey());
                if (accountGroupKey != null) {
                    projectGroupManager.saveAccountManagerGroupKey(accountGroupKey, cpm, this);
                }
            }
        }
        // loop through the project directories
        if (folderNodeData.exists()) {
            for (File projectDir : folderNodeData.listFiles(DirectoryFilter.DIRECTORY_FILTER)) {
                for (File projectFile : projectDir.listFiles(new FileNameSuffixFilter("xml"))) {
                    importProject(projectDir, projectFile, projectBroker, course, envMapper);
                }
            }
        }
    }
    super.postImport(importDirectory, course, envMapper, processType);
}
Also used : ProjectGroupManager(org.olat.course.nodes.projectbroker.service.ProjectGroupManager) FileNameSuffixFilter(org.olat.core.util.FileNameSuffixFilter) ProjectBroker(org.olat.course.nodes.projectbroker.datamodel.ProjectBroker) XStream(com.thoughtworks.xstream.XStream) ProjectBrokerManager(org.olat.course.nodes.projectbroker.service.ProjectBrokerManager) File(java.io.File) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager) PersistingCoursePropertyManager(org.olat.course.properties.PersistingCoursePropertyManager)

Aggregations

XStream (com.thoughtworks.xstream.XStream)2 File (java.io.File)2 FileNameSuffixFilter (org.olat.core.util.FileNameSuffixFilter)2 ProjectBroker (org.olat.course.nodes.projectbroker.datamodel.ProjectBroker)2 ProjectBrokerManager (org.olat.course.nodes.projectbroker.service.ProjectBrokerManager)2 ProjectGroupManager (org.olat.course.nodes.projectbroker.service.ProjectGroupManager)2 CoursePropertyManager (org.olat.course.properties.CoursePropertyManager)2 PersistingCoursePropertyManager (org.olat.course.properties.PersistingCoursePropertyManager)2