List of usage examples for com.liferay.portal.kernel.deploy.auto.context AutoDeploymentContext AutoDeploymentContext
AutoDeploymentContext
From source file:com.liferay.marketplace.service.impl.AppLocalServiceImpl.java
License:Open Source License
@Override public void installApp(long remoteAppId) throws PortalException { App app = appPersistence.findByRemoteAppId(remoteAppId); if (!DLStoreUtil.hasFile(app.getCompanyId(), CompanyConstants.SYSTEM, app.getFilePath())) { throw new NoSuchFileException(); }//from w ww.j a va 2s. c om String tmpDir = SystemProperties.get(SystemProperties.TMP_DIR) + StringPool.SLASH + Time.getTimestamp(); InputStream inputStream = null; ZipFile zipFile = null; try { inputStream = DLStoreUtil.getFileAsStream(app.getCompanyId(), CompanyConstants.SYSTEM, app.getFilePath()); if (inputStream == null) { throw new IOException("Unable to open file at " + app.getFilePath()); } File liferayPackageFile = FileUtil.createTempFile(inputStream); zipFile = new ZipFile(liferayPackageFile); Enumeration<ZipEntry> enu = (Enumeration<ZipEntry>) zipFile.entries(); while (enu.hasMoreElements()) { ZipEntry zipEntry = enu.nextElement(); String fileName = zipEntry.getName(); if (!fileName.endsWith(".jar") && !fileName.endsWith(".war") && !fileName.endsWith(".xml") && !fileName.endsWith(".zip") && !fileName.equals("liferay-marketplace.properties")) { continue; } if (_log.isInfoEnabled()) { _log.info("Extracting " + fileName + " from app " + app.getAppId()); } InputStream zipInputStream = null; try { zipInputStream = zipFile.getInputStream(zipEntry); if (fileName.equals("liferay-marketplace.properties")) { String propertiesString = StringUtil.read(zipInputStream); Properties properties = PropertiesUtil.load(propertiesString); processMarketplaceProperties(properties); } else { File pluginPackageFile = new File(tmpDir + StringPool.SLASH + fileName); FileUtil.write(pluginPackageFile, zipInputStream); String bundleSymbolicName = StringPool.BLANK; String bundleVersion = StringPool.BLANK; String contextName = StringPool.BLANK; AutoDeploymentContext autoDeploymentContext = new AutoDeploymentContext(); if (fileName.endsWith(".jar")) { Manifest manifest = BundleUtil.getManifest(pluginPackageFile); Attributes attributes = manifest.getMainAttributes(); bundleSymbolicName = GetterUtil.getString(attributes.getValue("Bundle-SymbolicName")); bundleVersion = GetterUtil.getString(attributes.getValue("Bundle-Version")); contextName = GetterUtil.getString(attributes.getValue("Web-ContextPath")); } else { contextName = getContextName(fileName); autoDeploymentContext.setContext(contextName); } autoDeploymentContext.setFile(pluginPackageFile); DeployManagerUtil.deploy(autoDeploymentContext); if (Validator.isNotNull(bundleSymbolicName) || Validator.isNotNull(contextName)) { moduleLocalService.addModule(app.getUserId(), app.getAppId(), bundleSymbolicName, bundleVersion, contextName); } } } finally { StreamUtil.cleanUp(zipInputStream); } } } catch (ZipException ze) { if (_log.isInfoEnabled()) { _log.info("Deleting corrupt package from app " + app.getAppId(), ze); } deleteApp(app); } catch (IOException ioe) { throw new PortalException(ioe.getMessage()); } catch (Exception e) { _log.error(e, e); } finally { FileUtil.deltree(tmpDir); if (zipFile != null) { try { zipFile.close(); } catch (IOException ioe) { } } StreamUtil.cleanUp(inputStream); clearInstalledAppsCache(); } }
From source file:com.liferay.server.manager.internal.executor.PluginExecutor.java
License:Open Source License
@Override public void executeCreate(HttpServletRequest request, JSONObject responseJSONObject, Queue<String> arguments) throws Exception { AutoDeploymentContext autoDeploymentContext = new AutoDeploymentContext(); String context = arguments.poll(); autoDeploymentContext.setContext(context); File tempFile = getTempFile(request, responseJSONObject); if (tempFile == null) { return;// w ww . j a va2 s . c o m } autoDeploymentContext.setFile(tempFile); DeployManagerUtil.deploy(autoDeploymentContext); boolean success = FileUtils.deleteQuietly(tempFile.getParentFile()); if (success) { return; } String message = "Unable to remove temp directory " + tempFile.getParentFile(); _log.error(message); responseJSONObject.put(JSONKeys.ERROR, message); success = FileUtils.deleteQuietly(tempFile); if (success) { return; } message = "Unable to remove temp file " + tempFile; _log.error(message); responseJSONObject.put(JSONKeys.ERROR, message); }
From source file:org.mimacom.commons.liferay.adapter612.LiferayToolsImpl.java
License:Apache License
public void deployLayout(String serverType, File sourceDir) throws Exception { AutoDeploymentContext autoDeploymentContext = new AutoDeploymentContext(); String context = System.getProperty("deployer.context"); autoDeploymentContext.setContext(context); autoDeploymentContext.setFile(sourceDir); new StandaloneLayoutDeployer(serverType).deployFile(autoDeploymentContext); }
From source file:org.mimacom.commons.liferay.adapter612.LiferayToolsImpl.java
License:Apache License
public void deployPortlet(String version, String serverType, File sourceDir) throws Exception { AutoDeploymentContext autoDeploymentContext = new AutoDeploymentContext(); String context = System.getProperty("deployer.context"); autoDeploymentContext.setContext(context); autoDeploymentContext.setFile(sourceDir); new StandalonePortletDeployer(version, serverType).deployFile(autoDeploymentContext); }
From source file:org.mimacom.commons.liferay.adapter612.LiferayToolsImpl.java
License:Apache License
public void deployTheme(String serverType, File sourceDir) throws Exception { AutoDeploymentContext autoDeploymentContext = new AutoDeploymentContext(); String context = System.getProperty("deployer.context"); autoDeploymentContext.setContext(context); autoDeploymentContext.setFile(sourceDir); new StandaloneThemeDeployer(serverType).deployFile(autoDeploymentContext); }
From source file:org.mimacom.commons.liferay.adapter612.LiferayToolsImpl.java
License:Apache License
public void deployHook(String serverType, File sourceDir) throws Exception { AutoDeploymentContext autoDeploymentContext = new AutoDeploymentContext(); String context = System.getProperty("deployer.context"); autoDeploymentContext.setContext(context); autoDeploymentContext.setFile(sourceDir); new StandaloneHookDeployer(serverType).deployFile(autoDeploymentContext); }