| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package com.xpn.xwiki.web; |
| 21 |
|
|
| 22 |
|
import java.io.IOException; |
| 23 |
|
|
| 24 |
|
import org.slf4j.Logger; |
| 25 |
|
import org.slf4j.LoggerFactory; |
| 26 |
|
import org.xwiki.formula.ImageData; |
| 27 |
|
import org.xwiki.formula.ImageStorage; |
| 28 |
|
|
| 29 |
|
import com.xpn.xwiki.XWikiContext; |
| 30 |
|
import com.xpn.xwiki.XWikiException; |
| 31 |
|
import com.xpn.xwiki.util.Util; |
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
@link@link |
| 36 |
|
|
| 37 |
|
@version |
| 38 |
|
@since |
| 39 |
|
|
| |
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 3 |
Complexity Density: 0.21 |
|
| 40 |
|
public class TexAction extends XWikiAction |
| 41 |
|
{ |
| 42 |
|
|
| 43 |
|
private static final Logger LOGGER = LoggerFactory.getLogger(TexAction.class); |
| 44 |
|
|
| |
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 3 |
Complexity Density: 0.21 |
|
| 45 |
0 |
@Override... |
| 46 |
|
public String render(XWikiContext context) throws XWikiException |
| 47 |
|
{ |
| 48 |
0 |
XWikiRequest request = context.getRequest(); |
| 49 |
0 |
XWikiResponse response = context.getResponse(); |
| 50 |
0 |
String path = request.getRequestURI(); |
| 51 |
|
|
| 52 |
0 |
String filename = Util.decodeURI(path.substring(path.lastIndexOf("/") + 1), context); |
| 53 |
0 |
ImageStorage storage = Utils.getComponent(ImageStorage.class); |
| 54 |
0 |
ImageData image = storage.get(filename); |
| 55 |
0 |
if (image == null) { |
| 56 |
0 |
return "docdoesnotexist"; |
| 57 |
|
} |
| 58 |
0 |
response.setContentLength(image.getData().length); |
| 59 |
0 |
response.setContentType(image.getMimeType()); |
| 60 |
0 |
try { |
| 61 |
0 |
response.getOutputStream().write(image.getData()); |
| 62 |
|
} catch (IOException e) { |
| 63 |
0 |
LOGGER.info("Failed to send image to the client"); |
| 64 |
|
} |
| 65 |
|
|
| 66 |
0 |
return null; |
| 67 |
|
} |
| 68 |
|
} |