@Override @Transactional( readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class) public void updateResource( String collectionId, String collectionResourceItemId, CollectionItem newCollectionItem, User user) { final CollectionItem collectionItem = this.getCollectionDao().getCollectionItem(collectionResourceItemId); rejectIfNull(collectionItem, GL0056, 404, _COLLECTION_ITEM); this.getResourceBoService() .updateResource( collectionItem.getContent().getGooruOid(), newCollectionItem.getResource(), user); Map<String, Object> data = generateResourceMetaData( collectionItem.getContent(), newCollectionItem.getResource(), user); if (data != null && data.size() > 0) { ContentMeta contentMeta = this.getContentRepository().getContentMeta(collectionItem.getContent().getContentId()); updateContentMeta(contentMeta, data); } }
@Override @Transactional( readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class) public ActionResponseDTO<CollectionItem> createResource( String collectionId, CollectionItem collectionItem, User user) { Resource resource = collectionItem.getResource(); final Errors errors = validateResource(resource); if (!errors.hasErrors()) { Collection collection = getCollectionDao().getCollectionByType(collectionId, COLLECTION_TYPES); rejectIfNull(collection, GL0056, 404, COLLECTION); resource.setSharing(collection.getSharing()); resource = getResourceBoService().createResource(resource, user); collectionItem.setItemType(ADDED); collectionItem = createCollectionItem(collectionItem, collection, resource, user); getCollectionEventLog() .collectionItemEventLog( collectionId, collectionItem, user.getPartyUid(), RESOURCE, collectionItem, ADD); updateCollectionMetaDataSummary(collection.getContentId(), RESOURCE, ADD); Map<String, Object> data = generateResourceMetaData(resource, collectionItem.getResource(), user); createContentMeta(resource, data); } return new ActionResponseDTO<CollectionItem>(collectionItem, errors); }