Example usage for com.liferay.portal.kernel.util ContentTypes APPLICATION_PDF

List of usage examples for com.liferay.portal.kernel.util ContentTypes APPLICATION_PDF

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util ContentTypes APPLICATION_PDF.

Prototype

String APPLICATION_PDF

To view the source code for com.liferay.portal.kernel.util ContentTypes APPLICATION_PDF.

Click Source Link

Usage

From source file:com.liferay.adaptive.media.document.library.thumbnails.internal.commands.test.AdaptiveMediaThumbnailsOSGiCommandsTest.java

License:Open Source License

private FileEntry _addPDFFileEntry() throws Exception {
    return DLAppLocalServiceUtil.addFileEntry(_user.getUserId(), _group.getGroupId(),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, StringUtil.randomString() + ".pdf",
            ContentTypes.APPLICATION_PDF, _getFileContents("sample.pdf"), _serviceContext);
}

From source file:com.liferay.adaptive.media.document.library.thumbnails.internal.osgi.commands.test.AMThumbnailsOSGiCommandsTest.java

License:Open Source License

private FileEntry _addPDFFileEntry() throws Exception {
    return DLAppLocalServiceUtil.addFileEntry(_user.getUserId(), _group.getGroupId(),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, RandomTestUtil.randomString() + ".pdf",
            ContentTypes.APPLICATION_PDF, _getFileContents("sample.pdf"), _serviceContext);
}

From source file:com.liferay.document.library.internal.exportimport.data.handler.test.FileEntryStagedModelDataHandlerTest.java

License:Open Source License

@Test
public void testExportImportFileExtension() throws Exception {
    String fileName = "PDF_Test.pdf";

    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(stagingGroup.getGroupId(),
            TestPropsValues.getUserId());

    FileEntry fileEntry = DLAppLocalServiceUtil.addFileEntry(TestPropsValues.getUserId(),
            stagingGroup.getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, fileName,
            ContentTypes.APPLICATION_PDF, FileUtil.getBytes(getClass(), "dependencies/" + fileName),
            serviceContext);/*  w w  w .  j  a va 2 s.  c o m*/

    exportImportStagedModel(fileEntry);

    FileEntry importedFileEntry = DLAppLocalServiceUtil.getFileEntryByUuidAndGroupId(fileEntry.getUuid(),
            liveGroup.getGroupId());

    Assert.assertEquals("pdf", importedFileEntry.getExtension());

    String title = RandomTestUtil.randomString() + ".awesome";

    DLAppServiceUtil.updateFileEntry(fileEntry.getFileEntryId(), StringPool.BLANK, ContentTypes.TEXT_PLAIN,
            title, StringPool.BLANK, StringPool.BLANK, false, (byte[]) null, serviceContext);

    exportImportStagedModel(fileEntry);

    importedFileEntry = DLAppLocalServiceUtil.getFileEntryByUuidAndGroupId(fileEntry.getUuid(),
            liveGroup.getGroupId());

    Assert.assertEquals("pdf", importedFileEntry.getExtension());
}

From source file:com.liferay.document.library.service.test.DLFileEntryFinderTest.java

License:Open Source License

