public void saveOrUpdate(Object model) { if (model instanceof Annotation) { if (((Annotation) model).getResource() != null) { ((Content) model).setOrganization(((Annotation) model).getResource().getOrganization()); ((Content) model) .setVersion( ((Content) model).getVersion() == null ? 1 : ((Content) model).getVersion() + 1); } } else if (model instanceof OrganizationWrapper && ((OrganizationWrapper) model).getOrganization() == null) { ((OrganizationWrapper) model).setOrganization(getCurrentUserPrimaryOrganization()); } if (model instanceof Content) { ((Content) model).setLastModified(new Date(System.currentTimeMillis())); ((Content) model) .setVersion( ((Content) model).getVersion() == null ? 1 : ((Content) model).getVersion() + 1); } if (model instanceof CollectionItem) { ((CollectionItem) model) .getCollection() .setLastModified(new Date(System.currentTimeMillis())); ((CollectionItem) model) .getCollection() .setVersion( ((CollectionItem) model).getCollection().getVersion() == null ? 1 : ((CollectionItem) model).getCollection().getVersion() + 1); } if (model instanceof User) { ((User) model).setLastModifiedOn(new Date(System.currentTimeMillis())); } getSession().saveOrUpdate(model); }