mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-08-27 06:39:24 +00:00
log issue
This commit is contained in:
parent
377c795fd6
commit
2148556f94
@ -146,7 +146,6 @@ public class ExceptionUtils {
|
|||||||
public static IllegalArgumentException createIllegalArgumentException(
|
public static IllegalArgumentException createIllegalArgumentException(
|
||||||
String messageKey, String defaultMessage, Object... args) {
|
String messageKey, String defaultMessage, Object... args) {
|
||||||
String message = I18nUtils.getMessage(messageKey, defaultMessage, args);
|
String message = I18nUtils.getMessage(messageKey, defaultMessage, args);
|
||||||
System.out.println("######## Test " + message);
|
|
||||||
return new IllegalArgumentException(message);
|
return new IllegalArgumentException(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,8 +227,6 @@ public class EndpointConfiguration {
|
|||||||
log.info(
|
log.info(
|
||||||
"No endpoints disabled despite missing tools - fallback implementations available");
|
"No endpoints disabled despite missing tools - fallback implementations available");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
|
@ -601,7 +601,7 @@ public class CompressController {
|
|||||||
if (bytesRead > 0) {
|
if (bytesRead > 0) {
|
||||||
byte[] dataToHash =
|
byte[] dataToHash =
|
||||||
bytesRead == buffer.length ? buffer : Arrays.copyOf(buffer, bytesRead);
|
bytesRead == buffer.length ? buffer : Arrays.copyOf(buffer, bytesRead);
|
||||||
return bytesToHexString(generatMD5(dataToHash));
|
return bytesToHexString(generateMD5(dataToHash));
|
||||||
}
|
}
|
||||||
return "empty-stream";
|
return "empty-stream";
|
||||||
}
|
}
|
||||||
@ -619,7 +619,7 @@ public class CompressController {
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] generatMD5(byte[] data) throws IOException {
|
private byte[] generateMD5(byte[] data) throws IOException {
|
||||||
try {
|
try {
|
||||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||||
return md.digest(data); // Get the MD5 hash of the image bytes
|
return md.digest(data); // Get the MD5 hash of the image bytes
|
||||||
|
@ -149,8 +149,7 @@ public class GetInfoOnPDF {
|
|||||||
try {
|
try {
|
||||||
PDMetadata pdMetadata = document.getDocumentCatalog().getMetadata();
|
PDMetadata pdMetadata = document.getDocumentCatalog().getMetadata();
|
||||||
if (pdMetadata != null) {
|
if (pdMetadata != null) {
|
||||||
COSInputStream metaStream = pdMetadata.createInputStream();
|
try (COSInputStream metaStream = pdMetadata.createInputStream()) {
|
||||||
|
|
||||||
// First try to read raw metadata as string to check for standard keywords
|
// First try to read raw metadata as string to check for standard keywords
|
||||||
byte[] metadataBytes = metaStream.readAllBytes();
|
byte[] metadataBytes = metaStream.readAllBytes();
|
||||||
String rawMetadata = new String(metadataBytes, StandardCharsets.UTF_8);
|
String rawMetadata = new String(metadataBytes, StandardCharsets.UTF_8);
|
||||||
@ -158,12 +157,10 @@ public class GetInfoOnPDF {
|
|||||||
if (rawMetadata.contains(standardKeyword)) {
|
if (rawMetadata.contains(standardKeyword)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If raw check doesn't find it, try parsing with XMP parser
|
// If raw check doesn't find it, try parsing with XMP parser
|
||||||
// Reset stream for parsing
|
try (COSInputStream metaStream = pdMetadata.createInputStream()) {
|
||||||
metaStream.close();
|
|
||||||
metaStream = pdMetadata.createInputStream();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DomXmpParser domXmpParser = new DomXmpParser();
|
DomXmpParser domXmpParser = new DomXmpParser();
|
||||||
XMPMetadata xmpMeta = domXmpParser.parse(metaStream);
|
XMPMetadata xmpMeta = domXmpParser.parse(metaStream);
|
||||||
@ -182,6 +179,7 @@ public class GetInfoOnPDF {
|
|||||||
e.getMessage());
|
e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("exception", e);
|
log.error("exception", e);
|
||||||
}
|
}
|
||||||
@ -409,20 +407,18 @@ public class GetInfoOnPDF {
|
|||||||
|
|
||||||
if (pdMetadata != null) {
|
if (pdMetadata != null) {
|
||||||
try {
|
try {
|
||||||
COSInputStream is = pdMetadata.createInputStream();
|
try (COSInputStream is = pdMetadata.createInputStream()) {
|
||||||
|
|
||||||
try {
|
|
||||||
DomXmpParser domXmpParser = new DomXmpParser();
|
DomXmpParser domXmpParser = new DomXmpParser();
|
||||||
XMPMetadata xmpMeta = domXmpParser.parse(is);
|
XMPMetadata xmpMeta = domXmpParser.parse(is);
|
||||||
|
|
||||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||||
new XmpSerializer().serialize(xmpMeta, os, true);
|
new XmpSerializer().serialize(xmpMeta, os, true);
|
||||||
xmpString = new String(os.toByteArray(), StandardCharsets.UTF_8);
|
xmpString = new String(os.toByteArray(), StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
} catch (XmpParsingException e) {
|
} catch (XmpParsingException e) {
|
||||||
// XMP parsing failed, try to read raw metadata instead
|
// XMP parsing failed, try to read raw metadata instead
|
||||||
log.debug("XMP parsing failed, reading raw metadata: {}", e.getMessage());
|
log.debug("XMP parsing failed, reading raw metadata: {}", e.getMessage());
|
||||||
is.close();
|
try (COSInputStream is = pdMetadata.createInputStream()) {
|
||||||
is = pdMetadata.createInputStream();
|
|
||||||
byte[] metadataBytes = is.readAllBytes();
|
byte[] metadataBytes = is.readAllBytes();
|
||||||
xmpString = new String(metadataBytes, StandardCharsets.UTF_8);
|
xmpString = new String(metadataBytes, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user