@RequestMapping("/UserDetailInfo")
  public ModelAndView userDetailInfo(HttpServletRequest request) throws Exception {
    ModelAndView mav = new ModelAndView("business/common/userDetailInfo");

    UserDto userDto = new UserDto();

    String userId = request.getParameter("userId");
    userDto = user.getUserInfo(userId);

    String userTypeName = null;
    CodeDto cdoeDto = code.getCodeInfo("SYSTEM", "USER_TYPE", userDto.getUserType());
    if (cdoeDto != null) userTypeName = cdoeDto.getCodeName();

    String birthDt = userDto.getBirthDt();
    if (!StringUtils.isEmpty(birthDt) && StringUtils.length(birthDt) == 8) {
      birthDt =
          StringUtils.substring(birthDt, 0, 2)
              + "/"
              + StringUtils.substring(birthDt, 2, 4)
              + "/"
              + StringUtils.substring(birthDt, 4);
    }
    userDto.setBirthDt(birthDt);
    userDto.setUserTypeName(userTypeName);

    mav.addObject("userPhoto", user.getProfilePhoto(userId));
    mav.addObject("userDto", userDto);

    return mav;
  }
 @RequestMapping(value = "/find.html")
 public ModelAndView find(@RequestParam(value = "q", required = false) String q) {
   ModelAndView mav = new ModelAndView();
   mav.addObject("operation", "find");
   if (StringUtils.isEmpty(q)) {
     mav.setViewName("find");
     return mav;
   }
   try {
     if (NumberUtils.isNumber(q) && StringUtils.length(q) == 7) {
       return show(Integer.valueOf(q));
     } else {
       long startTs = System.currentTimeMillis();
       List<TConcept> concepts = nodeService.findConcepts(q);
       mav.addObject("concepts", concepts);
       long endTs = System.currentTimeMillis();
       mav.addObject("q", q);
       mav.addObject("elapsed", new Long(endTs - startTs));
     }
   } catch (Exception e) {
     mav.addObject("error", e.getMessage());
   }
   mav.setViewName("find");
   return mav;
 }
Beispiel #3
0
  /** 获取上级编号 */
  public static final String findParentNo(String no) {
    int length = StringUtils.length(no);
    if (length <= ITEM_LENGTH) {
      return StringUtils.EMPTY;
    }

    return StringUtils.substring(no, 0, (length - ITEM_LENGTH));
  }
 private void checkThatYearIsFilledAndValid(Errors errors, BookDataFormData cmd) {
   ValidationUtils.rejectIfEmptyOrWhitespace(errors, "year", "empty");
   if (!errors.hasFieldErrors("year")) {
     if (!StringUtils.isNumeric(cmd.getYear())) {
       errors.rejectValue("year", "notvalid");
     } else if (StringUtils.length(cmd.getYear()) != 4) {
       errors.rejectValue("year", "invalid.length");
     }
   }
 }
  @Override
  public String post(String message) {
    requireAuthorization();

    final String msg =
        StringUtils.length(message) > 400 ? StringUtils.substring(message, 0, 400) : message;

    Map<String, String> params = new HashMap<String, String>();
    params.put("method", METHOD);
    params.put("text", msg);
    URI uri = URIBuilder.fromUri(makeOperationURL(params)).build();

    List result = restTemplate.getForObject(uri, List.class);
    return StringUtils.EMPTY;
  }
