throw new IllegalStateException("Cannot insert folder: Folder already exists.");
}
Collection groupCollection = getGroupInRepository();
if (groupCollection == null) {
CollectionDao collectionDao = CollectionDao.createInstance();
Collection rootCollection = collectionDao.getRootCollection();
groupCollection = new CollectionImpl();
groupCollection.setName(this.oldFolder.getGroupName());
groupCollection.setParent(rootCollection);
if (groupCollection.getReadUsers() == null) {
groupCollection.setReadUsers(new ArrayList());
}
groupCollection.getReadUsers().add(new UserImpl("anonymous", ""));
if (rootCollection.getCollections() != null) {
rootCollection.getCollections().add(groupCollection);
} else {
List collections = new ArrayList();
collections.add(groupCollection);
rootCollection.setCollections(collections);
}
collectionDao.save(groupCollection);
}
Collection seriesCollection = getSeriesInRepository(groupCollection);
if (seriesCollection == null) {
CollectionDao collectionDao = CollectionDao.createInstance();
seriesCollection = new CollectionImpl();
seriesCollection.setName(this.oldFolder.getSeriesName());
seriesCollection.setParent(groupCollection);
if (seriesCollection.getReadUsers() == null) {
seriesCollection.setReadUsers(new ArrayList());
}
seriesCollection.getReadUsers().add(new UserImpl("anonymous", ""));
if (groupCollection.getCollections() != null) {
groupCollection.getCollections().add(seriesCollection);
} else {
List collections = new ArrayList();
collections.add(seriesCollection);
groupCollection.setCollections(collections);
}
collectionDao.save(seriesCollection);
}
Folder folder = getFolderInRepository(seriesCollection);
if (folder == null) {
folder = new FolderImpl();