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/web.project/src/org/netbeans/modules/web/project/UpdateProjectImpl.java (-55 / +3 lines)
Lines 69-81 Link Here
69
import org.openide.filesystems.URLMapper;
69
import org.openide.filesystems.URLMapper;
70
import org.openide.util.Mutex;
70
import org.openide.util.Mutex;
71
import org.openide.util.NbBundle;
71
import org.openide.util.NbBundle;
72
import org.w3c.dom.Comment;
72
import org.openide.xml.XMLUtil;
73
import org.w3c.dom.Document;
73
import org.w3c.dom.Document;
74
import org.w3c.dom.Element;
74
import org.w3c.dom.Element;
75
import org.w3c.dom.NamedNodeMap;
76
import org.w3c.dom.Node;
75
import org.w3c.dom.Node;
77
import org.w3c.dom.NodeList;
76
import org.w3c.dom.NodeList;
78
import org.w3c.dom.Text;
79
77
80
/**
78
/**
81
 *
79
 *
Lines 295-301 Link Here
295
            if (oldRoot != null) {
293
            if (oldRoot != null) {
296
                Document doc = oldRoot.getOwnerDocument();
294
                Document doc = oldRoot.getOwnerDocument();
297
                Element newRoot = doc.createElementNS (WebProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
295
                Element newRoot = doc.createElementNS (WebProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N
298
                copyDocument (doc, oldRoot, newRoot);
296
                XMLUtil.copyDocument (doc, oldRoot, newRoot, WebProjectType.PROJECT_CONFIGURATION_NAMESPACE);
299
                if (version == 1) {
297
                if (version == 1) {
300
                    //1->2 upgrade
298
                    //1->2 upgrade
301
                    Element sourceRoots = doc.createElementNS(WebProjectType.PROJECT_CONFIGURATION_NAMESPACE,"source-roots");  //NOI18N
299
                    Element sourceRoots = doc.createElementNS(WebProjectType.PROJECT_CONFIGURATION_NAMESPACE,"source-roots");  //NOI18N
Lines 317-323 Link Here
317
                            Element library = (Element) libList.item(i);
315
                            Element library = (Element) libList.item(i);
318
                            Node webFile = library.getElementsByTagNameNS(ns, TAG_FILE).item(0);
316
                            Node webFile = library.getElementsByTagNameNS(ns, TAG_FILE).item(0);
319
                            //remove ${ and } from the beginning and end
317
                            //remove ${ and } from the beginning and end
320
                            String webFileText = findText(webFile);
318
                            String webFileText = XMLUtil.findText(webFile);
321
                            webFileText = webFileText.substring(2, webFileText.length() - 1);
319
                            webFileText = webFileText.substring(2, webFileText.length() - 1);
322
//                            warIncludesMap.put(webFileText, pathInWarElements.getLength() > 0 ? findText((Element) pathInWarElements.item(0)) : Item.PATH_IN_WAR_NONE);
320
//                            warIncludesMap.put(webFileText, pathInWarElements.getLength() > 0 ? findText((Element) pathInWarElements.item(0)) : Item.PATH_IN_WAR_NONE);
323
                            if (webFileText.startsWith ("lib.")) {
321
                            if (webFileText.startsWith ("lib.")) {
Lines 375-430 Link Here
375
        }
373
        }
376
    }
374
    }
377
375
378
    /**
379
     * Extract nested text from a node.
380
     * Currently does not handle coalescing text nodes, CDATA sections, etc.
381
     * @param parent a parent node
382
     * @return the nested text, or null if none was found
383
     */
384
    private static String findText(Node parent) {
385
        NodeList l = parent.getChildNodes();
386
        for (int i = 0; i < l.getLength(); i++) {
387
            if (l.item(i).getNodeType() == Node.TEXT_NODE) {
388
                Text text = (Text)l.item(i);
389
                return text.getNodeValue();
390
            }
391
        }
392
        return null;
393
    }
