/* */ {
/* 267 */ uri = uri != null ? null : pcm.getUri();
/* */
/* 269 */ if (uri == null)
/* */ {
/* 271 */ throw new SavePropertiesException("No uri is associated with this property manager");
/* */ }
/* */
/* 274 */ Properties props = pcm.getLocalProperties();
/* */ try
/* */ {
/* 278 */ String filename = FileLocator.locateFile(uri);
/* 279 */ Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(filename);
/* 280 */ Element root = doc.getDocumentElement();
/* 281 */ String depends = null;
/* */
/* 284 */ NodeList propertiesNodes = root.getElementsByTagName("properties");
/* */
/* 286 */ for (int count = 0; count < propertiesNodes.getLength(); count++)
/* */ {
/* 288 */ Element propertiesElement = (Element)propertiesNodes.item(count);
/* 289 */ String propertiesName = propertiesElement.getAttributeNode("name").getNodeValue();
/* */
/* 292 */ if (!propertiesName.equals(pcm.getName()))
/* */ continue;
/* 294 */ root.removeChild(propertiesElement);
/* 295 */ depends = propertiesElement.getAttributeNode("depends").getNodeValue();
/* 296 */ break;
/* */ }
/* */
/* 301 */ Element newPropertiesElement = doc.createElement("properties");
/* */
/* 303 */ newPropertiesElement.setAttribute("name", pcm.getName());
/* */
/* 305 */ if (depends != null)
/* */ {
/* 307 */ newPropertiesElement.setAttribute("depends", depends);
/* */ }
/* */
/* 310 */ for (Enumeration e = props.keys(); e.hasMoreElements(); )
/* */ {
/* 312 */ String key = (String)e.nextElement();
/* 313 */ String value = props.getProperty(key);
/* */
/* 315 */ Element newPropertyElement = doc.createElement("property");
/* 316 */ newPropertyElement.setAttribute("name", key);
/* 317 */ newPropertyElement.setAttribute("value", value);
/* */
/* 319 */ newPropertiesElement.appendChild(newPropertyElement);
/* */ }
/* */
/* 322 */ root.appendChild(newPropertiesElement);
/* */
/* 326 */ OutputFormat of = new OutputFormat(doc);
/* 327 */ of.setIndenting(true);
/* */ FileOutputStream out;
/* 328 */ XMLSerializer srl = new XMLSerializer(out = new FileOutputStream(filename), of);
/* */
/* 330 */ srl.serialize(doc);
/* */
/* 332 */ out.close();
/* */ }
/* */ catch (IOException e)
/* */ {
/* 336 */ throw e;
/* */ }
/* */ catch (Exception e)
/* */ {
/* 340 */ throw new SavePropertiesException("Unexpected exception: " + e);
/* */ }
/* */ }