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 ADDB1D802 for ; Mon, 27 May 2013 17:22:58 +0000 (UTC) Received: (qmail 73042 invoked by uid 500); 27 May 2013 17:22:58 -0000 Delivered-To: apmail-chemistry-commits-archive@chemistry.apache.org Received: (qmail 72995 invoked by uid 500); 27 May 2013 17:22:58 -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 72799 invoked by uid 99); 27 May 2013 17:22:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 27 May 2013 17:22:57 +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:48 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 2CDC12388CE5 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 [27/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.2CDC12388CE5@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/AbstractBrowserBindingService.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/AbstractBrowserBindingService.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/AbstractBrowserBindingService.html Mon May 27 17:20:56 2013 @@ -0,0 +1,497 @@ + + + + +AbstractBrowserBindingService 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.InputStream;
+22  import java.io.InputStreamReader;
+23  import java.util.ArrayList;
+24  import java.util.LinkedHashMap;
+25  import java.util.List;
+26  import java.util.Map;
+27  
+28  import org.apache.chemistry.opencmis.client.bindings.impl.CmisBindingsHelper;
+29  import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
+30  import org.apache.chemistry.opencmis.client.bindings.spi.LinkAccess;
+31  import org.apache.chemistry.opencmis.client.bindings.spi.http.HttpInvoker;
+32  import org.apache.chemistry.opencmis.client.bindings.spi.http.Output;
+33  import org.apache.chemistry.opencmis.client.bindings.spi.http.Response;
+34  import org.apache.chemistry.opencmis.commons.SessionParameter;
+35  import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
+36  import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+37  import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException;
+38  import org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException;
+39  import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
+40  import org.apache.chemistry.opencmis.commons.exceptions.CmisContentAlreadyExistsException;
+41  import org.apache.chemistry.opencmis.commons.exceptions.CmisFilterNotValidException;
+42  import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
+43  import org.apache.chemistry.opencmis.commons.exceptions.CmisNameConstraintViolationException;
+44  import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
+45  import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
+46  import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
+47  import org.apache.chemistry.opencmis.commons.exceptions.CmisProxyAuthenticationException;
+48  import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
+49  import org.apache.chemistry.opencmis.commons.exceptions.CmisStorageException;
+50  import org.apache.chemistry.opencmis.commons.exceptions.CmisStreamNotSupportedException;
+51  import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
+52  import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException;
+53  import org.apache.chemistry.opencmis.commons.exceptions.CmisVersioningException;
+54  import org.apache.chemistry.opencmis.commons.impl.Constants;
+55  import org.apache.chemistry.opencmis.commons.impl.JSONConstants;
+56  import org.apache.chemistry.opencmis.commons.impl.JSONConverter;
+57  import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
+58  import org.apache.chemistry.opencmis.commons.impl.dataobjects.RepositoryInfoBrowserBindingImpl;
+59  import org.apache.chemistry.opencmis.commons.impl.json.JSONObject;
+60  import org.apache.chemistry.opencmis.commons.impl.json.parser.ContainerFactory;
+61  import org.apache.chemistry.opencmis.commons.impl.json.parser.JSONParser;
+62  
+63  /**
+64   * Base class for all Browser Binding client services.
+65   */
+66  public abstract class AbstractBrowserBindingService implements LinkAccess {
+67  
+68      protected static final ContainerFactory SIMPLE_CONTAINER_FACTORY = new ContainerFactory() {
+69          public Map<String, Object> createObjectContainer() {
+70              return new LinkedHashMap<String, Object>();
+71          }
+72  
+73          public List<Object> creatArrayContainer() {
+74              return new ArrayList<Object>();
+75          }
+76      };
+77  
+78      private BindingSession session;
+79      private boolean succint;
+80  
+81      /**
+82       * Sets the current session.
+83       */
+84      protected void setSession(BindingSession session) {
+85          this.session = session;
+86  
+87          Object succintObj = session.get(SessionParameter.BROWSER_SUCCINCT);
+88          this.succint = (succintObj == null ? true : Boolean.parseBoolean(succintObj.toString()));
+89      }
+90  
+91      /**
+92       * Gets the current session.
+93       */
+94      protected BindingSession getSession() {
+95          return session;
+96      }
+97  
+98      /**
+99       * Gets the HTTP Invoker object.
+100      */
+101     protected HttpInvoker getHttpInvoker() {
+102         return CmisBindingsHelper.getHttpInvoker(session);
+103     }
+104 
+105     /**
+106      * Returns the service URL of this session.
+107      */
+108     protected String getServiceUrl() {
+109         Object url = session.get(SessionParameter.BROWSER_URL);
+110         if (url instanceof String) {
+111             return (String) url;
+112         }
+113 
+114         return null;
+115     }
+116 
+117     protected UrlBuilder getRepositoryUrl(String repositoryId, String selector) {
+118         UrlBuilder result = getRepositoryUrlCache().getRepositoryUrl(repositoryId, selector);
+119 
+120         if (result == null) {
+121             getRepositoriesInternal(repositoryId);
+122             result = getRepositoryUrlCache().getRepositoryUrl(repositoryId, selector);
+123         }
+124 
+125         if (result == null) {
+126             throw new CmisObjectNotFoundException("Unknown repository!");
+127         }
+128 
+129         return result;
+130     }
+131 
+132     protected UrlBuilder getRepositoryUrl(String repositoryId) {
+133         UrlBuilder result = getRepositoryUrlCache().getRepositoryUrl(repositoryId);
+134 
+135         if (result == null) {
+136             getRepositoriesInternal(repositoryId);
+137             result = getRepositoryUrlCache().getRepositoryUrl(repositoryId);
+138         }
+139 
+140         if (result == null) {
+141             throw new CmisObjectNotFoundException("Unknown repository!");
+142         }
+143 
+144         return result;
+145     }
+146 
+147     protected UrlBuilder getObjectUrl(String repositoryId, String objectId, String selector) {
+148         UrlBuilder result = getRepositoryUrlCache().getObjectUrl(repositoryId, objectId, selector);
+149 
+150         if (result == null) {
+151             getRepositoriesInternal(repositoryId);
+152             result = getRepositoryUrlCache().getObjectUrl(repositoryId, objectId, selector);
+153         }
+154 
+155         if (result == null) {
+156             throw new CmisObjectNotFoundException("Unknown repository!");
+157         }
+158 
+159         return result;
+160     }
+161 
+162     protected UrlBuilder getObjectUrl(String repositoryId, String objectId) {
+163         UrlBuilder result = getRepositoryUrlCache().getObjectUrl(repositoryId, objectId);
+164 
+165         if (result == null) {
+166             getRepositoriesInternal(repositoryId);
+167             result = getRepositoryUrlCache().getObjectUrl(repositoryId, objectId);
+168         }
+169 
+170         if (result == null) {
+171             throw new CmisObjectNotFoundException("Unknown repository!");
+172         }
+173 
+174         return result;
+175     }
+176 
+177     protected UrlBuilder getPathUrl(String repositoryId, String objectId, String selector) {
+178         UrlBuilder result = getRepositoryUrlCache().getPathUrl(repositoryId, objectId, selector);
+179 
+180         if (result == null) {
+181             getRepositoriesInternal(repositoryId);
+182             result = getRepositoryUrlCache().getPathUrl(repositoryId, objectId, selector);
+183         }
+184 
+185         if (result == null) {
+186             throw new CmisObjectNotFoundException("Unknown repository!");
+187         }
+188 
+189         return result;
+190     }
+191 
+192     protected boolean getSuccinct() {
+193         return succint;
+194     }
+195 
+196     protected String getSuccinctParameter() {
+197         return succint ? "true" : null;
+198     }
+199 
+200     // ---- exceptions ----
+201 
+202     /**
+203      * Converts an error message or a HTTP status code into an Exception.
+204      */
+205     protected CmisBaseException convertStatusCode(int code, String message, String errorContent, Throwable t) {
+206         Object obj = null;
+207         try {
+208             JSONParser parser = new JSONParser();
+209             obj = parser.parse(errorContent);
+210         } catch (Exception pe) {
+211         }
+212 
+213         if (obj instanceof JSONObject) {
+214             JSONObject json = (JSONObject) obj;
+215             Object jsonError = json.get(JSONConstants.ERROR_EXCEPTION);
+216             if (jsonError instanceof String) {
+217                 Object jsonMessage = json.get(JSONConstants.ERROR_MESSAGE);
+218                 if (jsonMessage != null) {
+219                     message = jsonMessage.toString();
+220                 }
+221 
+222                 if (CmisConstraintException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) {
+223                     return new CmisConstraintException(message, errorContent, t);
+224                 } else if (CmisContentAlreadyExistsException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) {
+225                     return new CmisContentAlreadyExistsException(message, errorContent, t);
+226                 } else if (CmisFilterNotValidException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) {
+227                     return new CmisFilterNotValidException(message, errorContent, t);
+228                 } else if (CmisInvalidArgumentException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) {
+229                     return new CmisInvalidArgumentException(message, errorContent, t);
+230                 } else if (CmisNameConstraintViolationException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) {
+231                     return new CmisNameConstraintViolationException(message, errorContent, t);
+232                 } else if (CmisNotSupportedException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) {
+233                     return new CmisNotSupportedException(message, errorContent, t);
+234                 } else if (CmisObjectNotFoundException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) {
+235                     return new CmisObjectNotFoundException(message, errorContent, t);
+236                 } else if (CmisPermissionDeniedException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) {
+237                     return new CmisPermissionDeniedException(message, errorContent, t);
+238                 } else if (CmisStorageException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) {
+239                     return new CmisStorageException(message, errorContent, t);
+240                 } else if (CmisStreamNotSupportedException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) {
+241                     return new CmisStreamNotSupportedException(message, errorContent, t);
+242                 } else if (CmisUpdateConflictException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) {
+243                     return new CmisUpdateConflictException(message, errorContent, t);
+244                 } else if (CmisVersioningException.EXCEPTION_NAME.equalsIgnoreCase((String) jsonError)) {
+245                     return new CmisVersioningException(message, errorContent, t);
+246                 }
+247             }
+248         }
+249 
+250         // fall back to status code
+251         switch (code) {
+252         case 400:
+253             return new CmisInvalidArgumentException(message, errorContent, t);
+254         case 401:
+255             return new CmisUnauthorizedException(message, errorContent, t);
+256         case 403:
+257             return new CmisPermissionDeniedException(message, errorContent, t);
+258         case 404:
+259             return new CmisObjectNotFoundException(message, errorContent, t);
+260         case 405:
+261             return new CmisNotSupportedException(message, errorContent, t);
+262         case 407:
+263             return new CmisProxyAuthenticationException(message, errorContent, t);
+264         case 409:
+265             return new CmisConstraintException(message, errorContent, t);
+266         default:
+267             return new CmisRuntimeException(message, errorContent, t);
+268         }
+269     }
+270 
+271     // ---- helpers ----
+272 
+273     /**
+274      * Parses an object from an input stream.
+275      */
+276     @SuppressWarnings("unchecked")
+277     protected Map<String, Object> parseObject(InputStream stream, String charset) {
+278         Object obj = parse(stream, charset, SIMPLE_CONTAINER_FACTORY);
+279 
+280         if (obj instanceof Map) {
+281             return (Map<String, Object>) obj;
+282         }
+283 
+284         throw new CmisConnectionException("Unexpected object!");
+285     }
+286 
+287     /**
+288      * Parses an array from an input stream.
+289      */
+290     @SuppressWarnings("unchecked")
+291     protected List<Object> parseArray(InputStream stream, String charset) {
+292         Object obj = parse(stream, charset, SIMPLE_CONTAINER_FACTORY);
+293 
+294         if (obj instanceof List) {
+295             return (List<Object>) obj;
+296         }
+297 
+298         throw new CmisConnectionException("Unexpected object!");
+299     }
+300 
+301     /**
+302      * Parses an input stream.
+303      */
+304     protected Object parse(InputStream stream, String charset, ContainerFactory containerFactory) {
+305 
+306         InputStreamReader reader = null;
+307 
+308         Object obj = null;
+309         try {
+310             reader = new InputStreamReader(stream, charset);
+311             JSONParser parser = new JSONParser();
+312             obj = parser.parse(reader, containerFactory);
+313         } catch (Exception e) {
+314             throw new CmisConnectionException("Parsing exception!", e);
+315         } finally {
+316             try {
+317                 char[] buffer = new char[4096];
+318                 while (reader.read(buffer) > -1) {
+319                 }
+320             } catch (Exception e) {
+321             }
+322             try {
+323                 if (reader == null) {
+324                     stream.close();
+325                 } else {
+326                     reader.close();
+327                 }
+328             } catch (Exception e) {
+329             }
+330         }
+331 
+332         return obj;
+333     }
+334 
+335     /**
+336      * Performs a GET on an URL, checks the response code and returns the
+337      * result.
+338      */
+339     protected Response read(UrlBuilder url) {
+340         // make the call
+341         Response resp = getHttpInvoker().invokeGET(url, session);
+342 
+343         // check response code
+344         if (resp.getResponseCode() != 200) {
+345             throw convertStatusCode(resp.getResponseCode(), resp.getResponseMessage(), resp.getErrorContent(), null);
+346         }
+347 
+348         return resp;
+349     }
+350 
+351     /**
+352      * Performs a POST on an URL, checks the response code and returns the
+353      * result.
+354      */
+355     protected Response post(UrlBuilder url, String contentType, Output writer) {
+356         // make the call
+357         Response resp = getHttpInvoker().invokePOST(url, contentType, writer, session);
+358 
+359         // check response code
+360         if (resp.getResponseCode() != 200 && resp.getResponseCode() != 201) {
+361             throw convertStatusCode(resp.getResponseCode(), resp.getResponseMessage(), resp.getErrorContent(), null);
+362         }
+363 
+364         return resp;
+365     }
+366 
+367     /**
+368      * Performs a POST on an URL, checks the response code and returns the
+369      * result.
+370      */
+371     protected void postAndConsume(UrlBuilder url, String contentType, Output writer) {
+372         Response resp = post(url, contentType, writer);
+373 
+374         InputStream stream = resp.getStream();
+375         try {
+376             byte[] buffer = new byte[4096];
+377             while (stream.read(buffer) > -1) {
+378             }
+379         } catch (Exception e) {
+380             // ignore
+381         } finally {
+382             try {
+383                 stream.close();
+384             } catch (Exception e) {
+385             }
+386         }
+387     }
+388 
+389     // ---- URL ----
+390 
+391     /**
+392      * Returns the repository URL cache or creates a new cache if it doesn't
+393      * exist.
+394      */
+395     protected RepositoryUrlCache getRepositoryUrlCache() {
+396         RepositoryUrlCache repositoryUrlCache = (RepositoryUrlCache) getSession().get(
+397                 SpiSessionParameter.REPOSITORY_URL_CACHE);
+398         if (repositoryUrlCache == null) {
+399             repositoryUrlCache = new RepositoryUrlCache();
+400             getSession().put(SpiSessionParameter.REPOSITORY_URL_CACHE, repositoryUrlCache);
+401         }
+402 
+403         return repositoryUrlCache;
+404     }
+405 
+406     /**
+407      * Retrieves the the repository info objects.
+408      */
+409     protected List<RepositoryInfo> getRepositoriesInternal(String repositoryId) {
+410 
+411         UrlBuilder url = null;
+412 
+413         if (repositoryId == null) {
+414             // no repository id provided -> get all
+415             url = new UrlBuilder(getServiceUrl());
+416         } else {
+417             // use URL of the specified repository
+418             url = getRepositoryUrlCache().getRepositoryUrl(repositoryId, Constants.SELECTOR_REPOSITORY_INFO);
+419             if (url == null) {
+420                 // repository infos haven't been fetched yet -> get them all
+421                 url = new UrlBuilder(getServiceUrl());
+422             }
+423         }
+424 
+425         // read and parse
+426         Response resp = read(url);
+427         Map<String, Object> json = parseObject(resp.getStream(), resp.getCharset());
+428 
+429         List<RepositoryInfo> repInfos = new ArrayList<RepositoryInfo>();
+430 
+431         for (Object jri : json.values()) {
+432             if (jri instanceof Map) {
+433                 @SuppressWarnings("unchecked")
+434                 RepositoryInfo ri = JSONConverter.convertRepositoryInfo((Map<String, Object>) jri);
+435                 String id = ri.getId();
+436 
+437                 if (ri instanceof RepositoryInfoBrowserBindingImpl) {
+438                     String repositoryUrl = ((RepositoryInfoBrowserBindingImpl) ri).getRepositoryUrl();
+439                     String rootUrl = ((RepositoryInfoBrowserBindingImpl) ri).getRootUrl();
+440 
+441                     if (id == null || repositoryUrl == null || rootUrl == null) {
+442                         throw new CmisConnectionException("Found invalid Repository Info! (id: " + id + ")");
+443                     }
+444 
+445                     getRepositoryUrlCache().addRepository(id, repositoryUrl, rootUrl);
+446                 }
+447 
+448                 repInfos.add(ri);
+449             } else {
+450                 throw new CmisConnectionException("Found invalid Repository Info!");
+451             }
+452         }
+453 
+454         return repInfos;
+455     }
+456 
+457     /**
+458      * Retrieves a type definition.
+459      */
+460     protected TypeDefinition getTypeDefinitionInternal(String repositoryId, String typeId) {
+461         // build URL
+462         UrlBuilder url = getRepositoryUrl(repositoryId, Constants.SELECTOR_TYPE_DEFINITION);
+463         url.addParameter(Constants.PARAM_TYPE_ID, typeId);
+464 
+465         // read and parse
+466         Response resp = read(url);
+467         Map<String, Object> json = parseObject(resp.getStream(), resp.getCharset());
+468 
+469         return JSONConverter.convertTypeDefinition(json);
+470     }
+471 
+472     // ---- LinkAccess interface ----
+473 
+474     public String loadLink(String repositoryId, String objectId, String rel, String type) {
+475         // AtomPub specific -> return null
+476         return null;
+477     }
+478 
+479     public String loadContentLink(String repositoryId, String documentId) {
+480         UrlBuilder result = getRepositoryUrlCache().getObjectUrl(repositoryId, documentId, Constants.SELECTOR_CONTENT);
+481         return result == null ? null : result.toString();
+482     }
+483 }
+
+
+ + 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/AclServiceImpl.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/AclServiceImpl.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/AclServiceImpl.html Mon May 27 17:20:56 2013 @@ -0,0 +1,115 @@ + + + + +AclServiceImpl 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.util.ArrayList;
+23  import java.util.List;
+24  import java.util.Map;
+25  
+26  import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
+27  import org.apache.chemistry.opencmis.client.bindings.spi.http.Output;
+28  import org.apache.chemistry.opencmis.client.bindings.spi.http.Response;
+29  import org.apache.chemistry.opencmis.commons.data.Ace;
+30  import org.apache.chemistry.opencmis.commons.data.Acl;
+31  import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
+32  import org.apache.chemistry.opencmis.commons.enums.AclPropagation;
+33  import org.apache.chemistry.opencmis.commons.impl.Constants;
+34  import org.apache.chemistry.opencmis.commons.impl.JSONConverter;
+35  import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
+36  import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlListImpl;
+37  import org.apache.chemistry.opencmis.commons.spi.AclService;
+38  import org.apache.chemistry.opencmis.commons.spi.ExtendedAclService;
+39  
+40  /**
+41   * ACL Service Browser Binding client.
+42   */
+43  public class AclServiceImpl extends AbstractBrowserBindingService implements AclService, ExtendedAclService {
+44  
+45      /**
+46       * Constructor.
+47       */
+48      public AclServiceImpl(BindingSession session) {
+49          setSession(session);
+50      }
+51  
+52      public Acl getAcl(String repositoryId, String objectId, Boolean onlyBasicPermissions, ExtensionsData extension) {
+53          // build URL
+54          UrlBuilder url = getObjectUrl(repositoryId, objectId, Constants.SELECTOR_ACL);
+55          url.addParameter(Constants.PARAM_ONLY_BASIC_PERMISSIONS, onlyBasicPermissions);
+56  
+57          // read and parse
+58          Response resp = read(url);
+59          Map<String, Object> json = parseObject(resp.getStream(), resp.getCharset());
+60  
+61          return JSONConverter.convertAcl(json, null);
+62      }
+63  
+64      public Acl applyAcl(String repositoryId, String objectId, Acl addAces, Acl removeAces,
+65              AclPropagation aclPropagation, ExtensionsData extension) {
+66          // build URL
+67          UrlBuilder url = getObjectUrl(repositoryId, objectId);
+68  
+69          // prepare form data
+70          final FormDataWriter formData = new FormDataWriter(Constants.CMISACTION_APPLY_ACL);
+71          formData.addAddAcesParameters(addAces);
+72          formData.addRemoveAcesParameters(removeAces);
+73          formData.addParameter(Constants.PARAM_ACL_PROPAGATION, aclPropagation);
+74  
+75          // send and parse
+76          Response resp = post(url, formData.getContentType(), new Output() {
+77              public void write(OutputStream out) throws Exception {
+78                  formData.write(out);
+79              }
+80          });
+81          Map<String, Object> json = parseObject(resp.getStream(), resp.getCharset());
+82  
+83          return JSONConverter.convertAcl(json, null);
+84      }
+85  
+86      public Acl setAcl(String repositoryId, String objectId, Acl aces) {
+87          Acl currentAcl = getAcl(repositoryId, objectId, false, null);
+88  
+89          List<Ace> removeAces = new ArrayList<Ace>();
+90          if (currentAcl.getAces() != null) {
+91              for (Ace ace : currentAcl.getAces()) {
+92                  if (ace.isDirect()) {
+93                      removeAces.add(ace);
+94                  }
+95              }
+96          }
+97  
+98          return applyAcl(repositoryId, objectId, aces, new AccessControlListImpl(removeAces), AclPropagation.OBJECTONLY,
+99                  null);
+100     }
+101 }
+
+
+ + 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/ClientTypeCacheImpl.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/ClientTypeCacheImpl.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/ClientTypeCacheImpl.html Mon May 27 17:20:56 2013 @@ -0,0 +1,74 @@ + + + + +ClientTypeCacheImpl 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.impl.CmisBindingsHelper;
+22  import org.apache.chemistry.opencmis.client.bindings.impl.TypeDefinitionCache;
+23  import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
+24  import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+25  import org.apache.chemistry.opencmis.commons.impl.TypeCache;
+26  
+27  public class ClientTypeCacheImpl implements TypeCache {
+28  
+29      private final String repositoryId;
+30      private final AbstractBrowserBindingService service;
+31  
+32      public ClientTypeCacheImpl(String repositoryId, AbstractBrowserBindingService service) {
+33          this.repositoryId = repositoryId;
+34          this.service = service;
+35      }
+36  
+37      public TypeDefinition getTypeDefinition(String typeId) {
+38  
+39          TypeDefinitionCache cache = CmisBindingsHelper.getTypeDefinitionCache(service.getSession());
+40  
+41          TypeDefinition type = cache.get(repositoryId, typeId);
+42          if (type == null) {
+43              type = service.getTypeDefinitionInternal(repositoryId, typeId);
+44              if (type != null) {
+45                  cache.put(repositoryId, type);
+46              }
+47          }
+48  
+49          return type;
+50      }
+51  
+52      public TypeDefinition getTypeDefinitionForObject(String objectId) {
+53          // not used
+54          return null;
+55      }
+56  
+57      public PropertyDefinition<?> getPropertyDefinition(String propId) {
+58          return null;
+59      }
+60  }
+
+
+ +