return null;
}
File courseExportData = ImportCourseController.getExportDataDir(course);
// get the export data directory
// create the repository entry
RepositoryManager rm = RepositoryManager.getInstance();
RepositoryEntry re = rm.createRepositoryEntryInstance("administrator");
RepositoryEntryImportExport importExport = new RepositoryEntryImportExport(courseExportData);
String softKey = importExport.getSoftkey();
RepositoryEntry existingEntry = rm.lookupRepositoryEntryBySoftkey(softKey, false);
if (existingEntry != null) {
Tracing.logInfo("RepositoryEntry with softkey " + softKey + " already exists. Course will not be deployed.", CourseFactory.class);
CourseFactory.deleteCourse(newCourseResource);
return existingEntry;
}
// ok, continue import
newCourseResource = OLATResourceManager.getInstance().findOrPersistResourceable(newCourseResource);
re.setOlatResource(newCourseResource);
re.setSoftkey(softKey);
re.setInitialAuthor(importExport.getInitialAuthor());
re.setDisplayname(importExport.getDisplayName());
re.setResourcename(importExport.getResourceName());
re.setDescription(importExport.getDescription());
re.setCanLaunch(true);
// set access configuration
re.setAccess(access);
course = openCourseEditSession(course.getResourceableId());
// create group management
CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager();
cgm.createCourseGroupmanagement(course.getResourceableId().toString());
// import groups
cgm.importCourseLearningGroups(courseExportData);
cgm.importCourseRightGroups(courseExportData);
// create security group
Manager securityManager = ManagerFactory.getManager();
SecurityGroup ownerGroup = securityManager.createAndPersistSecurityGroup();
// member of this group may modify member's membership
securityManager.createAndPersistPolicy(ownerGroup, Constants.PERMISSION_ACCESS, ownerGroup);
// members of this group are always authors also
securityManager.createAndPersistPolicy(ownerGroup, Constants.PERMISSION_HASROLE, Constants.ORESOURCE_AUTHOR);
securityManager.addIdentityToSecurityGroup(securityManager.findIdentityByName("administrator"), ownerGroup);
re.setOwnerGroup(ownerGroup);
// save the repository entry
rm.saveRepositoryEntry(re);
// Create course admin policy for owner group of repository entry
// -> All owners of repository entries are course admins
securityManager.createAndPersistPolicy(re.getOwnerGroup(), Constants.PERMISSION_ADMIN, re.getOlatResource());
// deploy any referenced repository entries of the editor structure. This will also