1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.xpn.xwiki.pdf.impl; |
21 |
|
|
22 |
|
import java.net.URL; |
23 |
|
import java.util.HashMap; |
24 |
|
import java.util.Map; |
25 |
|
|
26 |
|
import org.xwiki.model.reference.AttachmentReference; |
27 |
|
import org.xwiki.model.reference.DocumentReference; |
28 |
|
|
29 |
|
import com.xpn.xwiki.XWikiContext; |
30 |
|
import com.xpn.xwiki.internal.model.LegacySpaceResolver; |
31 |
|
import com.xpn.xwiki.web.Utils; |
32 |
|
import com.xpn.xwiki.web.XWikiServletURLFactory; |
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
@version |
40 |
|
|
|
|
| 0% |
Uncovered Elements: 27 (27) |
Complexity: 7 |
Complexity Density: 0.37 |
|
41 |
|
public class PdfURLFactory extends FileSystemURLFactory |
42 |
|
{ |
43 |
|
private LegacySpaceResolver legacySpaceResolver = Utils.getComponent(LegacySpaceResolver.class); |
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
@link |
48 |
|
|
49 |
|
private XWikiServletURLFactory servletURLFactory = new XWikiServletURLFactory(); |
50 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
51 |
0 |
@Override... |
52 |
|
public void init(XWikiContext context) |
53 |
|
{ |
54 |
0 |
super.init(context); |
55 |
0 |
this.servletURLFactory.init(context); |
56 |
|
} |
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
@see |
62 |
|
|
63 |
|
static final String PDF_EXPORT_CONTEXT_KEY = "pdfExportImageURLMap"; |
64 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
65 |
0 |
@Override... |
66 |
|
public URL createAttachmentURL(String filename, String spaces, String name, String action, String querystring, |
67 |
|
String wiki, XWikiContext context) |
68 |
|
{ |
69 |
0 |
URL url = |
70 |
|
this.servletURLFactory.createAttachmentURL(filename, spaces, name, action, querystring, wiki, context); |
71 |
0 |
saveAttachmentReference(url, wiki, spaces, name, filename, context); |
72 |
0 |
return url; |
73 |
|
} |
74 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
75 |
0 |
@Override... |
76 |
|
public URL createAttachmentRevisionURL(String filename, String spaces, String name, String revision, String wiki, |
77 |
|
XWikiContext context) |
78 |
|
{ |
79 |
0 |
URL url = this.servletURLFactory.createAttachmentURL(filename, spaces, name, revision, wiki, context); |
80 |
0 |
saveAttachmentReference(url, wiki, spaces, name, filename, context); |
81 |
0 |
return url; |
82 |
|
} |
83 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
84 |
0 |
@Override... |
85 |
|
public URL createAttachmentRevisionURL(String filename, String spaces, String name, String revision, |
86 |
|
String querystring, String xwikidb, XWikiContext context) |
87 |
|
{ |
88 |
0 |
URL url = |
89 |
|
this.servletURLFactory.createAttachmentRevisionURL(filename, spaces, name, revision, querystring, xwikidb, |
90 |
|
context); |
91 |
0 |
saveAttachmentReference(url, xwikidb, spaces, name, filename, context); |
92 |
0 |
return url; |
93 |
|
} |
94 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
95 |
0 |
@Override... |
96 |
|
public URL createAttachmentRevisionURL(String filename, String spaces, String name, String revision, long recycleId, |
97 |
|
String querystring, String xwikidb, XWikiContext context) |
98 |
|
{ |
99 |
0 |
URL url = |
100 |
|
this.servletURLFactory.createAttachmentRevisionURL(filename, spaces, name, revision, recycleId, querystring, |
101 |
|
xwikidb, context); |
102 |
0 |
saveAttachmentReference(url, xwikidb, spaces, name, filename, context); |
103 |
0 |
return url; |
104 |
|
} |
105 |
|
|
106 |
|
|
107 |
|
@param |
108 |
|
@param |
109 |
|
@param |
110 |
|
|
111 |
|
@param |
112 |
|
@param |
113 |
|
@param |
114 |
|
@see |
115 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
116 |
0 |
private void saveAttachmentReference(URL url, String wiki, String spaces, String page, String fileName,... |
117 |
|
XWikiContext context) |
118 |
|
{ |
119 |
|
|
120 |
|
|
121 |
0 |
Map<String, AttachmentReference> attachmentMap = |
122 |
|
(Map<String, AttachmentReference>) context.get(PDF_EXPORT_CONTEXT_KEY); |
123 |
0 |
if (attachmentMap == null) { |
124 |
0 |
attachmentMap = new HashMap<>(); |
125 |
0 |
context.put(PDF_EXPORT_CONTEXT_KEY, attachmentMap); |
126 |
|
} |
127 |
|
|
128 |
0 |
attachmentMap.put(url.toString(), new AttachmentReference(fileName, |
129 |
|
new DocumentReference(wiki, this.legacySpaceResolver.resolve(spaces), page))); |
130 |
|
} |
131 |
|
} |