Skip to content

Commit

Permalink
[RELEASE] iText 7 7.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
iText-CI committed Oct 11, 2022
2 parents bb9602a + 2b6d8b9 commit 2650275
Show file tree
Hide file tree
Showing 426 changed files with 58,335 additions and 8,486 deletions.
2 changes: 1 addition & 1 deletion barcodes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.itextpdf</groupId>
<artifactId>root</artifactId>
<version>7.2.3</version>
<version>7.2.4</version>
</parent>
<artifactId>barcodes</artifactId>
<name>iText 7 - barcodes</name>
Expand Down
4 changes: 2 additions & 2 deletions commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<parent>
<groupId>com.itextpdf</groupId>
<artifactId>root</artifactId>
<version>7.2.3</version>
<version>7.2.4</version>
</parent>
<artifactId>commons</artifactId>
<name>iText 7 - commons</name>
<url>https://itextpdf.com/</url>

<properties>
<jackson.core.version>2.13.3</jackson.core.version>
<jackson.core.version>2.13.4</jackson.core.version>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ public IContext getContext(String className) {

String getRecognisedNamespace(String className) {
if (className != null) {
String normalizedClassName = normalize(className);
// If both "a" and "a.b" namespaces are registered,
// iText should consider the context of "a.b" for an "a.b" event,
// that's why the contexts are sorted by the length of the namespace
for (String namespace : contextMappings.keySet()) {
//Conversion to lowercase is done to be compatible with possible changes in case of packages/namespaces
if (className.toLowerCase().startsWith(namespace)) {
if (normalizedClassName.startsWith(namespace)) {
return namespace;
}
}
Expand All @@ -129,7 +129,7 @@ String getRecognisedNamespace(String className) {

void unregisterContext(Collection<String> namespaces) {
for (String namespace : namespaces) {
contextMappings.remove(namespace);
contextMappings.remove(normalize(namespace));
}
}

Expand All @@ -143,11 +143,15 @@ private IContext getNamespaceMapping(String namespace) {
void registerGenericContext(Collection<String> namespaces, Collection<String> products) {
final GenericContext context = new GenericContext(products);
for (String namespace : namespaces) {
//Conversion to lowercase is done to be compatible with possible changes in case of packages/namespaces
contextMappings.put(namespace.toLowerCase(), context);
contextMappings.put(normalize(namespace), context);
}
}

private static String normalize(String namespace) {
// Conversion to lowercase is done to be compatible with possible changes in case of packages/namespaces
return namespace.toLowerCase();
}

private static class LengthComparator implements Comparator<String> {
@Override
public int compare(String o1, String o2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ This file is part of the iText (R) project.
public final class CommonsProductData {
static final String COMMONS_PUBLIC_PRODUCT_NAME = "Commons";
static final String COMMONS_PRODUCT_NAME = "commons";
static final String COMMONS_VERSION = "7.2.3";
static final String COMMONS_VERSION = "7.2.4";
static final int COMMONS_COPYRIGHT_SINCE = 2000;
static final int COMMONS_COPYRIGHT_TO = 2022;

Expand Down
15 changes: 15 additions & 0 deletions commons/src/main/java/com/itextpdf/commons/utils/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,21 @@ public static boolean fileExists(String path) {
return false;
}

/**
* Checks whether is provided file not empty.
*
* @param path the path to the file to be checked on emptiness
*
* @return {@code true} if such file is not empty, {@code false} otherwise
*/
public static boolean isFileNotEmpty(String path) {
if (path != null) {
File f = new File(path);
return f.exists() && f.isFile() && f.length() > 0;
}
return false;
}

/**
* Checks whether there is a directory at the provided path.
*
Expand Down
20 changes: 20 additions & 0 deletions commons/src/main/java/com/itextpdf/commons/utils/JsonUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ This file is part of the iText (R) project.
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.SerializationFeature;
Expand All @@ -51,6 +52,25 @@ private JsonUtil() {
// empty constructor
}

/**
* Compares two json strings without considering the order of the elements.
*
* @param expectedString expected json string
* @param toCompare string for comparison
*
* @return true if two json string are equals, false otherwise
*
* @throws IOException if an I/O error occurs
*/
public static boolean areTwoJsonObjectEquals(String expectedString, String toCompare) throws IOException {
final ObjectMapper mapper = new ObjectMapper();

JsonNode expectedObject = mapper.readTree(expectedString);
JsonNode actualObject = mapper.readTree(toCompare);

return actualObject.equals(expectedObject);
}

/**
* Serializes passed object to provided JSON output stream.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public ZipFileWriter(String archivePath) throws IOException {
if (archivePath == null) {
throw new IOException(CommonsExceptionMessageConstant.FILE_NAME_CAN_NOT_BE_NULL);
}
if (FileUtil.fileExists(archivePath) || FileUtil.directoryExists(archivePath)) {
if (FileUtil.isFileNotEmpty(archivePath) || FileUtil.directoryExists(archivePath)) {
throw new IOException(
MessageFormatUtil.format(CommonsExceptionMessageConstant.FILE_NAME_ALREADY_EXIST, archivePath));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ This file is part of the iText (R) project.

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.experimental.categories.Category;
Expand Down Expand Up @@ -95,13 +96,27 @@ public void notRegisteredNamespaceTest() {
@Test
public void unregisterNamespaceTest() {
String testNamespace = "com.hello.world";
String testNamespaceWithCapitals = "com.Bye.World";
List<String> testNamespaces = Arrays.asList(
testNamespace,
testNamespaceWithCapitals
);

ContextManager manager = new ContextManager();
Assert.assertNull(manager.getRecognisedNamespace(testNamespace));
manager.registerGenericContext(Arrays.asList(testNamespace), Arrays.asList("myProduct"));
Assert.assertNull(manager.getRecognisedNamespace(testNamespaceWithCapitals));

manager.registerGenericContext(testNamespaces, Arrays.asList("myProduct"));

Assert.assertEquals(testNamespace,
manager.getRecognisedNamespace(testNamespace + ".MyClass"));
manager.unregisterContext(Arrays.asList(testNamespace));
Assert.assertEquals(testNamespaceWithCapitals.toLowerCase(),
manager.getRecognisedNamespace(testNamespaceWithCapitals + ".MyClass"));

manager.unregisterContext(testNamespaces);

Assert.assertNull(manager.getRecognisedNamespace(testNamespace));
Assert.assertNull(manager.getRecognisedNamespace(testNamespaceWithCapitals));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void serializeInstanceWithEnumStringTest() throws IOException {
String resultString = JsonUtil.serializeToString(classWithEnum);

String cmpString = getJsonStringFromFile(cmp);
Assert.assertEquals(cmpString, resultString);
Assert.assertTrue(JsonUtil.areTwoJsonObjectEquals(cmpString, resultString));
}

@Test
Expand All @@ -97,7 +97,7 @@ public void serializeToMinimalInstanceWithEnumStringTest() throws IOException {
String resultString = JsonUtil.serializeToMinimalString(classWithEnum);

String compareString = getJsonStringFromFile(cmp);
Assert.assertEquals(compareString, resultString);
Assert.assertTrue(JsonUtil.areTwoJsonObjectEquals(compareString, resultString));
}

@Test
Expand All @@ -122,7 +122,7 @@ public void serializeStringWithLineBreakStringTest() throws IOException {
String resultString = JsonUtil.serializeToString(stringsForSerialization);

String cmpString = getJsonStringFromFile(cmp);
Assert.assertEquals(cmpString, resultString);
Assert.assertEquals(cmpString,resultString);
}

@Test
Expand All @@ -146,7 +146,7 @@ public void serializeToMinimalStringWithLineBreakStringTest() throws IOException
String resultString = JsonUtil.serializeToMinimalString(stringsForSerialization);

String cmpString = getJsonStringFromFile(cmp);
Assert.assertEquals(cmpString, resultString);
Assert.assertEquals(cmpString,resultString);
}

@Test
Expand All @@ -170,7 +170,7 @@ public void serializeComplexStructureStringTest() throws IOException {
String resultString = JsonUtil.serializeToString(complexStructure);

String compareString = getJsonStringFromFile(cmp);
Assert.assertEquals(compareString, resultString);
Assert.assertTrue(JsonUtil.areTwoJsonObjectEquals(compareString, resultString));
}

@Test
Expand All @@ -195,7 +195,7 @@ public void serializeToMinimalComplexStructureStringTest() throws IOException {
String resultString = JsonUtil.serializeToMinimalString(complexStructure);

String compareString = getJsonStringFromFile(cmp);
Assert.assertEquals(compareString, resultString);
Assert.assertTrue(JsonUtil.areTwoJsonObjectEquals(compareString, resultString));
}

@Test
Expand All @@ -221,7 +221,7 @@ public void serializeWithNullFieldsStringTest() throws IOException {
String resultString = JsonUtil.serializeToString(complexStructure);

String compareString = getJsonStringFromFile(cmp);
Assert.assertEquals(compareString, resultString);
Assert.assertTrue(JsonUtil.areTwoJsonObjectEquals(compareString, resultString));
}

@Test
Expand All @@ -247,7 +247,7 @@ public void serializeToMinimalWithNullFieldsStringTest() throws IOException {
String resultString = JsonUtil.serializeToMinimalString(complexStructure);

String compareString = getJsonStringFromFile(cmp);
Assert.assertEquals(compareString, resultString);
Assert.assertTrue(JsonUtil.areTwoJsonObjectEquals(compareString, resultString));
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion font-asian/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.itextpdf</groupId>
<artifactId>root</artifactId>
<version>7.2.3</version>
<version>7.2.4</version>
</parent>
<artifactId>font-asian</artifactId>
<name>iText 7 - Asian fonts</name>
Expand Down
14 changes: 6 additions & 8 deletions font-asian/src/main/resources/com/itextpdf/io/font/cmap/78-EUC-H
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
%%IncludeResource: ProcSet (CIDInit)
%%BeginResource: CMap (78-EUC-H)
%%Title: (78-EUC-H Adobe Japan1 0)
%%Version: 10.003
%%Version: 10.006
%%Copyright: -----------------------------------------------------------
%%Copyright: Copyright 1990-2009 Adobe Systems Incorporated.
%%Copyright: All rights reserved.
%%Copyright: Copyright 1990-2019 Adobe. All rights reserved.
%%Copyright:
%%Copyright: Redistribution and use in source and binary forms, with or
%%Copyright: without modification, are permitted provided that the
Expand All @@ -21,10 +20,9 @@
%%Copyright: disclaimer in the documentation and/or other materials
%%Copyright: provided with the distribution.
%%Copyright:
%%Copyright: Neither the name of Adobe Systems Incorporated nor the names
%%Copyright: of its contributors may be used to endorse or promote
%%Copyright: products derived from this software without specific prior
%%Copyright: written permission.
%%Copyright: Neither the name of Adobe nor the names of its contributors
%%Copyright: may be used to endorse or promote products derived from
%%Copyright: this software without specific prior written permission.
%%Copyright:
%%Copyright: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
%%Copyright: CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
Expand Down Expand Up @@ -55,7 +53,7 @@ begincmap
end def

/CMapName /78-EUC-H def
/CMapVersion 10.003 def
/CMapVersion 10.006 def
/CMapType 1 def

/XUID [1 10 25347] def
Expand Down
14 changes: 6 additions & 8 deletions font-asian/src/main/resources/com/itextpdf/io/font/cmap/78-EUC-V
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
%%IncludeResource: CMap (78-EUC-H)
%%BeginResource: CMap (78-EUC-V)
%%Title: (78-EUC-V Adobe Japan1 0)
%%Version: 10.003
%%Version: 10.006
%%Copyright: -----------------------------------------------------------
%%Copyright: Copyright 1990-2009 Adobe Systems Incorporated.
%%Copyright: All rights reserved.
%%Copyright: Copyright 1990-2019 Adobe. All rights reserved.
%%Copyright:
%%Copyright: Redistribution and use in source and binary forms, with or
%%Copyright: without modification, are permitted provided that the
Expand All @@ -23,10 +22,9 @@
%%Copyright: disclaimer in the documentation and/or other materials
%%Copyright: provided with the distribution.
%%Copyright:
%%Copyright: Neither the name of Adobe Systems Incorporated nor the names
%%Copyright: of its contributors may be used to endorse or promote
%%Copyright: products derived from this software without specific prior
%%Copyright: written permission.
%%Copyright: Neither the name of Adobe nor the names of its contributors
%%Copyright: may be used to endorse or promote products derived from
%%Copyright: this software without specific prior written permission.
%%Copyright:
%%Copyright: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
%%Copyright: CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
Expand Down Expand Up @@ -59,7 +57,7 @@ begincmap
end def

/CMapName /78-EUC-V def
/CMapVersion 10.003 def
/CMapVersion 10.006 def
/CMapType 1 def

/XUID [1 10 25355] def
Expand Down
14 changes: 6 additions & 8 deletions font-asian/src/main/resources/com/itextpdf/io/font/cmap/78-H
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
%%IncludeResource: ProcSet (CIDInit)
%%BeginResource: CMap (78-H)
%%Title: (78-H Adobe Japan1 0)
%%Version: 10.003
%%Version: 10.006
%%Copyright: -----------------------------------------------------------
%%Copyright: Copyright 1990-2009 Adobe Systems Incorporated.
%%Copyright: All rights reserved.
%%Copyright: Copyright 1990-2019 Adobe. All rights reserved.
%%Copyright:
%%Copyright: Redistribution and use in source and binary forms, with or
%%Copyright: without modification, are permitted provided that the
Expand All @@ -21,10 +20,9 @@
%%Copyright: disclaimer in the documentation and/or other materials
%%Copyright: provided with the distribution.
%%Copyright:
%%Copyright: Neither the name of Adobe Systems Incorporated nor the names
%%Copyright: of its contributors may be used to endorse or promote
%%Copyright: products derived from this software without specific prior
%%Copyright: written permission.
%%Copyright: Neither the name of Adobe nor the names of its contributors
%%Copyright: may be used to endorse or promote products derived from
%%Copyright: this software without specific prior written permission.
%%Copyright:
%%Copyright: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
%%Copyright: CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
Expand Down Expand Up @@ -55,7 +53,7 @@ begincmap
end def

/CMapName /78-H def
/CMapVersion 10.003 def
/CMapVersion 10.006 def
/CMapType 1 def

/XUID [1 10 25345] def
Expand Down
Loading

0 comments on commit 2650275

Please sign in to comment.