001    /**
002     * Copyright (c) 2000-present 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.AutoDeployer;
019    import com.liferay.portal.kernel.deploy.auto.context.AutoDeploymentContext;
020    import com.liferay.portal.kernel.util.FileUtil;
021    import com.liferay.portal.tools.deploy.BaseDeployer;
022    import com.liferay.portal.util.PropsValues;
023    
024    import java.io.File;
025    import java.io.IOException;
026    
027    import org.apache.commons.io.FileUtils;
028    
029    /**
030     * @author Miguel Pastor
031     */
032    public class ModuleAutoDeployer extends BaseDeployer {
033    
034            @Override
035            public int deployFile(AutoDeploymentContext autoDeploymentContext)
036                    throws Exception {
037    
038                    String destDir = PropsValues.MODULE_FRAMEWORK_AUTO_DEPLOY_DIRS[0];
039    
040                    FileUtil.mkdirs(destDir);
041    
042                    try {
043                            FileUtils.copyFileToDirectory(
044                                    autoDeploymentContext.getFile(), new File(destDir));
045                    }
046                    catch (IOException ioe) {
047                            throw new AutoDeployException(ioe);
048                    }
049    
050                    return AutoDeployer.CODE_DEFAULT;
051            }
052    
053    }