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.image; |
21 |
|
|
22 |
|
import org.slf4j.Logger; |
23 |
|
import org.slf4j.LoggerFactory; |
24 |
|
import org.xwiki.model.reference.DocumentReference; |
25 |
|
import org.xwiki.model.reference.DocumentReferenceResolver; |
26 |
|
|
27 |
|
import com.xpn.xwiki.XWikiContext; |
28 |
|
import com.xpn.xwiki.XWikiException; |
29 |
|
import com.xpn.xwiki.doc.XWikiAttachment; |
30 |
|
import com.xpn.xwiki.doc.XWikiDocument; |
31 |
|
import com.xpn.xwiki.plugin.PluginApi; |
32 |
|
import com.xpn.xwiki.web.Utils; |
33 |
|
|
34 |
|
|
35 |
|
@version |
36 |
|
@deprecated |
37 |
|
|
38 |
|
@Deprecated |
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 6 |
Complexity Density: 0.5 |
|
39 |
|
public class ImagePluginAPI extends PluginApi<ImagePlugin> |
40 |
|
{ |
41 |
|
|
42 |
|
private static final Logger LOG = LoggerFactory.getLogger(ImagePluginAPI.class); |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
private DocumentReferenceResolver<String> currentMixedDocumentReferenceResolver = |
50 |
|
Utils.getComponent(DocumentReferenceResolver.TYPE_STRING, "currentmixed"); |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
@param |
56 |
|
@param |
57 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
58 |
0 |
public ImagePluginAPI(ImagePlugin imagePlugin, XWikiContext context)... |
59 |
|
{ |
60 |
0 |
super(imagePlugin, context); |
61 |
|
} |
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
@param |
67 |
|
@param |
68 |
|
@return |
69 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
70 |
0 |
public int getHeight(String pageName, String attachmentName)... |
71 |
|
{ |
72 |
0 |
try { |
73 |
0 |
return getProtectedPlugin().getHeight(getAttachment(pageName, attachmentName), getXWikiContext()); |
74 |
|
} catch (Exception e) { |
75 |
0 |
LOG.error(String.format("Failed to detect the height of %s attached to %s.", attachmentName, pageName), e); |
76 |
0 |
return -1; |
77 |
|
} |
78 |
|
} |
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
@param |
84 |
|
@param |
85 |
|
@return |
86 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
87 |
0 |
public int getWidth(String pageName, String attachmentName)... |
88 |
|
{ |
89 |
0 |
try { |
90 |
0 |
return getProtectedPlugin().getWidth(getAttachment(pageName, attachmentName), getXWikiContext()); |
91 |
|
} catch (Exception e) { |
92 |
0 |
LOG.error(String.format("Failed to detect the width of %s attached to %s.", attachmentName, pageName), e); |
93 |
0 |
return -1; |
94 |
|
} |
95 |
|
} |
96 |
|
|
97 |
|
|
98 |
|
@param |
99 |
|
@param |
100 |
|
@return |
101 |
|
@throws |
102 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
103 |
0 |
private XWikiAttachment getAttachment(String pageName, String attachmentName) throws XWikiException... |
104 |
|
{ |
105 |
0 |
DocumentReference documentReference = this.currentMixedDocumentReferenceResolver.resolve(pageName); |
106 |
0 |
XWikiDocument document = getXWikiContext().getWiki().getDocument(documentReference, getXWikiContext()); |
107 |
0 |
return document.getAttachment(attachmentName); |
108 |
|
} |
109 |
|
} |