List of usage examples for com.liferay.portal.util PropsValues ASSET_FILTER_SEARCH_LIMIT
int ASSET_FILTER_SEARCH_LIMIT
To view the source code for com.liferay.portal.util PropsValues ASSET_FILTER_SEARCH_LIMIT.
Click Source Link
From source file:com.liferay.portlet.asset.service.impl.AssetEntryServiceImpl.java
License:Open Source License
protected Object[] filterQuery(AssetEntryQuery entryQuery) throws PortalException, SystemException { ThreadLocalCache<Object[]> threadLocalCache = ThreadLocalCacheManager.getThreadLocalCache(Lifecycle.REQUEST, AssetEntryServiceImpl.class.getName()); String key = entryQuery.toString(); Object[] results = threadLocalCache.get(key); if (results != null) { return results; }// w w w. j a v a2 s .c om int end = entryQuery.getEnd(); int start = entryQuery.getStart(); if (entryQuery.isEnablePermissions()) { entryQuery.setEnd(end + PropsValues.ASSET_FILTER_SEARCH_LIMIT); entryQuery.setStart(0); } List<AssetEntry> entries = assetEntryLocalService.getEntries(entryQuery); List<AssetEntry> filteredEntries = null; int filteredEntriesCount = 0; if (entryQuery.isEnablePermissions()) { PermissionChecker permissionChecker = getPermissionChecker(); filteredEntries = new ArrayList<AssetEntry>(); for (AssetEntry entry : entries) { String className = entry.getClassName(); long classPK = entry.getClassPK(); AssetRendererFactory assetRendererFactory = AssetRendererFactoryRegistryUtil .getAssetRendererFactoryByClassName(className); try { if (assetRendererFactory.hasPermission(permissionChecker, classPK, ActionKeys.VIEW)) { filteredEntries.add(entry); } } catch (Exception e) { } if (filteredEntries.size() > end) { break; } } filteredEntriesCount = filteredEntries.size(); if ((end != QueryUtil.ALL_POS) && (start != QueryUtil.ALL_POS)) { if (end > filteredEntriesCount) { end = filteredEntriesCount; } if (start > filteredEntriesCount) { start = filteredEntriesCount; } filteredEntries = filteredEntries.subList(start, end); } entryQuery.setEnd(end); entryQuery.setStart(start); } else { filteredEntries = entries; filteredEntriesCount = entries.size(); } results = new Object[] { filteredEntries, filteredEntriesCount }; threadLocalCache.put(key, results); return results; }