001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.verify;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    import com.liferay.portlet.documentlibrary.model.DLFileEntry;
020    import com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil;
021    
022    import java.util.List;
023    
024    /**
025     * @author Raymond Augé
026     */
027    public class VerifyDocumentLibrary extends VerifyProcess {
028    
029            protected void doVerify() throws Exception {
030                    List<DLFileEntry> fileEntries =
031                            DLFileEntryLocalServiceUtil.getNoAssetFileEntries();
032    
033                    if (_log.isDebugEnabled()) {
034                            _log.debug(
035                                    "Processing " + fileEntries.size() +
036                                            " file entries with no asset");
037                    }
038    
039                    for (DLFileEntry fileEntry : fileEntries) {
040                            try {
041                                    DLFileEntryLocalServiceUtil.updateAsset(
042                                            fileEntry.getUserId(), fileEntry, null, null, null);
043                            }
044                            catch (Exception e) {
045                                    if (_log.isWarnEnabled()) {
046                                            _log.warn(
047                                                    "Unable to update asset for file entry " +
048                                                            fileEntry.getFileEntryId() + ": " + e.getMessage());
049                                    }
050                            }
051                    }
052    
053                    if (_log.isDebugEnabled()) {
054                            _log.debug("Assets verified for file entries");
055                    }
056            }
057    
058            private static Log _log = LogFactoryUtil.getLog(
059                    VerifyDocumentLibrary.class);
060    
061    }