List of usage examples for java.util Properties storeToXML
public void storeToXML(OutputStream os, String comment, Charset charset) throws IOException
From source file:com.webpagebytes.cms.local.WPBLocalFileStorage.java
private void storeFileProperties(Properties props, String filePath) throws IOException { FileOutputStream os = new FileOutputStream(filePath); props.storeToXML(os, "", "UTF-8"); IOUtils.closeQuietly(os);/* ww w .j av a2s .c o m*/ }
From source file:com.webpagebytes.plugins.WPBLocalFileStorage.java
private void storeFileProperties(Properties props, String filePath) throws IOException { FileOutputStream os = new FileOutputStream(filePath); try {// ww w . j a v a 2 s . c om props.storeToXML(os, "", "UTF-8"); } catch (IOException e) { throw e; } finally { IOUtils.closeQuietly(os); } }
From source file:org.onecmdb.ui.gwt.desktop.server.service.model.mdr.MDRSetupService.java
public boolean storeTransformConfig(String token, ContentData ciMDRData, CIModel mdr, CIModel mdrCfg, TransformConfig cfg) throws Exception { IContentService svc = (IContentService) ServiceLocator.getService(IContentService.class); if (svc == null) { svc = new ContentServiceImpl(); }/*from w w w. j ava 2s .c om*/ String mdrPath = "MDR/" + mdr.getValueAsString("name") + "/conf/" + mdrCfg.getValueAsString("name"); ContentFolder mdrFolder = new ContentFolder(mdrPath); svc.stat(mdrFolder); if (!mdrFolder.isExists()) { svc.mkdir(token, mdrFolder); } // Store data source. Properties p = getDataSourceProperties(cfg, false); String sPath = mdrPath + "/source.xml"; ByteArrayOutputStream out = new ByteArrayOutputStream(); p.storeToXML(out, "", "UTF-8"); svc.put(token, new ContentFile(sPath), out.toString("UTF-8")); // Store transform data. TransformModel transform = cfg.getTransformModel(); String tPath = mdrPath + "/transform.xml"; ContentFile f = new ContentFile(tPath); String transformXML = TransformConverter.toXML(cfg.getDataSourceType(), transform); svc.put(token, f, "UTF-8", transformXML); return (true); }
From source file:eu.planets_project.tb.impl.model.exec.ExecutionRecordImpl.java
public void setPropertiesListResult(Properties props) throws IOException { ByteArrayOutputStream bout = new ByteArrayOutputStream(); props.storeToXML(bout, "Property List Testbed Result", "UTF-8"); this.setResult(bout.toString("UTF-8")); this.setResultType(RESULT_PROPERTIES_LIST); }
From source file:com.webpagebytes.cms.controllers.FlatStorageImporterExporter.java
private void exportToXMLFormat(Map<String, Object> props, OutputStream os) throws IOException { Properties properties = new Properties(); properties.putAll(props);// www . ja va 2 s. c o m ByteArrayOutputStream bos = new ByteArrayOutputStream(); properties.storeToXML(bos, "", "UTF-8"); byte metadataBytes[] = bos.toByteArray(); os.write(metadataBytes); }
From source file:com.dianping.phoenix.dev.core.tools.generator.dynamic.ServiceLionPropertiesGenerator.java
public void generate(File file, ServiceLionContext context) throws Exception { Scanner<ServicePortEntry> serviceMetaScanner = new ServiceMetaScanner(); List<ServicePortEntry> servicePortList = serviceMetaScanner.scan(context.getServiceMetaConfig()); Map<String, Integer> servicePortMapping = new HashMap<String, Integer>(); for (ServicePortEntry entry : servicePortList) { servicePortMapping.put(entry.getService(), entry.getPort()); }/*from w ww . j ava 2 s .c o m*/ Properties prop = new SortedProperties(); Scanner<String> serviceScanner = new ServiceScanner(); for (Map.Entry<String, File> entry : context.getProjectBaseDirMapping().entrySet()) { Collection<File> allXmlFiles = FileUtils.listFiles(entry.getValue(), new String[] { "xml" }, true); List<String> serviceKeys = new ArrayList<String>(); for (File xml : allXmlFiles) { serviceKeys.addAll(serviceScanner.scan(xml)); } for (String serviceKey : serviceKeys) { prop.put(serviceKey, context.getServiceHost() + ":" + servicePortMapping.get(serviceKey)); } } OutputStream os = null; try { os = new FileOutputStream(file); prop.storeToXML(os, "", "utf-8"); } finally { if (os != null) { try { os.close(); } catch (IOException e) { } } } }
From source file:org.pentaho.platform.plugin.services.importexport.legacy.MondrianCatalogRepositoryHelper.java
public void addOlap4jServer(String name, String className, String URL, String user, String password, Properties props) { final RepositoryFile etcOlapServers = repository.getFile(ETC_OLAP_SERVERS_JCR_FOLDER); RepositoryFile entry = repository.getFile(ETC_OLAP_SERVERS_JCR_FOLDER + RepositoryFile.SEPARATOR + name); if (entry == null) { entry = repository.createFolder(etcOlapServers.getId(), new RepositoryFile.Builder(name).folder(true).build(), "Creating entry for olap server: " + name + " into folder " + ETC_OLAP_SERVERS_JCR_FOLDER); }//from ww w. j av a2 s .c o m final String path = ETC_OLAP_SERVERS_JCR_FOLDER + RepositoryFile.SEPARATOR + name + RepositoryFile.SEPARATOR + "metadata"; // Convert the properties to a serializable XML format. final String xmlProperties; final ByteArrayOutputStream os = new ByteArrayOutputStream(); try { props.storeToXML(os, "Connection properties for server: " + name, "UTF-8"); xmlProperties = os.toString("UTF-8"); } catch (IOException e) { // Very bad. Just throw. throw new RuntimeException(e); } finally { try { os.close(); } catch (IOException e) { // Don't care. Just cleaning up. } } final DataNode node = new DataNode("server"); node.setProperty("name", name); node.setProperty("className", className); node.setProperty("URL", URL); node.setProperty("user", user); node.setProperty("password", password); node.setProperty("properties", xmlProperties); NodeRepositoryFileData data = new NodeRepositoryFileData(node); final RepositoryFile metadata = repository.getFile(path); if (metadata == null) { repository.createFile(entry.getId(), new RepositoryFile.Builder("metadata").build(), data, "Creating olap-server metadata for server " + name); } else { repository.updateFile(metadata, data, "Updating olap-server metadata for server " + name); } }
From source file:de.huxhorn.lilith.swing.ApplicationPreferences.java
/** * @param file the properties xml file * @param stringStringMap the map to be written * @param comment the comment/* w ww . j a v a 2 s . c om*/ * @return whether or not the file could be written * @noinspection MismatchedQueryAndUpdateOfCollection */ private boolean writePropertiesXml(File file, Map<String, String> stringStringMap, String comment) { Properties output = new Properties(); for (Map.Entry<String, String> entry : stringStringMap.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); if (value != null) { output.put(key, value); } } OutputStream os = null; Throwable error = null; try { os = new BufferedOutputStream(new FileOutputStream(file)); output.storeToXML(os, comment, StandardCharsets.UTF_8.toString()); } catch (IOException e) { error = e; } finally { IOUtilities.closeQuietly(os); } if (error != null) { if (logger.isWarnEnabled()) logger.warn("Exception while writing source names!", error); return false; } return true; }
From source file:uk.chromis.pos.inventory.ProductsEditor.java
private void jPropertyAddButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPropertyAddButtonActionPerformed Properties props = new Properties(); try {/* w ww.jav a2 s . c o m*/ if (!txtProperties.getText().isEmpty()) { props.loadFromXML( new ByteArrayInputStream(txtProperties.getText().getBytes(StandardCharsets.UTF_8))); } } catch (IOException ex) { Logger.getLogger(ProductsEditor.class.getName()).log(Level.SEVERE, null, ex); } String sel = (String) jComboProperties.getSelectedItem(); String type = m_PropertyOptions.getProperty(sel, ""); int nComma = type.indexOf(','); if (nComma > 0) { type = type.substring(0, nComma).trim(); } switch (type) { case "boolean": String sYes = (String) jPropertyValueCombo.getSelectedItem(); sYes = sYes.compareTo("Yes") == 0 ? "1" : "0"; props.put(sel, sYes); break; case "number": Double dValue; try { dValue = (Double) Formats.DOUBLE.parseValue(jPropertyValueText.getText()); } catch (BasicException ex) { dValue = 0.0; } props.put(sel, dValue.toString()); break; case "option": props.put(sel, (String) jPropertyValueCombo.getSelectedItem()); break; case "text": props.put(sel, (String) jPropertyValueText.getText()); break; default: break; } try { ByteArrayOutputStream o = new ByteArrayOutputStream(); props.storeToXML(o, AppLocal.APP_NAME, "UTF-8"); txtProperties.setText(o.toString()); } catch (IOException ex) { Logger.getLogger(ProductsEditor.class.getName()).log(Level.SEVERE, null, ex); } }