394
    
395
    private static void copyDocument (Document doc, Element from, Element to) {
396
        NodeList nl = from.getChildNodes();
397
        int length = nl.getLength();
398
        for (int i=0; i< length; i++) {
399
            Node node = nl.item (i);
400
            Node newNode = null;
401
            switch (node.getNodeType()) {
402
                case Node.ELEMENT_NODE:
403
                    Element oldElement = (Element) node;
404
                    newNode = doc.createElementNS(WebProjectType.PROJECT_CONFIGURATION_NAMESPACE,oldElement.getTagName());
405
                    NamedNodeMap m = oldElement.getAttributes();
406
                    Element newElement = (Element) newNode;
407
                    for (int index = 0; index < m.getLength(); index++) {
408
                        Node attr = m.item(index);
409
                        newElement.setAttribute(attr.getNodeName(), attr.getNodeValue());
410
                    }
411
                    copyDocument(doc,oldElement,(Element)newNode);
412
                    break;
413
                case Node.TEXT_NODE:
414
                    Text oldText = (Text) node;
415
                    newNode = doc.createTextNode(oldText.getData());
416
                    break;
417
                case Node.COMMENT_NODE:
418
                    Comment oldComment = (Comment) node;
419
                    newNode = doc.createComment(oldComment.getData());
420
                    break;
421
            }
422
            if (newNode != null) {
423
                to.appendChild (newNode);
424
            }
425
        }
426
    }
