001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.deploy.auto;
016    
017    import com.liferay.portal.kernel.deploy.auto.AutoDeployException;
018    import com.liferay.portal.kernel.deploy.auto.BaseAutoDeployListener;
019    import com.liferay.portal.kernel.deploy.auto.context.AutoDeploymentContext;
020    import com.liferay.portal.kernel.log.Log;
021    import com.liferay.portal.kernel.log.LogFactoryUtil;
022    
023    import java.io.File;
024    
025    /**
026     * @author Ivica Cardic
027     * @author Brian Wing Shun Chan
028     */
029    public class ThemeAutoDeployListener extends BaseAutoDeployListener {
030    
031            public ThemeAutoDeployListener() {
032                    _autoDeployer = new ThemeAutoDeployer();
033            }
034    
035            public void deploy(AutoDeploymentContext autoDeploymentContext)
036                    throws AutoDeployException {
037    
038                    File file = autoDeploymentContext.getFile();
039    
040                    if (_log.isDebugEnabled()) {
041                            _log.debug("Invoking deploy for " + file.getPath());
042                    }
043    
044                    if (!isThemePlugin(file)) {
045                            return;
046                    }
047    
048                    if (_log.isInfoEnabled()) {
049                            _log.info("Copying themes for " + file.getPath());
050                    }
051    
052                    int code = _autoDeployer.autoDeploy(autoDeploymentContext);
053    
054                    if ((code == AutoDeployer.CODE_DEFAULT) && _log.isInfoEnabled()) {
055                            _log.info(
056                                    "Themes for " + file.getPath() + " copied successfully. " +
057                                            "Deployment will start in a few seconds.");
058                    }
059            }
060    
061            private static Log _log = LogFactoryUtil.getLog(
062                    ThemeAutoDeployListener.class);
063    
064            private AutoDeployer _autoDeployer;
065    
066    }