public class FolderFactory implements IntegrationEntityFactory {
@Override
public void createEntity(Folder parent, IntegrationEntityFactoryCallback callback) {
try {
RootFolder rf = parent.getRootFolder();
if (rf != null) {
Folder folder = new Folder("", rf.getItemType());
folder.setName(EntityFactoryUtils.getNewEntityName(folder, parent));
callback.creationSucceeded(folder, parent);
} else {
callback.creationFailed(new IntegrationEntityFactoryException(
"Unknown root folder for the parent " + parent));