Skip to content

Commit

Permalink
minor improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
Likqez committed May 31, 2022
1 parent 26169c0 commit a617a8e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
5 changes: 2 additions & 3 deletions src/main/java/dev/dotspace/url/ctrl/URLController.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public GenerationResponse createMinified(@Validated @RequestBody CreationRequest

/* QR-Code generation */
var qrcode = QRCodeGenerator.getQRCodeBase64(minifiedURL + "?q", 500, 500, getClass().getResource("/static/img/logo_round-128x128.png").toString());
image = qrcode.orElse(QRCodeGenerator.SAMPLE);
image = qrcode.orElse("-");

/* Try inserting into Storage. If uid is duplicate -> try again */
StorageManager.newMinified(
Expand All @@ -54,8 +54,7 @@ public GenerationResponse createMinified(@Validated @RequestBody CreationRequest

@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(MethodArgumentNotValidException.class)
public Map<String, String> handleValidationExceptions(
MethodArgumentNotValidException ex) {
public Map<String, String> handleValidationExceptions(MethodArgumentNotValidException ex) {
Map<String, String> errors = new HashMap<>();
ex.getBindingResult().getAllErrors().forEach((error) -> {
String fieldName = ((FieldError) error).getField();
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/dev/dotspace/url/storage/StorageManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

/**
* For explanations
*
* @see StorageImplementation
*/
public class StorageManager {
Expand Down Expand Up @@ -48,8 +49,8 @@ public static Optional<String> queryUrl(String uid) {

public static void newMinified(String uid, String url, String image, Runnable success) throws RuntimeException {
executorService.execute(() -> {
boolean b = storageImpl.get().newMinified(uid, url, image);
if (b) success.run();
if (storageImpl.get().newMinified(uid, url, image))
success.run();
});
}

Expand Down
14 changes: 0 additions & 14 deletions src/main/java/dev/dotspace/url/util/QRCodeGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,6 @@
*/
public class QRCodeGenerator {

@SuppressWarnings("all")
public static final String SAMPLE = "iVBORw0KGgoAAAANSUhEUgAAANwAAADcAQMAAAAhlF3CAAAABlBMVEX///" +
"8AAABVwtN+AAAACXBIWXMAAA7EAAAOxAGVKw4bAAABlklEQVRYhd2YsZHE" +
"MAhF0ThQ6BJUiks7leZSXILCDTRi+YB3fLfXACjYsfU24Qt9wMS6XrRfRH" +
"T0H3lZm20OigWX7FF97Xw1bHSisraJzT0XLCJBFRGYLzqYiUSEKTKMqBBx" +
"Xsepx0mJIVHDgXbSvA0KPTVHwx2UOP/L2wTQrQawnWI1xOXLhzLAxzJosn" +
"ytAFCjrPhFnAyvKXObOOFUEI9Cx10F1VJRFpG3sWARk7SC3iwh5e88/TwT" +
"wTtLvQp2iED3eSaCUjlmNRGuQ0Uwk1WjiQbn9tI45QpKdZAwfQt5mwlCBK" +
"sEh5Z7VIf5VCgKhLG46ahratusd3KkgrLwvHt16Kw7LkIsuMwjtQcT9qkO" +
"1RvRNFAi1olOll5BE4GqipAJkvoKxiAyq8HxW94GhFrWUB260HK3ZSMT9G" +
"X3E09iqXpl40FrvGyikyG882dyJcoEfXLVCf30ntpTeaSC/lHFJlc0aM+k" +
"DgmlafZPl8uqYFrY2HtNu51I3GDQUlNdUydX/jsG5YC31ZgI+BC2MLP/9q" +
"H48A2o0D2Y1cCU2wAAAABJRU5ErkJggg==";

/**
* TODO add documentation
*
Expand Down

0 comments on commit a617a8e

Please sign in to comment.