Ejemplo n.º 1
0
  /**
   * Gets globally popular applications (the per-user popular apps are a property on UserDMO)
   *
   * @param viewpoint
   * @param start
   * @return
   * @throws IQException
   */
  @IQMethod(name = "getPopularApplications", type = IQ.Type.get)
  @IQParams({"start=0", "category=null", "distribution=null", "lang=null"})
  public Collection<ApplicationDMO> getPopularApplications(
      UserViewpoint viewpoint, int start, String category, String distribution, String lang)
      throws IQException {
    if (start < 0 || start > 4096) // Arbitrary but reasonable limit
    start = 0;

    Pageable<ApplicationView> pageable = new Pageable<ApplicationView>("applications");
    pageable.setPosition(start);
    pageable.setInitialPerPage(30);

    ApplicationCategory cat = null;
    if (category != null) {
      for (ApplicationCategory c : ApplicationCategory.values()) {
        if (c.getDisplayName().equals(category)) {
          cat = c;
          break;
        }
      }
      if (cat == null) cat = ApplicationCategory.fromRaw(Collections.singleton(category));
    }
    applicationSystem.pagePopularApplications(null, -1, cat, pageable);

    return getResults(pageable);
  }
Ejemplo n.º 2
0
  /**
   * Searches applications globally (not per-user)
   *
   * @param viewpoint
   * @param start
   * @return
   * @throws IQException
   */
  @IQMethod(name = "searchApplications", type = IQ.Type.get)
  @IQParams({"start=0", "search", "distribution=null", "lang=null"})
  public Collection<ApplicationDMO> searchApplications(
      UserViewpoint viewpoint, int start, String search, String distribution, String lang)
      throws IQException {
    if (start < 0 || start > 4096) // Arbitrary but reasonable limit
    start = 0;

    Pageable<ApplicationView> pageable = new Pageable<ApplicationView>("applications");
    pageable.setPosition(start);
    pageable.setInitialPerPage(30);
    applicationSystem.search(search, -1, null, pageable);

    return getResults(pageable);
  }