コード例 #1
0
 @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() + "";
 }