List of usage examples for org.apache.commons.vfs VFS getManager
public static synchronized FileSystemManager getManager() throws FileSystemException
From source file:org.jahia.configuration.configurators.JackrabbitConfiguratorTest.java
public void testUpdateConfiguration() throws Exception { URL repositoryURL = this.getClass().getClassLoader() .getResource("configurators/WEB-INF/etc/repository/jackrabbit/repository.xml"); FileSystemManager fsManager = VFS.getManager(); AbstractLogger logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO); File repositoryFile = new File(repositoryURL.getFile()); String repositoryFileParentPath = repositoryFile.getParentFile().getPath() + File.separator; oracleDBProperties.setProperty("storeFilesInDB", "true"); JackrabbitConfigurator websphereOracleJackrabbitConfigurator = new JackrabbitConfigurator( oracleDBProperties, websphereOracleConfigBean, logger); websphereOracleJackrabbitConfigurator.updateConfiguration( new VFSConfigFile(fsManager, repositoryURL.toExternalForm()), repositoryFileParentPath + "repository-modified.xml"); // The following tests are NOT exhaustive SAXBuilder saxBuilder = new SAXBuilder(); saxBuilder.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); Document jdomDocument = saxBuilder.build(repositoryFileParentPath + "repository-modified.xml"); String prefix = ""; String tagPre = ("".equals(prefix) ? "" : prefix + ":"); assertAllTextEquals(jdomDocument, "//param[@name=\"databaseType\"]/@value", prefix, oracleDBProperties.getProperty("jahia.jackrabbit.schema")); checkOnlyOneElement(jdomDocument, "//Cluster/Journal", prefix); checkOnlyOneElement(jdomDocument, "/Repository/Cluster/Journal/param[@name=\"janitorEnabled\"]", prefix); assertAllTextEquals(jdomDocument, "//param[@name=\"externalBLOBs\"]/@value", prefix, "false"); assertAllTextEquals(jdomDocument, "/Repository/FileSystem/@class", prefix, oracleDBProperties.getProperty("jahia.jackrabbit.filesystem")); assertAllTextEquals(jdomDocument, "//PersistenceManager/@class", prefix, oracleDBProperties.getProperty("jahia.jackrabbit.persistence")); mysqlDBProperties.setProperty("storeFilesInDB", "false"); JackrabbitConfigurator tomcatMySQLJackrabbitConfigurator = new JackrabbitConfigurator(mysqlDBProperties, tomcatMySQLConfigBean, logger); tomcatMySQLJackrabbitConfigurator.updateConfiguration( new VFSConfigFile(fsManager, repositoryFileParentPath + "repository-modified.xml"), repositoryFileParentPath + "repository-modified2.xml"); // The following tests are NOT exhaustive saxBuilder = new SAXBuilder(); saxBuilder.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); jdomDocument = saxBuilder.build(repositoryFileParentPath + "repository-modified2.xml"); assertAllTextEquals(jdomDocument, "//param[@name=\"databaseType\"]/@value", prefix, mysqlDBProperties.getProperty("jahia.jackrabbit.schema")); assertNotNull(getNode(jdomDocument, "//Cluster/Journal", prefix)); assertAllTextEquals(jdomDocument, "/Repository/FileSystem/@class", prefix, mysqlDBProperties.getProperty("jahia.jackrabbit.filesystem")); assertAllTextEquals(jdomDocument, "//PersistenceManager/@class", prefix, mysqlDBProperties.getProperty("jahia.jackrabbit.persistence")); new JackrabbitConfigurator(mysqlDBProperties, tomcatMySQLConfigBean, logger).updateConfiguration( new VFSConfigFile(fsManager, repositoryFileParentPath + "repository-modified2.xml"), repositoryFileParentPath + "repository-modified-store.xml"); saxBuilder = new SAXBuilder(); saxBuilder.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); jdomDocument = saxBuilder.build(repositoryFileParentPath + "repository-modified-store.xml"); assertTrue(XPath/*from w ww. jav a 2 s . c om*/ .selectNodes(jdomDocument, "//Repository/DataStore[@class=\"org.apache.jackrabbit.core.data.db.DbDataStore\"]") .isEmpty()); assertNotNull(XPath.selectSingleNode(jdomDocument, "//Repository/DataStore[@class=\"org.apache.jackrabbit.core.data.FileDataStore\"]")); mysqlDBProperties.setProperty("storeFilesInDB", "true"); new JackrabbitConfigurator(mysqlDBProperties, tomcatMySQLConfigBean, logger).updateConfiguration( new VFSConfigFile(fsManager, repositoryFileParentPath + "repository-modified-store.xml"), repositoryFileParentPath + "repository-modified-store-db.xml"); saxBuilder = new SAXBuilder(); saxBuilder.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); jdomDocument = saxBuilder.build(repositoryFileParentPath + "repository-modified-store-db.xml"); assertTrue(XPath .selectNodes(jdomDocument, "//Repository/DataStore[@class=\"org.apache.jackrabbit.core.data.FileDataStore\"]") .isEmpty()); assertNotNull(XPath.selectSingleNode(jdomDocument, "//Repository/DataStore[@class=\"org.apache.jackrabbit.core.data.db.DbDataStore\"]")); }
From source file:org.jahia.configuration.configurators.JahiaGlobalConfigurator.java
private void updateConfigurationFiles(String sourceWebAppPath, String webappPath, Properties dbProps, JahiaConfigInterface jahiaConfigInterface) throws Exception { getLogger().info("Configuring file using source " + sourceWebAppPath + " to target " + webappPath); FileSystemManager fsManager = VFS.getManager(); new JackrabbitConfigurator(dbProps, jahiaConfigInterface, getLogger()).updateConfiguration( new VFSConfigFile(fsManager, sourceWebAppPath + "/WEB-INF/etc/repository/jackrabbit/repository.xml"), webappPath + "/WEB-INF/etc/repository/jackrabbit/repository.xml"); new TomcatContextXmlConfigurator(dbProps, jahiaConfigInterface).updateConfiguration( new VFSConfigFile(fsManager, sourceWebAppPath + "/META-INF/context.xml"), webappPath + "/META-INF/context.xml"); String rootUserTemplate = sourceWebAppPath + "/WEB-INF/etc/repository/template-root-user.xml"; FileObject rootUserTemplateFile = fsManager.resolveFile(rootUserTemplate); if (rootUserTemplateFile.exists()) { if (Boolean.valueOf(jahiaConfigInterface.getProcessingServer())) { new RootUserConfigurator(dbProps, jahiaConfigInterface, encryptPassword(jahiaConfigInterface.getJahiaRootPassword())).updateConfiguration( new VFSConfigFile(fsManager, rootUserTemplate), webappPath + "/WEB-INF/etc/repository/root-user.xml"); }/*from www . j a v a2 s. co m*/ } else { new RootUserConfigurator(dbProps, jahiaConfigInterface, encryptPassword(jahiaConfigInterface.getJahiaRootPassword())).updateConfiguration( new VFSConfigFile(fsManager, sourceWebAppPath + "/WEB-INF/etc/repository/root.xml"), webappPath + "/WEB-INF/etc/repository/root.xml"); } String mailServerTemplate = sourceWebAppPath + "/WEB-INF/etc/repository/template-root-mail-server.xml"; if (fsManager.resolveFile(mailServerTemplate).exists() && Boolean.valueOf(jahiaConfigInterface.getProcessingServer())) { new MailServerConfigurator(dbProps, jahiaConfigInterface).updateConfiguration( new VFSConfigFile(fsManager, mailServerTemplate), webappPath + "/WEB-INF/etc/repository/root-mail-server.xml"); } if ("jboss".equalsIgnoreCase(jahiaConfigInterface.getTargetServerType())) { updateForJBoss(dbProps, jahiaConfigInterface, fsManager); } String targetConfigPath = webappPath + "/WEB-INF/etc/config"; String jahiaPropertiesFileName = "jahia.properties"; String jahiaNodePropertiesFileName = "jahia.node.properties"; if (externalizedConfigTempPath != null) { targetConfigPath = externalizedConfigTempPath; if (!StringUtils.isBlank(jahiaConfigInterface.getExternalizedConfigClassifier())) { jahiaPropertiesFileName = "jahia." + jahiaConfigInterface.getExternalizedConfigClassifier() + ".properties"; jahiaNodePropertiesFileName = "jahia.node." + jahiaConfigInterface.getExternalizedConfigClassifier() + ".properties"; } } ConfigFile jahiaPropertiesConfigFile = readJahiaProperties(sourceWebAppPath, fsManager); new JahiaPropertiesConfigurator(dbProps, jahiaConfigInterface) .updateConfiguration(jahiaPropertiesConfigFile, targetConfigPath + "/" + jahiaPropertiesFileName); try { ConfigFile jahiaNodePropertiesConfigFile = readJahiaNodeProperties(sourceWebAppPath, fsManager); if (jahiaNodePropertiesConfigFile != null) { new JahiaNodePropertiesConfigurator(logger, jahiaConfigInterface).updateConfiguration( jahiaNodePropertiesConfigFile, targetConfigPath + "/" + jahiaNodePropertiesFileName); } } catch (FileSystemException fse) { // in the case we cannot access the file, it means we should not do the advanced configuration, which is expected for community edition. } // create empty Spring config file for custom configuration InputStream is = getClass().getResourceAsStream("/applicationcontext-custom.xml"); FileOutputStream os = new FileOutputStream(new File(targetConfigPath, "applicationcontext-custom.xml")); try { IOUtils.copy(is, os); } finally { IOUtils.closeQuietly(is); IOUtils.closeQuietly(os); } String ldapTargetFile = new File(getDataDir(), "modules").getAbsolutePath(); new LDAPConfigurator(dbProps, jahiaConfigInterface) .updateConfiguration(new VFSConfigFile(fsManager, sourceWebAppPath), ldapTargetFile); String jeeApplicationLocation = jahiaConfigInterface.getJeeApplicationLocation(); boolean jeeLocationSpecified = !StringUtils.isEmpty(jeeApplicationLocation); if (jeeLocationSpecified || getDeployer().isEarDeployment()) { if (!jeeLocationSpecified) { jeeApplicationLocation = getDeployer().getDeploymentFilePath("digitalfactory", "ear") .getAbsolutePath(); } String jeeApplicationModuleList = jahiaConfigInterface.getJeeApplicationModuleList(); if (StringUtils.isEmpty(jeeApplicationModuleList)) { jeeApplicationModuleList = "ROOT".equals(jahiaConfigInterface.getWebAppDirName()) ? "jahia-war:web:jahia.war:" : ("jahia-war:web:jahia.war:" + jahiaConfigInterface.getWebAppDirName()); } new ApplicationXmlConfigurator(jahiaConfigInterface, jeeApplicationModuleList).updateConfiguration( new VFSConfigFile(fsManager, jeeApplicationLocation + "/META-INF/application.xml"), jeeApplicationLocation + "/META-INF/application.xml"); } }
From source file:org.jahia.configuration.configurators.JahiaGlobalConfigurator.java
public FileObject findVFSFile(String parentPath, String fileMatchingPattern) { Pattern matchingPattern = Pattern.compile(fileMatchingPattern); try {/*from w ww. j a va2 s .c o m*/ FileSystemManager fsManager = VFS.getManager(); FileObject parentFileObject = fsManager.resolveFile(parentPath); FileObject[] children = parentFileObject.getChildren(); for (FileObject child : children) { Matcher matcher = matchingPattern.matcher(child.getName().getBaseName()); if (matcher.matches()) { return child; } } } catch (FileSystemException e) { logger.debug("Couldn't find file matching pattern " + fileMatchingPattern + " at path " + parentPath); } return null; }
From source file:org.jahia.configuration.configurators.JahiaPropertiesConfiguratorTest.java
public void testUpdateConfiguration() throws IOException { URL jahiaDefaultConfigJARURL = this.getClass().getClassLoader().getResource("jahia-default-config.jar"); // Locate the Jar file FileSystemManager fsManager = VFS.getManager(); ConfigFile jahiaPropertiesConfigFile = new VFSConfigFile( fsManager.resolveFile("jar:" + jahiaDefaultConfigJARURL.toExternalForm()), "org/jahia/defaults/config/properties/jahia.properties"); File jahiaDefaultConfigFile = new File(jahiaDefaultConfigJARURL.getFile()); String jahiaDefaultConfigFileParentPath = jahiaDefaultConfigFile.getParentFile().getPath() + File.separator; String targetJahiaPropertiesFile = jahiaDefaultConfigFileParentPath + "jahia.properties"; String secondTargetJahiaPropertiesFile = jahiaDefaultConfigFileParentPath + "jahia2.properties"; SLF4JLogger logger = new SLF4JLogger(LoggerFactory.getLogger(JahiaPropertiesConfiguratorTest.class)); jahiaPropertiesConfigFile = new VFSConfigFile( fsManager.resolveFile("jar:" + jahiaDefaultConfigJARURL.toExternalForm()), "org/jahia/defaults/config/properties/jahia.advanced.properties"); targetJahiaPropertiesFile = jahiaDefaultConfigFileParentPath + "jahia.advanced.properties"; JahiaPropertiesConfigurator websphereOracleConfigurator = new JahiaPropertiesConfigurator( oracleDBProperties, websphereOracleConfigBean); websphereOracleConfigurator.updateConfiguration(jahiaPropertiesConfigFile, targetJahiaPropertiesFile); new JahiaNodePropertiesConfigurator(logger, websphereOracleConfigBean) .updateConfiguration(jahiaPropertiesConfigFile, targetJahiaPropertiesFile); Properties websphereOracleProperties = new Properties(); FileInputStream inStream = new FileInputStream( jahiaDefaultConfigFileParentPath + "jahia.advanced.properties"); try {/*from w w w .j a va 2 s . c o m*/ websphereOracleProperties.load(inStream); } finally { IOUtils.closeQuietly(inStream); } // test for the additional properties assertEquals("true", websphereOracleProperties.getProperty("jahia.dm.viewer.enabled")); assertEquals("c:\\Program Files (x86)\\SWFTools\\pdf2swf.exe", websphereOracleProperties.getProperty("jahia.dm.viewer.pdf2swf")); assertNotNull(websphereOracleProperties.getProperty("auth.spnego.bypassForUrls")); JahiaPropertiesConfigurator tomcatMySQLConfigurator = new JahiaPropertiesConfigurator(mysqlDBProperties, tomcatMySQLConfigBean); tomcatMySQLConfigurator.updateConfiguration(new VFSConfigFile(fsManager, targetJahiaPropertiesFile), secondTargetJahiaPropertiesFile); new JahiaNodePropertiesConfigurator(logger, tomcatMySQLConfigBean).updateConfiguration( new VFSConfigFile(fsManager, secondTargetJahiaPropertiesFile), secondTargetJahiaPropertiesFile); Properties tomcatMySQLProperties = new Properties(); inStream = new FileInputStream(secondTargetJahiaPropertiesFile); try { tomcatMySQLProperties.load(inStream); } finally { IOUtils.closeQuietly(inStream); } //assertEquals("tomcat", tomcatMySQLProperties.getProperty("server")); }
From source file:org.jahia.configuration.configurators.JBossConfiguratorTest.java
@Override public void testUpdateConfiguration() throws Exception { FileSystemManager fsManager = VFS.getManager(); AbstractLogger logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO); URL cfgFileUrl = this.getClass().getClassLoader().getResource("configurators/jboss/standalone.xml"); File sourceCfgFile = new File(cfgFileUrl.getFile()); JBossConfigurator configurator = new JBossConfigurator(oracleDBProperties, websphereOracleConfigBean, null, logger);//from w w w .j a va 2 s.co m String destFileName = sourceCfgFile.getParent() + "/standalone-modified.xml"; configurator.updateConfiguration(new VFSConfigFile(fsManager, cfgFileUrl.toExternalForm()), destFileName); String content = FileUtils.readFileToString(new File(destFileName)); assertTrue(content.contains("<driver name=\"jahia.oracle\" module=\"org.jahia.jdbc.oracle\">")); assertTrue(content.contains("<driver-class>oracle.jdbc.OracleDriver</driver-class>")); assertTrue(content.contains("<datasource jndi-name=\"java:/jahiaDS\"")); assertTrue(content.contains("<connection-url>jdbc:oracle")); assertTrue(content.contains("enable-welcome-root=\"false\"")); String unchangedDestFileName = sourceCfgFile.getParent() + "/standalone-modified-unchanged.xml"; configurator.updateConfiguration(new VFSConfigFile(fsManager, destFileName), unchangedDestFileName); assertTrue(FileUtils.contentEquals(new File(destFileName), new File(unchangedDestFileName))); configurator = new JBossConfigurator(mysqlDBProperties, tomcatMySQLConfigBean, null, logger); String updatedDestFileName = sourceCfgFile.getParent() + "/standalone-modified-updated.xml"; configurator.updateConfiguration(new VFSConfigFile(fsManager, unchangedDestFileName), updatedDestFileName); assertFalse(FileUtils.contentEquals(new File(unchangedDestFileName), new File(updatedDestFileName))); content = FileUtils.readFileToString(new File(updatedDestFileName)); assertTrue(content.contains("<driver name=\"jahia.mysql\" module=\"org.jahia.jdbc.mysql\">")); assertTrue(content.contains("<driver-class>com.mysql.jdbc.Driver</driver-class>")); assertTrue(content.contains("<connection-url>jdbc:mysql")); assertFalse(content.contains("<connection-url>jdbc:oracle")); assertTrue(content.contains( "<connector name=\"http\" protocol=\"org.apache.coyote.http11.Http11NioProtocol\" scheme=\"http\" socket-binding=\"http\" />")); }
From source file:org.jahia.configuration.configurators.RootUserConfiguratorTest.java
public void testUpdateConfiguration() throws Exception { FileSystemManager fsManager = VFS.getManager(); URL rootXmlUrl = this.getClass().getClassLoader() .getResource("configurators/WEB-INF/etc/repository/root-test.xml"); File rootXmlFile = new File(rootXmlUrl.getFile()); String rootXmlFileParentPath = rootXmlFile.getParentFile().getPath() + File.separator; RootUserConfigurator websphereOracleConfigurator = new RootUserConfigurator(oracleDBProperties, websphereOracleConfigBean, "password"); websphereOracleConfigurator.updateConfiguration(new VFSConfigFile(fsManager, rootXmlUrl.toExternalForm()), rootXmlFileParentPath + "root-modified.xml"); SAXBuilder saxBuilder = new SAXBuilder(); saxBuilder.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); Document jdomDocument = saxBuilder.build(rootXmlFileParentPath + "root-modified.xml"); String prefix = ""; Element el = (Element) getNode(jdomDocument, "/content/users/*", prefix); assertEquals(websphereOracleConfigBean.getJahiaRootUsername(), el.getName()); assertEquals("password", ((Attribute) getNode(jdomDocument, "/content/users/" + websphereOracleConfigBean.getJahiaRootUsername() + "/@j:password", prefix)).getValue()); assertEquals(websphereOracleConfigBean.getJahiaRootFirstname(), ((Attribute) getNode(jdomDocument, "/content/users/" + websphereOracleConfigBean.getJahiaRootUsername() + "/@j:firstName", prefix)).getValue()); assertEquals(websphereOracleConfigBean.getJahiaRootLastname(), ((Attribute) getNode(jdomDocument, "/content/users/" + websphereOracleConfigBean.getJahiaRootUsername() + "/@j:lastName", prefix)).getValue()); assertEquals(websphereOracleConfigBean.getJahiaRootEmail(), ((Attribute) getNode(jdomDocument, "/content/users/" + websphereOracleConfigBean.getJahiaRootUsername() + "/@j:email", prefix)) .getValue()); assertEquals("de", ((Attribute) getNode(jdomDocument, "/content/users/" + websphereOracleConfigBean.getJahiaRootUsername() + "/@preferredLanguage", prefix)) .getValue()); RootUserConfigurator tomcatMySQLConfigurator = new RootUserConfigurator(mysqlDBProperties, tomcatMySQLConfigBean, "1234root"); tomcatMySQLConfigurator.updateConfiguration( new VFSConfigFile(fsManager, rootXmlFileParentPath + "root-test.xml"), rootXmlFileParentPath + "root-modified2.xml"); jdomDocument = saxBuilder.build(rootXmlFileParentPath + "root-modified2.xml"); assertEquals("root", ((Element) getNode(jdomDocument, "/content/users/*", prefix)).getName()); assertEquals("1234root", ((Attribute) getNode(jdomDocument, "/content/users/root/@j:password", prefix)).getValue()); }
From source file:org.jahia.configuration.configurators.TomcatContextXmlConfiguratorTest.java
public void testUpdateConfiguration() throws Exception { FileSystemManager fsManager = VFS.getManager(); URL contextXmlUrl = this.getClass().getClassLoader().getResource("configurators/META-INF/context.xml"); File contextXmlFile = new File(contextXmlUrl.getFile()); String contextXmlParentPath = contextXmlFile.getParentFile().getPath() + File.separator; TomcatContextXmlConfigurator tomcatOracleConfigurator = new TomcatContextXmlConfigurator(oracleDBProperties, tomcatMySQLConfigBean);/*from w ww .j av a 2 s . c o m*/ tomcatOracleConfigurator.updateConfiguration(new VFSConfigFile(fsManager, contextXmlUrl.toExternalForm()), contextXmlParentPath + "context-modified.xml"); // The following tests are NOT exhaustive SAXBuilder saxBuilder = new SAXBuilder(); saxBuilder.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); Document jdomDocument = saxBuilder.build(contextXmlParentPath + "context-modified.xml"); String prefix = ""; assertAllTextEquals(jdomDocument, "//Resource/@username", prefix, oracleDBProperties.getProperty("jahia.database.user")); assertAllTextEquals(jdomDocument, "//Resource/@password", prefix, oracleDBProperties.getProperty("jahia.database.pass")); assertAllTextEquals(jdomDocument, "//Resource/@url", prefix, oracleDBProperties.getProperty("jahia.database.url")); assertAllTextEquals(jdomDocument, "//Resource/@driverClassName", prefix, oracleDBProperties.getProperty("jahia.database.driver")); TomcatContextXmlConfigurator tomcatMySQLContextXmlConfigurator = new TomcatContextXmlConfigurator( mysqlDBProperties, tomcatMySQLConfigBean); tomcatMySQLContextXmlConfigurator.updateConfiguration( new VFSConfigFile(fsManager, contextXmlParentPath + "context-modified.xml"), contextXmlParentPath + "context-modified2.xml"); // The following tests are NOT exhaustive saxBuilder = new SAXBuilder(); jdomDocument = saxBuilder.build(contextXmlParentPath + "context-modified2.xml"); assertAllTextEquals(jdomDocument, "//Resource/@username", prefix, mysqlDBProperties.getProperty("jahia.database.user")); assertAllTextEquals(jdomDocument, "//Resource/@password", prefix, mysqlDBProperties.getProperty("jahia.database.pass")); assertAllTextEquals(jdomDocument, "//Resource/@url", prefix, mysqlDBProperties.getProperty("jahia.database.url")); assertAllTextEquals(jdomDocument, "//Resource/@driverClassName", prefix, mysqlDBProperties.getProperty("jahia.database.driver")); }
From source file:org.jahia.services.content.impl.external.vfs.VFSDataSource.java
public void setRoot(String root) { this.root = root; try {//w ww. ja va2 s. c o m manager = VFS.getManager(); rootPath = getFile("/").getName().getPath(); } catch (FileSystemException e) { logger.error(e.getMessage(), e); } }
From source file:org.jahia.services.content.impl.vfs.VFSRepositoryImpl.java
public VFSRepositoryImpl(String root, VFSAccessControlManager accessControlManager) { initDescriptors();//www . jav a 2 s . c o m this.root = root; this.accessControlManager = accessControlManager; try { manager = VFS.getManager(); rootPath = getFile("/").getName().getPath(); } catch (FileSystemException e) { logger.error(e.getMessage(), e); } }
From source file:org.jbpm.form.builder.services.impl.fs.FSMenuService.java
protected void writeToURL(URL url, String json) throws FileNotFoundException, IOException { if (url.toExternalForm().startsWith("vfs")) { FileObject to = VFS.getManager().resolveFile(url.toExternalForm()); File tmpFile = File.createTempFile("xxFilexx", ".json"); FileUtils.writeStringToFile(tmpFile, json); FileObject from = VFS.getManager().toFileObject(tmpFile); to.copyFrom(from, new AllFileSelector()); FileUtils.deleteQuietly(tmpFile); } else {// w w w . j a v a 2 s .c o m FileUtils.writeStringToFile(FileUtils.toFile(url), json); } }