コード例 #1
0
  @Published()
  @GET
  @Path("/{pubids: [0-9,]+}")
  @Produces({"text/html", "text/javascript", "application/json"})
  public String getPublicationByPubIDs(@DefaultValue("") @PathParam("pubids") String pubIDStr) {

    // Check permission.
    String denyReason = support.checkPermission(request, uriInfo);
    if (null != denyReason) {
      return denyReason;
    }

    String[] ids = pubIDStr.split(",");
    Set<Integer> pubIDSet = new LinkedHashSet<Integer>();
    for (String idstr : ids) pubIDSet.add(Integer.parseInt(idstr.trim()));
    try {
      boolean withAbs = false;
      String fieldSelectString = Strings.safeTrim(REQ.get(request, FIELDS));
      if (fieldSelectString.contains("+abs") || fieldSelectString.contains("abs")) {
        withAbs = true;
      }
      List<Publication> pubSet =
          publicationService.getPublications(withAbs, pubIDSet.toArray(new Integer[] {}));

      // if has html, return here.
      String htmlResult = support.returnHtml(request, "person_profile.vm", pubSet);
      if (null != htmlResult) {
        return htmlResult;
      }

      Publication[] parray = new Publication[pubSet.size()];
      parray = pubSet.toArray(parray);

      return _returnPublication(request, parray);
    } catch (Throwable t) {
      t.printStackTrace();
      return support.throwJson(t.getMessage(), t);
    }
  }
コード例 #2
0
  /**
   * @param option default tff, [contactInfo, publicationList, coauthors]
   * @return
   */
  @Published()
  @GET
  @Path("/{pubid: [0-9]+}")
  @Produces({"text/html", "text/javascript", "application/json"})
  public String getPublicationByPubID(@DefaultValue("-1") @PathParam("pubid") Integer pubID) {

    // Check permission.
    String denyReason = support.checkPermission(request, uriInfo);
    if (null != denyReason) {
      return denyReason;
    }

    try {
      boolean withAbs = false;
      String fieldSelectString = Strings.safeTrim(REQ.get(request, FIELDS));
      if (fieldSelectString.contains("+abs") || fieldSelectString.contains("abs")) {
        withAbs = true;
      }
      Publication pub = null;
      if (withAbs) {
        pub = publicationService.getPublicationFull(pubID);
      } else {
        pub = publicationService.getPublication(pubID);
      }

      // if has html, return here.
      String htmlResult = support.returnHtml(request, "person_profile.vm", pub);
      if (null != htmlResult) {
        return htmlResult;
      }

      return _returnPublication(request, pub);
    } catch (Throwable t) {
      t.printStackTrace();
      return support.throwJson(t.getMessage(), t);
    }
  }