Beispiel #1
0
  /**
   * requires a valid JStor Ticket ID
   *
   * @param query The search term to query JStor for.
   * @param ticket JStor ticket
   * @return cookie value of the key JSTORFetcher.COOKIE_CITATIONS. null if search is empty or
   *     ticket is invalid
   * @throws IOException
   */
  private String getCitations(String ticket, String query) throws IOException {
    String urlQuery;
    try {
      urlQuery =
          "http://www.jstor.org/search/BasicResults?hp="
              + JSTORFetcher.MAX_CITATIONS
              + "&si=1&gw=jtx&jtxsi=1&jcpsi=1&artsi=1&Query="
              + URLEncoder.encode(query, "UTF-8")
              + "&wc=on&citationAction=saveAll";
    } catch (UnsupportedEncodingException e) {
      throw new RuntimeException(e);
    }

    URL url = new URL(urlQuery);
    URLConnection conn = url.openConnection();
    conn.setRequestProperty("Cookie", ticket);
    return JSTORFetcher.getCookie(JSTORFetcher.COOKIE_CITATIONS, conn);
  }
Beispiel #2
0
 /**
  * @return a Jstor ticket ID
  * @throws IOException
  */
 private String openTicket() throws IOException {
   URL url = new URL(JSTORFetcher.URL_TICKET);
   URLConnection conn = url.openConnection();
   return JSTORFetcher.getCookie(JSTORFetcher.COOKIE_TICKET, conn);
 }