/** * Converts binary content into JCR node. * * @param id the id of the CMIS document. * @return JCR node representation. */ private Document cmisContent( String id ) { DocumentWriter writer = newDocument(ObjectId.toString(ObjectId.Type.CONTENT, id)); org.apache.chemistry.opencmis.client.api.Document doc = (org.apache.chemistry.opencmis.client.api.Document)session.getObject(id); writer.setPrimaryType(NodeType.NT_RESOURCE); writer.setParent(id); ContentStream contentStream = doc.getContentStream(); if (contentStream != null) { BinaryValue content = new CmisConnectorBinary(contentStream, getSourceName(), id, getMimeTypeDetector()); writer.addProperty(JcrConstants.JCR_DATA, content); writer.addProperty(JcrConstants.JCR_MIME_TYPE, contentStream.getMimeType()); } Property<Object> lastModified = doc.getProperty(PropertyIds.LAST_MODIFICATION_DATE); Property<Object> lastModifiedBy = doc.getProperty(PropertyIds.LAST_MODIFIED_BY); writer.addProperty(JcrLexicon.LAST_MODIFIED, properties.jcrValues(lastModified)); writer.addProperty(JcrLexicon.LAST_MODIFIED_BY, properties.jcrValues(lastModifiedBy)); return writer.document(); }
Calendar doc1LastModifiedBefore = (Calendar)doc1.getProperty(PropertyIds.LAST_MODIFICATION_DATE).getFirstValue(); assertNotNull(doc1LastModifiedBefore); Calendar doc2LastModifiedBefore = (Calendar)doc2.getProperty(PropertyIds.LAST_MODIFICATION_DATE).getFirstValue(); assertNotNull(doc2LastModifiedBefore); Calendar doc1LastModifiedAfter = (Calendar)doc1.getProperty(PropertyIds.LAST_MODIFICATION_DATE).getFirstValue(); assertNotNull(doc1LastModifiedAfter); Calendar doc2LastModifiedAfter = (Calendar)doc2.getProperty(PropertyIds.LAST_MODIFICATION_DATE).getFirstValue(); assertNotNull(doc2LastModifiedAfter);
addResult(assertNotNull(doc1.getProperty(PropertyIds.CONTENT_STREAM_MIME_TYPE), null, f)); f = createResult(FAILURE, "Document should not have the property " + PropertyIds.PATH + "!"); addResult(assertNull(doc1.getProperty(PropertyIds.PATH), null, f)); f = createResult(FAILURE, "Document should not have the property " + INVALID_PROPERTY + "!"); addResult(assertNull(doc1.getProperty(INVALID_PROPERTY), null, f)); addResult(assertNull(doc2.getProperty(PropertyIds.CONTENT_STREAM_MIME_TYPE), null, f)); f = createResult(FAILURE, "Document should not have the property " + PropertyIds.PATH + "!"); addResult(assertNull(doc2.getProperty(PropertyIds.PATH), null, f)); f = createResult(FAILURE, "Document should not have the property " + INVALID_PROPERTY + "!"); addResult(assertNull(doc2.getProperty(INVALID_PROPERTY), null, f)); addResult(assertNull(doc3.getProperty(PropertyIds.CONTENT_STREAM_MIME_TYPE), null, f)); f = createResult(FAILURE, "Document should not have the property" + PropertyIds.PATH + "!"); addResult(assertNull(doc3.getProperty(PropertyIds.PATH), null, f)); f = createResult(FAILURE, "Document should not have the property" + INVALID_PROPERTY + "!"); addResult(assertNull(doc3.getProperty(INVALID_PROPERTY), null, f));