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 215135
Collapse All | Expand All

(-)a/hudson/src/org/netbeans/modules/hudson/impl/HudsonConnector.java (-5 / +9 lines)
Lines 141-147 Link Here
141
        // Parse jobs and return them
141
        // Parse jobs and return them
142
        Collection<ViewData> viewsData = getViewData(docInstance, instanceUrl);
142
        Collection<ViewData> viewsData = getViewData(docInstance, instanceUrl);
143
        Collection<FolderData> foldersData = new ArrayList<FolderData>();
143
        Collection<FolderData> foldersData = new ArrayList<FolderData>();
144
        Collection<JobData> jobsData = getJobsData(docInstance, instanceUrl, viewsData, foldersData);
144
        Collection<JobData> jobsData = getJobsData(docInstance, instanceUrl, viewsData, foldersData, null);
145
        return new InstanceData(jobsData, viewsData, foldersData);
145
        return new InstanceData(jobsData, viewsData, foldersData);
146
    }
146
    }
147
147
Lines 160-166 Link Here
160
        // Clear cache
160
        // Clear cache
161
        cache.clear();
161
        cache.clear();
162
        Collection<FolderData> foldersData = new ArrayList<FolderData>();
162
        Collection<FolderData> foldersData = new ArrayList<FolderData>();
163
        Collection<JobData> jobsData = getJobsData(docInstance, parentFolder.getUrl(), Collections.<ViewData>emptySet(), foldersData);
163
        Collection<JobData> jobsData = getJobsData(docInstance, parentFolder.getUrl(), Collections.<ViewData>emptySet(), foldersData, parentFolder);
164
        return new InstanceData(jobsData, Collections.<ViewData>emptySet(), foldersData);
164
        return new InstanceData(jobsData, Collections.<ViewData>emptySet(), foldersData);
165
    }
165
    }
166
166
Lines 324-330 Link Here
324
    }
324
    }
325
    
325
    
326
    private Collection<JobData> getJobsData(Document doc, String baseUrl,
326
    private Collection<JobData> getJobsData(Document doc, String baseUrl,
327
            Collection<ViewData> viewsData, Collection<FolderData> foldersData) {
327
            Collection<ViewData> viewsData, Collection<FolderData> foldersData,
328
            HudsonFolder parentFolder) {
328
        Collection<JobData> jobs = new ArrayList<JobData>();
329
        Collection<JobData> jobs = new ArrayList<JobData>();
329
        
330
        
330
        NodeList nodes = doc.getDocumentElement().getChildNodes();
331
        NodeList nodes = doc.getDocumentElement().getChildNodes();
Lines 348-355 Link Here
348
                }
349
                }
349
                String nodeName = d.getNodeName();
350
                String nodeName = d.getNodeName();
350
                if (nodeName.equals(XML_API_NAME_ELEMENT)) {
351
                if (nodeName.equals(XML_API_NAME_ELEMENT)) {
351
                    jd.setJobName(d.getFirstChild().getTextContent());
352
                    String folder = parentFolder == null
352
                    fd.setName(d.getFirstChild().getTextContent());
353
                            ? "" : parentFolder.getName() + "/";        //NOI18N
354
                    String name = folder + d.getFirstChild().getTextContent();
355
                    jd.setJobName(name);
356
                    fd.setName(name);
353
                } else if (nodeName.equals(XML_API_URL_ELEMENT)) {
357
                } else if (nodeName.equals(XML_API_URL_ELEMENT)) {
354
                    String u = normalizeUrl(baseUrl, d.getFirstChild().getTextContent(), "job/[^/]+/"); // NOI18N
358
                    String u = normalizeUrl(baseUrl, d.getFirstChild().getTextContent(), "job/[^/]+/"); // NOI18N
355
                    jd.setJobUrl(u);
359
                    jd.setJobUrl(u);
(-)a/hudson/src/org/netbeans/modules/hudson/impl/HudsonInstanceProperties.java (-5 / +15 lines)
Lines 46-51 Link Here
46
46
47
import java.beans.PropertyChangeListener;
47
import java.beans.PropertyChangeListener;
48
import java.beans.PropertyChangeSupport;
48
import java.beans.PropertyChangeSupport;
49
import java.util.ArrayList;
49
import java.util.Arrays;
50
import java.util.Arrays;
50
import java.util.Collections;
51
import java.util.Collections;
51
import java.util.HashMap;
52
import java.util.HashMap;
Lines 191-209 Link Here
191
    }
192
    }
