Return-Path: X-Original-To: apmail-chemistry-commits-archive@www.apache.org Delivered-To: apmail-chemistry-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A8C69D632 for ; Tue, 28 May 2013 07:23:34 +0000 (UTC) Received: (qmail 76854 invoked by uid 500); 28 May 2013 07:23:34 -0000 Delivered-To: apmail-chemistry-commits-archive@chemistry.apache.org Received: (qmail 76791 invoked by uid 500); 28 May 2013 07:23:33 -0000 Mailing-List: contact commits-help@chemistry.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@chemistry.apache.org Delivered-To: mailing list commits@chemistry.apache.org Received: (qmail 76781 invoked by uid 99); 28 May 2013 07:23:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 May 2013 07:23:33 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 May 2013 07:23:29 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id AF9222388C7D; Tue, 28 May 2013 07:21:51 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1486787 [38/40] - in /chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-server/chemistry-opencmis-server-bindings: ./ css/ images/ images/logos/ xref-test/ xref-test/org/ xref-test/org/apache/ xref-test/org/apache/chemistry/... Date: Tue, 28 May 2013 07:21:44 -0000 To: commits@chemistry.apache.org From: gabriele@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130528072151.AF9222388C7D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-server/chemistry-opencmis-server-bindings/xref/org/apache/chemistry/opencmis/server/shared/HttpUtils.html URL: http://svn.apache.org/viewvc/chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-server/chemistry-opencmis-server-bindings/xref/org/apache/chemistry/opencmis/server/shared/HttpUtils.html?rev=1486787&view=auto ============================================================================== --- chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-server/chemistry-opencmis-server-bindings/xref/org/apache/chemistry/opencmis/server/shared/HttpUtils.html (added) +++ chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-server/chemistry-opencmis-server-bindings/xref/org/apache/chemistry/opencmis/server/shared/HttpUtils.html Tue May 28 07:21:41 2013 @@ -0,0 +1,90 @@ + + + + +HttpUtils xref + + + +
+
+1   /*
+2    * Licensed to the Apache Software Foundation (ASF) under one
+3    * or more contributor license agreements.  See the NOTICE file
+4    * distributed with this work for additional information
+5    * regarding copyright ownership.  The ASF licenses this file
+6    * to you under the Apache License, Version 2.0 (the
+7    * "License"); you may not use this file except in compliance
+8    * with the License.  You may obtain a copy of the License at
+9    *
+10   * http://www.apache.org/licenses/LICENSE-2.0
+11   *
+12   * Unless required by applicable law or agreed to in writing,
+13   * software distributed under the License is distributed on an
+14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+15   * KIND, either express or implied.  See the License for the
+16   * specific language governing permissions and limitations
+17   * under the License.
+18   */
+19  package org.apache.chemistry.opencmis.server.shared;
+20  
+21  import java.io.UnsupportedEncodingException;
+22  import java.net.URLDecoder;
+23  import java.util.Map;
+24  
+25  import javax.servlet.http.HttpServletRequest;
+26  
+27  import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
+28  
+29  public class HttpUtils {
+30  
+31      /**
+32       * Extracts a string parameter.
+33       */
+34      public static String getStringParameter(final HttpServletRequest request, final String name) {
+35          if (name == null) {
+36              return null;
+37          }
+38  
+39          @SuppressWarnings("unchecked")
+40          Map<String, String[]> parameters = (Map<String, String[]>) request.getParameterMap();
+41          for (Map.Entry<String, String[]> parameter : parameters.entrySet()) {
+42              if (name.equalsIgnoreCase(parameter.getKey())) {
+43                  if (parameter.getValue() == null) {
+44                      return null;
+45                  }
+46                  return parameter.getValue()[0];
+47              }
+48          }
+49  
+50          return null;
+51      }
+52  
+53      /**
+54       * Splits the path into its fragments.
+55       */
+56      public static String[] splitPath(final HttpServletRequest request) {
+57          int prefixLength = request.getContextPath().length() + request.getServletPath().length();
+58          String p = request.getRequestURI().substring(prefixLength);
+59  
+60          if (p.length() == 0) {
+61              return new String[0];
+62          }
+63  
+64          String[] result = p.substring(1).split("/");
+65          for (int i = 0; i < result.length; i++) {
+66              try {
+67                  result[i] = URLDecoder.decode(result[i], "UTF-8");
+68              } catch (UnsupportedEncodingException e) {
+69                  // should not happen
+70                  throw new CmisRuntimeException(e.getMessage(), e);
+71              }
+72          }
+73  
+74          return result;
+75      }
+76  }
+
+
+ + Added: chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-server/chemistry-opencmis-server-bindings/xref/org/apache/chemistry/opencmis/server/shared/QueryStringHttpServletRequestWrapper.html URL: http://svn.apache.org/viewvc/chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-server/chemistry-opencmis-server-bindings/xref/org/apache/chemistry/opencmis/server/shared/QueryStringHttpServletRequestWrapper.html?rev=1486787&view=auto ============================================================================== --- chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-server/chemistry-opencmis-server-bindings/xref/org/apache/chemistry/opencmis/server/shared/QueryStringHttpServletRequestWrapper.html (added) +++ chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-server/chemistry-opencmis-server-bindings/xref/org/apache/chemistry/opencmis/server/shared/QueryStringHttpServletRequestWrapper.html Tue May 28 07:21:41 2013 @@ -0,0 +1,141 @@ + + + + +QueryStringHttpServletRequestWrapper xref + + + +
+
+1   /*
+2    * Licensed to the Apache Software Foundation (ASF) under one
+3    * or more contributor license agreements.  See the NOTICE file
+4    * distributed with this work for additional information
+5    * regarding copyright ownership.  The ASF licenses this file
+6    * to you under the Apache License, Version 2.0 (the
+7    * "License"); you may not use this file except in compliance
+8    * with the License.  You may obtain a copy of the License at
+9    *
+10   * http://www.apache.org/licenses/LICENSE-2.0
+11   *
+12   * Unless required by applicable law or agreed to in writing,
+13   * software distributed under the License is distributed on an
+14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+15   * KIND, either express or implied.  See the License for the
+16   * specific language governing permissions and limitations
+17   * under the License.
+18   */
+19  package org.apache.chemistry.opencmis.server.shared;
+20  
+21  import java.io.IOException;
+22  import java.net.URLDecoder;
+23  import java.util.Collections;
+24  import java.util.Enumeration;
+25  import java.util.HashMap;
+26  import java.util.Map;
+27  
+28  import javax.servlet.http.HttpServletRequest;
+29  import javax.servlet.http.HttpServletRequestWrapper;
+30  
+31  /**
+32   * HttpServletRequest wrapper that reads the query string in container
+33   * independent way and decodes the parameter values with UTF-8.
+34   */
+35  public class QueryStringHttpServletRequestWrapper extends HttpServletRequestWrapper {
+36  
+37      private Map<String, String[]> parameters;
+38  
+39      public QueryStringHttpServletRequestWrapper(HttpServletRequest request) throws IOException {
+40          super(request);
+41  
+42          parameters = new HashMap<String, String[]>();
+43  
+44          // parse query string
+45          parseFormData(request.getQueryString());
+46      }
+47  
+48      /**
+49       * Parses the query string.
+50       */
+51      protected void parseFormData(String queryString) throws IOException {
+52          if (queryString == null || queryString.length() < 3) {
+53              return;
+54          }
+55  
+56          String[] nameValuePairs = queryString.split("&");
+57          for (String nameValuePair : nameValuePairs) {
+58              int x = nameValuePair.indexOf('=');
+59              if (x > 0) {
+60                  String name = URLDecoder.decode(nameValuePair.substring(0, x), "UTF-8");
+61                  String value = (x == nameValuePair.length() - 1 ? "" : URLDecoder.decode(
+62                          nameValuePair.substring(x + 1), "UTF-8"));
+63                  addParameter(name, value);
+64              } else {
+65                  String name = URLDecoder.decode(nameValuePair, "UTF-8");
+66                  addParameter(name, (String) null);
+67              }
+68          }
+69      }
+70  
+71      /**
+72       * Adds a value to a parameter.
+73       */
+74      protected void addParameter(String name, String value) {
+75          String[] values = parameters.get(name);
+76  
+77          if (values == null) {
+78              parameters.put(name, new String[] { value });
+79          } else {
+80              String[] newValues = new String[values.length + 1];
+81              System.arraycopy(values, 0, newValues, 0, values.length);
+82              newValues[newValues.length - 1] = value;
+83              parameters.put(name, newValues);
+84          }
+85      }
+86  
+87      /**
+88       * Adds an array of values to a parameter.
+89       */
+90      protected void addParameter(String name, String[] additionalValues) {
+91          String[] values = parameters.get(name);
+92  
+93          if (values == null) {
+94              parameters.put(name, additionalValues);
+95          } else {
+96              String[] newValues = new String[values.length + additionalValues.length];
+97              System.arraycopy(values, 0, newValues, 0, values.length);
+98              System.arraycopy(additionalValues, 0, newValues, values.length, additionalValues.length);
+99              parameters.put(name, newValues);
+100         }
+101     }
+102 
+103     @Override
+104     public String getParameter(String name) {
+105         String[] values = parameters.get(name);
+106         if ((values == null) || (values.length == 0)) {
+107             return null;
+108         }
+109 
+110         return values[0];
+111     }
+112 
+113     @Override
+114     public Map<String, String[]> getParameterMap() {
+115         return parameters;
+116     }
+117 
+118     @Override
+119     public Enumeration<String> getParameterNames() {
+120         return Collections.enumeration(parameters.keySet());
+121     }
+122 
+123     @Override
+124     public String[] getParameterValues(String name) {
+125         return parameters.get(name);
+126     }
+127 }
+
+
+ + Added: chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-server/chemistry-opencmis-server-bindings/xref/org/apache/chemistry/opencmis/server/shared/ServiceCall.html URL: http://svn.apache.org/viewvc/chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-server/chemistry-opencmis-server-bindings/xref/org/apache/chemistry/opencmis/server/shared/ServiceCall.html?rev=1486787&view=auto ============================================================================== --- chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-server/chemistry-opencmis-server-bindings/xref/org/apache/chemistry/opencmis/server/shared/ServiceCall.html (added) +++ chemistry/site/trunk/content/java/0.9.0/maven/chemistry-opencmis-server/chemistry-opencmis-server-bindings/xref/org/apache/chemistry/opencmis/server/shared/ServiceCall.html Tue May 28 07:21:41 2013 @@ -0,0 +1,48 @@ + + + + +ServiceCall xref + + + +
+
+1   /*
+2    * Licensed to the Apache Software Foundation (ASF) under one
+3    * or more contributor license agreements.  See the NOTICE file
+4    * distributed with this work for additional information
+5    * regarding copyright ownership.  The ASF licenses this file
+6    * to you under the Apache License, Version 2.0 (the
+7    * "License"); you may not use this file except in compliance
+8    * with the License.  You may obtain a copy of the License at
+9    *
+10   * http://www.apache.org/licenses/LICENSE-2.0
+11   *
+12   * Unless required by applicable law or agreed to in writing,
+13   * software distributed under the License is distributed on an
+14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+15   * KIND, either express or implied.  See the License for the
+16   * specific language governing permissions and limitations
+17   * under the License.
+18   */
+19  package org.apache.chemistry.opencmis.server.shared;
+20  
+21  import javax.servlet.http.HttpServletRequest;
+22  import javax.servlet.http.HttpServletResponse;
+23  
+24  import org.apache.chemistry.opencmis.commons.server.CallContext;
+25  import org.apache.chemistry.opencmis.commons.server.CmisService;
+26  
+27  public interface ServiceCall {
+28  
+29      /**
+30       * Serves an AtomPub or Browser binding call.
+31       */
+32      void serve(CallContext context, CmisService service, String repositoryId, HttpServletRequest request,
+33              HttpServletResponse response) throws Exception;
+34  }
+
+
+ +