List of usage examples for com.liferay.portal.kernel.util FileUtil deltree
public static void deltree(String directory)
From source file:com.liferay.content.targeting.benchmark.tools.CTSampleSQLBuilder.java
License:Open Source License
public CTSampleSQLBuilder(Properties properties, DataFactory dataFactory) throws Exception { new SampleSQLBuilder(properties, dataFactory); String portalOutputDir = properties.getProperty("sample.sql.output.dir"); File output = new File(portalOutputDir, "plugin"); FileUtil.deltree(output); output.mkdirs();/*from w ww . java2 s . c om*/ properties.put("sample.sql.output.dir", output.getPath()); properties.put("sample.sql.output.csv.file.names", "ct"); properties.put("sample.sql.script", "com/liferay/content/targeting/benchmark/tools/dependencies/" + "ct.ftl"); new SampleSQLBuilder(properties, dataFactory); String dbType = properties.getProperty("sample.sql.db.type"); String sqlDir = properties.getProperty("sql.dir"); buildPluginSqls(dbType, sqlDir, output); }
From source file:com.liferay.content.targeting.tools.CTSampleSQLBuilder.java
License:Open Source License
public CTSampleSQLBuilder(Properties properties, DataFactory dataFactory) throws Exception { new SampleSQLBuilder(properties, dataFactory); String portalOutputDir = properties.getProperty("sample.sql.output.dir"); File output = new File(portalOutputDir, "plugin"); FileUtil.deltree(output); output.mkdirs();// w w w . j a v a 2 s . c om properties.put("sample.sql.output.dir", output.getPath()); properties.put("sample.sql.output.csv.file.names", "ct,layout"); properties.put("sample.sql.script", "com/liferay/content/targeting/tools/dependencies/ct.ftl"); new SampleSQLBuilder(properties, dataFactory); String dbType = properties.getProperty("sample.sql.db.type"); String sqlDir = properties.getProperty("sql.dir"); buildPluginSqls(dbType, sqlDir, output); }
From source file:com.liferay.httpservice.internal.servlet.BundleServletContext.java
License:Open Source License
public void close() { _httpServiceTracker.close(); _serviceRegistration.unregister(); FileUtil.deltree(_tempDir); }
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(); }/* w ww. j a v a 2 s .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.portlet.documentlibrary.store.FileSystemStore.java
License:Open Source License
@Override public void deleteDirectory(long companyId, long repositoryId, String dirName) throws PortalException { File dirNameDir = getDirNameDir(companyId, repositoryId, dirName); if (!dirNameDir.exists()) { throw new NoSuchDirectoryException(dirNameDir.getPath()); }// w w w .j a v a 2s . co m File parentFile = dirNameDir.getParentFile(); FileUtil.deltree(dirNameDir); RepositoryDirKey repositoryDirKey = new RepositoryDirKey(companyId, repositoryId); _repositoryDirs.remove(repositoryDirKey); deleteEmptyAncestors(parentFile); }
From source file:com.liferay.portlet.documentlibrary.store.FileSystemStore.java
License:Open Source License
@Override public void deleteFile(long companyId, long repositoryId, String fileName) throws PortalException { File fileNameDir = getFileNameDir(companyId, repositoryId, fileName); if (!fileNameDir.exists()) { throw new NoSuchFileException(fileNameDir.getPath()); }//from ww w . ja v a2s . c o m File parentFile = fileNameDir.getParentFile(); FileUtil.deltree(fileNameDir); deleteEmptyAncestors(companyId, repositoryId, parentFile); }
From source file:com.liferay.rtl.scripting.ruby.RubyExecutor.java
License:Open Source License
protected void initRubyGems() throws Exception { File rubyGemsJarFile = new File(PropsValues.LIFERAY_LIB_PORTAL_DIR, "ruby-gems.jar"); if (!rubyGemsJarFile.exists()) { if (_log.isWarnEnabled()) { _log.warn(rubyGemsJarFile + " does not exist"); }/* ww w. ja v a 2 s. co m*/ return; } String tmpDir = SystemProperties.get(SystemProperties.TMP_DIR); File rubyDir = new File(tmpDir + "/liferay/ruby"); if (!rubyDir.exists() || (rubyDir.lastModified() < rubyGemsJarFile.lastModified())) { FileUtil.deltree(rubyDir); rubyDir.mkdirs(); ZipUtil.unzip(rubyGemsJarFile, rubyDir); rubyDir.setLastModified(rubyGemsJarFile.lastModified()); } }
From source file:com.sqli.liferay.imex.portal.kernel.deploy.auto.ImExAutoDeployListener.java
License:Open Source License
private void createTempFolder() { File tempFolder = temp.get(); if (tempFolder != null) { FileUtil.deltree(tempFolder); } else {/*ww w .j av a2 s .c o m*/ String basepath = System.getProperty("java.io.tmpdir"); tempFolder = new File(basepath + "/" + UUID.randomUUID().toString()); LOG.info("java.io.temp.dir=" + basepath); LOG.info("ImEx temp folder: " + tempFolder); } tempFolder.mkdirs(); tempFolder.deleteOnExit(); }
From source file:com.sqli.liferay.imex.portal.kernel.deploy.auto.ImExAutoDeployListener.java
License:Open Source License
private void deleteTempFolder() { File tempFolder = temp.get(); if (tempFolder != null && tempFolder.exists()) { FileUtil.deltree(tempFolder); } }
From source file:com.sqli.liferay.imex.portal.kernel.deploy.auto.ImExAutoDeployListener.java
License:Open Source License
private void processExport(File data, File config) throws AutoDeployException { if (data.exists()) { FileUtil.deltree(data); }// w ww.j av a 2 s . co m boolean success = data.mkdirs(); if (!success) { throw new AutoDeployException("Failed to create directory " + data); } try { Properties props = new Properties(); props.load(new FileReader(config)); //ImExLocalServiceUtil.doExport(data, config); new Exporter().doExport(data, props); } catch (Exception e) { throw new AutoDeployException(e); } }