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 EAB2FD816 for ; Mon, 27 May 2013 17:23:08 +0000 (UTC) Received: (qmail 75934 invoked by uid 500); 27 May 2013 17:23:08 -0000 Delivered-To: apmail-chemistry-commits-archive@chemistry.apache.org Received: (qmail 75848 invoked by uid 500); 27 May 2013 17:23:08 -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 75830 invoked by uid 99); 27 May 2013 17:23:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 May 2013 17:23:08 +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; Mon, 27 May 2013 17:22:53 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 2FA772388CE8 for ; Mon, 27 May 2013 17:21:10 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r863336 [28/44] - in /websites/staging/chemistry/trunk/content: ./ java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/ java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/css/ java/0.9.0/... Date: Mon, 27 May 2013 17:20:59 -0000 To: commits@chemistry.apache.org From: buildbot@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130527172110.2FA772388CE8@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: websites/staging/chemistry/trunk/content/java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/browser/CmisBrowserBindingSpi.html ============================================================================== --- websites/staging/chemistry/trunk/content/java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/browser/CmisBrowserBindingSpi.html (added) +++ websites/staging/chemistry/trunk/content/java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/browser/CmisBrowserBindingSpi.html Mon May 27 17:20:56 2013 @@ -0,0 +1,136 @@ + + + + +CmisBrowserBindingSpi 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.client.bindings.spi.browser;
+20  
+21  import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
+22  import org.apache.chemistry.opencmis.client.bindings.spi.CmisSpi;
+23  import org.apache.chemistry.opencmis.commons.spi.AclService;
+24  import org.apache.chemistry.opencmis.commons.spi.DiscoveryService;
+25  import org.apache.chemistry.opencmis.commons.spi.MultiFilingService;
+26  import org.apache.chemistry.opencmis.commons.spi.NavigationService;
+27  import org.apache.chemistry.opencmis.commons.spi.ObjectService;
+28  import org.apache.chemistry.opencmis.commons.spi.PolicyService;
+29  import org.apache.chemistry.opencmis.commons.spi.RelationshipService;
+30  import org.apache.chemistry.opencmis.commons.spi.RepositoryService;
+31  import org.apache.chemistry.opencmis.commons.spi.VersioningService;
+32  import org.slf4j.Logger;
+33  import org.slf4j.LoggerFactory;
+34  
+35  public class CmisBrowserBindingSpi implements CmisSpi {
+36  
+37      private static final Logger LOG = LoggerFactory.getLogger(CmisBrowserBindingSpi.class);
+38  
+39      private final BindingSession session;
+40  
+41      private final RepositoryService repositoryService;
+42      private final NavigationService navigationService;
+43      private final ObjectService objectService;
+44      private final VersioningService versioningService;
+45      private final DiscoveryService discoveryService;
+46      private final MultiFilingService multiFilingService;
+47      private final RelationshipService relationshipService;
+48      private final PolicyService policyService;
+49      private final AclService aclService;
+50  
+51      /**
+52       * Constructor.
+53       */
+54      public CmisBrowserBindingSpi(BindingSession session) {
+55          if (LOG.isDebugEnabled()) {
+56              LOG.debug("Initializing Browser Binding SPI...");
+57          }
+58  
+59          this.session = session;
+60  
+61          repositoryService = new RepositoryServiceImpl(session);
+62          navigationService = new NavigationServiceImpl(session);
+63          objectService = new ObjectServiceImpl(session);
+64          versioningService = new VersioningServiceImpl(session);
+65          discoveryService = new DiscoveryServiceImpl(session);
+66          multiFilingService = new MultiFilingServiceImpl(session);
+67          relationshipService = new RelationshipServiceImpl(session);
+68          policyService = new PolicyServiceImpl(session);
+69          aclService = new AclServiceImpl(session);
+70      }
+71  
+72      public RepositoryService getRepositoryService() {
+73          return repositoryService;
+74      }
+75  
+76      public NavigationService getNavigationService() {
+77          return navigationService;
+78      }
+79  
+80      public ObjectService getObjectService() {
+81          return objectService;
+82      }
+83  
+84      public VersioningService getVersioningService() {
+85          return versioningService;
+86      }
+87  
+88      public RelationshipService getRelationshipService() {
+89          return relationshipService;
+90      }
+91  
+92      public DiscoveryService getDiscoveryService() {
+93          return discoveryService;
+94      }
+95  
+96      public MultiFilingService getMultiFilingService() {
+97          return multiFilingService;
+98      }
+99  
+100     public AclService getAclService() {
+101         return aclService;
+102     }
+103 
+104     public PolicyService getPolicyService() {
+105         return policyService;
+106     }
+107 
+108     public void clearAllCaches() {
+109         session.remove(SpiSessionParameter.REPOSITORY_URL_CACHE);
+110     }
+111 
+112     public void clearRepositoryCache(String repositoryId) {
+113         RepositoryUrlCache repUrlCache = (RepositoryUrlCache) session.get(SpiSessionParameter.REPOSITORY_URL_CACHE);
+114         if (repUrlCache != null) {
+115             repUrlCache.removeRepository(repositoryId);
+116         }
+117     }
+118 
+119     public void close() {
+120         // no-op for Browser Binding
+121     }
+122 }
+
+
+ + Added: websites/staging/chemistry/trunk/content/java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/browser/DiscoveryServiceImpl.html ============================================================================== --- websites/staging/chemistry/trunk/content/java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/browser/DiscoveryServiceImpl.html (added) +++ websites/staging/chemistry/trunk/content/java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/browser/DiscoveryServiceImpl.html Mon May 27 17:20:56 2013 @@ -0,0 +1,122 @@ + + + + +DiscoveryServiceImpl 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.client.bindings.spi.browser;
+20  
+21  import java.io.OutputStream;
+22  import java.math.BigInteger;
+23  import java.util.Map;
+24  
+25  import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
+26  import org.apache.chemistry.opencmis.client.bindings.spi.http.Output;
+27  import org.apache.chemistry.opencmis.client.bindings.spi.http.Response;
+28  import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
+29  import org.apache.chemistry.opencmis.commons.data.ObjectList;
+30  import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
+31  import org.apache.chemistry.opencmis.commons.impl.Constants;
+32  import org.apache.chemistry.opencmis.commons.impl.JSONConstants;
+33  import org.apache.chemistry.opencmis.commons.impl.JSONConverter;
+34  import org.apache.chemistry.opencmis.commons.impl.TypeCache;
+35  import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
+36  import org.apache.chemistry.opencmis.commons.spi.DiscoveryService;
+37  import org.apache.chemistry.opencmis.commons.spi.Holder;
+38  
+39  /**
+40   * Discovery Service Browser Binding client.
+41   */
+42  public class DiscoveryServiceImpl extends AbstractBrowserBindingService implements DiscoveryService {
+43  
+44      /**
+45       * Constructor.
+46       */
+47      public DiscoveryServiceImpl(BindingSession session) {
+48          setSession(session);
+49      }
+50  
+51      public ObjectList query(String repositoryId, String statement, Boolean searchAllVersions,
+52              Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
+53              BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) {
+54          // build URL
+55          UrlBuilder url = getRepositoryUrl(repositoryId);
+56  
+57          // prepare form data
+58          final FormDataWriter formData = new FormDataWriter(Constants.CMISACTION_QUERY);
+59          formData.addParameter(Constants.PARAM_STATEMENT, statement);
+60          formData.addParameter(Constants.PARAM_SEARCH_ALL_VERSIONS, searchAllVersions);
+61          formData.addParameter(Constants.PARAM_ALLOWABLE_ACTIONS, includeAllowableActions);
+62          formData.addParameter(Constants.PARAM_RELATIONSHIPS, includeRelationships);
+63          formData.addParameter(Constants.PARAM_RENDITION_FILTER, renditionFilter);
+64          formData.addParameter(Constants.PARAM_MAX_ITEMS, maxItems);
+65          formData.addParameter(Constants.PARAM_SKIP_COUNT, skipCount);
+66          // Important: No succinct flag here!!!
+67  
+68          // send and parse
+69          Response resp = post(url, formData.getContentType(), new Output() {
+70              public void write(OutputStream out) throws Exception {
+71                  formData.write(out);
+72              }
+73          });
+74  
+75          TypeCache typeCache = new ClientTypeCacheImpl(repositoryId, this);
+76  
+77          Map<String, Object> json = parseObject(resp.getStream(), resp.getCharset());
+78          return JSONConverter.convertObjectList(json, typeCache, true);
+79      }
+80  
+81      public ObjectList getContentChanges(String repositoryId, Holder<String> changeLogToken, Boolean includeProperties,
+82              String filter, Boolean includePolicyIds, Boolean includeAcl, BigInteger maxItems, ExtensionsData extension) {
+83          // build URL
+84          UrlBuilder url = getRepositoryUrl(repositoryId, Constants.SELECTOR_CONTENT_CHANGES);
+85          url.addParameter(Constants.PARAM_CHANGE_LOG_TOKEN, changeLogToken == null ? null : changeLogToken.getValue());
+86          url.addParameter(Constants.PARAM_PROPERTIES, includeProperties);
+87          url.addParameter(Constants.PARAM_FILTER, filter);
+88          url.addParameter(Constants.PARAM_POLICY_IDS, includePolicyIds);
+89          url.addParameter(Constants.PARAM_ACL, includeAcl);
+90          url.addParameter(Constants.PARAM_MAX_ITEMS, maxItems);
+91          url.addParameter(Constants.PARAM_SUCCINCT, getSuccinctParameter());
+92  
+93          // read and parse
+94          Response resp = read(url);
+95          Map<String, Object> json = parseObject(resp.getStream(), resp.getCharset());
+96  
+97          if (changeLogToken != null && json != null) {
+98              Object token = json.get(JSONConstants.JSON_OBJECTLIST_CHANGE_LOG_TOKEN);
+99              if (token instanceof String) {
+100                 changeLogToken.setValue((String) token);
+101             }
+102         }
+103 
+104         TypeCache typeCache = new ClientTypeCacheImpl(repositoryId, this);
+105 
+106         return JSONConverter.convertObjectList(json, typeCache, false);
+107     }
+108 }
+
+
+ + Added: websites/staging/chemistry/trunk/content/java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/browser/FormDataWriter.html ============================================================================== --- websites/staging/chemistry/trunk/content/java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/browser/FormDataWriter.html (added) +++ websites/staging/chemistry/trunk/content/java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/browser/FormDataWriter.html Mon May 27 17:20:56 2013 @@ -0,0 +1,305 @@ + + + + +FormDataWriter 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.client.bindings.spi.browser;
+20  
+21  import java.io.BufferedInputStream;
+22  import java.io.ByteArrayInputStream;
+23  import java.io.InputStream;
+24  import java.io.OutputStream;
+25  import java.net.URLEncoder;
+26  import java.util.GregorianCalendar;
+27  import java.util.LinkedHashMap;
+28  import java.util.List;
+29  import java.util.Map;
+30  
+31  import org.apache.chemistry.opencmis.commons.data.Ace;
+32  import org.apache.chemistry.opencmis.commons.data.Acl;
+33  import org.apache.chemistry.opencmis.commons.data.BulkUpdateObjectIdAndChangeToken;
+34  import org.apache.chemistry.opencmis.commons.data.ContentStream;
+35  import org.apache.chemistry.opencmis.commons.data.Properties;
+36  import org.apache.chemistry.opencmis.commons.data.PropertyData;
+37  import org.apache.chemistry.opencmis.commons.impl.Constants;
+38  import org.apache.chemistry.opencmis.commons.impl.MimeHelper;
+39  import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
+40  
+41  public class FormDataWriter {
+42  
+43      private static final String CONTENT_TYPE_URLENCODED = "application/x-www-form-urlencoded;charset=utf-8";
+44      private static final String CONTENT_TYPE_FORMDATA = "multipart/form-data; boundary=";
+45      private static final String CRLF = "\r\n";
+46      private static final int BUFFER_SIZE = 64 * 1024;
+47  
+48      private final String boundary;
+49      private final Map<String, String> parameters = new LinkedHashMap<String, String>();
+50      private ContentStream contentStream;
+51  
+52      public FormDataWriter(String action) {
+53          this(action, null);
+54      }
+55  
+56      public FormDataWriter(String action, ContentStream contentStream) {
+57          addParameter(Constants.CONTROL_CMISACTION, action);
+58          this.contentStream = contentStream;
+59          boundary = "aPacHeCheMIStryoPEncmiS" + Long.toHexString(action.hashCode()) + action
+60                  + Long.toHexString(System.currentTimeMillis()) + Long.toHexString(this.hashCode());
+61      }
+62  
+63      public void addParameter(String name, Object value) {
+64          if (name == null || value == null) {
+65              return;
+66          }
+67  
+68          parameters.put(name, UrlBuilder.normalizeParameter(value));
+69      }
+70  
+71      public void addPropertiesParameters(Properties properties) {
+72          if (properties == null) {
+73              return;
+74          }
+75  
+76          int idx = 0;
+77          for (PropertyData<?> prop : properties.getPropertyList()) {
+78              if (prop == null) {
+79                  continue;
+80              }
+81  
+82              String idxStr = "[" + idx + "]";
+83              addParameter(Constants.CONTROL_PROP_ID + idxStr, prop.getId());
+84  
+85              if (prop.getValues() != null && prop.getValues().size() > 0) {
+86                  if (prop.getValues().size() == 1) {
+87                      addParameter(Constants.CONTROL_PROP_VALUE + idxStr, convertPropertyValue(prop.getFirstValue()));
+88                  } else {
+89                      int vidx = 0;
+90                      for (Object obj : prop.getValues()) {
+91                          String vidxStr = "[" + vidx + "]";
+92                          addParameter(Constants.CONTROL_PROP_VALUE + idxStr + vidxStr, convertPropertyValue(obj));
+93                          vidx++;
+94                      }
+95                  }
+96              }
+97  
+98              idx++;
+99          }
+100     }
+101 
+102     public void addSuccinctFlag(boolean succinct) {
+103         if (succinct) {
+104             addParameter(Constants.CONTROL_SUCCINCT, "true");
+105         }
+106     }
+107 
+108     public void addPoliciesParameters(List<String> policies) {
+109         if (policies == null) {
+110             return;
+111         }
+112 
+113         int idx = 0;
+114         for (String policy : policies) {
+115             if (policy != null) {
+116                 String idxStr = "[" + idx + "]";
+117                 addParameter(Constants.CONTROL_POLICY + idxStr, policy);
+118                 idx++;
+119             }
+120         }
+121     }
+122 
+123     public void addAddAcesParameters(Acl acl) {
+124         addAcesParameters(acl, Constants.CONTROL_ADD_ACE_PRINCIPAL, Constants.CONTROL_ADD_ACE_PERMISSION);
+125     }
+126 
+127     public void addRemoveAcesParameters(Acl acl) {
+128         addAcesParameters(acl, Constants.CONTROL_REMOVE_ACE_PRINCIPAL, Constants.CONTROL_REMOVE_ACE_PERMISSION);
+129     }
+130 
+131     private void addAcesParameters(Acl acl, String principalControl, String permissionControl) {
+132         if (acl == null || acl.getAces() == null) {
+133             return;
+134         }
+135 
+136         int idx = 0;
+137         for (Ace ace : acl.getAces()) {
+138             if (ace.getPrincipalId() != null && ace.getPermissions() != null && !ace.getPermissions().isEmpty()) {
+139                 String idxStr = "[" + idx + "]";
+140                 addParameter(principalControl + idxStr, ace.getPrincipalId());
+141 
+142                 int permIdx = 0;
+143                 for (String perm : ace.getPermissions()) {
+144                     if (perm != null) {
+145                         String permIdxStr = "[" + permIdx + "]";
+146                         addParameter(permissionControl + idxStr + permIdxStr, perm);
+147                         permIdx++;
+148                     }
+149                 }
+150                 idx++;
+151             }
+152         }
+153     }
+154 
+155     public void addObjectIdsAndChangeTokens(List<BulkUpdateObjectIdAndChangeToken> objectIdsAndChangeTokens) {
+156         if (objectIdsAndChangeTokens == null || objectIdsAndChangeTokens.size() == 0) {
+157             return;
+158         }
+159 
+160         int idx = 0;
+161         for (BulkUpdateObjectIdAndChangeToken oc : objectIdsAndChangeTokens) {
+162             if (oc == null || oc.getId() == null || oc.getId().length() == 0) {
+163                 continue;
+164             }
+165 
+166             String idxStr = "[" + idx + "]";
+167             addParameter(Constants.CONTROL_OBJECT_ID + idxStr, oc.getId());
+168             addParameter(Constants.CONTROL_CHANGE_TOKEN + idxStr,
+169                     (oc.getChangeToken() == null ? "" : oc.getChangeToken()));
+170 
+171             idx++;
+172         }
+173     }
+174 
+175     public void addSecondaryTypeIds(List<String> secondaryTypeIds) {
+176         addSecondaryTypeIdParameters(secondaryTypeIds, Constants.CONTROL_ADD_SECONDARY_TYPE);
+177     }
+178 
+179     public void removeSecondaryTypeIds(List<String> secondaryTypeIds) {
+180         addSecondaryTypeIdParameters(secondaryTypeIds, Constants.CONTROL_REMOVE_SECONDARY_TYPE);
+181     }
+182 
+183     private void addSecondaryTypeIdParameters(List<String> secondaryTypeIds, String secondaryTypeIdControl) {
+184         if (secondaryTypeIds == null || secondaryTypeIds.size() == 0) {
+185             return;
+186         }
+187 
+188         int idx = 0;
+189         for (String typeId : secondaryTypeIds) {
+190             if (typeId == null || typeId.length() == 0) {
+191                 continue;
+192             }
+193 
+194             String idxStr = "[" + idx + "]";
+195             addParameter(secondaryTypeIdControl + idxStr, typeId);
+196 
+197             idx++;
+198         }
+199     }
+200 
+201     private String convertPropertyValue(Object value) {
+202         if (value == null) {
+203             return null;
+204         }
+205 
+206         if (value instanceof GregorianCalendar) {
+207             return "" + ((GregorianCalendar) value).getTimeInMillis();
+208         }
+209 
+210         return value.toString();
+211     }
+212 
+213     public String getContentType() {
+214         return (contentStream == null ? CONTENT_TYPE_URLENCODED : CONTENT_TYPE_FORMDATA + boundary);
+215     }
+216 
+217     public void write(OutputStream out) throws Exception {
+218         if (contentStream == null || contentStream.getStream() == null) {
+219             boolean first = true;
+220             byte[] amp = "&".getBytes("UTF-8");
+221 
+222             for (Map.Entry<String, String> param : parameters.entrySet()) {
+223                 if (first) {
+224                     first = false;
+225                 } else {
+226                     out.write(amp);
+227                 }
+228 
+229                 out.write((param.getKey() + "=" + URLEncoder.encode(param.getValue(), "UTF-8")).getBytes("UTF-8"));
+230             }
+231         } else {
+232             writeLine(out);
+233 
+234             // parameters
+235             for (Map.Entry<String, String> param : parameters.entrySet()) {
+236                 writeLine(out, "--" + boundary);
+237                 writeLine(out, "Content-Disposition: form-data; name=\"" + param.getKey() + "\"");
+238                 writeLine(out, "Content-Type: text/plain; charset=utf-8");
+239                 writeLine(out);
+240                 writeLine(out, param.getValue());
+241             }
+242 
+243             // content
+244             String filename = contentStream.getFileName();
+245             if (filename == null || filename.length() == 0) {
+246                 filename = "content";
+247             }
+248 
+249             String mediaType = contentStream.getMimeType();
+250             if (mediaType == null || mediaType.indexOf('/') < 1 || mediaType.indexOf('\n') > -1
+251                     || mediaType.indexOf('\r') > -1) {
+252                 mediaType = Constants.MEDIATYPE_OCTETSTREAM;
+253             }
+254 
+255             writeLine(out, "--" + boundary);
+256             writeLine(
+257                     out,
+258                     "Content-Disposition: "
+259                             + MimeHelper.encodeContentDisposition(MimeHelper.DISPOSITION_FORM_DATA_CONTENT, filename));
+260             writeLine(out, "Content-Type: " + mediaType);
+261             writeLine(out, "Content-Transfer-Encoding: binary");
+262             writeLine(out);
+263 
+264             InputStream stream = contentStream.getStream();
+265             if (!(stream instanceof BufferedInputStream) && !(stream instanceof ByteArrayInputStream)) {
+266                 // avoid double buffering
+267                 stream = new BufferedInputStream(stream, BUFFER_SIZE);
+268             }
+269 
+270             byte[] buffer = new byte[BUFFER_SIZE];
+271             int b;
+272             while ((b = stream.read(buffer)) > -1) {
+273                 if (b > 0) {
+274                     out.write(buffer, 0, b);
+275                 }
+276             }
+277 
+278             writeLine(out);
+279             writeLine(out, "--" + boundary + "--");
+280         }
+281     }
+282 
+283     private void writeLine(OutputStream out) throws Exception {
+284         writeLine(out, null);
+285     }
+286 
+287     private void writeLine(OutputStream out, String s) throws Exception {
+288         s = (s == null ? CRLF : s + CRLF);
+289         out.write(s.getBytes("UTF-8"));
+290     }
+291 }
+
+
+ + Added: websites/staging/chemistry/trunk/content/java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/browser/MultiFilingServiceImpl.html ============================================================================== --- websites/staging/chemistry/trunk/content/java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/browser/MultiFilingServiceImpl.html (added) +++ websites/staging/chemistry/trunk/content/java/0.9.0/maven/chemistry-opencmis-client/chemistry-opencmis-client-bindings/xref/org/apache/chemistry/opencmis/client/bindings/spi/browser/MultiFilingServiceImpl.html Mon May 27 17:20:56 2013 @@ -0,0 +1,89 @@ + + + + +MultiFilingServiceImpl 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.client.bindings.spi.browser;
+20  
+21  import java.io.OutputStream;
+22  
+23  import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
+24  import org.apache.chemistry.opencmis.client.bindings.spi.http.Output;
+25  import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
+26  import org.apache.chemistry.opencmis.commons.impl.Constants;
+27  import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
+28  import org.apache.chemistry.opencmis.commons.spi.MultiFilingService;
+29  
+30  /**
+31   * MultiFiling Service Browser Binding client.
+32   */
+33  public class MultiFilingServiceImpl extends AbstractBrowserBindingService implements MultiFilingService {
+34  
+35      /**
+36       * Constructor.
+37       */
+38      public MultiFilingServiceImpl(BindingSession session) {
+39          setSession(session);
+40      }
+41  
+42      public void addObjectToFolder(String repositoryId, String objectId, String folderId, Boolean allVersions,
+43              ExtensionsData extension) {
+44          // build URL
+45          UrlBuilder url = getObjectUrl(repositoryId, objectId);
+46  
+47          // prepare form data
+48          final FormDataWriter formData = new FormDataWriter(Constants.CMISACTION_ADD_OBJECT_TO_FOLDER);
+49          formData.addParameter(Constants.PARAM_FOLDER_ID, folderId);
+50          formData.addParameter(Constants.PARAM_ALL_VERSIONS, allVersions);
+51  
+52          // send and parse
+53          postAndConsume(url, formData.getContentType(), new Output() {
+54              public void write(OutputStream out) throws Exception {
+55                  formData.write(out);
+56              }
+57          });
+58      }
+59  
+60      public void removeObjectFromFolder(String repositoryId, String objectId, String folderId, ExtensionsData extension) {
+61          // build URL
+62          UrlBuilder url = getObjectUrl(repositoryId, objectId);
+63  
+64          // prepare form data
+65          final FormDataWriter formData = new FormDataWriter(Constants.CMISACTION_REMOVE_OBJECT_FROM_FOLDER);
+66          formData.addParameter(Constants.PARAM_FOLDER_ID, folderId);
+67  
+68          // send and parse
+69          postAndConsume(url, formData.getContentType(), new Output() {
+70              public void write(OutputStream out) throws Exception {
+71                  formData.write(out);
+72              }
+73          });
+74      }
+75  }
+
+
+ +