Beispiel #6
0
 /**
  * parse IPV6 ARPA domain to IP bytes.
  *
  * @param name an ARPA string.
  * @return ARPA.
  */
 private static NetworkInBytes parseIpV6Arpa(String name) {
   LOGGER.debug("parseIp6Arpa, name:" + name);
   String arpa = StringUtils.removeEndIgnoreCase(name, CHAR_DOT + DomainUtil.IPV6_ARPA_SUFFIX);
   arpa = StringUtils.remove(arpa, CHAR_DOT);
   String ip = StringUtils.reverse(arpa);
   String fullIp = StringUtils.rightPad(ip, 32, '0');
   byte[] startIpBytes = DatatypeConverter.parseHexBinary(fullIp);
   int networkMask = StringUtils.length(arpa) * 4;
   IPv6Address fromByteArray = IPv6Address.fromByteArray(startIpBytes);
   IPv6Network network =
       IPv6Network.fromAddressAndMask(
           fromByteArray, IPv6NetworkMask.fromPrefixLength(networkMask));
   NetworkInBytes result =
       new NetworkInBytes(
           IpVersion.V6, network.getFirst().toByteArray(), network.getLast().toByteArray());
   return result;
 }
  @RequestMapping(value = "/map.html")
  public ModelAndView map(
      @RequestParam(value = "q1", required = false) String q1,
      @RequestParam(value = "q2", required = false) String q2,
      @RequestParam(value = "q3", required = false) String q3,
      @RequestParam(value = "if", required = false, defaultValue = UimaUtils.MIMETYPE_STRING)
          String inputFormat,
      @RequestParam(value = "of", required = true, defaultValue = "html") String outputFormat,
      @RequestParam(value = "ofs", required = false, defaultValue = "pretty")
          String outputFormatStyle,
      @RequestParam(value = "sgf", required = false) String[] styGroupFilter,
      @RequestParam(value = "scf", required = false) String[] styCodeFilter) {

    ModelAndView mav = new ModelAndView();
    mav.addObject("operation", "map");
    // validate parameters (at least one of o, q, u or t must
    // be supplied, otherwise show the input form
    mav.addObject("q1", StringUtils.isEmpty(q1) ? "" : q1);
    mav.addObject("q2", StringUtils.isEmpty(q2) ? "" : q2);
    mav.addObject("q3", StringUtils.isEmpty(q3) ? "" : q3);
    String q =
        StringUtils.isNotEmpty(q1)
            ? q1
            : StringUtils.isNotEmpty(q2) ? q2 : StringUtils.isNotEmpty(q3) ? q3 : null;
    if (StringUtils.isEmpty(q)) {
      setViewName(mav, outputFormat, outputFormatStyle);
      return mav;
    }
    try {
      if (NumberUtils.isNumber(q) && StringUtils.length(q) == 7) {
        return show(Integer.valueOf(q));
      } else {
        // show list of concepts
        String text = q;
        if ((q.startsWith("http://") && UimaUtils.MIMETYPE_HTML.equals(inputFormat))) {
          URL u = new URL(q);
          BufferedReader br = new BufferedReader(new InputStreamReader(u.openStream()));
          StringBuilder tbuf = new StringBuilder();
          String line = null;
          while ((line = br.readLine()) != null) {
            tbuf.append(line).append("\n");
          }
          br.close();
          text = tbuf.toString();
        }
        List<ConceptAnnotation> annotations = new ArrayList<ConceptAnnotation>();
        long startTs = System.currentTimeMillis();
        JCas jcas = UimaUtils.runAE(conceptMappingAE, text, inputFormat, null);
        FSIndex fsindex = jcas.getAnnotationIndex(ConceptAnnotation.type);
        for (Iterator<ConceptAnnotation> it = fsindex.iterator(); it.hasNext(); ) {
          ConceptAnnotation annotation = it.next();
          annotations.add(annotation);
        }
        CollectionUtils.filter(annotations, new StyGroupPredicate(styGroupFilter));
        CollectionUtils.filter(annotations, new StyCodePredicate(styCodeFilter));
        annotations = filterSubsumedConcepts(q, annotations);
        if (annotations.size() == 0) {
          mav.addObject("error", "No concepts found");
        } else {
          mav.addObject("text", text);
          mav.addObject("annotations", annotations);
          long endTs = System.currentTimeMillis();
          mav.addObject("elapsed", new Long(endTs - startTs));
        }
        setViewName(mav, outputFormat, outputFormatStyle);
      }
    } catch (Exception e) {
      mav.addObject("error", e.getMessage());
      setViewName(mav, outputFormat, outputFormatStyle);
    }
    return mav;
  }
Beispiel #8
0
 /** 编号是否合法 */
 public static final boolean isValidNo(String no) {
   int length = StringUtils.length(no);
   return (length % ITEM_LENGTH == 0);
 }
