001    /**
002     * Copyright (c) 2000-2013 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.portlet.documentlibrary.messaging;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    import com.liferay.portal.kernel.messaging.BaseMessageListener;
020    import com.liferay.portal.kernel.messaging.Message;
021    import com.liferay.portal.kernel.repository.model.FileVersion;
022    import com.liferay.portlet.documentlibrary.util.RawMetadataProcessorUtil;
023    
024    /**
025     * @author Miguel Pastor
026     */
027    public class RawMetadataProcessorMessageListener extends BaseMessageListener {
028    
029            @Override
030            protected void doReceive(Message message) throws Exception {
031                    FileVersion fileVersion = (FileVersion)message.getPayload();
032    
033                    try {
034                            RawMetadataProcessorUtil.saveMetadata(fileVersion);
035                    }
036                    catch (Exception e) {
037                            if (_log.isWarnEnabled()) {
038                                    _log.warn(
039                                            "Unable to save metadata for file version " +
040                                                    fileVersion.getFileVersionId(),
041                                            e);
042                            }
043                    }
044            }
045    
046            private static Log _log = LogFactoryUtil.getLog(
047                    RawMetadataProcessorMessageListener.class);
048    
049    }