Package org.exoplatform.common.http.client

Examples of org.exoplatform.common.http.client.NVPair


      String xmlBody =
         "<?xml version='1.0' encoding='utf-8' ?><D:searchrequest xmlns:D='DAV:'>" + "<D:xpath>" + query + "</D:xpath>"
            + "</D:searchrequest>";

      NVPair[] headers = new NVPair[2];
      headers[0] = new NVPair(HttpHeaders.CONTENT_TYPE, "text/xml; charset='utf-8'");
      headers[1] = new NVPair(HttpHeaders.CONTENT_LENGTH, Integer.toString(xmlBody.length()));

      HTTPResponse response = ExtensionMethod("SEARCH", workspacePath, xmlBody.getBytes(), headers);
      response.getStatusCode();

      return response;
View Full Code Here


      String xmlBody =
         "<?xml version='1.0' encoding='utf-8' ?><D:searchrequest xmlns:D='DAV:'>" + "<D:sql>" + query + "</D:sql>"
            + "</D:searchrequest>";

      NVPair[] headers = new NVPair[2];
      headers[0] = new NVPair(HttpHeaders.CONTENT_TYPE, "text/xml; charset='utf-8'");
      headers[1] = new NVPair(HttpHeaders.CONTENT_LENGTH, Integer.toString(xmlBody.length()));

      HTTPResponse response = ExtensionMethod("SEARCH", workspacePath, xmlBody.getBytes(), headers);
      response.getStatusCode();

      return response;
View Full Code Here

   private void prepareRequestHeaders(HttpServletRequest httpRequest)
   {
      ArrayList<NVPair> hds = new ArrayList<NVPair>();
      for (Enumeration<String> en = httpRequest.getHeaderNames(); en.hasMoreElements();)
      {
         NVPair pair = null;
         String headerName = (String)en.nextElement();
         for (Enumeration<String> en2 = httpRequest.getHeaders(headerName); en2.hasMoreElements();)
         {
            pair = new NVPair(headerName, en2.nextElement());
         }
         hds.add(pair);
         this.headers = new NVPair[hds.size()];
         this.headers = hds.toArray(headers);
      }
View Full Code Here

         HTTPConnection conn = new HTTPConnection(url);
         conn.setTimeout(DEFAULT_CONNECT_TIMEOUT_MS);
         NVPair[] headerPairs = toNVPair(headers.getRequestHeaders(), //
            Collections.singleton(new CaseInsensitiveStringWrapper(HttpHeaders.HOST)));
         conn.setAllowUserInteraction(false);
         NVPair credentials = getCredentials(url);
         if (credentials != null)
         {
            conn.addBasicAuthorization(null, credentials.getName(), credentials.getValue());
         }
         HTTPResponse resp = conn.Delete(url.getFile(), headerPairs);
         if (resp.getStatusCode() >= 300)
         {
            if (LOG.isDebugEnabled())
View Full Code Here

         HTTPConnection conn = new HTTPConnection(url);
         conn.setTimeout(DEFAULT_CONNECT_TIMEOUT_MS);
         NVPair[] headerPairs = toNVPair(headers.getRequestHeaders(), //
            Collections.singleton(new CaseInsensitiveStringWrapper(HttpHeaders.HOST)));
         conn.setAllowUserInteraction(false);
         NVPair credentials = getCredentials(url);
         if (credentials != null)
         {
            conn.addBasicAuthorization(null, credentials.getName(), credentials.getValue());
         }
         HTTPResponse resp = conn.Get(url.getFile(), (NVPair[])null, headerPairs);
         if (resp.getStatusCode() >= 300)
         {
            if (LOG.isDebugEnabled())
View Full Code Here

         HTTPConnection conn = new HTTPConnection(url);
         conn.setTimeout(DEFAULT_CONNECT_TIMEOUT_MS);
         NVPair[] headerPairs = toNVPair(headers.getRequestHeaders(), //
            Collections.singleton(new CaseInsensitiveStringWrapper(HttpHeaders.HOST)));
         conn.setAllowUserInteraction(false);
         NVPair credentials = getCredentials(url);
         if (credentials != null)
         {
            conn.addBasicAuthorization(null, credentials.getName(), credentials.getValue());
         }
         HTTPResponse resp = null;
         if (entity != null)
         {
            HttpOutputStream stream = new HttpOutputStream();
View Full Code Here

         HTTPConnection conn = new HTTPConnection(url);
         conn.setTimeout(DEFAULT_CONNECT_TIMEOUT_MS);
         NVPair[] headerPairs = toNVPair(headers.getRequestHeaders(), //
            Collections.singleton(new CaseInsensitiveStringWrapper(HttpHeaders.HOST)));
         conn.setAllowUserInteraction(false);
         NVPair credentials = getCredentials(url);
         if (credentials != null)
         {
            conn.addBasicAuthorization(null, credentials.getName(), credentials.getValue());
         }
         HTTPResponse resp = null;
         if (entity != null)
         {
            HttpOutputStream stream = new HttpOutputStream();
View Full Code Here

   }

   private NVPair getCredentials(URL url)
   {
      String userInfo = url.getUserInfo();
      NVPair credentials = null;
      if (userInfo != null)
      {
         int col = userInfo.indexOf(':');
         if (col == -1)
         {
            credentials = new NVPair(userInfo, "");
         }
         else if (col == userInfo.length() - 1)
         {
            credentials = new NVPair(userInfo.substring(0, userInfo.length() - 1), "");
         }
         else
         {
            credentials = new NVPair(userInfo.substring(0, col), userInfo.substring(col + 1));
         }
      }
      return credentials;
   }
View Full Code Here

      {
         if (!skip.contains(new CaseInsensitiveStringWrapper(e.getKey())))
         {
            for (String v : e.getValue())
            {
               hds.add(new NVPair(e.getKey(), v));
            }
         }
      }
      return hds.toArray(new NVPair[hds.size()]);
   }
View Full Code Here

   }

   public void addNode(String name, String nodeType, byte[] data) throws IOException, ModuleException
   {
      NVPair[] headers = new NVPair[1];
      headers[0] = new NVPair("File-NodeType", nodeType);
      Put(workspacePath + name, data, headers).getStatusCode();
   }
View Full Code Here

TOP

Related Classes of org.exoplatform.common.http.client.NVPair

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.