@Override @Transactional( readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class) public ActionResponseDTO<Collection> createCollection( String folderId, User user, Collection collection) { if (collection.getBuildTypeId() != null) { collection.setBuildTypeId(Constants.BUILD_WEB_TYPE_ID); } final Errors errors = validateCollection(collection); if (!errors.hasErrors()) { Collection targetCollection = null; if (folderId != null) { targetCollection = this.getCollectionDao().getCollectionByType(folderId, FOLDER_TYPE); rejectIfNull(targetCollection, GL0056, 404, FOLDER); } else { targetCollection = getCollectionDao() .getCollection(user.getPartyUid(), CollectionType.SHElf.getCollectionType()); if (targetCollection == null) { targetCollection = new Collection(); targetCollection.setCollectionType(CollectionType.SHElf.getCollectionType()); targetCollection.setTitle(CollectionType.SHElf.getCollectionType()); super.createCollection(targetCollection, user); } } createCollection(user, collection, targetCollection); getAsyncExecutor().deleteFromCache(V2_ORGANIZE_DATA + user.getPartyUid() + "*"); } return new ActionResponseDTO<Collection>(collection, errors); }
@Override @Transactional( readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class) public void moveCollection(String folderId, String collectionId, User user) { Collection targetCollection = null; if (folderId != null) { targetCollection = this.getCollectionDao().getCollectionByType(folderId, FOLDER_TYPE); rejectIfNull(targetCollection, GL0056, 404, FOLDER); } else { targetCollection = getCollectionDao() .getCollection(user.getPartyUid(), CollectionType.SHElf.getCollectionType()); if (targetCollection == null) { targetCollection = new Collection(); targetCollection.setCollectionType(CollectionType.SHElf.getCollectionType()); targetCollection.setTitle(CollectionType.SHElf.getCollectionType()); super.createCollection(targetCollection, user); } } moveCollection(collectionId, targetCollection, user); }