192
193
193
    public static List<String> split(String prop) {
194
    public static List<String> split(String prop) {
194
        return prop != null && prop.trim().length() > 0 ?
195
        if (prop != null && prop.trim().length() > 0) {
195
            Arrays.asList(prop.split("/")) : // NOI18N
196
            String[] escaped = prop.split("(?<!/)/(?!/)");              //NOI18N
196
            Collections.<String>emptyList();
197
            List<String> list = new ArrayList<String>(escaped.length);
198
            for (String e : escaped) {
199
                list.add(e.replace("//", "/"));                         //NOI18N
200
            }
201
            return list;
202
        } else {
203
            return Collections.<String>emptyList();
204
        }
197
    }
205
    }
198
206
199
    public static String join(List<String> pieces) {
207
    public static String join(List<String> pieces) {
200
        StringBuilder b = new StringBuilder();
208
        StringBuilder b = new StringBuilder();
201
        for (String piece : pieces) {
209
        for (String piece : pieces) {
202
            assert !piece.contains("/") : piece;
210
            assert !piece.startsWith("/") //NOI18N
211
                    && !piece.endsWith("/") : piece;                    //NOI18N
212
            String escaped = piece.replace("/", "//");                  //NOI18N
203
            if (b.length() > 0) {
213
            if (b.length() > 0) {
204
                b.append('/');
214
                b.append('/');
205
            }
215
            }
206
            b.append(piece);
216
            b.append(escaped);
207
        }
217
        }
208
        return b.toString();
218
        return b.toString();
209
    }
219
    }
(-)a/hudson/src/org/netbeans/modules/hudson/spi/ProjectHudsonProvider.java (-1 / +14 lines)
Lines 244-250 Link Here
244
         * @return the code name of the job on that server; may be null
244
         * @return the code name of the job on that server; may be null
245
         */
245
         */
246
        public String getJobName() {
246
        public String getJobName() {
247
            return jobPath.length > 1 ? jobPath[jobPath.length - 1] : null;
247
            if (jobPath.length == 2) {
248
                return jobPath[1];
249
            } else if (jobPath.length > 2) {
250
                StringBuilder sb = new StringBuilder();
251
                for (int i = 1; i < jobPath.length; i++) {
252
                    if (sb.length() > 0) {
253
                        sb.append("/");                                 //NOI18N
254
                    }
255
                    sb.append(jobPath[i]);
256
                }
257
                return sb.toString();
258
            } else {
259
                return null;
260
            }
248
        }
261
        }
249
262
250
        /**
263
        /**
(-)a/hudson/src/org/netbeans/modules/hudson/ui/nodes/HudsonFolderNode.java (-1 / +5 lines)
Lines 71-77 Link Here
71
    HudsonFolderNode(HudsonFolder folder) {
71
    HudsonFolderNode(HudsonFolder folder) {
72
        super(Children.create(new HudsonFolderChildren(folder), true), Lookups.singleton(folder));
72
        super(Children.create(new HudsonFolderChildren(folder), true), Lookups.singleton(folder));
73
        this.folder = folder;
73
        this.folder = folder;
74
        setName(folder.getName());
74
        String name = folder.getName();
75
        setName(name);
76
        setDisplayName(!name.contains("/") ? name //NOI18N
77
                : name.substring(name.lastIndexOf("/") + 1, //NOI18N
78
                name.length()));
75
    }
79
    }
76
80
77
    public @Override Image getIcon(int type) {
81
    public @Override Image getIcon(int type) {
(-)a/hudson/test/unit/src/org/netbeans/modules/hudson/spi/ProjectHudsonProviderTest.java (-1 / +1 lines)
Lines 80-86 Link Here
80
        Association a = Association.fromString(
80
        Association a = Association.fromString(
81
                "http://localhost:8080/app/hudson/job/folder%201/job/folder%201a/job/TestJob/");
81
                "http://localhost:8080/app/hudson/job/folder%201/job/folder%201a/job/TestJob/");
82
        assertEquals("http://localhost:8080/app/hudson/", a.getServerUrl());
82
        assertEquals("http://localhost:8080/app/hudson/", a.getServerUrl());
83
        assertEquals("TestJob", a.getJobName());
83
        assertEquals("folder 1/folder 1a/TestJob", a.getJobName());
84
        String[] expectedPath = {"http://localhost:8080/app/hudson/",
84
        String[] expectedPath = {"http://localhost:8080/app/hudson/",
85
            "folder 1", "folder 1a", "TestJob"};
85
            "folder 1", "folder 1a", "TestJob"};
86
        assertEquals("Job path length is wrong",
86
        assertEquals("Job path length is wrong",

Return to bug 215135