if (this.exists != null && this.exists.equals(Boolean.valueOf(true))) {
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();
folder.setName(this.oldFolder.getOiDb());
folder.setDatestamp(new GregorianCalendar());
folder.setParentCollection(seriesCollection);
if (folder.getReadUsers() == null) {
folder.setReadUsers(new ArrayList());
}
folder.getReadUsers().add(new UserImpl("anonymous", ""));
if (seriesCollection.getFolders() != null) {
seriesCollection.getFolders().add(folder);
} else {
List folders = new ArrayList();
folders.add(folder);
seriesCollection.setFolders(folders);
}
FolderDao folderDao = FolderDao.createInstance();
folderDao.save(folder);