001/* 002 * (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Florent Guillaume 018 */ 019package org.nuxeo.ecm.core.opencmis.impl.client; 020 021import java.util.List; 022 023import org.apache.chemistry.opencmis.client.api.CmisObject; 024import org.apache.chemistry.opencmis.client.api.ObjectId; 025import org.apache.chemistry.opencmis.client.api.ObjectType; 026import org.apache.chemistry.opencmis.client.api.OperationContext; 027import org.apache.chemistry.opencmis.client.api.Relationship; 028import org.apache.chemistry.opencmis.client.api.SecondaryType; 029import org.apache.chemistry.opencmis.commons.PropertyIds; 030import org.nuxeo.ecm.core.opencmis.impl.server.NuxeoObjectData; 031 032/** 033 * Live local CMIS Relationship, which is backed by a Nuxeo document. 034 */ 035public class NuxeoRelationship extends NuxeoObject implements Relationship { 036 037 public NuxeoRelationship(NuxeoSession session, NuxeoObjectData data, ObjectType type, 038 List<SecondaryType> secondaryTypes) { 039 super(session, data, type, secondaryTypes); 040 } 041 042 @Override 043 public ObjectId getSourceId() { 044 String id = getPropertyValue(PropertyIds.SOURCE_ID); 045 return id == null ? null : session.createObjectId(id); 046 } 047 048 @Override 049 public CmisObject getSource() { 050 String id = getPropertyValue(PropertyIds.SOURCE_ID); 051 return id == null ? null : session.getObject(session.createObjectId(id)); 052 } 053 054 @Override 055 public CmisObject getSource(OperationContext context) { 056 String id = getPropertyValue(PropertyIds.SOURCE_ID); 057 return id == null ? null : session.getObject(session.createObjectId(id), context); 058 } 059 060 @Override 061 public ObjectId getTargetId() { 062 String id = getPropertyValue(PropertyIds.TARGET_ID); 063 return id == null ? null : session.createObjectId(id); 064 } 065 066 @Override 067 public CmisObject getTarget() { 068 String id = getPropertyValue(PropertyIds.TARGET_ID); 069 return id == null ? null : session.getObject(session.createObjectId(id)); 070 } 071 072 @Override 073 public CmisObject getTarget(OperationContext context) { 074 String id = getPropertyValue(PropertyIds.TARGET_ID); 075 return id == null ? null : session.getObject(session.createObjectId(id), context); 076 } 077 078}