Package org.apache.commons.httpclient.cookie

Examples of org.apache.commons.httpclient.cookie.Cookie2


        // Now, insert the new cookies
        int i = 0;
        while (i < cookies.getCookieCount())
        {
          Cookie c = cookies.getCookie(i);
          Cookie2 c2;
          if (c instanceof Cookie2)
            c2 = (Cookie2)c;
          else
            c2 = null;
          HashMap map = new HashMap();
          map.put(keyField,sessionKey);
          map.put(ordinalField,new Long(i));
          String domain = c.getDomain();
          if (domain != null && domain.length() > 0)
            map.put(domainField,domain);
          map.put(domainSpecifiedField,booleanToString(c.isDomainAttributeSpecified()));
          String name = c.getName();
          if (name != null && name.length() > 0)
            map.put(nameField,name);
          String value = c.getValue();
          if (value != null && value.length() > 0)
            map.put(valueField,value);
          String path = c.getPath();
          if (path != null && path.length() > 0)
            map.put(pathField,path);
          map.put(pathSpecifiedField,booleanToString(c.isPathAttributeSpecified()));
          map.put(versionField,new Long(c.getVersion()));
          if (c2 != null)
            map.put(versionSpecifiedField,booleanToString(c2.isVersionAttributeSpecified()));
          else
            // Make something up.  It may not be correct, but there's really no choice.
            map.put(versionSpecifiedField,booleanToString(true));
          String comment = c.getComment();
          if (comment != null && comment.length() > 0)
            map.put(commentField,comment);
          map.put(secureField,booleanToString(c.getSecure()));
          Date expirationDate = c.getExpiryDate();
          if (expirationDate != null)
            map.put(expirationDateField,new Long(expirationDate.getTime()));
          if (c2 != null)
            map.put(discardField,booleanToString(!c2.isPersistent()));
          else
            // Once again, make something up.
            map.put(discardField,booleanToString(true));
          if (c2 != null)
          {
            String commentURL = c2.getCommentURL();
            if (commentURL != null && commentURL.length() > 0)
              map.put(commentURLField,commentURL);
          }
          if (c2 != null)
          {
            int[] ports = c2.getPorts();
            if (ports != null && ports.length > 0)
              map.put(portField,portsToString(ports));
          }
          if (c2 != null)
            map.put(portBlankField,booleanToString(c2.isPortAttributeBlank()));
          else
            map.put(portBlankField,booleanToString(true));
          if (c2 != null)
            map.put(portSpecifiedField,booleanToString(c2.isPortAttributeSpecified()));
          else
            map.put(portSpecifiedField,booleanToString(false));
          performInsert(map,null);
          i++;
        }
View Full Code Here


    DynamicCookieSet dcs = new DynamicCookieSet();
    int i = 0;
    while (i < result.getRowCount())
    {
      IResultRow row = result.getRow(i++);
      Cookie2 c = new Cookie2();
      String domain = (String)row.getValue(domainField);
      if (domain != null && domain.length() > 0)
        c.setDomain(domain);
      c.setDomainAttributeSpecified(stringToBoolean((String)row.getValue(domainSpecifiedField)));
      String name = (String)row.getValue(nameField);
      if (name != null && name.length() > 0)
        c.setName(name);
      String value = (String)row.getValue(valueField);
      if (value != null && value.length() > 0)
        c.setValue(value);
      String path = (String)row.getValue(pathField);
      if (path != null && path.length() > 0)
        c.setPath(path);
      c.setPathAttributeSpecified(stringToBoolean((String)row.getValue(pathSpecifiedField)));
      Long version = (Long)row.getValue(versionField);
      if (version != null)
        c.setVersion((int)version.longValue());
      c.setVersionAttributeSpecified(stringToBoolean((String)row.getValue(versionSpecifiedField)));
      String comment = (String)row.getValue(commentField);
      if (comment != null)
        c.setComment(comment);
      c.setSecure(stringToBoolean((String)row.getValue(secureField)));
      Long expirationDate = (Long)row.getValue(expirationDateField);
      if (expirationDate != null)
        c.setExpiryDate(new Date(expirationDate.longValue()));
      c.setDiscard(stringToBoolean((String)row.getValue(discardField)));
      String commentURL = (String)row.getValue(commentURLField);
      if (commentURL != null && commentURL.length() > 0)
        c.setCommentURL(commentURL);
      String ports = (String)row.getValue(portField);
      // Ports are comma-separated
      if (ports != null && ports.length() > 0)
        c.setPorts(stringToPorts(ports));
      c.setPortAttributeBlank(stringToBoolean((String)row.getValue(portBlankField)));
      c.setPortAttributeSpecified(stringToBoolean((String)row.getValue(portSpecifiedField)));

      dcs.addCookie(c);
    }
    return dcs;
  }
