@Override @Transactional public MultimediaImpl createMultimedia( BlackboardMultimediaResponse multimediaResponse, String filename) { // Find the creator user final String creatorId = multimediaResponse.getCreatorId(); ConferenceUserImpl creator = this.conferenceUserDao.getUserByUniqueId(creatorId); if (creator == null) { logger.warn( "Internal user {} doesn't exist for {}. Creating a bare bones user to compensate", creatorId, multimediaResponse); creator = this.conferenceUserDao.createInternalUser(creatorId); } // Create and populate a new blackboardMultimedia final MultimediaImpl blackboardMultimedia = new MultimediaImpl(multimediaResponse.getMultimediaId(), creator); updateBlackboardMultimedia(multimediaResponse, filename, blackboardMultimedia); // Persist and return the new multimedia this.getEntityManager().persist(blackboardMultimedia); creator.getMultimedias().add(blackboardMultimedia); this.getEntityManager().persist(creator); return blackboardMultimedia; }
private void updateBlackboardMultimedia( BlackboardMultimediaResponse multimediaResponse, String filename, MultimediaImpl multimedia) { multimedia.setDescription(multimediaResponse.getDescription()); multimedia.setFilename(filename); multimedia.setSize(multimediaResponse.getSize()); }