本文整理汇总了Java中org.alfresco.repo.content.MimetypeMap.MIMETYPE_PDF属性的典型用法代码示例。如果您正苦于以下问题:Java MimetypeMap.MIMETYPE_PDF属性的具体用法?Java MimetypeMap.MIMETYPE_PDF怎么用?Java MimetypeMap.MIMETYPE_PDF使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.alfresco.repo.content.MimetypeMap
的用法示例。
在下文中一共展示了MimetypeMap.MIMETYPE_PDF属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCreateRenditionThumbnailFromPdfPage2
public void testCreateRenditionThumbnailFromPdfPage2() throws Exception
{
ImageTransformationOptions options = new ImageTransformationOptions();
PagedSourceOptions pagedSourceOptions = new PagedSourceOptions();
pagedSourceOptions.setStartPageNumber(new Integer(2));
pagedSourceOptions.setEndPageNumber(new Integer(2));
options.addSourceOptions(pagedSourceOptions);
ThumbnailDefinition thumbnailDefinition = new ThumbnailDefinition(MimetypeMap.MIMETYPE_PDF, options, "doclib_2");
thumbnailService.getThumbnailRegistry().addThumbnailDefinition(thumbnailDefinition);
checkTransformer();
NodeRef pdfOrig = createOriginalContent(this.folder, MimetypeMap.MIMETYPE_PDF);
NodeRef thumbnail0 = this.thumbnailService.createThumbnail(pdfOrig, ContentModel.PROP_CONTENT,
MimetypeMap.MIMETYPE_IMAGE_JPEG, thumbnailDefinition.getTransformationOptions(), "doclib_2");
assertNotNull(thumbnail0);
checkRenditioned(pdfOrig, Collections.singletonList(new ExpectedAssoc(RegexQNamePattern.MATCH_ALL, "doclib_2", 1)));
checkRendition("doclib_2", thumbnail0);
// Check the length
File tempFile = TempFileProvider.createTempFile("thumbnailServiceImplTest", ".jpg");
ContentReader reader = this.contentService.getReader(thumbnail0, ContentModel.PROP_CONTENT);
long size = reader.getSize();
System.out.println("size=" + size);
assertTrue("Page 2 should be blank and less than 4500 bytes", size < 4500);
reader.getContent(tempFile);
System.out.println("doclib_2 test: " + tempFile.getPath());
}
示例2: testArchiveToPdf
public void testArchiveToPdf() throws Exception
{
String sourceMimetype = MimetypeMap.MIMETYPE_ZIP;
String targetMimetype = MimetypeMap.MIMETYPE_PDF;
// force Transformers subsystem to start (this will also load the ContentTransformerRegistry - including complex/dynamic pipelines)
// note: a call to contentService.getTransformer would also do this .. even if transformer cannot be found (returned as null)
ChildApplicationContextFactory transformersSubsystem = (ChildApplicationContextFactory) ctx.getBean("Transformers");
transformersSubsystem.start();
assertNotNull(registry.getTransformer("transformer.complex.ArchiveToPdf"));
// note: txt -> pdf currently uses OpenOffice/LibreOffice
if (! isOpenOfficeWorkerAvailable())
{
// no connection
System.err.println("ooWorker not available - skipping testArchiveToPdf !!");
return;
}
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
ContentTransformer transformer = serviceRegistry.getContentService().getTransformer(sourceMimetype, targetMimetype);
assertNotNull(transformer);
String sourceExtension = mimetypeService.getExtension(sourceMimetype);
String targetExtension = mimetypeService.getExtension(targetMimetype);
File zipSourceFile = loadQuickTestFile("zip");
ContentReader sourceReader = new FileContentReader(zipSourceFile);
// make a writer for the target file
File targetFile = TempFileProvider.createTempFile(getClass().getSimpleName() + "_"
+ getName() + "_" + sourceExtension + "_", "." + targetExtension);
ContentWriter targetWriter = new FileContentWriter(targetFile);
// do the transformation
sourceReader.setMimetype(sourceMimetype);
targetWriter.setMimetype(targetMimetype);
transformer.transform(sourceReader.getReader(), targetWriter);
ContentReader targetReader = new FileContentReader(targetFile);
assertTrue(targetReader.getSize() > 0);
}
示例3: testRFC822ToPdf
/**
* Test transforming a valid eml file to pdf using complex transformer ("Rfc822ToPdf") - eg. for HTML5 preview
*/
public void testRFC822ToPdf() throws Exception
{
String sourceMimetype = MimetypeMap.MIMETYPE_RFC822;
String targetMimetype = MimetypeMap.MIMETYPE_PDF;
// force Transformers subsystem to start (this will also load the ContentTransformerRegistry - including complex/dynamic pipelines)
// note: a call to contentService.getTransformer would also do this .. even if transformer cannot be found (returned as null)
ChildApplicationContextFactory transformersSubsystem = (ChildApplicationContextFactory) ctx.getBean("Transformers");
transformersSubsystem.start();
assertNotNull(registry.getTransformer("transformer.complex.Rfc822ToPdf"));
// note: txt -> pdf currently uses OpenOffice/LibreOffice
if (! isOpenOfficeWorkerAvailable())
{
// no connection
System.err.println("ooWorker available - skipping testRFC822ToPdf !!");
return;
}
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
ContentTransformer transformer = serviceRegistry.getContentService().getTransformer(sourceMimetype, targetMimetype);
assertNotNull(transformer);
String sourceExtension = mimetypeService.getExtension(sourceMimetype);
String targetExtension = mimetypeService.getExtension(targetMimetype);
File emlSourceFile = loadQuickTestFile("eml");
ContentReader sourceReader = new FileContentReader(emlSourceFile);
// make a writer for the target file
File targetFile = TempFileProvider.createTempFile(getClass().getSimpleName() + "_"
+ getName() + "_" + sourceExtension + "_", "." + targetExtension);
ContentWriter targetWriter = new FileContentWriter(targetFile);
// do the transformation
sourceReader.setMimetype(sourceMimetype);
targetWriter.setMimetype(targetMimetype);
transformer.transform(sourceReader.getReader(), targetWriter);
ContentReader targetReader = new FileContentReader(targetFile);
assertTrue(targetReader.getSize() > 0);
}
示例4: PdfBoxContentTransformer
public PdfBoxContentTransformer() {
super(new String[] {
MimetypeMap.MIMETYPE_PDF
});
}
示例5: testPdfToTextConversions
/**
* Added to test a single transform that appeared to have problems.
* Commented out once issue was fixed, but left in the code to help with
* future issues.
* @throws Exception
*/
public void testPdfToTextConversions() throws Exception
{
final String sourceMimetype = MimetypeMap.MIMETYPE_PDF;
final String targetMimetype = MimetypeMap.MIMETYPE_TEXT_PLAIN;
int transforms = 100;
final String filename = "svn-book.pdf";
final CountDownLatch doneSignal = new CountDownLatch(transforms);
int threadCount = 8;
final ExecutorService threadPool = Executors.newFixedThreadPool(threadCount);
long time = System.currentTimeMillis();
for (int i=0; i<transforms; i++)
{
threadPool.submit(new Runnable() {
public void run()
{
try
{
pdfToTextTransform(filename, sourceMimetype, targetMimetype);
doneSignal.countDown();
}
catch (IOException e)
{
threadPool.shutdown();
e.printStackTrace();
}
}});
if (i < threadCount)
{
Thread.sleep(1000);
}
}
boolean okay = doneSignal.await(100, TimeUnit.SECONDS);
time = System.currentTimeMillis() - time;
transforms = transforms - (int)doneSignal.getCount();
String message = "Total time "+time+" ms "+(transforms > 0 ? "average="+(time/transforms)+" ms" : "")+" threads="+threadCount+" transforms="+transforms;
System.out.println(message);
if (!okay)
{
// Before the changes to PDFBox, this would fail having only done about 50 transforms.
// After the change, this takes about 55 seconds
fail("********** Transforms did not finish ********** "+message);
}
}
示例6: testAspectWithChildAssociationsCreationAndRetrieval
public void testAspectWithChildAssociationsCreationAndRetrieval() throws Exception
{
// Create a folder. This is like the user's home folder, say.
NodeRef folderNodeRef = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName(BaseNodeServiceTest.NAMESPACE, "UserX-" + GUID.generate()),
ContentModel.TYPE_FOLDER).getChildRef();
// Create a document. This is the actual document uploaded by the user.
NodeRef fileNodeRef = nodeService.createNode(
folderNodeRef,
ContentModel.ASSOC_CONTAINS,
QName.createQName(BaseNodeServiceTest.NAMESPACE, "Uploaded.pdf"),
ContentModel.TYPE_FOLDER).getChildRef();
// So, thus far, this is exactly what you have. Now for the bit to add some renditions.
// First, we can make some content data pages - spoofed, of course
List<ContentData> renditionContentPages = new ArrayList<ContentData>(20);
// This loop is where you will, outside of the transaction, push the page content into the repo
for(int i = 0; i < 100; i++)
{
ContentData contentData = new ContentData(null, MimetypeMap.MIMETYPE_PDF, 10245, "UTF-8");
renditionContentPages.add(contentData);
}
nodeService.addAspect(fileNodeRef, ASPECT_QNAME_TEST_RENDERED, null);
int pageNumber = 0;
for (ContentData renditionContentPage : renditionContentPages)
{
pageNumber++;
QName renditionQName = makePageAssocName(pageNumber);
Map<QName, Serializable> properties = Collections.singletonMap(
PROP_QNAME_TEST_RENDITION_PAGE_CONTENT,
(Serializable) renditionContentPage);
nodeService.createNode(
fileNodeRef,
ASSOC_TYPE_QNAME_TEST_RENDITION,
renditionQName,
TYPE_QNAME_TEST_RENDITION_PAGE,
properties);
}
// That's it for uploading. Now we retrieve them.
if (!nodeService.hasAspect(fileNodeRef, ASPECT_QNAME_TEST_RENDERED))
{
// Jump to the original rendition retrieval code
return;
}
// It has the aspect, so it's the new model
List<ChildAssociationRef> fetchedRenditionChildAssocs = nodeService.getChildAssocs(
fileNodeRef,
ASSOC_TYPE_QNAME_TEST_RENDITION,
RegexQNamePattern.MATCH_ALL);
assertEquals(
"We didn't get the correct number of pages back",
renditionContentPages.size(),
fetchedRenditionChildAssocs.size());
// Get page ... 5. This is to prove that they are ordered.
ChildAssociationRef fetchedRenditionChildAssoc5 = fetchedRenditionChildAssocs.get(4);
QName page5QName = makePageAssocName(5);
assertEquals(
"Local name of page 5 assoc is not correct",
page5QName,
fetchedRenditionChildAssoc5.getQName());
// Now retrieve page 5 using the NodeService
List<ChildAssociationRef> fetchedRenditionChildAssocsPage5 = nodeService.getChildAssocs(
fileNodeRef,
ASSOC_TYPE_QNAME_TEST_RENDITION,
page5QName);
assertEquals("Expected exactly one result", 1, fetchedRenditionChildAssocsPage5.size());
assertEquals("Targeted page retrieval was not correct",
page5QName,
fetchedRenditionChildAssocsPage5.get(0).getQName());
}