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.utils; |
21 |
|
|
22 |
|
import com.xpn.xwiki.api.Attachment; |
23 |
|
import com.xpn.xwiki.api.Document; |
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
@version |
29 |
|
|
|
|
| 0% |
Uncovered Elements: 26 (26) |
Complexity: 8 |
Complexity Density: 0.57 |
|
30 |
|
public final class XWikiDavUtils |
31 |
|
{ |
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
public static final String URL_SEPARATOR = "/"; |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
public static final String VIRTUAL_DIRECTORY_PREFIX = "_"; |
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
public static final String VIRTUAL_DIRECTORY_POSTFIX = VIRTUAL_DIRECTORY_PREFIX; |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
public static final String XWIKI_ATTACHMENT_SIGNATURE = "/xwiki/bin/download/"; |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
public static final String XWIKI_WEBDAV_SIGNATURE = "/xwiki/webdav/spaces/"; |
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
60 |
|
public interface BaseViews |
61 |
|
{ |
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
String ROOT = "root"; |
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
String PAGES = "spaces"; |
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
String ATTACHMENTS = "attachments"; |
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
String HOME = "home"; |
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
String ORPHANS = "orphans"; |
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
String WHATSNEW = "whatsnew"; |
91 |
|
} |
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
96 |
0 |
private XWikiDavUtils()... |
97 |
|
{ |
98 |
|
|
99 |
|
} |
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
|
104 |
|
@param |
105 |
|
@return |
106 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
107 |
0 |
public static int getSubViewNameLength(int totalDocumentCount)... |
108 |
|
{ |
109 |
|
|
110 |
0 |
if (totalDocumentCount < 200) { |
111 |
0 |
return 1; |
112 |
0 |
} else if (totalDocumentCount < 5000) { |
113 |
0 |
return 2; |
114 |
|
} else { |
115 |
0 |
return 3; |
116 |
|
} |
117 |
|
} |
118 |
|
|
119 |
|
|
120 |
|
@param@link |
121 |
|
@param@link |
122 |
|
@return |
123 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
124 |
0 |
public static String getDavURL(Document doc, Attachment attachment)... |
125 |
|
{ |
126 |
0 |
String docDownloadURL = doc.getExternalURL("download"); |
127 |
0 |
String httpUrl = docDownloadURL.endsWith(URL_SEPARATOR) ? docDownloadURL + attachment.getFilename() |
128 |
|
: docDownloadURL + URL_SEPARATOR + attachment.getFilename(); |
129 |
0 |
return getDavURL(httpUrl); |
130 |
|
} |
131 |
|
|
132 |
|
|
133 |
|
@param |
134 |
|
@return |
135 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
136 |
0 |
private static String getDavURL(String httpUrl)... |
137 |
|
{ |
138 |
|
|
139 |
0 |
String webDAVUrl = ""; |
140 |
0 |
if (httpUrl.contains(XWIKI_ATTACHMENT_SIGNATURE)) { |
141 |
0 |
String[] parts = httpUrl.split(XWIKI_ATTACHMENT_SIGNATURE); |
142 |
0 |
String[] elements = parts[1].split(URL_SEPARATOR); |
143 |
0 |
webDAVUrl = parts[0] + XWIKI_WEBDAV_SIGNATURE + elements[0] |
144 |
|
+ URL_SEPARATOR + elements[1] + URL_SEPARATOR + elements[2]; |
145 |
|
} |
146 |
0 |
return webDAVUrl; |
147 |
|
} |
148 |
|
} |