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 6E9CF9043 for ; Thu, 9 Aug 2012 15:05:37 +0000 (UTC) Received: (qmail 7919 invoked by uid 500); 9 Aug 2012 15:05:37 -0000 Delivered-To: apmail-chemistry-commits-archive@chemistry.apache.org Received: (qmail 7824 invoked by uid 500); 9 Aug 2012 15:05:37 -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 7809 invoked by uid 99); 9 Aug 2012 15:05:37 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Aug 2012 15:05:37 +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; Thu, 09 Aug 2012 15:05:33 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id F151923888E3; Thu, 9 Aug 2012 15:04:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1371244 [2/2] - in /chemistry/opencmis/trunk: chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/ chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/j... Date: Thu, 09 Aug 2012 15:04:47 -0000 To: commits@chemistry.apache.org From: fmui@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120809150448.F151923888E3@eris.apache.org> Added: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ServerTypeCacheImpl.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ServerTypeCacheImpl.java?rev=1371244&view=auto ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ServerTypeCacheImpl.java (added) +++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ServerTypeCacheImpl.java Thu Aug 9 15:04:46 2012 @@ -0,0 +1,84 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.chemistry.opencmis.server.impl.browser; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.chemistry.opencmis.commons.PropertyIds; +import org.apache.chemistry.opencmis.commons.data.ObjectData; +import org.apache.chemistry.opencmis.commons.data.PropertyData; +import org.apache.chemistry.opencmis.commons.data.PropertyId; +import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition; +import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships; +import org.apache.chemistry.opencmis.commons.impl.TypeCache; +import org.apache.chemistry.opencmis.commons.server.CmisService; + +/** + * Temporary type cache used for one call. + */ +public class ServerTypeCacheImpl implements TypeCache { + + private final String repositoryId; + private final CmisService service; + private final Map typeDefinitions; + private final Map objectToTypeDefinitions; + + public ServerTypeCacheImpl(String repositoryId, CmisService service) { + this.repositoryId = repositoryId; + this.service = service; + typeDefinitions = new HashMap(); + objectToTypeDefinitions = new HashMap(); + } + + public TypeDefinition getTypeDefinition(String typeId) { + TypeDefinition type = typeDefinitions.get(typeId); + if (type == null) { + type = service.getTypeDefinition(repositoryId, typeId, null); + if (type != null) { + typeDefinitions.put(type.getId(), type); + } + } + + return type; + } + + public TypeDefinition getTypeDefinitionForObject(String objectId) { + TypeDefinition type = objectToTypeDefinitions.get(objectId); + if (type == null) { + ObjectData obj = service.getObject(repositoryId, objectId, + "cmis:objectId,cmis:objectTypeId,cmis:baseTypeId", false, IncludeRelationships.NONE, "cmis:none", + false, false, null); + + if (obj != null && obj.getProperties() != null) { + PropertyData typeProp = obj.getProperties().getProperties().get(PropertyIds.OBJECT_TYPE_ID); + if (typeProp instanceof PropertyId) { + String typeId = ((PropertyId) typeProp).getFirstValue(); + if (typeId != null) { + type = getTypeDefinition(typeId); + } + } + } + + objectToTypeDefinitions.put(objectId, type); + } + + return type; + } +} Propchange: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ServerTypeCacheImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/VersioningService.java URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/VersioningService.java?rev=1371244&r1=1371243&r2=1371244&view=diff ============================================================================== --- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/VersioningService.java (original) +++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/VersioningService.java Thu Aug 9 15:04:46 2012 @@ -54,7 +54,6 @@ import org.apache.chemistry.opencmis.com import org.apache.chemistry.opencmis.commons.impl.TypeCache; import org.apache.chemistry.opencmis.commons.impl.json.JSONArray; import org.apache.chemistry.opencmis.commons.impl.json.JSONObject; -import org.apache.chemistry.opencmis.commons.impl.server.TypeCacheImpl; import org.apache.chemistry.opencmis.commons.server.CallContext; import org.apache.chemistry.opencmis.commons.server.CmisService; import org.apache.chemistry.opencmis.commons.spi.Holder; @@ -87,7 +86,7 @@ public class VersioningService { } // return object - TypeCache typeCache = new TypeCacheImpl(repositoryId, service); + TypeCache typeCache = new ServerTypeCacheImpl(repositoryId, service); JSONObject jsonObject = JSONConverter.convert(object, typeCache, false, succinct); // set headers @@ -132,7 +131,7 @@ public class VersioningService { // execute ControlParser cp = new ControlParser(request); - TypeCache typeCache = new TypeCacheImpl(repositoryId, service); + TypeCache typeCache = new ServerTypeCacheImpl(repositoryId, service); Holder objectIdHolder = new Holder(objectId); service.checkIn(repositoryId, objectIdHolder, major, createProperties(cp, typeId, typeCache), @@ -179,7 +178,7 @@ public class VersioningService { throw new CmisRuntimeException("Versions are null!"); } - TypeCache typeCache = new TypeCacheImpl(repositoryId, service); + TypeCache typeCache = new ServerTypeCacheImpl(repositoryId, service); JSONArray jsonVersions = new JSONArray(); for (ObjectData version : versions) { jsonVersions.add(JSONConverter.convert(version, typeCache, false, succinct));