This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 136595
Collapse All | Expand All

(-)a/projectapi/src/org/netbeans/modules/projectapi/AuxiliaryConfigImpl.java (-22 / +3 lines)
Lines 98-104 Link Here
98
                                InputSource input = new InputSource(is);
98
                                InputSource input = new InputSource(is);
99
                                input.setSystemId(config.getURL().toString());
99
                                input.setSystemId(config.getURL().toString());
100
                                Element root = XMLUtil.parse(input, false, true, /*XXX*/null, null).getDocumentElement();
100
                                Element root = XMLUtil.parse(input, false, true, /*XXX*/null, null).getDocumentElement();
101
                                return findElement(root, elementName, namespace);
101
                                return XMLUtil.findElement(root, elementName, namespace);
102
                            } finally {
102
                            } finally {
103
                                is.close();
103
                                is.close();
104
                            }
104
                            }
Lines 163-169 Link Here
163
                            doc = XMLUtil.createDocument("auxiliary-configuration", "http://www.netbeans.org/ns/auxiliary-configuration/1", null, null);
163
                            doc = XMLUtil.createDocument("auxiliary-configuration", "http://www.netbeans.org/ns/auxiliary-configuration/1", null, null);
164
                        }
164
                        }
165
                        Element root = doc.getDocumentElement();
165
                        Element root = doc.getDocumentElement();
166
                        Element oldFragment = findElement(root, elementName, namespace);
166
                        Element oldFragment = XMLUtil.findElement(root, elementName, namespace);
167
                        if (oldFragment != null) {
167
                        if (oldFragment != null) {
168
                            root.removeChild(oldFragment);
168
                            root.removeChild(oldFragment);
169
                        }
169
                        }
Lines 230-236 Link Here
230
                            is.close();
230
                            is.close();
231
                        }
231
                        }
232
                        Element root = doc.getDocumentElement();
232
                        Element root = doc.getDocumentElement();
233
                        Element toRemove = findElement(root, elementName, namespace);
233
                        Element toRemove = XMLUtil.findElement(root, elementName, namespace);
234
                        if (toRemove != null) {
234
                        if (toRemove != null) {
235
                            root.removeChild(toRemove);
235
                            root.removeChild(toRemove);
236
                            if (root.getElementsByTagName("*").getLength() > 0) {
236
                            if (root.getElementsByTagName("*").getLength() > 0) {
Lines 276-298 Link Here
276
        });
276
        });
277
    }
277
    }
278
278
279
    private static Element findElement(Element parent, String name, String namespace) {
280
        Element result = null;
281
        NodeList l = parent.getChildNodes();
282
        int len = l.getLength();
283
        for (int i = 0; i < len; i++) {
284
            if (l.item(i).getNodeType() == Node.ELEMENT_NODE) {
285
                Element el = (Element) l.item(i);
286
                if (name.equals(el.getLocalName()) && namespace.equals(el.getNamespaceURI())) {
287
                    if (result == null) {
288
                        result = el;
289
                    } else {
290
                        return null;
291
                    }
292
                }
293
            }
294
        }
295
        return result;
296
    }
297
298
}
279
}

Return to bug 136595