Beispiel #9
0
 /** Functionality to handle the "Save" button being clicked. */
 private void save(HttpServletRequest request, ModelAndView next, WikiPageInfo pageInfo)
     throws Exception {
   String topicName = WikiUtil.getTopicFromRequest(request);
   String virtualWiki = pageInfo.getVirtualWikiName();
   Topic topic = loadTopic(virtualWiki, topicName);
   Topic lastTopic = WikiBase.getDataHandler().lookupTopic(virtualWiki, topicName, false, null);
   if (lastTopic != null
       && !lastTopic.getCurrentVersionId().equals(retrieveLastTopicVersionId(request, topic))) {
     // someone else has edited the topic more recently
     resolve(request, next, pageInfo);
     return;
   }
   String contents = request.getParameter("contents");
   String sectionName = "";
   if (!StringUtils.isBlank(request.getParameter("section"))) {
     // load section of topic
     int section = Integer.valueOf(request.getParameter("section"));
     ParserOutput parserOutput = new ParserOutput();
     String[] spliceResult =
         ParserUtil.parseSplice(
             parserOutput,
             request.getContextPath(),
             request.getLocale(),
             virtualWiki,
             topicName,
             section,
             contents);
     contents = spliceResult[1];
     sectionName = parserOutput.getSectionName();
   }
   if (contents == null) {
     logger.warning("The topic " + topicName + " has no content");
     throw new WikiException(new WikiMessage("edit.exception.nocontent", topicName));
   }
   // strip line feeds
   contents = StringUtils.remove(contents, '\r');
   String lastTopicContent =
       (lastTopic != null) ? StringUtils.remove(lastTopic.getTopicContent(), '\r') : "";
   if (lastTopic != null && StringUtils.equals(lastTopicContent, contents)) {
     // topic hasn't changed. redirect to prevent user from refreshing and re-submitting
     ServletUtil.redirect(next, virtualWiki, topic.getName());
     return;
   }
   String editComment = request.getParameter("editComment");
   if (handleSpam(request, next, topicName, contents, editComment)) {
     this.loadEdit(request, next, pageInfo, contents, virtualWiki, topicName, false);
     return;
   }
   // parse for signatures and other syntax that should not be saved in raw form
   WikiUser user = ServletUtil.currentWikiUser();
   ParserInput parserInput = new ParserInput();
   parserInput.setContext(request.getContextPath());
   parserInput.setLocale(request.getLocale());
   parserInput.setWikiUser(user);
   parserInput.setTopicName(topicName);
   parserInput.setUserDisplay(ServletUtil.getIpAddress(request));
   parserInput.setVirtualWiki(virtualWiki);
   ParserOutput parserOutput = ParserUtil.parseMetadata(parserInput, contents);
   // parse signatures and other values that need to be updated prior to saving
   contents = ParserUtil.parseMinimal(parserInput, contents);
   topic.setTopicContent(contents);
   if (!StringUtils.isBlank(parserOutput.getRedirect())) {
     // set up a redirect
     topic.setRedirectTo(parserOutput.getRedirect());
     topic.setTopicType(TopicType.REDIRECT);
   } else if (topic.getTopicType() == TopicType.REDIRECT) {
     // no longer a redirect
     topic.setRedirectTo(null);
     topic.setTopicType(TopicType.ARTICLE);
   }
   int charactersChanged = StringUtils.length(contents) - StringUtils.length(lastTopicContent);
   TopicVersion topicVersion =
       new TopicVersion(
           user, ServletUtil.getIpAddress(request), editComment, contents, charactersChanged);
   if (request.getParameter("minorEdit") != null) {
     topicVersion.setEditType(TopicVersion.EDIT_MINOR);
   }
   WikiBase.getDataHandler()
       .writeTopic(topic, topicVersion, parserOutput.getCategories(), parserOutput.getLinks());
   // update watchlist
   WikiUserDetailsImpl userDetails = ServletUtil.currentUserDetails();
   if (!userDetails.hasRole(Role.ROLE_ANONYMOUS)) {
     Watchlist watchlist = ServletUtil.currentWatchlist(request, virtualWiki);
     boolean watchTopic = (request.getParameter("watchTopic") != null);
     if (watchlist.containsTopic(topicName) != watchTopic) {
       WikiBase.getDataHandler()
           .writeWatchlistEntry(watchlist, virtualWiki, topicName, user.getUserId());
     }
   }
   // redirect to prevent user from refreshing and re-submitting
   String target = topic.getName();
   if (!StringUtils.isBlank(sectionName)) {
     target += "#" + sectionName;
   }
   ServletUtil.redirect(next, virtualWiki, target);
 }
