public void redeployModule(IModule[] module) { setModulePublishState(module, IServer.PUBLISH_STATE_FULL); IAdaptable info = new IAdaptable() { public Object getAdapter(Class adapter) { if (String.class.equals(adapter)) { return "user"; //$NON-NLS-1$ } return null; } }; final List<IModule[]> modules = new ArrayList<IModule[]>(); modules.add(module); try { redeployModules = modules; publish(IServer.PUBLISH_FULL, modules, null, info); } catch (CoreException e) { LiferayTomcatPlugin.logError("redploying module " + module[0].getName() + " failed.", e); } finally { redeployModules = null; } }
private void publishDir(IModule module2, List status, IProgressMonitor monitor) throws CoreException { IPath path = server.getModuleDeployDirectory(module2); // Remove if requested or if previously published and are now serving without publishing if (kind == IServer.PUBLISH_CLEAN || deltaKind == ServerBehaviourDelegate.REMOVED || server.getTomcatServer().isServeModulesWithoutPublish()) { File f = path.toFile(); if (f.exists()) { try { IPath baseDir = server.getRuntimeBaseDirectory(); IPath serverXml = baseDir.append("conf").append("server.xml"); // $NON-NLS-1$ //$NON-NLS-2$ ServerInstance oldInstance = TomcatVersionHelper.getCatalinaServerInstance(serverXml, null, null); IPath contextDir = oldInstance.getContextXmlDirectory(baseDir.append("conf")); // $NON-NLS-1$ String contextFileName = path.lastSegment() + ".xml"; // $NON-NLS-1$ File contextFile = contextDir.append(contextFileName).toFile(); if (contextFile.exists()) { contextFile.delete(); } File autoDeployDir = baseDir.append(server.getLiferayTomcatServer().getAutoDeployDirectory()).toFile(); File autoDeployFile = new File(autoDeployDir, contextFileName); if (autoDeployFile.exists()) { autoDeployFile.delete(); } } catch (Exception e) { LiferayTomcatPlugin.logError("Could not delete context xml file.", e); // $NON-NLS-1$ } IStatus[] stat = PublishHelper.deleteDirectory(f, monitor); addArrayToList(status, stat); } if (deltaKind == ServerBehaviourDelegate.REMOVED || server.getTomcatServer().isServeModulesWithoutPublish()) return; } IPath baseDir = server.getTomcatServer().getRuntimeBaseDirectory(); IPath autoDeployDir = new Path(server.getLiferayTomcatServer().getAutoDeployDirectory()); boolean serverStopped = server.getServer().getServerState() == IServer.STATE_STOPPED; if (kind == IServer.PUBLISH_CLEAN || kind == IServer.PUBLISH_FULL) { IModuleResource[] mr = server.getResources(module); IStatus[] stat = helper.publishFull(mr, path, monitor); addArrayToList(status, stat); clearWebXmlDescriptors(module2.getProject(), path, monitor); server.moveContextToAutoDeployDir(module2, path, baseDir, autoDeployDir, true, serverStopped); return; } IModuleResourceDelta[] delta = server.getPublishedResourceDelta(module); int size = delta.length; for (int i = 0; i < size; i++) { IStatus[] stat = helper.publishDelta(delta[i], path, monitor); addArrayToList(status, stat); } // check to see if we need to re-invoke the liferay plugin deployer String[] paths = new String[] { WEB_XML_PATH, "WEB-INF/portlet.xml", "WEB-INF/liferay-portlet.xml", //$NON-NLS-1$ //$NON-NLS-2$ "WEB-INF/liferay-display.xml", "WEB-INF/liferay-look-and-feel.xml", "WEB-INF/liferay-hook.xml", //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ "WEB-INF/liferay-layout-templates.xml", "WEB-INF/liferay-plugin-package.properties", //$NON-NLS-1$//$NON-NLS-2$ "WEB-INF/liferay-plugin-package.xml", "WEB-INF/server-config.wsdd", }; //$NON-NLS-1$ //$NON-NLS-2$ for (IModuleResourceDelta del : delta) { if (CoreUtil.containsMember(del, paths) || isHookProjectDelta(del)) { clearWebXmlDescriptors(module2.getProject(), path, monitor); server.moveContextToAutoDeployDir( module2, path, baseDir, autoDeployDir, true, serverStopped); break; } } }