Examples of UrlResponseObject


Examples of org.opentides.bean.UrlResponseObject

        // set the IP Address as param
        Map<String, Object> param = new HashMap<String, Object>();       
        if (StringUtil.isEmpty(IPAddress))
          param.put("IPAddress", IPAddress);
       
        UrlResponseObject response = UrlUtil.getPage(url, req, param);
        if (response==null)
          return null;
        if (response.getResponseType()
            .startsWith(Widget.TYPE_IMAGE)) {
          _log.debug("Retrieving image [" + widget.getName()
              + "] from url [" + widget.getUrl() + "]...");
          widget.setCacheType(response.getResponseType());
          widget.setCache(response.getResponseBody());
          widget.setLastCacheUpdate(new Date());
          save(widget);
          _log.debug("Saved image [" + widget.getName()
              + "] to cache...");
          return widget;
        } else {
          _log.debug("Retrieving widget [" + widget.getName()
              + "] from url [" + widget.getUrl() + "]...");
          widget.setCacheType(response.getResponseType());
          // check for image inside the html
          String html = new String(response.getResponseBody());
          String hostname = UrlUtil.getHostname(url);
          Matcher matcher = pattern.matcher(html);
          while (matcher.find()) {
            // add image link to cache
            String imageUrl = matcher.group(1);
View Full Code Here

Examples of org.opentides.bean.UrlResponseObject

   */
  private String addCache(String url, HttpServletRequest req, Widget parentSettings) {
    Widget settings = this.findByUrl(url);
    if (settings == null)
      settings = new Widget(url, parentSettings);
    UrlResponseObject response = UrlUtil.getPage(url, req, null);
    if (response.getResponseType().startsWith(Widget.TYPE_IMAGE))
      settings.setCacheType(Widget.TYPE_IMAGE);
    else
      settings.setCacheType(Widget.TYPE_HTML);
    settings.setCache(response.getResponseBody());
    this.save(settings);
    settings.setName(""+settings.getId());
    this.save(settings);
    return settings.getName();
  }
View Full Code Here

Examples of org.opentides.bean.UrlResponseObject

      // now let's retrieve the data
      client.executeMethod(hostConfig, httpMethodBase);
     
      // Read the response body.
      UrlResponseObject response = new UrlResponseObject();
      response.setResponseBody(httpMethodBase.getResponseBody());
      Header contentType = httpMethodBase.getResponseHeader("Content-Type");
      if (contentType!=null)
        response.setResponseType(contentType.getValue());
      else
        response.setResponseType(Widget.TYPE_HTML);
      return response;

    } catch (Exception ex) {
      _log.error("Failed to request from URL: ["+queryURL+"]", ex);
      return null;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.