protected Object[] setUp(long repositoryId, String titleSuffix, ServiceContext serviceContext)
        throws Exception {

    Folder folder = DLAppLocalServiceUtil.addFolder(TestPropsValues.getUserId(), repositoryId,
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, "Folder A", StringPool.BLANK, serviceContext);

    DLAppLocalServiceUtil.addFolder(TestPropsValues.getUserId(), repositoryId, folder.getFolderId(), "Folder B",
            StringPool.BLANK, serviceContext);

    Folder folderC = DLAppLocalServiceUtil.addFolder(TestPropsValues.getUserId(), repositoryId,
            folder.getFolderId(), "Folder C", StringPool.BLANK, serviceContext);

    DLTrashServiceUtil.moveFolderToTrash(folderC.getFolderId());

    FileEntry fileEntry = addFileEntry(_user.getUserId(), repositoryId, folder.getFolderId(), "FE1.txt",
            titleSuffix, ContentTypes.TEXT_PLAIN, DLFileEntryTypeConstants.FILE_ENTRY_TYPE_ID_BASIC_DOCUMENT);

    LiferayFileEntry liferayFileEntry = (LiferayFileEntry) fileEntry;

    DLFileEntry dlFileEntry = liferayFileEntry.getDLFileEntry();

    dlFileEntry.setExtraSettings("hello=world");
    dlFileEntry.setSmallImageId(_SMALL_IMAGE_ID);

    dlFileEntry = DLFileEntryLocalServiceUtil.updateDLFileEntry(dlFileEntry);

    DLFileVersion dlFileVersion = dlFileEntry.getFileVersion();

    addFileEntry(TestPropsValues.getUserId(), repositoryId, folder.getFolderId(), "FE2.pdf", titleSuffix,
            ContentTypes.APPLICATION_PDF, DLFileEntryTypeConstants.FILE_ENTRY_TYPE_ID_ALL);

    fileEntry = addFileEntry(TestPropsValues.getUserId(), repositoryId, folder.getFolderId(), "FE3.txt",
            titleSuffix, ContentTypes.TEXT_PLAIN, DLFileEntryTypeConstants.FILE_ENTRY_TYPE_ID_ALL);

    fileEntry = DLAppServiceUtil.updateFileEntry(fileEntry.getFileEntryId(), "FE3.txt", ContentTypes.TEXT_PLAIN,
            "FE3.txt".concat(titleSuffix), StringPool.BLANK, StringPool.BLANK, false,
            RandomTestUtil.randomBytes(TikaSafeRandomizerBumper.INSTANCE), serviceContext);

    liferayFileEntry = (LiferayFileEntry) fileEntry;

    dlFileEntry = liferayFileEntry.getDLFileEntry();

    dlFileEntry.setDescription("FE3.txt");

    DLFileEntryLocalServiceUtil.updateDLFileEntry(dlFileEntry);

    DLFileVersion dlFileVersion3 = dlFileEntry.getFileVersion();

    dlFileVersion3.setExtraSettings("hello=world");

    DLFileVersionLocalServiceUtil.updateDLFileVersion(dlFileVersion3);

    DLTrashServiceUtil.moveFileEntryToTrash(fileEntry.getFileEntryId());

    return new Object[] { folder, dlFileVersion };
}

From source file:com.liferay.document.library.service.test.PDFProcessorTest.java

License:Open Source License

@Test
public void testShouldCleanUpProcessorsOnCancelCheckOut() throws Exception {
    AtomicBoolean cleanUp = registerCleanUpDLProcessor();

    FileEntry fileEntry = DLAppServiceUtil.addFileEntry(_serviceContext.getScopeGroupId(),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, StringUtil.randomString() + ".pdf",
            ContentTypes.APPLICATION_PDF, StringUtil.randomString(), StringUtil.randomString(),
            StringUtil.randomString(), FileUtil.getBytes(getClass(), "dependencies/test.pdf"), _serviceContext);

    DLAppServiceUtil.checkOutFileEntry(fileEntry.getFileEntryId(), _serviceContext);

    DLAppServiceUtil.cancelCheckOut(fileEntry.getFileEntryId());

    Assert.assertTrue(cleanUp.get());/*from   w  ww  .  ja  va 2 s . c o  m*/
}

From source file:com.liferay.document.library.service.test.PDFProcessorTest.java

License:Open Source License

@Test
public void testShouldCleanUpProcessorsOnDelete() throws Exception {
    AtomicBoolean cleanUp = registerCleanUpDLProcessor();

    FileEntry fileEntry = DLAppServiceUtil.addFileEntry(_serviceContext.getScopeGroupId(),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, StringUtil.randomString() + ".pdf",
            ContentTypes.APPLICATION_PDF, StringUtil.randomString(), StringUtil.randomString(),
            StringUtil.randomString(), FileUtil.getBytes(getClass(), "dependencies/test.pdf"), _serviceContext);

    DLAppServiceUtil.deleteFileEntry(fileEntry.getFileEntryId());

    Assert.assertTrue(cleanUp.get());/*  w w  w . ja  va2 s.  c om*/
}

From source file:com.liferay.document.library.service.test.PDFProcessorTest.java

