Example usage for com.liferay.portal.kernel.repository.capabilities ThumbnailCapability setLargeImageId

List of usage examples for com.liferay.portal.kernel.repository.capabilities ThumbnailCapability setLargeImageId

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.repository.capabilities ThumbnailCapability setLargeImageId.

Prototype

public FileEntry setLargeImageId(FileEntry fileEntry, long imageId) throws PortalException;

Source Link

Usage

From source file:com.liferay.exportimport.internal.content.processor.test.DefaultExportImportContentProcessorTest.java

License:Open Source License

@Before
public void setUp() throws Exception {
    _defaultLocale = LocaleUtil.getDefault();
    _nonDefaultLocale = getNonDefaultLocale();

    _liveGroup = GroupTestUtil.addGroup();
    _stagingGroup = GroupTestUtil.addGroup();

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

    _fileEntry = DLAppLocalServiceUtil.addFileEntry(TestPropsValues.getUserId(), _stagingGroup.getGroupId(),
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID, RandomTestUtil.randomString() + ".txt",
            ContentTypes.TEXT_PLAIN, RandomTestUtil.randomBytes(TikaSafeRandomizerBumper.INSTANCE),
            serviceContext);//  w  w w.jav  a  2s.  com

    ThumbnailCapability thumbnailCapability = _fileEntry.getRepositoryCapability(ThumbnailCapability.class);

    _fileEntry = thumbnailCapability.setLargeImageId(_fileEntry, _fileEntry.getFileEntryId());

    TestReaderWriter testReaderWriter = new TestReaderWriter();

    _portletDataContextExport = PortletDataContextFactoryUtil.createExportPortletDataContext(
            _stagingGroup.getCompanyId(), _stagingGroup.getGroupId(), new HashMap<>(),
            new Date(System.currentTimeMillis() - Time.HOUR), new Date(), testReaderWriter);

    Document document = SAXReaderUtil.createDocument();

    Element manifestRootElement = document.addElement("root");

    manifestRootElement.addElement("header");

    testReaderWriter.addEntry("/manifest.xml", document.asXML());

    Element rootElement = SAXReaderUtil.createElement("root");

    _portletDataContextExport.setExportDataRootElement(rootElement);

    _stagingPrivateLayout = addMultiLocaleLayout(_stagingGroup, true);
    _stagingPublicLayout = addMultiLocaleLayout(_stagingGroup, false);

    _portletDataContextExport.setPlid(_stagingPublicLayout.getPlid());

    _portletDataContextImport = PortletDataContextFactoryUtil.createImportPortletDataContext(
            _liveGroup.getCompanyId(), _liveGroup.getGroupId(), new HashMap<>(), new TestUserIdStrategy(),
            testReaderWriter);

    _portletDataContextImport.setImportDataRootElement(rootElement);

    Element missingReferencesElement = rootElement.addElement("missing-references");

    _portletDataContextExport.setMissingReferencesElement(missingReferencesElement);

    _portletDataContextImport.setMissingReferencesElement(missingReferencesElement);

    _livePrivateLayout = addMultiLocaleLayout(_liveGroup, true);
    _livePublicLayout = addMultiLocaleLayout(_liveGroup, false);

    Map<Long, Long> layoutPlids = (Map<Long, Long>) _portletDataContextImport
            .getNewPrimaryKeysMap(Layout.class);

    layoutPlids.put(_stagingPrivateLayout.getPlid(), _livePrivateLayout.getPlid());
    layoutPlids.put(_stagingPublicLayout.getPlid(), _livePublicLayout.getPlid());

    _portletDataContextImport.setPlid(_livePublicLayout.getPlid());

    _portletDataContextImport.setSourceGroupId(_stagingGroup.getGroupId());

    rootElement.addElement("entry");

    _referrerStagedModel = JournalTestUtil.addArticle(_stagingGroup.getGroupId(), RandomTestUtil.randomString(),
            RandomTestUtil.randomString());

    _exportImportContentProcessor = ExportImportContentProcessorRegistryUtil
            .getExportImportContentProcessor(String.class.getName());

    _layoutReferencesExportImportContentProcessor = _serviceTracker.getService();
}

From source file:com.liferay.exportimport.test.ExportImportHelperUtilTest.java

License:Open Source License

protected FileEntry getFileEntry() throws PortalException {
    ServiceContext serviceContext = ServiceContextTestUtil.getServiceContext(_stagingGroup.getGroupId(),
            TestPropsValues.getUserId());

    FileEntry fileEntry = DLAppLocalServiceUtil.addFileEntry(TestPropsValues.getUserId(),
            _stagingGroup.getGroupId(), DLFolderConstants.DEFAULT_PARENT_FOLDER_ID,
            RandomTestUtil.randomString() + ".txt", ContentTypes.TEXT_PLAIN,
            RandomTestUtil.randomBytes(TikaSafeRandomizerBumper.INSTANCE), serviceContext);

    ThumbnailCapability thumbnailCapability = fileEntry.getRepositoryCapability(ThumbnailCapability.class);

    fileEntry = thumbnailCapability.setLargeImageId(fileEntry, fileEntry.getFileEntryId());

    return fileEntry;
}