mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-16 10:16:16 +01:00
improve screenshot resource
This commit is contained in:
@@ -124,7 +124,8 @@ public class ScreenshotResource
|
|||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Produces("image/jpeg")
|
@Produces("image/jpeg")
|
||||||
public Response getScreenshot(@PathParam("groupId") String groupId,
|
public Response getScreenshot(
|
||||||
|
@PathParam("groupId") String groupId,
|
||||||
@PathParam("artifactId") String artifactId,
|
@PathParam("artifactId") String artifactId,
|
||||||
@PathParam("number") int number,
|
@PathParam("number") int number,
|
||||||
@PathParam("size") String size)
|
@PathParam("size") String size)
|
||||||
@@ -153,15 +154,9 @@ public class ScreenshotResource
|
|||||||
}
|
}
|
||||||
|
|
||||||
String checksum = ChecksumUtil.createChecksum(screenshot);
|
String checksum = ChecksumUtil.createChecksum(screenshot);
|
||||||
StringBuilder path = new StringBuilder(PATH_IMAGE);
|
|
||||||
|
|
||||||
path.append(File.separator).append(groupId);
|
File file = createThumbnailFile(groupId, artifactId, number, size,
|
||||||
path.append(File.separator).append(artifactId).append(File.separator);
|
checksum);
|
||||||
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());
|
|
||||||
|
|
||||||
if (!file.exists())
|
if (!file.exists())
|
||||||
{
|
{
|
||||||
@@ -207,6 +202,32 @@ public class ScreenshotResource
|
|||||||
ImageIO.write(image, FORMAT, file);
|
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 ---------------------------------------------------------------
|
//~--- fields ---------------------------------------------------------------
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
|
|||||||
Reference in New Issue
Block a user