License:Open Source License

@Test
public void testShouldCleanUpProcessorsOnUpdate() throws Exception {
    AtomicBoolean cleanUp = registerCleanUpDLProcessor();

    FileEntry fileEntry = DLAppServiceUtil.addFileEntry(_serviceContext.getScopeGroupId(),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, StringUtil.randomString() + ".pdf",
            ContentTypes.APPLICATION_PDF, StringUtil.randomString(), StringUtil.randomString(),
            StringUtil.randomString(), FileUtil.getBytes(getClass(), "dependencies/test.pdf"), _serviceContext);

    DLAppServiceUtil.updateFileEntry(fileEntry.getFileEntryId(), StringUtil.randomString() + ".pdf",
            ContentTypes.APPLICATION_PDF, StringUtil.randomString(), StringUtil.randomString(),
            StringUtil.randomString(), true, FileUtil.getBytes(getClass(), "dependencies/test.pdf"),
            _serviceContext);/*from w  w w . ja  v a 2 s .c  o  m*/

    Assert.assertTrue(cleanUp.get());
}

From source file:com.liferay.document.library.service.test.PDFProcessorTest.java

License:Open Source License

@Test
public void testShouldCleanUpProcessorsOnUpdateAndCheckIn() throws Exception {

    AtomicBoolean cleanUp = registerCleanUpDLProcessor();

    FileEntry fileEntry = DLAppServiceUtil.addFileEntry(_serviceContext.getScopeGroupId(),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, StringUtil.randomString() + ".pdf",
            ContentTypes.APPLICATION_PDF, StringUtil.randomString(), StringUtil.randomString(),
            StringUtil.randomString(), FileUtil.getBytes(getClass(), "dependencies/test.pdf"), _serviceContext);

    byte[] bytes = FileUtil.getBytes(getClass(), "dependencies/test.pdf");

    InputStream inputStream = new ByteArrayInputStream(bytes);

    DLAppServiceUtil.updateFileEntryAndCheckIn(fileEntry.getFileEntryId(), StringUtil.randomString() + ".pdf",
            ContentTypes.APPLICATION_PDF, StringUtil.randomString(), StringUtil.randomString(),
            StringUtil.randomString(), true, inputStream, bytes.length, _serviceContext);

    Assert.assertTrue(cleanUp.get());// w w w  . jav  a2  s . com
}

From source file:com.liferay.document.library.service.test.PDFProcessorTest.java

License:Open Source License

@Test
public void testShouldCopyPreviousPreviewOnCheckIn() throws Exception {
    AtomicInteger count = registerPDFProcessorMessageListener(EventType.COPY_PREVIOUS);

    FileEntry fileEntry = DLAppServiceUtil.addFileEntry(_serviceContext.getScopeGroupId(),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, StringUtil.randomString() + ".pdf",
            ContentTypes.APPLICATION_PDF, StringUtil.randomString(), StringUtil.randomString(),
            StringUtil.randomString(), FileUtil.getBytes(getClass(), "dependencies/test.pdf"), _serviceContext);

    DLAppServiceUtil.checkInFileEntry(fileEntry.getFileEntryId(), true, StringUtil.randomString(),
            _serviceContext);//  w  ww . jav a2 s .  co  m

    Assert.assertEquals(1, count.get());
}

From source file:com.liferay.document.library.service.test.PDFProcessorTest.java

License:Open Source License

@Test
public void testShouldCopyPreviousPreviewOnCheckOut() throws Exception {
    AtomicInteger count = registerPDFProcessorMessageListener(EventType.COPY_PREVIOUS);

    FileEntry fileEntry = DLAppServiceUtil.addFileEntry(_serviceContext.getScopeGroupId(),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, StringUtil.randomString() + ".pdf",
            ContentTypes.APPLICATION_PDF, StringUtil.randomString(), StringUtil.randomString(),
            StringUtil.randomString(), FileUtil.getBytes(getClass(), "dependencies/test.pdf"), _serviceContext);

    DLAppServiceUtil.checkOutFileEntry(fileEntry.getFileEntryId(), _serviceContext);

    Assert.assertEquals(1, count.get());
}