Merge conflict fixes
This commit is contained in:
+1
-2
@@ -23,8 +23,7 @@ public class KoreaderController {
|
|||||||
@GetMapping("/users/auth")
|
@GetMapping("/users/auth")
|
||||||
public ResponseEntity<Map<String, String>> authorizeUser() {
|
public ResponseEntity<Map<String, String>> authorizeUser() {
|
||||||
return koreaderService
|
return koreaderService
|
||||||
.authorizeUser()
|
.authorizeUser();
|
||||||
.contentType(MediaType.APPLICATION_JSON);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/users/create")
|
@PostMapping("/users/create")
|
||||||
|
|||||||
+1
-1
@@ -330,7 +330,7 @@ public class DoubanBookParser implements BookParser {
|
|||||||
|
|
||||||
String encodedSearchTerm = searchTerm.toString().replace(" ", "+");
|
String encodedSearchTerm = searchTerm.toString().replace(" ", "+");
|
||||||
String url = "https://search.douban.com/book/subject_search?search_text=" + encodedSearchTerm;
|
String url = "https://search.douban.com/book/subject_search?search_text=" + encodedSearchTerm;
|
||||||
log.info("Query URL: {}", url);
|
log.info("Douban Query URL: {}", url);
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ import java.awt.image.BufferedImage;
|
|||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
@@ -171,26 +169,9 @@ public class FileService {
|
|||||||
return input == null ? null : (input.length() <= maxLength ? input : input.substring(0, maxLength));
|
return input == null ? null : (input.length() <= maxLength ? input : input.substring(0, maxLength));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resizeAndSaveImage(String imageSource, File outputFolder, String outputFileName) throws IOException {
|
private void validateCoverFile(MultipartFile file) {
|
||||||
BufferedImage originalImage;
|
if (file.isEmpty()) {
|
||||||
File file = new File(imageSource);
|
throw new IllegalArgumentException("Uploaded file is empty");
|
||||||
if (file.exists()) {
|
|
||||||
try (InputStream inputStream = new FileInputStream(file)) {
|
|
||||||
originalImage = ImageIO.read(inputStream);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
URL url = new URL(imageSource);
|
|
||||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
|
||||||
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36");
|
|
||||||
connection.setConnectTimeout(10000);
|
|
||||||
connection.setReadTimeout(10000);
|
|
||||||
try (InputStream inputStream = connection.getInputStream()) {
|
|
||||||
originalImage = ImageIO.read(inputStream);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new IOException("Failed to download image from URL: " + imageSource + " - " + e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
String contentType = file.getContentType();
|
String contentType = file.getContentType();
|
||||||
if (!(JPEG_MIME_TYPE.equalsIgnoreCase(contentType) || PNG_MIME_TYPE.equalsIgnoreCase(contentType))) {
|
if (!(JPEG_MIME_TYPE.equalsIgnoreCase(contentType) || PNG_MIME_TYPE.equalsIgnoreCase(contentType))) {
|
||||||
|
|||||||
-1
@@ -36,7 +36,6 @@ class KoreaderControllerTest {
|
|||||||
when(koreaderService.authorizeUser()).thenReturn(ResponseEntity.ok(expected));
|
when(koreaderService.authorizeUser()).thenReturn(ResponseEntity.ok(expected));
|
||||||
ResponseEntity<Map<String, String>> resp = controller.authorizeUser();
|
ResponseEntity<Map<String, String>> resp = controller.authorizeUser();
|
||||||
assertEquals(HttpStatus.OK, resp.getStatusCode());
|
assertEquals(HttpStatus.OK, resp.getStatusCode());
|
||||||
assertEquals(MediaType.APPLICATION_JSON, resp.getHeaders().getContentType());
|
|
||||||
assertEquals(expected, resp.getBody());
|
assertEquals(expected, resp.getBody());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user