1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.xpn.xwiki.plugin.webdav.resources.views; |
21 |
|
|
22 |
|
import java.util.ArrayList; |
23 |
|
import java.util.List; |
24 |
|
|
25 |
|
import org.apache.jackrabbit.webdav.DavException; |
26 |
|
import org.apache.jackrabbit.webdav.DavResource; |
27 |
|
import org.apache.jackrabbit.webdav.DavResourceIterator; |
28 |
|
import org.apache.jackrabbit.webdav.DavResourceIteratorImpl; |
29 |
|
import org.apache.jackrabbit.webdav.DavServletResponse; |
30 |
|
import org.slf4j.Logger; |
31 |
|
import org.slf4j.LoggerFactory; |
32 |
|
|
33 |
|
import com.xpn.xwiki.plugin.webdav.resources.XWikiDavResource; |
34 |
|
import com.xpn.xwiki.plugin.webdav.resources.partial.AbstractDavView; |
35 |
|
import com.xpn.xwiki.plugin.webdav.resources.views.attachments.AttachmentsView; |
36 |
|
import com.xpn.xwiki.plugin.webdav.resources.views.pages.PagesView; |
37 |
|
import com.xpn.xwiki.plugin.webdav.utils.XWikiDavUtils.BaseViews; |
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
@version |
43 |
|
|
|
|
| 94.8% |
Uncovered Elements: 3 (58) |
Complexity: 12 |
Complexity Density: 0.3 |
|
44 |
|
public class RootView extends AbstractDavView |
45 |
|
{ |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
private static final Logger logger = LoggerFactory.getLogger(RootView.class); |
50 |
|
|
|
|
| 94.4% |
Uncovered Elements: 2 (36) |
Complexity: 10 |
Complexity Density: 0.5 |
|
51 |
83 |
@Override... |
52 |
|
public XWikiDavResource decode(String[] tokens, int next) throws DavException |
53 |
|
{ |
54 |
83 |
String nextToken = tokens[next]; |
55 |
83 |
boolean last = (next == tokens.length - 1); |
56 |
83 |
XWikiDavResource resource = null; |
57 |
83 |
if (isTempResource(nextToken)) { |
58 |
26 |
return super.decode(tokens, next); |
59 |
57 |
} else if (last && getContext().isCreateOrMoveRequest()) { |
60 |
14 |
throw new DavException(DavServletResponse.SC_METHOD_NOT_ALLOWED); |
61 |
43 |
} else if (nextToken.equals(BaseViews.HOME)) { |
62 |
1 |
resource = new HomeView(); |
63 |
42 |
} else if (nextToken.equals(BaseViews.PAGES)) { |
64 |
39 |
resource = new PagesView(); |
65 |
3 |
} else if (nextToken.equals(BaseViews.ORPHANS)) { |
66 |
1 |
resource = new OrphansView(); |
67 |
2 |
} else if (nextToken.equals(BaseViews.WHATSNEW)) { |
68 |
1 |
resource = new WhatsnewView(); |
69 |
1 |
} else if (nextToken.equals(BaseViews.ATTACHMENTS)) { |
70 |
1 |
resource = new AttachmentsView(); |
71 |
|
} else { |
72 |
0 |
throw new DavException(DavServletResponse.SC_BAD_REQUEST); |
73 |
|
} |
74 |
43 |
resource.init(this, nextToken, "/" + nextToken); |
75 |
43 |
return last ? resource : resource.decode(tokens, next + 1); |
76 |
|
} |
77 |
|
|
|
|
| 95% |
Uncovered Elements: 1 (20) |
Complexity: 2 |
Complexity Density: 0.1 |
|
78 |
1 |
@Override... |
79 |
|
public DavResourceIterator getMembers() |
80 |
|
{ |
81 |
1 |
List<DavResource> children = new ArrayList<DavResource>(); |
82 |
1 |
try { |
83 |
1 |
XWikiDavResource homeView = new HomeView(); |
84 |
1 |
homeView.init(this, "home", "/home"); |
85 |
1 |
children.add(homeView); |
86 |
1 |
XWikiDavResource pagesView = new PagesView(); |
87 |
1 |
pagesView.init(this, "spaces", "/spaces"); |
88 |
1 |
children.add(pagesView); |
89 |
1 |
XWikiDavResource attachmentsView = new AttachmentsView(); |
90 |
1 |
attachmentsView.init(this, "attachments", "/attachments"); |
91 |
1 |
children.add(attachmentsView); |
92 |
1 |
XWikiDavResource orphansView = new OrphansView(); |
93 |
1 |
orphansView.init(this, "orphans", "/orphans"); |
94 |
1 |
children.add(orphansView); |
95 |
1 |
XWikiDavResource whatsnewView = new WhatsnewView(); |
96 |
1 |
whatsnewView.init(this, "whatsnew", "/whatsnew"); |
97 |
1 |
children.add(whatsnewView); |
98 |
|
} catch (DavException e) { |
99 |
0 |
logger.error("Unexpected Error : ", e); |
100 |
|
} |
101 |
1 |
children.addAll(getVirtualMembers()); |
102 |
1 |
return new DavResourceIteratorImpl(children); |
103 |
|
} |
104 |
|
} |