/** * Copyright (c) 2000-present Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ package com.liferay.bookmarks.verify; import com.liferay.bookmarks.model.BookmarksEntry; import com.liferay.bookmarks.model.BookmarksFolder; import com.liferay.bookmarks.service.BookmarksEntryLocalService; import com.liferay.bookmarks.service.BookmarksFolderLocalService; import com.liferay.portal.instances.service.PortalInstancesLocalService; import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.util.LoggingTimer; import com.liferay.portal.verify.VerifyProcess; import java.util.List; import org.osgi.service.component.annotations.Reference; /** * @author Raymond Augé * @author Alexander Chow * @deprecated As of 1.1.0, replaced by {@link * com.liferay.bookmarks.internal.verify.BookmarksServiceVerifyProcess} */ @Deprecated public class BookmarksServiceVerifyProcess extends VerifyProcess { @Override protected void doVerify() throws Exception { updateEntryAssets(); updateFolderAssets(); verifyTree(); } @Reference(unbind = "-") protected void setBookmarksEntryLocalService( BookmarksEntryLocalService bookmarksEntryLocalService) { _bookmarksEntryLocalService = bookmarksEntryLocalService; } @Reference(unbind = "-") protected void setBookmarksFolderLocalService( BookmarksFolderLocalService bookmarksFolderLocalService) { _bookmarksFolderLocalService = bookmarksFolderLocalService; } protected void updateEntryAssets() throws Exception { try (LoggingTimer loggingTimer = new LoggingTimer()) { List<BookmarksEntry> entries = _bookmarksEntryLocalService.getNoAssetEntries(); if (_log.isDebugEnabled()) { _log.debug( "Processing " + entries.size() + " entries with no asset"); } for (BookmarksEntry entry : entries) { try { _bookmarksEntryLocalService.updateAsset( entry.getUserId(), entry, null, null, null, null); } catch (Exception e) { if (_log.isWarnEnabled()) { _log.warn( "Unable to update asset for entry " + entry.getEntryId() + ": " + e.getMessage()); } } } if (_log.isDebugEnabled()) { _log.debug("Assets verified for entries"); } } } protected void updateFolderAssets() throws Exception { try (LoggingTimer loggingTimer = new LoggingTimer()) { List<BookmarksFolder> folders = _bookmarksFolderLocalService.getNoAssetFolders(); if (_log.isDebugEnabled()) { _log.debug( "Processing " + folders.size() + " folders with no asset"); } for (BookmarksFolder folder : folders) { try { _bookmarksFolderLocalService.updateAsset( folder.getUserId(), folder, null, null, null, null); } catch (Exception e) { if (_log.isWarnEnabled()) { _log.warn( "Unable to update asset for folder " + folder.getFolderId() + ": " + e.getMessage()); } } } if (_log.isDebugEnabled()) { _log.debug("Assets verified for folders"); } } } protected void verifyTree() throws Exception { try (LoggingTimer loggingTimer = new LoggingTimer()) { long[] companyIds = _portalInstancesLocalService.getCompanyIdsBySQL(); for (long companyId : companyIds) { _bookmarksFolderLocalService.rebuildTree(companyId); } } } private static final Log _log = LogFactoryUtil.getLog( BookmarksServiceVerifyProcess.class); private BookmarksEntryLocalService _bookmarksEntryLocalService; private BookmarksFolderLocalService _bookmarksFolderLocalService; @Reference private PortalInstancesLocalService _portalInstancesLocalService; }