View Full Code Here

          try {
             
              trace("before cookies");
              HttpState initialState = new HttpState();
              for (Iterator iterator = this.cookies.iterator(); iterator.hasNext();) {
                    Cookie2 c = (Cookie2) iterator.next();
                    initialState.addCookie(c);
                    trace("Cookie " + c.toString());
                    trace("Client enriched with cookie " +  c.toString());
                }
              client.setState(initialState);
              trace("after cookies");
             
              pm = new PostMethod(this.url);
View Full Code Here

                    if (null != cooks) {
                    for (int i = 0; i < cooks.length; i++) {
                        trace("Adding cookie " + cooks[i]);
                        String c = getCookie(cooks[i]);
                        if (null !=c) {
                            cs.add(new Cookie2("127.0.0.1",cooks[i], c));
                            trace("Cookie added " + cooks[i]);
                        } else {
                            trace("Cookie not added " + cooks[i]);
                        }
                    }
View Full Code Here

        // Now, insert the new cookies
        int i = 0;
        while (i < cookies.getCookieCount())
        {
          Cookie c = cookies.getCookie(i);
          Cookie2 c2;
          if (c instanceof Cookie2)
            c2 = (Cookie2)c;
          else
            c2 = null;
          HashMap map = new HashMap();
          map.put(keyField,sessionKey);
          map.put(ordinalField,new Long(i));
          String domain = c.getDomain();
          if (domain != null && domain.length() > 0)
            map.put(domainField,domain);
          map.put(domainSpecifiedField,booleanToString(c.isDomainAttributeSpecified()));
          String name = c.getName();
          if (name != null && name.length() > 0)
            map.put(nameField,name);
          String value = c.getValue();
          if (value != null && value.length() > 0)
            map.put(valueField,value);
          String path = c.getPath();
          if (path != null && path.length() > 0)
            map.put(pathField,path);
          map.put(pathSpecifiedField,booleanToString(c.isPathAttributeSpecified()));
          map.put(versionField,new Long(c.getVersion()));
          if (c2 != null)
            map.put(versionSpecifiedField,booleanToString(c2.isVersionAttributeSpecified()));
          else
            // Make something up.  It may not be correct, but there's really no choice.
            map.put(versionSpecifiedField,booleanToString(true));
          String comment = c.getComment();
          if (comment != null && comment.length() > 0)
            map.put(commentField,comment);
          map.put(secureField,booleanToString(c.getSecure()));
          Date expirationDate = c.getExpiryDate();
          if (expirationDate != null)
            map.put(expirationDateField,new Long(expirationDate.getTime()));
          if (c2 != null)
            map.put(discardField,booleanToString(!c2.isPersistent()));
          else
            // Once again, make something up.
            map.put(discardField,booleanToString(true));
          if (c2 != null)
          {
            String commentURL = c2.getCommentURL();
            if (commentURL != null && commentURL.length() > 0)
              map.put(commentURLField,commentURL);
          }
          if (c2 != null)
          {
            int[] ports = c2.getPorts();
            if (ports != null && ports.length > 0)
              map.put(portField,portsToString(ports));
          }
          if (c2 != null)
            map.put(portBlankField,booleanToString(c2.isPortAttributeBlank()));
          else
            map.put(portBlankField,booleanToString(true));
          if (c2 != null)
            map.put(portSpecifiedField,booleanToString(c2.isPortAttributeSpecified()));
          else
            map.put(portSpecifiedField,booleanToString(false));
          performInsert(map,null);
          i++;
        }
View Full Code Here

    DynamicCookieSet dcs = new DynamicCookieSet();
    int i = 0;
    while (i < result.getRowCount())
    {
      IResultRow row = result.getRow(i++);
      Cookie2 c = new Cookie2();
      String domain = (String)row.getValue(domainField);
      if (domain != null && domain.length() > 0)
        c.setDomain(domain);
      c.setDomainAttributeSpecified(stringToBoolean((String)row.getValue(domainSpecifiedField)));
      String name = (String)row.getValue(nameField);
      if (name != null && name.length() > 0)
        c.setName(name);
      String value = (String)row.getValue(valueField);
      if (value != null && value.length() > 0)
        c.setValue(value);
      String path = (String)row.getValue(pathField);
      if (path != null && path.length() > 0)
        c.setPath(path);
      c.setPathAttributeSpecified(stringToBoolean((String)row.getValue(pathSpecifiedField)));
      Long version = (Long)row.getValue(versionField);
      if (version != null)
        c.setVersion((int)version.longValue());
      c.setVersionAttributeSpecified(stringToBoolean((String)row.getValue(versionSpecifiedField)));
      String comment = (String)row.getValue(commentField);
      if (comment != null)
        c.setComment(comment);
      c.setSecure(stringToBoolean((String)row.getValue(secureField)));
      Long expirationDate = (Long)row.getValue(expirationDateField);
      if (expirationDate != null)
        c.setExpiryDate(new Date(expirationDate.longValue()));
      c.setDiscard(stringToBoolean((String)row.getValue(discardField)));
      String commentURL = (String)row.getValue(commentURLField);
      if (commentURL != null && commentURL.length() > 0)
        c.setCommentURL(commentURL);
      String ports = (String)row.getValue(portField);
      // Ports are comma-separated
      if (ports != null && ports.length() > 0)
        c.setPorts(stringToPorts(ports));
      c.setPortAttributeBlank(stringToBoolean((String)row.getValue(portBlankField)));
      c.setPortAttributeSpecified(stringToBoolean((String)row.getValue(portSpecifiedField)));

      dcs.addCookie(c);
    }
    return dcs;
  }
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.cookie.Cookie2

Copyright © 2018 www.massapicom. 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.