/** * Copyright (C) 2010 eXo Platform SAS. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.xcmis.sp.inmemory; import org.xcmis.spi.CmisConstants; import org.xcmis.spi.ConstraintException; import org.xcmis.spi.ContentStream; import org.xcmis.spi.FolderData; import org.xcmis.spi.ObjectData; import org.xcmis.spi.RelationshipData; import org.xcmis.spi.StorageException; import org.xcmis.spi.UpdateConflictException; import org.xcmis.spi.VersioningException; import org.xcmis.spi.model.TypeDefinition; import java.util.Collection; import java.util.Collections; /** * @author <a href="mailto:andrew00x@gmail.com">Andrey Parfonov</a> * @version $Id: RelationshipDataImpl.java 1197 2010-05-28 08:15:37Z * alexey.zavizionov@gmail.com $ */ class RelationshipDataImpl extends BaseObjectData implements RelationshipData { protected ObjectData source; protected ObjectData target; public RelationshipDataImpl(Entry entry, TypeDefinition type, StorageImpl storage) { super(entry, type, storage); } /** * {@inheritDoc} */ public ContentStream getContentStream(String streamId) { // no content or renditions for relationship return null; } /** * {@inheritDoc} */ @Override public FolderData getParent() throws ConstraintException { return null; } /** * {@inheritDoc} */ @Override public Collection<FolderData> getParents() { return Collections.emptySet(); } /** * {@inheritDoc} */ public String getSourceId() { return getString(CmisConstants.SOURCE_ID); } /** * {@inheritDoc} */ public String getTargetId() { return getString(CmisConstants.TARGET_ID); } /** * {@inheritDoc} */ protected void delete() throws UpdateConflictException, VersioningException, StorageException { String objectId = getObjectId(); String sourceId = getSourceId(); String targetId = getTargetId(); storage.entries.remove(objectId); storage.relationships.get(sourceId).remove(objectId); storage.relationships.get(targetId).remove(objectId); } }