org.alfresco.service.cmr.repository.ContentReader Java Examples
The following examples show how to use
org.alfresco.service.cmr.repository.ContentReader.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MailContentTransformerTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Test transforming a valid unicode msg file to text */ public void testUnicodeMsgToText() throws Exception { File msgSourceFile = loadQuickTestFile("unicode.msg"); File txtTargetFile = TempFileProvider.createTempFile(getName() + "-target-2", ".txt"); ContentReader reader = new FileContentReader(msgSourceFile); reader.setMimetype(MimetypeMap.MIMETYPE_OUTLOOK_MSG); ContentWriter writer = new FileContentWriter(txtTargetFile); writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); transformer.transform(reader, writer); ContentReader reader2 = new FileContentReader(txtTargetFile); reader2.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); assertTrue(reader2.getContentString().contains(QUICK_CONTENT)); }
Example #2
Source File: JodConverterMetadataExtracterWorker.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public Map<String, Serializable> extractRaw(ContentReader reader) throws Throwable { String sourceMimetype = reader.getMimetype(); if (logger.isDebugEnabled()) { StringBuilder msg = new StringBuilder(); msg.append("Extracting metadata content from ") .append(sourceMimetype); logger.debug(msg.toString()); } // create temporary files to convert from and to File tempFile = TempFileProvider.createTempFile(this.getClass() .getSimpleName() + "-", "." + mimetypeService.getExtension(sourceMimetype)); // download the content from the source reader reader.getContent(tempFile); ResultsCallback callback = new ResultsCallback(); jodc.getOfficeManager().execute(new ExtractMetadataOfficeTask(tempFile, callback)); return callback.getResults(); }
Example #3
Source File: AbstractRoutingContentStore.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * @return Returns a valid reader from one of the stores otherwise * a {@link EmptyContentReader} is returned. */ public ContentReader getReader(String contentUrl) throws ContentIOException { ContentStore store = selectReadStore(contentUrl); if (store != null) { if (logger.isDebugEnabled()) { logger.debug("Getting reader from store: \n" + " Content URL: " + contentUrl + "\n" + " Store: " + store); } return store.getReader(contentUrl); } else { if (logger.isDebugEnabled()) { logger.debug("Getting empty reader for content URL: " + contentUrl); } return new EmptyContentReader(contentUrl); } }
Example #4
Source File: HtmlParserContentTransformer.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected void transformRemote(RemoteTransformerClient remoteTransformerClient, ContentReader reader, ContentWriter writer, TransformationOptions options, String sourceMimetype, String targetMimetype, String sourceExtension, String targetExtension, String targetEncoding) throws Exception { String sourceEncoding = reader.getEncoding(); long timeoutMs = options.getTimeoutMs(); remoteTransformerClient.request(reader, writer, sourceMimetype, sourceExtension, targetExtension, timeoutMs, logger, "transformName", "html", "sourceMimetype", sourceMimetype, "sourceExtension", sourceExtension, "targetMimetype", targetMimetype, SOURCE_ENCODING, sourceEncoding); }
Example #5
Source File: EMLTransformerTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Test transforming a valid eml with nested mimetype multipart/alternative to text */ public void testRFC822NestedAlternativeToText() throws Exception { File emlSourceFile = loadQuickTestFile("nested.alternative.eml"); File txtTargetFile = TempFileProvider.createTempFile("test5", ".txt"); ContentReader reader = new FileContentReader(emlSourceFile); reader.setMimetype(MimetypeMap.MIMETYPE_RFC822); ContentWriter writer = new FileContentWriter(txtTargetFile); writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); transformer.transform(reader, writer); ContentReader reader2 = new FileContentReader(txtTargetFile); reader2.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); String contentStr = reader2.getContentString(); assertTrue(contentStr.contains(QUICK_EML_NESTED_ALTERNATIVE_CONTENT)); }
Example #6
Source File: ContentTransformServiceAdaptor.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Deprecated @Override public void transform(ContentReader reader, ContentWriter writer, TransformationOptions transformationOptions) throws NoTransformerException, ContentIOException { try { Map<String, String> options = converter.getOptions(transformationOptions, null, null); synchronousTransformClient.transform(reader, writer, options, null, null); } catch (UnsupportedTransformationException ute) { throw newNoTransformerException(reader, writer); } catch (IllegalArgumentException iae) { if (iae.getMessage().contains("sourceNodeRef null has no content")) { throw newNoTransformerException(reader, writer); } throw new AlfrescoRuntimeException(iae.getMessage(), iae); } }
Example #7
Source File: SpoofedTextContentReaderTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public void testGetContentString_01() { // To URL String url = SpoofedTextContentReader.createContentUrl(Locale.ENGLISH, 12345L, 56L, "harry"); // To Reader ContentReader reader = new SpoofedTextContentReader(url); String readerText = reader.getContentString(); assertEquals("harry have voice the from countered growth invited ", readerText); // Cannot repeat try { reader.getContentString(); fail("Should not be able to reread content."); } catch (ContentIOException e) { // Expected } // Get a new Reader reader = reader.getReader(); // Get exactly the same text assertEquals(readerText, reader.getContentString()); }
Example #8
Source File: AbstractContentWriter.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * @see ContentReader#getContentInputStream() * @see #putContent(InputStream) */ public void putContent(ContentReader reader) throws ContentIOException { try { // get the stream to read from InputStream is = reader.getContentInputStream(); // put the content putContent(is); } catch (Throwable e) { throw new ContentIOException("Failed to copy reader content to writer: \n" + " writer: " + this + "\n" + " source reader: " + reader, e); } }
Example #9
Source File: FailoverContentTransformerTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected void transformInternal(ContentReader reader, ContentWriter writer, TransformationOptions options) throws Exception { // Do not actually perform any transformation. The test above is only interested in whether // an exception is thrown and handled. if (logger.isInfoEnabled()) { logger.info(springBeanName + " is attempting a transformation"); } reader.getContentString(); if (alwaysFail) { throw new AlfrescoRuntimeException("Test code intentionally failed method call."); } else { return; } }
Example #10
Source File: RoutingContentServiceTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Checks that multiple writes can occur to the same node outside of any transactions. * <p> * It is only when the streams are closed that the node is updated. */ public void testConcurrentWritesNoTxn() throws Exception { // ensure that the transaction is ended - ofcourse, we need to force a commit txn.commit(); txn = null; ContentWriter writer1 = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true); ContentWriter writer2 = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true); ContentWriter writer3 = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, true); writer1.putContent("writer1 wrote this"); writer2.putContent("writer2 wrote this"); writer3.putContent("writer3 wrote this"); // get the content ContentReader reader = contentService.getReader(contentNodeRef, ContentModel.PROP_CONTENT); String contentCheck = reader.getContentString(); assertEquals("Content check failed", "writer3 wrote this", contentCheck); }
Example #11
Source File: XmlMetadataExtracterTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public void testXpathSelector() throws Exception { // Load the example files ContentReader alfrescoModelReader = getReader(FILE_ALFRESCO_MODEL); assertTrue(alfrescoModelReader.exists()); ContentReader eclipseProjectReader = getReader(FILE_ECLIPSE_PROJECT); assertTrue(eclipseProjectReader.exists()); // Check with an alfresco model document MetadataExtracter alfrescoModelExtracter = xpathMetadataExtracterSelector.getWorker(alfrescoModelReader); assertNotNull("Failed to select correct extracter", alfrescoModelExtracter); assertTrue("Incorrect extracter instance selected", alfrescoModelMetadataExtracter == alfrescoModelExtracter); assertFalse("Read channel not closed", alfrescoModelReader.isChannelOpen()); // Check with an eclipse project document MetadataExtracter eclipseProjectExtracter = xpathMetadataExtracterSelector.getWorker(eclipseProjectReader); assertNotNull("Failed to select correct extracter", eclipseProjectExtracter); assertTrue("Incorrect extracter instance selected", eclipseProjectMetadataExtracter == eclipseProjectExtracter); assertFalse("Read channel not closed", eclipseProjectReader.isChannelOpen()); }
Example #12
Source File: RepoTransferProgressMonitorImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public InputStream getLogInputStream(String transferId) throws TransferException { NodeRef transferRecord = getTransferRecord(transferId); ContentReader reader = contentService.getReader(transferRecord, ContentModel.PROP_CONTENT); if(reader != null) { return reader.getContentInputStream(); } else { return null; } }
Example #13
Source File: DownloadServiceIntegrationTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private Set<String> getEntries(final NodeRef downloadNode) { return TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback<Set<String>>() { @Override public Set<String> execute() throws Throwable { Set<String> entryNames = new TreeSet<String>(); ContentReader reader = CONTENT_SERVICE.getReader(downloadNode, ContentModel.PROP_CONTENT); ZipArchiveInputStream zipInputStream = new ZipArchiveInputStream(reader.getContentInputStream()); try { ZipArchiveEntry zipEntry = zipInputStream.getNextZipEntry(); while (zipEntry != null) { String name = zipEntry.getName(); entryNames.add(name); zipEntry = zipInputStream.getNextZipEntry(); } } finally { zipInputStream.close(); } return entryNames; } }); }
Example #14
Source File: AlfrescoPdfRendererContentTransformerWorker.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void transform(ContentReader reader, ContentWriter writer, TransformationOptions options) throws Exception { // get mimetypes String sourceMimetype = getMimetype(reader); String targetMimetype = getMimetype(writer); // get the extensions to use MimetypeService mimetypeService = getMimetypeService(); String sourceExtension = mimetypeService.getExtension(sourceMimetype); String targetExtension = mimetypeService.getExtension(targetMimetype); if (sourceExtension == null || targetExtension == null) { throw new AlfrescoRuntimeException("Unknown extensions for mimetypes: \n" + " source mimetype: " + sourceMimetype + "\n" + " source extension: " + sourceExtension + "\n" + " target mimetype: " + targetMimetype + "\n" + " target extension: " + targetExtension); } if (remoteTransformerClientConfigured()) { transformRemote(reader, writer, options, sourceMimetype, targetMimetype, sourceExtension, targetExtension); } else { transformLocal(reader, writer, options, sourceMimetype, targetMimetype, sourceExtension, targetExtension); } // done if (logger.isDebugEnabled()) { logger.debug("Transformation completed: \n" + " source: " + reader + "\n" + " target: " + writer + "\n" + " options: " + options); } }
Example #15
Source File: ContentCacheImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected ContentReader createReader() throws ContentIOException { FileContentReader reader = new FileContentReader(getFile(), getContentUrl()); // TODO: what about reader.setAllowRandomAccess(this.allowRandomAccess); ? return reader; }
Example #16
Source File: FileContentStoreTest.java From alfresco-simple-content-stores with Apache License 2.0 | 5 votes |
private ContentWriter testIndividualWriteAndRead(final FileContentStore fileContentStore, final ContentContext context, final String testText) { return ContentStoreContext.executeInNewContext(() -> { final ContentWriter writer = fileContentStore.getWriter(context); writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); writer.setEncoding(StandardCharsets.UTF_8.name()); writer.setLocale(Locale.ENGLISH); writer.putContent(testText); final String contentUrl = writer.getContentUrl(); Assert.assertNotNull("Content URL was not set after writing content", contentUrl); Assert.assertTrue("Content URL does not start with the configured protocol", contentUrl.startsWith(STORE_PROTOCOL + ContentStore.PROTOCOL_DELIMITER)); Assert.assertTrue("Store does not report content URL to exist after writing content", fileContentStore.exists(contentUrl)); final String relativePath = contentUrl .substring(contentUrl.indexOf(ContentStore.PROTOCOL_DELIMITER) + ContentStore.PROTOCOL_DELIMITER.length()); final Path rootPath = this.storeFolder.toPath(); final File file = rootPath.resolve(relativePath).toFile(); Assert.assertTrue("File should be stored in literal path from content URL", file.exists()); final ContentReader properReader = fileContentStore.getReader(contentUrl); Assert.assertTrue("Reader was not returned for freshly written content", properReader != null); Assert.assertTrue("Reader does not refer to existing file for freshly written content", properReader.exists()); // reader does not know about mimetype (provided via persisted ContentData at server runtime) properReader.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); final String readText = properReader.getContentString(); Assert.assertEquals("Read content does not match written test content", testText, readText); return writer; }); }
Example #17
Source File: HttpRangeProcessor.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
/** * Process a range header for a WebScriptResponse - handles single and multiple range requests. * * @param res the webscript response * @param reader the content reader * @param range the byte range * @param ref the content NodeRef * @param property the content property * @param mimetype the content mimetype * @param userAgent the user agent string * @return whether or not the range could be processed * @throws IOException */ public boolean processRange(WebScriptResponse res, ContentReader reader, String range, NodeRef ref, QName property, String mimetype, String userAgent) throws IOException { // test for multiple byte ranges present in header if (range.indexOf(',') == -1) { return processSingleRange(res, reader, range, mimetype); } else { return processMultiRange(res, range, ref, property, mimetype, userAgent); } }
Example #18
Source File: MetadataExtracterLimitsTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
protected Map<QName, Serializable> extractFromFile(File sourceFile, String mimetype) { Map<QName, Serializable> properties = new HashMap<QName, Serializable>(); // construct a reader onto the source file ContentReader sourceReader = new FileContentReader(sourceFile); sourceReader.setMimetype(mimetype); getExtracter().extract(sourceReader, properties); return properties; }
Example #19
Source File: OpenCmisLocalTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public void DISABLED_testBasicFileOps() { Repository repository = getRepository("admin", "admin"); Session session = repository.createSession(); Folder rootFolder = session.getRootFolder(); // create folder Map<String,String> folderProps = new HashMap<String, String>(); { folderProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder"); folderProps.put(PropertyIds.NAME, getName() + "-" + GUID.generate()); } Folder folder = rootFolder.createFolder(folderProps, null, null, null, session.getDefaultContext()); Map<String, String> fileProps = new HashMap<String, String>(); { fileProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document"); fileProps.put(PropertyIds.NAME, "mydoc-" + GUID.generate() + ".txt"); } ContentStreamImpl fileContent = new ContentStreamImpl(); { ContentWriter writer = new FileContentWriter(TempFileProvider.createTempFile(getName(), ".txt")); writer.putContent("Ipsum and so on"); ContentReader reader = writer.getReader(); fileContent.setMimeType(MimetypeMap.MIMETYPE_TEXT_PLAIN); fileContent.setStream(reader.getContentInputStream()); } folder.createDocument(fileProps, fileContent, VersioningState.MAJOR); }
Example #20
Source File: TransformerPropertyGetterTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private void normalTest(boolean isAvailable) { AbstractContentTransformer2 simple = new AbstractContentTransformer2() { @Override protected void transformInternal(ContentReader reader, ContentWriter writer, TransformationOptions options) throws Exception { }}; simple.setBeanName("transformer.exampleSimple"); when(transformerRegistry.getAllTransformers()).thenReturn(Arrays.asList(new ContentTransformer[] {(ContentTransformer)simple})); if (isAvailable) { when(transformerRegistry.getTransformers()).thenReturn(Arrays.asList(new ContentTransformer[] {(ContentTransformer)simple})); } when(transformerLog.getPropertyAndValue(any(Properties.class))).thenReturn("# transformer.log.entries=0"); when(transformerDebugLog.getPropertyAndValue(any(Properties.class))).thenReturn("# transformer.debug.entries=0"); String actual = new TransformerPropertyGetter(false, transformerProperties, mimetypeService, transformerRegistry, transformerLog, transformerDebugLog).toString(); assertEquals("# LOG and DEBUG history sizes\n" + "# ===========================\n" + "# Use small values as these logs are held in memory. 0 to disable.\n" + "# transformer.log.entries=0\n" + "# transformer.debug.entries=0\n" + "\n" + "# Transformers without extra configuration settings\n" + "# =================================================\n" + "\n" + "# exampleSimple\n" + "# -------------\n" + (isAvailable ? "" : "# content.transformer.exampleSimple.available=false\n"), actual); }
Example #21
Source File: DiscussionServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private PostInfo buildPost(NodeRef nodeRef, TopicInfo topic, String name, String preLoadedContents) { PostInfoImpl post = new PostInfoImpl(nodeRef, name, topic); // Grab all the properties, we need the bulk of them anyway Map<QName,Serializable> props = nodeService.getProperties(nodeRef); // Start with the auditable properties post.setCreator((String)props.get(ContentModel.PROP_CREATOR)); post.setModifier((String)props.get(ContentModel.PROP_MODIFIER)); post.setCreatedAt((Date)props.get(ContentModel.PROP_CREATED)); post.setModifiedAt((Date)props.get(ContentModel.PROP_MODIFIED)); post.setUpdatedAt((Date)props.get(ContentModel.PROP_UPDATED)); // Now do the discussion ones post.setTitle((String)props.get(ContentModel.PROP_TITLE)); // Finally, do the content String contents = preLoadedContents; if (contents == null) { ContentReader reader = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT); if (reader != null) { contents = reader.getContentString(); } } post.setContents(contents); // All done return post; }
Example #22
Source File: AppleIWorksContentTransformer.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void transformRemote(RemoteTransformerClient remoteTransformerClient, ContentReader reader, ContentWriter writer, TransformationOptions options, String sourceMimetype, String targetMimetype, String sourceExtension, String targetExtension, String targetEncoding) throws Exception { long timeoutMs = options.getTimeoutMs(); remoteTransformerClient.request(reader, writer, sourceMimetype, sourceExtension, targetExtension, timeoutMs, logger, "transformName", "appleIWorks", "sourceMimetype", sourceMimetype, "sourceExtension", sourceExtension, "targetMimetype", targetMimetype); }
Example #23
Source File: AdminUiTransformerDebug.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private String runWithinTransaction(String sourceExtension, String targetExtension) { String targetMimetype = getMimetype(targetExtension, false); String sourceMimetype = getMimetype(sourceExtension, true); File tempFile = TempFileProvider.createTempFile( "TestTransform_" + sourceExtension + "_", "." + targetExtension); ContentWriter writer = new FileContentWriter(tempFile); writer.setMimetype(targetMimetype); NodeRef sourceNodeRef = null; StringBuilder sb = new StringBuilder(); try { setStringBuilder(sb); sourceNodeRef = createSourceNode(sourceExtension, sourceMimetype); ContentReader reader = contentService.getReader(sourceNodeRef, ContentModel.PROP_CONTENT); SynchronousTransformClient synchronousTransformClient = getSynchronousTransformClient(); Map<String, String> actualOptions = Collections.emptyMap(); synchronousTransformClient.transform(reader, writer, actualOptions, null, sourceNodeRef); } catch (Exception e) { logger.debug("Unexpected test transform error", e); } finally { setStringBuilder(null); deleteSourceNode(sourceNodeRef); } return sb.toString(); }
Example #24
Source File: AbstractWritableContentStoreTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * The simplest test. Write a string and read it again, checking that we receive the same values. * If the resource accessed by {@link #getReader(String)} and {@link #getWriter()} is not the same, then * values written and read won't be the same. */ @Test public void testWriteAndReadString() throws Exception { ContentWriter writer = getWriter(); String content = "ABC"; writer.putContent(content); assertTrue("Stream close not detected", writer.isClosed()); ContentReader reader = writer.getReader(); String check = reader.getContentString(); assertTrue("Read and write may not share same resource", check.length() > 0); assertEquals("Write and read didn't work", content, check); }
Example #25
Source File: ContentMetadataExtracterTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public Map<String, Serializable> extractRaw(ContentReader reader) throws Throwable { Map<String, Serializable> rawMap = newRawMap(); rawMap.put("unknown1", new Integer(1)); rawMap.put("unknown2", "TWO"); return rawMap; }
Example #26
Source File: JodConverterMetadataExtracter.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ @Override public Map<String, Serializable> extractRaw(ContentReader reader) throws Throwable { Map<String, Serializable> rawProperties = newRawMap(); Map<String, Serializable> result = this.worker.extractRaw(reader); for (Map.Entry<String, Serializable> entry : result.entrySet()) { putRawValue(entry.getKey(), entry.getValue(), rawProperties); } return rawProperties; }
Example #27
Source File: StringExtractingContentTransformerTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Writes some content using the mimetype and encoding specified. * * @param mimetype String * @param encoding String * @return Returns a reader onto the newly written content */ private ContentReader writeContent(String mimetype, String encoding) { ContentWriter writer = new FileContentWriter(getTempFile()); writer.setMimetype(mimetype); writer.setEncoding(encoding); // put content writer.putContent(SOME_CONTENT); // return a reader onto the new content return writer.getReader(); }
Example #28
Source File: ContentServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** {@inheritDoc} */ public ContentReader getRawReader(String contentUrl) { ContentReader reader = null; try { reader = store.getReader(contentUrl); } catch (UnsupportedContentUrlException e) { // The URL is not supported, so we spoof it reader = new EmptyContentReader(contentUrl); } if (reader == null) { throw new AlfrescoRuntimeException("ContentStore implementations may not return null ContentReaders"); } // set extra data on the reader reader.setMimetype(MimetypeMap.MIMETYPE_BINARY); reader.setEncoding("UTF-8"); reader.setLocale(I18NUtil.getLocale()); // Done if (logger.isDebugEnabled()) { logger.debug( "Direct request for reader: \n" + " Content URL: " + contentUrl + "\n" + " Reader: " + reader); } return reader; }
Example #29
Source File: ContentCacheImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void putForZeroLengthFile() { ContentReader contentReader = Mockito.mock(ContentReader.class); Mockito.when(contentReader.getSize()).thenReturn(0L); boolean putResult = contentCache.put("", contentReader); assertFalse("Zero length files should not be cached", putResult); }
Example #30
Source File: AbstractMappingMetadataExtracter.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * {@inheritDoc} */ @Override public final Map<QName, Serializable> extract( ContentReader reader, OverwritePolicy overwritePolicy, Map<QName, Serializable> destination) { return extract(reader, overwritePolicy, destination, this.mapping); }