This project has retired. For details please refer to its
Attic page.
TypeCacheImpl xref
1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing,13 * software distributed under the License is distributed on an14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY15 * KIND, either express or implied. See the License for the16 * specific language governing permissions and limitations17 * under the License.18 */19package org.apache.chemistry.opencmis.commons.impl.server;
2021import java.util.HashMap;
22import java.util.Map;
2324import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
25import org.apache.chemistry.opencmis.commons.impl.TypeCache;
26import org.apache.chemistry.opencmis.commons.server.CmisService;
27import org.apache.chemistry.opencmis.commons.server.ObjectInfo;
2829/**30 * Temporary type cache used for one call.31 */32publicclassTypeCacheImpl implements TypeCache {
3334privatefinal String repositoryId;
35privatefinal CmisService service;
36privatefinal Map<String, TypeDefinition> typeDefinitions;
3738publicTypeCacheImpl(String repositoryId, CmisService service) {
39this.repositoryId = repositoryId;
40this.service = service;
41 typeDefinitions = new HashMap<String, TypeDefinition>();
42 }
4344public TypeDefinition getTypeDefinition(String typeId) {
45 TypeDefinition type = typeDefinitions.get(typeId);
46if (type == null) {
47 type = service.getTypeDefinition(repositoryId, typeId, null);
48if (type != null) {
49 typeDefinitions.put(type.getId(), type);
50 }
51 }
5253return type;
54 }
5556public TypeDefinition getTypeDefinitionForObject(String objectId) {
57 ObjectInfo info = service.getObjectInfo(repositoryId, objectId);
58if (info == null) {
59returnnull;
60 }
6162return getTypeDefinition(info.getTypeId());
63 }
64 }