List of usage examples for com.liferay.portal.kernel.deploy.auto AutoDeployException AutoDeployException
public AutoDeployException(Throwable cause)
From source file:com.liferay.marketplace.bundle.BundleManager.java
License:Open Source License
protected String getInstallDirName() throws Exception { String[] autoDeployDirNames = PropsUtil.getArray(PropsKeys.MODULE_FRAMEWORK_AUTO_DEPLOY_DIRS); if (ArrayUtil.isEmpty(autoDeployDirNames)) { throw new AutoDeployException( "The portal property \"" + PropsKeys.MODULE_FRAMEWORK_AUTO_DEPLOY_DIRS + "\" is not set"); }/*w ww . jav a 2 s . c o m*/ String autoDeployDirName = autoDeployDirNames[0]; for (String curDirName : autoDeployDirNames) { if (curDirName.endsWith("/marketplace")) { autoDeployDirName = curDirName; break; } } return autoDeployDirName; }
From source file:com.sqli.liferay.imex.portal.kernel.deploy.auto.ImExAutoDeployListener.java
License:Open Source License
public void deploy(File file, String context) throws AutoDeployException { Properties config = new Properties(); try {/*from w w w . ja va 2s . c o m*/ FileReader fileReader = new FileReader(file); config.load(fileReader); fileReader.close(); } catch (FileNotFoundException e) { throw new AutoDeployException(e); } catch (IOException e) { throw new AutoDeployException(e); } String fileName = file.getName().toLowerCase(); if (fileName.endsWith(".import.properties")) { LOG.info("Import started for " + file); createTempFolder(); try { File data = getImportDataDir(file); processImport(config, data); } catch (Exception e) { throw new AutoDeployException(e); } finally { deleteTempFolder(); } LOG.info("Import finished for " + file); } else if (fileName.endsWith(".export.properties")) { LOG.info("Export started for " + file); File data = getExportDataDir(file); processExport(data, file); ZipUtils zipUtils = new ZipUtils(LOG); try { zipUtils.zipFiles(new File(data.getParent(), data.getName() + ".imex.zip"), data); } catch (IOException e) { throw new AutoDeployException(); } LOG.info("Export finished for " + file); } try { FileUtil.copyFile(file, new File(file.getParentFile(), file.getName() + ".done")); } catch (IOException e) { LOG.error(e, e); throw new AutoDeployException(); } }
From source file:com.sqli.liferay.imex.portal.kernel.deploy.auto.ImExAutoDeployListener.java
License:Open Source License
private void processImport(Properties config, File data) throws AutoDeployException { try {/*from w w w .java2 s . c o m*/ new Importer().doImport(data, config); //ImExLocalServiceUtil.doImport(data); } catch (Exception e) { throw new AutoDeployException(e); } }
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);/*from w ww . jav 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); } }
From source file:com.sqli.liferay.imex.portal.kernel.deploy.auto.ImExAutoDeployListener.java
License:Open Source License
private File getImportDataDir(File configFile) throws Exception { File parent = configFile.getParentFile(); String basename = configFile.getName(); basename = basename.substring(0, basename.indexOf('.')); File dataDir = null;/*from w w w. j a v a 2s.c o m*/ for (String ext : DATADIR_EXTENSIONS) { String name = basename + ext; dataDir = new File(parent, name); if (dataDir.exists() && dataDir.isDirectory()) { break; } else { dataDir = null; } } if (dataDir == null) { File zipFile = null; for (String ext : ZIPFILE_EXTENSIONS) { String name = basename + ext; zipFile = new File(parent, name); if (zipFile.exists() && zipFile.isFile()) { break; } else { zipFile = null; } } if (zipFile == null) { throw new AutoDeployException("No data found to import for config file " + configFile); } else { dataDir = new File(this.temp.get(), zipFile.getName()); ZipUtils zipUtils = new ZipUtils(LOG); zipUtils.unzipArchive(zipFile, dataDir); } } return dataDir; }