001    /**
002     * Copyright (c) 2000-2013 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.sandbox;
016    
017    import com.liferay.portal.kernel.deploy.sandbox.SandboxDeployException;
018    import com.liferay.portal.kernel.deploy.sandbox.SandboxDeployListener;
019    import com.liferay.portal.kernel.util.ServerDetector;
020    import com.liferay.portal.tools.deploy.PortletDeployer;
021    import com.liferay.portal.util.PortalUtil;
022    
023    import java.io.File;
024    
025    import java.util.ArrayList;
026    
027    /**
028     * @author Igor Spasic
029     * @author Brian Wing Shun Chan
030     */
031    public class PortletSandboxDeployListener
032            extends PortletDeployer implements SandboxDeployListener {
033    
034            public PortletSandboxDeployListener() {
035                    _sandboxHandler = new PortletSandboxHandler(this);
036    
037                    appServerType = ServerDetector.getServerId();
038    
039                    String portalWebDir = PortalUtil.getPortalWebDir();
040    
041                    auiTaglibDTD = portalWebDir + "/WEB-INF/tld/aui.tld";
042                    portletTaglibDTD = portalWebDir + "/WEB-INF/tld/liferay-portlet.tld";
043                    portletExtTaglibDTD =
044                            portalWebDir + "/WEB-INF/tld/liferay-portlet-ext.tld";
045                    securityTaglibDTD = portalWebDir + "/WEB-INF/tld/liferay-security.tld";
046                    themeTaglibDTD = portalWebDir + "/WEB-INF/tld/liferay-theme.tld";
047                    uiTaglibDTD = portalWebDir + "/WEB-INF/tld/liferay-ui.tld";
048                    utilTaglibDTD = portalWebDir + "/WEB-INF/tld/liferay-util.tld";
049    
050                    jars = new ArrayList<String>();
051    
052                    String portalLibDir = PortalUtil.getPortalLibDir();
053    
054                    jars.add(portalLibDir + "/commons-logging.jar");
055                    jars.add(portalLibDir + "/log4j.jar");
056                    jars.add(portalLibDir + "/util-bridges.jar");
057                    jars.add(portalLibDir + "/util-java.jar");
058                    jars.add(portalLibDir + "/util-taglib.jar");
059            }
060    
061            @Override
062            public void deploy(File dir) throws SandboxDeployException {
063                    _sandboxHandler.deploy(dir);
064            }
065    
066            @Override
067            public String getDisplayName(File srcFile) {
068                    String displayName = super.getDisplayName(srcFile);
069    
070                    return _sandboxHandler.getDisplayName(displayName);
071            }
072    
073            @Override
074            public void undeploy(File dir) throws SandboxDeployException {
075                    _sandboxHandler.undeploy(dir);
076            }
077    
078            private SandboxHandler _sandboxHandler;
079    
080    }