001/* 002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 * 009 * Contributors: 010 * Florent Guillaume 011 */ 012package org.nuxeo.ecm.core.opencmis.impl.client; 013 014import java.util.List; 015 016import org.apache.chemistry.opencmis.client.api.CmisObject; 017import org.apache.chemistry.opencmis.client.api.ObjectId; 018import org.apache.chemistry.opencmis.client.api.ObjectType; 019import org.apache.chemistry.opencmis.client.api.OperationContext; 020import org.apache.chemistry.opencmis.client.api.Relationship; 021import org.apache.chemistry.opencmis.client.api.SecondaryType; 022import org.apache.chemistry.opencmis.commons.PropertyIds; 023import org.nuxeo.ecm.core.opencmis.impl.server.NuxeoObjectData; 024 025/** 026 * Live local CMIS Relationship, which is backed by a Nuxeo document. 027 */ 028public class NuxeoRelationship extends NuxeoObject implements Relationship { 029 030 public NuxeoRelationship(NuxeoSession session, NuxeoObjectData data, ObjectType type, 031 List<SecondaryType> secondaryTypes) { 032 super(session, data, type, secondaryTypes); 033 } 034 035 @Override 036 public ObjectId getSourceId() { 037 String id = getPropertyValue(PropertyIds.SOURCE_ID); 038 return id == null ? null : session.createObjectId(id); 039 } 040 041 @Override 042 public CmisObject getSource() { 043 String id = getPropertyValue(PropertyIds.SOURCE_ID); 044 return id == null ? null : session.getObject(session.createObjectId(id)); 045 } 046 047 @Override 048 public CmisObject getSource(OperationContext context) { 049 String id = getPropertyValue(PropertyIds.SOURCE_ID); 050 return id == null ? null : session.getObject(session.createObjectId(id), context); 051 } 052 053 @Override 054 public ObjectId getTargetId() { 055 String id = getPropertyValue(PropertyIds.TARGET_ID); 056 return id == null ? null : session.createObjectId(id); 057 } 058 059 @Override 060 public CmisObject getTarget() { 061 String id = getPropertyValue(PropertyIds.TARGET_ID); 062 return id == null ? null : session.getObject(session.createObjectId(id)); 063 } 064 065 @Override 066 public CmisObject getTarget(OperationContext context) { 067 String id = getPropertyValue(PropertyIds.TARGET_ID); 068 return id == null ? null : session.getObject(session.createObjectId(id), context); 069 } 070 071}