List of usage examples for com.liferay.portal.kernel.repository.model FileEntry getCompanyId
@Override
public long getCompanyId();
From source file:com.custom.portal.verify.CustomVerifyDynamicDataMapping.java
License:Open Source License
protected void updateDLFileUploadReferences(long dlFileEntryMetadataId) throws Exception { DLFileEntryMetadata dlFileEntryMetadata = DLFileEntryMetadataLocalServiceUtil .getFileEntryMetadata(dlFileEntryMetadataId); FileEntry fileEntry = DLAppLocalServiceUtil.getFileEntry(dlFileEntryMetadata.getFileEntryId()); FileVersion fileVersion = fileEntry.getFileVersion(); updateFileUploadReferences(fileEntry.getCompanyId(), dlFileEntryMetadata.getDDMStorageId(), fileEntry.getUserId(), fileEntry.getGroupId(), dlFileEntryMetadata, fileVersion.getStatus()); }
From source file:com.liferay.adaptive.media.image.internal.media.query.MediaQueryProviderImpl.java
License:Open Source License
private Collection<AdaptiveMedia<AMImageProcessor>> _getAdaptiveMedias(FileEntry fileEntry) throws PortalException { Collection<AMImageConfigurationEntry> amImageConfigurationEntries = _amImageConfigurationHelper .getAMImageConfigurationEntries(fileEntry.getCompanyId()); List<AdaptiveMedia<AMImageProcessor>> adaptiveMedias = new ArrayList<>(); for (AMImageConfigurationEntry amImageConfigurationEntry : amImageConfigurationEntries) { AdaptiveMedia<AMImageProcessor> adaptiveMedia = _getAdaptiveMediaFromConfigurationEntry(fileEntry, amImageConfigurationEntry); if (_getWidth(adaptiveMedia) > 0) { adaptiveMedias.add(adaptiveMedia); }//from w w w . j a v a2 s . c o m } Collections.sort(adaptiveMedias, _comparator); return adaptiveMedias; }
From source file:com.liferay.adaptive.media.image.internal.mediaquery.MediaQueryProviderImpl.java
License:Open Source License
private Collection<AdaptiveMedia<AdaptiveMediaImageProcessor>> _getAdaptiveMedias(FileEntry fileEntry) throws PortalException { Collection<AdaptiveMediaImageConfigurationEntry> configurationEntries = _adaptiveMediaImageConfigurationHelper .getAdaptiveMediaImageConfigurationEntries(fileEntry.getCompanyId()); List<AdaptiveMedia<AdaptiveMediaImageProcessor>> adaptiveMedias = new ArrayList<>(); for (AdaptiveMediaImageConfigurationEntry configurationEntry : configurationEntries) { AdaptiveMedia<AdaptiveMediaImageProcessor> adaptiveMedia = _getAdaptiveMediaFromConfigurationEntry( fileEntry, configurationEntry); if (_getWidth(adaptiveMedia) > 0) { adaptiveMedias.add(adaptiveMedia); }//from w w w.j a v a 2 s .co m } Collections.sort(adaptiveMedias, _comparator); return adaptiveMedias; }
From source file:com.liferay.document.library.internal.service.DLFileRankDLAppHelperLocalServiceWrapper.java
License:Open Source License
@Override public void getFileAsStream(long userId, FileEntry fileEntry, boolean incrementCounter) { super.getFileAsStream(userId, fileEntry, incrementCounter); if (!incrementCounter) { return;/*from w w w .j ava 2 s . com*/ } if (userId > 0) { TransactionCommitCallbackUtil.registerCallback(() -> { _dlFileRankLocalService.updateFileRank(fileEntry.getGroupId(), fileEntry.getCompanyId(), userId, fileEntry.getFileEntryId(), new ServiceContext()); return null; }); } }
From source file:com.liferay.document.library.internal.service.SubscriptionDLAppHelperLocalServiceWrapper.java
License:Open Source License
@Override public void deleteFileEntry(FileEntry fileEntry) throws PortalException { if (!_isEnabled(fileEntry)) { return;//from w w w . j av a 2 s . co m } super.deleteFileEntry(fileEntry); _subscriptionLocalService.deleteSubscriptions(fileEntry.getCompanyId(), DLFileEntryConstants.getClassName(), fileEntry.getFileEntryId()); }
From source file:com.liferay.document.library.service.test.DLAppServiceTest.java
License:Open Source License
protected static void search(FileEntry fileEntry, String keywords, boolean expected) throws Exception { SearchContext searchContext = new SearchContext(); searchContext.setAttribute("paginationType", "regular"); searchContext.setCompanyId(fileEntry.getCompanyId()); searchContext.setFolderIds(new long[] { fileEntry.getFolderId() }); searchContext.setGroupIds(new long[] { fileEntry.getRepositoryId() }); searchContext.setKeywords(keywords); QueryConfig queryConfig = searchContext.getQueryConfig(); queryConfig.setHighlightEnabled(false); queryConfig.setScoreEnabled(false);/*from w ww . ja v a2 s. c om*/ Indexer<DLFileEntry> indexer = IndexerRegistryUtil.getIndexer(DLFileEntryConstants.getClassName()); Hits hits = indexer.search(searchContext); boolean found = false; for (Document document : hits.getDocs()) { long fileEntryId = GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK)); if (fileEntryId == fileEntry.getFileEntryId()) { found = true; break; } } Assert.assertEquals(hits.toString(), expected, found); }
From source file:com.liferay.exportimport.internal.content.processor.test.DefaultExportImportContentProcessorTest.java
License:Open Source License
protected String replaceParameters(String content, FileEntry fileEntry) { Company company = CompanyLocalServiceUtil.fetchCompany(fileEntry.getCompanyId()); content = replaceMultiLocaleLayoutFriendlyURLs(content); Map<Locale, String> livePublicLayoutFriendlyURLMap = _livePublicLayout.getFriendlyURLMap(); Map<Locale, String> stagingPrivateLayoutFriendlyURLMap = _stagingPrivateLayout.getFriendlyURLMap(); Map<Locale, String> stagingPublicLayoutFriendlyURLMap = _stagingPublicLayout.getFriendlyURLMap(); content = StringUtil.replace(content, new String[] { "[$CANONICAL_URL_SEPARATOR$]", "[$CONTROL_PANEL_FRIENDLY_URL$]", "[$CONTROL_PANEL_LAYOUT_FRIENDLY_URL$]", "[$GROUP_FRIENDLY_URL$]", "[$GROUP_ID$]", "[$IMAGE_ID$]", "[$LIVE_GROUP_FRIENDLY_URL$]", "[$LIVE_GROUP_ID$]", "[$LIVE_PUBLIC_LAYOUT_FRIENDLY_URL$]", "[$NON_DEFAULT_LIVE_PUBLIC_LAYOUT_FRIENDLY_URL$]", "[$NON_DEFAULT_PRIVATE_LAYOUT_FRIENDLY_URL$]", "[$NON_DEFAULT_PUBLIC_LAYOUT_FRIENDLY_URL$]", "[$PATH_CONTEXT$]", "[$PATH_FRIENDLY_URL_PRIVATE_GROUP$]", "[$PATH_FRIENDLY_URL_PRIVATE_USER$]", "[$PATH_FRIENDLY_URL_PUBLIC$]", "[$PRIVATE_LAYOUT_FRIENDLY_URL$]", "[$PUBLIC_LAYOUT_FRIENDLY_URL$]", "[$TITLE$]", "[$UUID$]", "[$WEB_ID$]" }, new String[] { VirtualLayoutConstants.CANONICAL_URL_SEPARATOR, GroupConstants.CONTROL_PANEL_FRIENDLY_URL, PropsValues.CONTROL_PANEL_LAYOUT_FRIENDLY_URL, _stagingGroup.getFriendlyURL(), String.valueOf(fileEntry.getGroupId()), String.valueOf(fileEntry.getFileEntryId()), _liveGroup.getFriendlyURL(), String.valueOf(_liveGroup.getGroupId()), _livePublicLayout.getFriendlyURL(), livePublicLayoutFriendlyURLMap.get(_nonDefaultLocale), stagingPrivateLayoutFriendlyURLMap.get(_nonDefaultLocale), stagingPublicLayoutFriendlyURLMap.get(_nonDefaultLocale), PortalUtil.getPathContext(), PropsValues.LAYOUT_FRIENDLY_URL_PRIVATE_GROUP_SERVLET_MAPPING, PropsValues.LAYOUT_FRIENDLY_URL_PRIVATE_USER_SERVLET_MAPPING, PropsValues.LAYOUT_FRIENDLY_URL_PUBLIC_SERVLET_MAPPING, _stagingPrivateLayout.getFriendlyURL(), _stagingPublicLayout.getFriendlyURL(), fileEntry.getTitle(), fileEntry.getUuid(), company.getWebId() }); if (!content.contains("[$TIMESTAMP")) { return content; }/*from ww w. j a v a2s . c o m*/ return replaceTimestampParameters(content); }
From source file:com.liferay.portlet.documentlibrary.lar.FileEntryUtil.java
License:Open Source License
public static InputStream getContentStream(FileEntry fileEntry) throws PortalException, SystemException { long repositoryId = DLFolderConstants.getDataRepositoryId(fileEntry.getRepositoryId(), fileEntry.getFolderId());/*from ww w .j a va2 s .c om*/ String name = ((DLFileEntry) fileEntry.getModel()).getName(); return DLStoreUtil.getFileAsStream(fileEntry.getCompanyId(), repositoryId, name, fileEntry.getVersion()); }
From source file:com.liferay.portlet.documentlibrary.service.impl.DLAppHelperLocalServiceImpl.java
License:Open Source License
public void getFileAsStream(long userId, FileEntry fileEntry, boolean incrementCounter) throws SystemException { // File rank/* w ww .ja v a 2 s . co m*/ if (userId > 0 && incrementCounter) { dlFileRankLocalService.updateFileRank(fileEntry.getGroupId(), fileEntry.getCompanyId(), userId, fileEntry.getFileEntryId(), new ServiceContext()); } // File read count if (PropsValues.DL_FILE_ENTRY_READ_COUNT_ENABLED && incrementCounter) { assetEntryLocalService.incrementViewCounter(userId, DLFileEntryConstants.getClassName(), fileEntry.getFileEntryId(), 1); List<DLFileShortcut> fileShortcuts = dlFileShortcutPersistence .findByToFileEntryId(fileEntry.getFileEntryId()); for (DLFileShortcut fileShortcut : fileShortcuts) { assetEntryLocalService.incrementViewCounter(userId, DLFileShortcut.class.getName(), fileShortcut.getFileShortcutId(), 1); } } }
From source file:com.liferay.portlet.documentlibrary.service.impl.DLAppHelperLocalServiceImpl.java
License:Open Source License
public void updateStatus(long userId, FileEntry fileEntry, FileVersion latestFileVersion, int status, Map<String, Serializable> workflowContext) throws PortalException, SystemException { if (status == WorkflowConstants.STATUS_APPROVED) { // Asset// www. j a v a 2s .c om String latestFileVersionVersion = latestFileVersion.getVersion(); if (latestFileVersionVersion.equals(fileEntry.getVersion())) { if (!latestFileVersionVersion.equals(DLFileEntryConstants.VERSION_DEFAULT)) { AssetEntry draftAssetEntry = null; try { long fileEntryTypeId = getFileEntryTypeId(fileEntry); draftAssetEntry = assetEntryLocalService.getEntry(DLFileEntryConstants.getClassName(), latestFileVersion.getPrimaryKey()); long[] assetCategoryIds = draftAssetEntry.getCategoryIds(); String[] assetTagNames = draftAssetEntry.getTagNames(); List<AssetLink> assetLinks = assetLinkLocalService .getDirectLinks(draftAssetEntry.getEntryId(), AssetLinkConstants.TYPE_RELATED); long[] assetLinkEntryIds = StringUtil .split(ListUtil.toString(assetLinks, AssetLink.ENTRY_ID2_ACCESSOR), 0L); AssetEntry assetEntry = assetEntryLocalService.updateEntry(userId, fileEntry.getGroupId(), DLFileEntryConstants.getClassName(), fileEntry.getFileEntryId(), fileEntry.getUuid(), fileEntryTypeId, assetCategoryIds, assetTagNames, true, null, null, null, null, draftAssetEntry.getMimeType(), fileEntry.getTitle(), fileEntry.getDescription(), null, null, null, 0, 0, null, false); assetLinkLocalService.updateLinks(userId, assetEntry.getEntryId(), assetLinkEntryIds, AssetLinkConstants.TYPE_RELATED); assetEntryLocalService.deleteEntry(draftAssetEntry.getEntryId()); } catch (NoSuchEntryException nsee) { } } assetEntryLocalService.updateVisible(DLFileEntryConstants.getClassName(), fileEntry.getFileEntryId(), true); } // Sync String event = (String) workflowContext.get("event"); if (!isStagingGroup(fileEntry.getGroupId()) && Validator.isNotNull(event)) { if (event.equals(DLSyncConstants.EVENT_ADD)) { dlSyncLocalService.addSync(fileEntry.getFileEntryId(), fileEntry.getUuid(), fileEntry.getCompanyId(), fileEntry.getRepositoryId(), fileEntry.getFolderId(), fileEntry.getTitle(), DLSyncConstants.TYPE_FILE, fileEntry.getVersion()); } else if (event.equals(DLSyncConstants.EVENT_UPDATE)) { dlSyncLocalService.updateSync(fileEntry.getFileEntryId(), fileEntry.getFolderId(), fileEntry.getTitle(), DLSyncConstants.EVENT_UPDATE, fileEntry.getVersion()); } } // Social int activityType = DLActivityKeys.UPDATE_FILE_ENTRY; if (latestFileVersionVersion.equals(DLFileEntryConstants.VERSION_DEFAULT)) { activityType = DLActivityKeys.ADD_FILE_ENTRY; } socialActivityLocalService.addUniqueActivity(latestFileVersion.getStatusByUserId(), fileEntry.getGroupId(), latestFileVersion.getCreateDate(), DLFileEntryConstants.getClassName(), fileEntry.getFileEntryId(), activityType, StringPool.BLANK, 0); } else { // Asset if (Validator.isNull(fileEntry.getVersion())) { assetEntryLocalService.updateVisible(DLFileEntryConstants.getClassName(), fileEntry.getFileEntryId(), false); } } }