private AnnotationData addAnnotationCommon(final Annotation annotation, final String userId, final String parentId, String topParentId, String targetId, final String eventTag) { if (annotation.getId() == null) { throw new InvalidAnnotationException(annotation.getId(), "Annotation has no ID"); } final AnnotationHibernateModel hibernateModel = new AnnotationHibernateModel(); setCommonHibernateModel(userId, parentId, topParentId, targetId, hibernateModel); hibernateModel.setCreatorId(userId); hibernateModel.setCreationDate(hibernateModel.getEditionDate()); hibernateModel.fillDaoWithDataFromAnnotation(annotation); final AnnotationHibernateModel potentialSame = getNewestAnnotationForId(hibernateModel.getKey().getId()); if (potentialSame != null) { throw new AnnotationWithThisIdAlreadyExistException(annotation.getId()); } try { logger.debug("save annotaiotion {}", hibernateModel); AnnotationIdentifier annId = (AnnotationIdentifier) hibernateTemplate.save(hibernateModel); saveEvent(annId.getId(), annotation.getState().equals(AnnotationStateConstants.DELETED), eventTag); } catch (DataException dae) { dae.getCause().printStackTrace(); } return hibernateModel.translateToAnnotationData(); }