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.calendar.model.CalEvent;
020    import com.liferay.portlet.calendar.service.CalEventLocalServiceUtil;
021    
022    import java.util.List;
023    
024    /**
025     * @author Juan Fernández
026     */
027    public class VerifyCalendar extends VerifyProcess {
028    
029            protected void doVerify() throws Exception {
030                    List<CalEvent> events = CalEventLocalServiceUtil.getNoAssetEvents();
031    
032                    if (_log.isDebugEnabled()) {
033                            _log.debug(
034                                    "Processing " + events.size() + " events with no asset");
035                    }
036    
037                    for (CalEvent event : events) {
038                            try {
039                                    CalEventLocalServiceUtil.updateAsset(
040                                            event.getUserId(), event, null, null);
041                            }
042                            catch (Exception e) {
043                                    if (_log.isWarnEnabled()) {
044                                            _log.warn(
045                                                    "Unable to update asset for event " +
046                                                            event.getEventId() + ": " + e.getMessage());
047                                    }
048                            }
049                    }
050    
051                    if (_log.isDebugEnabled()) {
052                            _log.debug("Assets verified for events");
053                    }
054    
055            }
056    
057            private static Log _log = LogFactoryUtil.getLog(VerifyCalendar.class);
058    
059    }