@Deprecated public void updateEntity(EntityReference ref, Object entity, Map<String, Object> params) { String id = ref.getId(); if (id == null) { throw new IllegalArgumentException( "The reference must include an id for updates (id is currently null)"); } String userReference = developerHelperService.getCurrentUserReference(); if (userReference == null) { throw new EntityException( "Anonymous user cannot update option", ref.getId(), HttpServletResponse.SC_UNAUTHORIZED); } Option current = getOptionById(id); if (current == null) { throw new IllegalArgumentException( "No option found to update for the given reference: " + ref); } Option option = (Option) entity; checkOptionPermission(userReference, current); developerHelperService.copyBean( option, current, 0, new String[] {"id", "pollId", "UUId"}, true); boolean saved = pollListManager.saveOption(current); if (!saved) { throw new IllegalStateException( "Unable to update option (" + option + ") for user (" + userReference + "): " + ref); } }
@Deprecated public String createEntity(EntityReference ref, Object entity, Map<String, Object> params) { String userReference = developerHelperService.getCurrentUserReference(); if (userReference == null) { throw new EntityException( "User must be logged in to create new options", ref.getId(), HttpServletResponse.SC_UNAUTHORIZED); } Option option = (Option) entity; // check minimum settings if (option.getPollId() == null) { throw new IllegalArgumentException("Poll ID must be set to create an option"); } // check minimum settings if (option.getOptionText() == null) { throw new IllegalArgumentException("Poll Option text must be set to create an option"); } checkOptionPermission(userReference, option); // set default values option.setUUId(UUID.randomUUID().toString()); boolean saved = pollListManager.saveOption(option); if (!saved) { throw new IllegalStateException( "Unable to save option (" + option + ") for user (" + userReference + "): " + ref); } return option.getId() + ""; }