return null;
}
}
// create repository entry
RepositoryManager rm = RepositoryManager.getInstance();
RepositoryEntry importedRepositoryEntry = rm.createRepositoryEntryInstance(owner.getName());
importedRepositoryEntry.setDisplayname(importExport.getDisplayName());
importedRepositoryEntry.setResourcename(importExport.getResourceName());
importedRepositoryEntry.setDescription(importExport.getDescription());
if (keepSoftkey) {
String theSoftKey = importExport.getSoftkey();
if (rm.lookupRepositoryEntryBySoftkey(theSoftKey, false) != null) {
/*
* keepSoftKey == true -> is used for importing in unattended mode.
* "Importing and keeping the soft key" only works if there is not an
* already existing soft key. In the case both if's are taken the
* respective IMS resource is not imported. It is important to be aware
* that the resource which triggered the import process still keeps the
* soft key reference, and thus points to the already existing resource.
*/
return null;
}
importedRepositoryEntry.setSoftkey(importExport.getSoftkey());
}
// Set the resource on the repository entry.
OLATResource ores = OLATResourceManager.getInstance().findOrPersistResourceable(fileResource);
importedRepositoryEntry.setOlatResource(ores);
RepositoryHandler rh = RepositoryHandlerFactory.getInstance().getRepositoryHandler(importedRepositoryEntry);
importedRepositoryEntry.setCanLaunch(rh.supportsLaunch());
// create security group
Manager securityManager = ManagerFactory.getManager();
SecurityGroup newGroup = securityManager.createAndPersistSecurityGroup();
// member of this group may modify member's membership
securityManager.createAndPersistPolicy(newGroup, Constants.PERMISSION_ACCESS, newGroup);
// members of this group are always authors also
securityManager.createAndPersistPolicy(newGroup, Constants.PERMISSION_HASROLE, Constants.ORESOURCE_AUTHOR);
securityManager.addIdentityToSecurityGroup(owner, newGroup);
importedRepositoryEntry.setOwnerGroup(newGroup);
rm.saveRepositoryEntry(importedRepositoryEntry);
if (!keepSoftkey) setReference(importedRepositoryEntry, node, importMode);
return importedRepositoryEntry;
}