427
428
    private static Element updateMinAntVersion (final Element root, final Document doc) {
376
    private static Element updateMinAntVersion (final Element root, final Document doc) {
429
        NodeList list = root.getElementsByTagNameNS (WebProjectType.PROJECT_CONFIGURATION_NAMESPACE,TAG_MINIMUM_ANT_VERSION);
377
        NodeList list = root.getElementsByTagNameNS (WebProjectType.PROJECT_CONFIGURATION_NAMESPACE,TAG_MINIMUM_ANT_VERSION);
430
        if (list.getLength() == 1) {
378
        if (list.getLength() == 1) {
(-)a/web.project/src/org/netbeans/modules/web/project/classpath/ClassPathSupportCallbackImpl.java (-39 / +4 lines)
Lines 45-60 Link Here
45
import java.util.List;
45
import java.util.List;
46
import java.util.Map;
46
import java.util.Map;
47
import org.netbeans.modules.j2ee.common.Util;
47
import org.netbeans.modules.j2ee.common.Util;
48
import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
49
import org.netbeans.modules.java.api.common.classpath.ClassPathSupport.Item;
48
import org.netbeans.modules.java.api.common.classpath.ClassPathSupport.Item;
50
import org.netbeans.modules.java.api.common.util.CommonProjectUtils;
49
import org.netbeans.modules.java.api.common.util.CommonProjectUtils;
51
import org.netbeans.modules.web.project.WebProjectType;
50
import org.netbeans.modules.web.project.WebProjectType;
52
import org.netbeans.spi.project.support.ant.AntProjectHelper;
51
import org.netbeans.spi.project.support.ant.AntProjectHelper;
52
import org.openide.xml.XMLUtil;
53
import org.w3c.dom.Document;
53
import org.w3c.dom.Document;
54
import org.w3c.dom.Element;
54
import org.w3c.dom.Element;
55
import org.w3c.dom.Node;
55
import org.w3c.dom.Node;
56
import org.w3c.dom.NodeList;
56
import org.w3c.dom.NodeList;
57
import org.w3c.dom.Text;
58
57
59
/**
58
/**
60
 * Defines the various class paths for a web project.
59
 * Defines the various class paths for a web project.
Lines 120-139 Link Here
120
                            Node webFile = library.getElementsByTagNameNS(ns, TAG_FILE).item(0);
119
                            Node webFile = library.getElementsByTagNameNS(ns, TAG_FILE).item(0);
121
                            NodeList pathInWarElements = library.getElementsByTagNameNS(ns, TAG_PATH_IN_WAR);
120
                            NodeList pathInWarElements = library.getElementsByTagNameNS(ns, TAG_PATH_IN_WAR);
122
                            //remove ${ and } from the beginning and end
121
                            //remove ${ and } from the beginning and end
123
                            String webFileText = findText(webFile);
122
                            String webFileText = XMLUtil.findText(webFile);
124
                            webFileText = webFileText.substring(2, webFileText.length() - 1);
123
                            webFileText = webFileText.substring(2, webFileText.length() - 1);
125
                            
124
                            
126
                            //#86522
125
                            //#86522
127
                            if (webModuleLibraries.equals(TAG_WEB_MODULE__ADDITIONAL_LIBRARIES)) {
126
                            if (webModuleLibraries.equals(TAG_WEB_MODULE__ADDITIONAL_LIBRARIES)) {
128
                                String pathInWar = PATH_IN_WAR_NONE;
127
                                String pathInWar = PATH_IN_WAR_NONE;
129
                                if (pathInWarElements.getLength() > 0) {
128
                                if (pathInWarElements.getLength() > 0) {
130
                                    pathInWar = findText((Element) pathInWarElements.item(0));
129
                                    pathInWar = XMLUtil.findText((Element) pathInWarElements.item(0));
131
                                    if (pathInWar == null)
130
                                    if (pathInWar == null)
132
                                        pathInWar = "";
131
                                        pathInWar = "";
133
                                }
132
                                }
134
                                warIncludesMap.put(webFileText, pathInWar);
133
                                warIncludesMap.put(webFileText, pathInWar);
135
                            } else {
134
                            } else {
136
                                warIncludesMap.put(webFileText, pathInWarElements.getLength() > 0 ? findText((Element) pathInWarElements.item(0)) : PATH_IN_WAR_NONE);
135
                                warIncludesMap.put(webFileText, pathInWarElements.getLength() > 0 ? XMLUtil.findText((Element) pathInWarElements.item(0)) : PATH_IN_WAR_NONE);
137
                            }
136
                            }
138
                            if (dirs != null) {
137
                            if (dirs != null) {
139
                                warIncludesMap.put(webFileText+"."+Util.DESTINATION_DIRECTORY, dirs);
138
                                warIncludesMap.put(webFileText+"."+Util.DESTINATION_DIRECTORY, dirs);
Lines 148-187 Link Here
148
    }
147
    }
149
148
150
    /**
149
    /**
151
     * Extracts <b>the first</b> nested text from an element.
152
     * Currently does not handle coalescing text nodes, CDATA sections, etc.
153
     * @param parent a parent element
154
     * @return the nested text, or null if none was found
155
     */
156
    private static String findText( Element parent ) {
157
        NodeList l = parent.getChildNodes();
158
        for ( int i = 0; i < l.getLength(); i++ ) {
159
            if ( l.item(i).getNodeType() == Node.TEXT_NODE ) {
160
                Text text = (Text)l.item( i );
161
                return text.getNodeValue();
162
            }
163
        }
164
        return null;
165
    }
166
    
167
    /**
168
     * Extract nested text from a node.
169
     * Currently does not handle coalescing text nodes, CDATA sections, etc.
170
     * @param parent a parent node
171
     * @return the nested text, or null if none was found
172
     */
173
    private static String findText(Node parent) {
174
        NodeList l = parent.getChildNodes();
175
        for (int i = 0; i < l.getLength(); i++) {
176
            if (l.item(i).getNodeType() == Node.TEXT_NODE) {
177
                Text text = (Text)l.item(i);
178
                return text.getNodeValue();
179
            }
180
        }
181
        return null;
182
    }
183
184
    /**
185
     * Updates the project helper with the list of classpath items which are to be
150
     * Updates the project helper with the list of classpath items which are to be
186
     * included in deployment.
151
     * included in deployment.
187
     */
152
     */

Return to bug 136595