improve screenshot resource

This commit is contained in:
Sebastian Sdorra
2013-01-04 20:26:30 +01:00
parent 0af5638d52
commit 14f8a3f999

View File

@@ -124,7 +124,8 @@ public class ScreenshotResource
*/
@GET
@Produces("image/jpeg")
public Response getScreenshot(@PathParam("groupId") String groupId,
public Response getScreenshot(
@PathParam("groupId") String groupId,
@PathParam("artifactId") String artifactId,
@PathParam("number") int number,
@PathParam("size") String size)
@@ -153,15 +154,9 @@ public class ScreenshotResource
}
String checksum = ChecksumUtil.createChecksum(screenshot);
StringBuilder path = new StringBuilder(PATH_IMAGE);
path.append(File.separator).append(groupId);
path.append(File.separator).append(artifactId).append(File.separator);
path.append(String.valueOf(number)).append(File.separator);
path.append(size).append(File.separator).append(checksum);
path.append(EXTENSION_IMAGE);
File file = new File(backend.getBaseDirectory(), path.toString());
File file = createThumbnailFile(groupId, artifactId, number, size,
checksum);
if (!file.exists())
{
@@ -207,6 +202,32 @@ public class ScreenshotResource
ImageIO.write(image, FORMAT, file);
}
/**
* Method description
*
*
* @param groupId
* @param artifactId
* @param number
* @param size
* @param checksum
*
* @return
*/
private File createThumbnailFile(String groupId, String artifactId,
int number, String size, String checksum)
{
StringBuilder path = new StringBuilder(PATH_IMAGE);
path.append(File.separator).append(groupId);
path.append(File.separator).append(artifactId).append(File.separator);
path.append(String.valueOf(number)).append(File.separator);
path.append(size).append(File.separator).append(checksum);
path.append(EXTENSION_IMAGE);
return new File(backend.getBaseDirectory(), path.toString());
}
//~--- fields ---------------------------------------------------------------
/** Field description */