Beispiel #10
0
  @Path("/entries")
  @GET
  @ApiOperation(
      value = "Get category entries",
      notes = "Get a list of category entries",
      responseClass = "com.commafeed.frontend.model.Entries")
  public Response getCategoryEntries(
      @ApiParam(value = "id of the category, 'all' or 'starred'", required = true) @QueryParam("id")
          String id,
      @ApiParam(
              value = "all entries or only unread ones",
              allowableValues = "all,unread",
              required = true)
          @DefaultValue("unread")
          @QueryParam("readType")
          ReadingMode readType,
      @ApiParam(value = "only entries newer than this") @QueryParam("newerThan") Long newerThan,
      @ApiParam(value = "offset for paging") @DefaultValue("0") @QueryParam("offset") int offset,
      @ApiParam(value = "limit for paging, default 20, maximum 1000")
          @DefaultValue("20")
          @QueryParam("limit")
          int limit,
      @ApiParam(value = "date ordering", allowableValues = "asc,desc")
          @QueryParam("order")
          @DefaultValue("desc")
          ReadingOrder order,
      @ApiParam(
              value =
                  "search for keywords in either the title or the content of the entries, separated by spaces, 3 characters minimum")
          @QueryParam("keywords")
          String keywords,
      @ApiParam(value = "return only entry ids") @DefaultValue("false") @QueryParam("onlyIds")
          boolean onlyIds) {

    Preconditions.checkNotNull(readType);

    keywords = StringUtils.trimToNull(keywords);
    Preconditions.checkArgument(keywords == null || StringUtils.length(keywords) >= 3);

    limit = Math.min(limit, 1000);
    limit = Math.max(0, limit);

    Entries entries = new Entries();
    entries.setOffset(offset);
    entries.setLimit(limit);
    boolean unreadOnly = readType == ReadingMode.unread;
    if (StringUtils.isBlank(id)) {
      id = ALL;
    }

    Date newerThanDate = newerThan == null ? null : new Date(Long.valueOf(newerThan));

    if (ALL.equals(id)) {
      entries.setName("All");
      List<FeedSubscription> subscriptions = feedSubscriptionDAO.findAll(getUser());
      List<FeedEntryStatus> list =
          feedEntryStatusDAO.findBySubscriptions(
              subscriptions,
              unreadOnly,
              keywords,
              newerThanDate,
              offset,
              limit + 1,
              order,
              true,
              onlyIds);

      for (FeedEntryStatus status : list) {
        entries
            .getEntries()
            .add(
                Entry.build(
                    status,
                    applicationSettingsService.get().getPublicUrl(),
                    applicationSettingsService.get().isImageProxyEnabled()));
      }

    } else if (STARRED.equals(id)) {
      entries.setName("Starred");
      List<FeedEntryStatus> starred =
          feedEntryStatusDAO.findStarred(
              getUser(), newerThanDate, offset, limit + 1, order, !onlyIds);
      for (FeedEntryStatus status : starred) {
        entries
            .getEntries()
            .add(
                Entry.build(
                    status,
                    applicationSettingsService.get().getPublicUrl(),
                    applicationSettingsService.get().isImageProxyEnabled()));
      }
    } else {
      FeedCategory parent = feedCategoryDAO.findById(getUser(), Long.valueOf(id));
      if (parent != null) {
        List<FeedCategory> categories =
            feedCategoryDAO.findAllChildrenCategories(getUser(), parent);
        List<FeedSubscription> subs = feedSubscriptionDAO.findByCategories(getUser(), categories);

        List<FeedEntryStatus> list =
            feedEntryStatusDAO.findBySubscriptions(
                subs, unreadOnly, keywords, newerThanDate, offset, limit + 1, order, true, onlyIds);

        for (FeedEntryStatus status : list) {
          entries
              .getEntries()
              .add(
                  Entry.build(
                      status,
                      applicationSettingsService.get().getPublicUrl(),
                      applicationSettingsService.get().isImageProxyEnabled()));
        }
        entries.setName(parent.getName());
      }
    }

    boolean hasMore = entries.getEntries().size() > limit;
    if (hasMore) {
      entries.setHasMore(true);
      entries.getEntries().remove(entries.getEntries().size() - 1);
    }

    entries.setTimestamp(System.currentTimeMillis());
    FeedUtils.removeUnwantedFromSearch(entries.getEntries(), keywords);
    return Response.ok(entries).build();
  }