コード例 #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() + "";
 }
コード例 #2
0
ファイル: PollUtil.java プロジェクト: RebeccaOxfordUni/sakai
 public static Option xmlToOption(Element element) {
   Option option = new Option();
   option.setUUId(element.getAttribute(UUID));
   if (!"".equals(element.getAttribute(OPTION_ID))) {
     try {
       option.setOptionId(Long.parseLong(element.getAttribute(OPTION_ID)));
     } catch (NumberFormatException e) {
       // LOG THIS
     }
   }
   option.setOptionText(element.getAttribute(TEXT));
   option.setDeleted(Boolean.parseBoolean(element.getAttribute(DELETED)));
   return option;
 }