@Test public void testFindByNoAssets() throws Exception { AssetEntryLocalServiceUtil.deleteEntry( DLFileEntry.class.getName(), _defaultRepositoryDLFileVersion.getFileEntryId()); LastSessionRecorderUtil.syncLastSessionState(); List<DLFileEntry> dlFileEntries = DLFileEntryLocalServiceUtil.getNoAssetFileEntries(); Assert.assertEquals(1, dlFileEntries.size()); DLFileEntry dlFileEntry = dlFileEntries.get(0); Assert.assertEquals("FE1.txt", dlFileEntry.getTitle()); }
public AssetEntry incrementViewCounter(AssetEntry assetEntry) throws PortalException { // Dynamically created asset entries are never persisted so incrementing // the view counter breaks if ((assetEntry == null) || assetEntry.isNew() || !assetEntry.isVisible() || !isEnableViewCountIncrement()) { return assetEntry; } if (isEnablePermissions()) { return AssetEntryServiceUtil.incrementViewCounter( assetEntry.getClassName(), assetEntry.getClassPK()); } else { ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); return AssetEntryLocalServiceUtil.incrementViewCounter( themeDisplay.getUserId(), assetEntry.getClassName(), assetEntry.getClassPK()); } }
public static String getSearchResultViewURL( RenderRequest renderRequest, RenderResponse renderResponse, String className, long classPK, boolean viewInContext, String currentURL) throws Exception { try { PortletURL viewContentURL = renderResponse.createRenderURL(); viewContentURL.setParameter("mvcPath", "/view_content.jsp"); viewContentURL.setParameter("redirect", currentURL); viewContentURL.setPortletMode(PortletMode.VIEW); viewContentURL.setWindowState(WindowState.MAXIMIZED); if (Validator.isNull(className) || (classPK <= 0)) { return viewContentURL.toString(); } AssetEntry assetEntry = AssetEntryLocalServiceUtil.getEntry(className, classPK); AssetRendererFactory<?> assetRendererFactory = AssetRendererFactoryRegistryUtil.getAssetRendererFactoryByClassName(className); if (assetRendererFactory == null) { return viewContentURL.toString(); } viewContentURL.setParameter("assetEntryId", String.valueOf(assetEntry.getEntryId())); viewContentURL.setParameter("type", assetRendererFactory.getType()); if (viewInContext) { String viewFullContentURLString = viewContentURL.toString(); viewFullContentURLString = HttpUtil.setParameter(viewFullContentURLString, "redirect", currentURL); AssetRenderer<?> assetRenderer = assetRendererFactory.getAssetRenderer(classPK); String viewURL = assetRenderer.getURLViewInContext( (LiferayPortletRequest) renderRequest, (LiferayPortletResponse) renderResponse, viewFullContentURLString); ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); return AssetUtil.checkViewURL(assetEntry, viewInContext, viewURL, currentURL, themeDisplay); } return viewContentURL.toString(); } catch (Exception e) { _log.error( "Unable to get search result view URL for class " + className + " with primary key " + classPK, e); return ""; } }