@Override public List<StoredObject> getRelationships( String objectId, List<String> typeIds, RelationshipDirection direction) { List<StoredObject> res = new ArrayList<StoredObject>(); if (typeIds != null && typeIds.size() > 0) { for (String typeId : typeIds) { for (StoredObject so : fStoredObjectMap.values()) { if (so instanceof Relationship && so.getTypeId().equals(typeId)) { Relationship ro = (Relationship) so; if (ro.getSourceObjectId().equals(objectId) && (RelationshipDirection.EITHER == direction || RelationshipDirection.SOURCE == direction)) { res.add(so); } else if (ro.getTargetObjectId().equals(objectId) && (RelationshipDirection.EITHER == direction || RelationshipDirection.TARGET == direction)) { res.add(so); } } } } } else { res = getAllRelationships(objectId, direction); } return res; }
@Override public boolean isTypeInUse(String typeId) { // iterate over all the objects and check for each if the type matches for (String objectId : getIds()) { StoredObject so = getObjectById(objectId); if (so.getTypeId().equals(typeId)) { return true; } } return false; }
@Override public ContentStream setContent(StoredObject so, ContentStream contentStream) { if (so instanceof Content) { ContentStreamDataImpl newContent; Content content = (Content) so; if (null == contentStream) { newContent = null; } else { boolean useFakeContentStore = so.getTypeId().equals(DefaultTypeSystemCreator.BIG_CONTENT_FAKE_TYPE); newContent = new ContentStreamDataImpl( MAX_CONTENT_SIZE_KB == null ? 0 : MAX_CONTENT_SIZE_KB, useFakeContentStore); String fileName = contentStream.getFileName(); if (null == fileName || fileName.length() <= 0) { fileName = so.getName(); // use name of document as fallback } newContent.setFileName(fileName); String mimeType = contentStream.getMimeType(); if (null == mimeType || mimeType.length() <= 0) { mimeType = "application/octet-stream"; // use as fallback } newContent.setMimeType(mimeType); newContent.setLastModified(new GregorianCalendar()); try { newContent.setContent(contentStream.getStream()); } catch (IOException e) { throw new CmisRuntimeException("Failed to get content from InputStream", e); } } content.setContent(newContent); return newContent; } else { throw new CmisInvalidArgumentException( "Cannot set content, object does not implement interface Content."); } }