Skip to content

Commit fe4462b

Browse files
committed
[RELEASE] iText 7 7.2.1
2 parents c4daee4 + c2fb4f6 commit fe4462b

File tree

1,453 files changed

+7652
-2093
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,453 files changed

+7652
-2093
lines changed

barcodes/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.itextpdf</groupId>
66
<artifactId>root</artifactId>
7-
<version>7.2.0</version>
7+
<version>7.2.1</version>
88
</parent>
99
<artifactId>barcodes</artifactId>
1010
<name>iText 7 - barcodes</name>

barcodes/src/test/java/com/itextpdf/barcodes/BarcodePDF417Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public void barcode417XObjectTest() throws IOException, InterruptedException {
238238
barcode.setCode(text);
239239
PdfFormXObject xObject = barcode.createFormXObject(document);
240240

241-
canvas.addXObject(xObject, 10, 650);
241+
canvas.addXObjectAt(xObject, 10, 650);
242242

243243
document.close();
244244

commons/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.itextpdf</groupId>
66
<artifactId>root</artifactId>
7-
<version>7.2.0</version>
7+
<version>7.2.1</version>
88
</parent>
99
<artifactId>commons</artifactId>
1010
<name>iText 7 - commons</name>

commons/src/main/java/com/itextpdf/commons/actions/ProductEventHandler.java

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ This file is part of the iText (R) project.
2525
import com.itextpdf.commons.actions.confirmations.ConfirmEvent;
2626
import com.itextpdf.commons.actions.confirmations.ConfirmedEventWrapper;
2727
import com.itextpdf.commons.actions.contexts.UnknownContext;
28-
import com.itextpdf.commons.exceptions.UnknownProductException;
29-
import com.itextpdf.commons.logs.CommonsLogMessageConstant;
3028
import com.itextpdf.commons.actions.processors.DefaultITextProductEventProcessor;
3129
import com.itextpdf.commons.actions.processors.ITextProductEventProcessor;
3230
import com.itextpdf.commons.actions.sequence.SequenceId;
31+
import com.itextpdf.commons.exceptions.ProductEventHandlerRepeatException;
32+
import com.itextpdf.commons.exceptions.UnknownProductException;
33+
import com.itextpdf.commons.logs.CommonsLogMessageConstant;
3334
import com.itextpdf.commons.utils.MessageFormatUtil;
3435

3536
import java.util.ArrayList;
@@ -47,7 +48,11 @@ This file is part of the iText (R) project.
4748
*/
4849
final class ProductEventHandler extends AbstractContextBasedEventHandler {
4950
static final ProductEventHandler INSTANCE = new ProductEventHandler();
51+
5052
private static final Logger LOGGER = LoggerFactory.getLogger(ProductEventHandler.class);
53+
// The constant has the following value for two reasons. First, to avoid the infinite loop.
54+
// Second, to retry event processing several times for technical reasons.
55+
private static final int MAX_EVENT_RETRY_COUNT = 4;
5156

5257
private final ConcurrentHashMap<String, ITextProductEventProcessor> processors = new ConcurrentHashMap<>();
5358
private final WeakHashMap<SequenceId, List<AbstractProductProcessITextEvent>> events = new WeakHashMap<>();
@@ -63,24 +68,17 @@ private ProductEventHandler() {
6368
*/
6469
@Override
6570
protected void onAcceptedEvent(AbstractContextBasedITextEvent event) {
66-
if (! (event instanceof AbstractProductProcessITextEvent)) {
67-
return;
68-
}
69-
final AbstractProductProcessITextEvent productEvent = (AbstractProductProcessITextEvent) event;
70-
final String productName = productEvent.getProductName();
71-
final ITextProductEventProcessor productEventProcessor = getActiveProcessor(productName);
72-
if (productEventProcessor == null) {
73-
throw new UnknownProductException(
74-
MessageFormatUtil.format(UnknownProductException.UNKNOWN_PRODUCT, productName));
75-
}
76-
productEventProcessor.onEvent(productEvent);
77-
if (productEvent.getSequenceId() != null) {
78-
if (productEvent instanceof ConfirmEvent) {
79-
wrapConfirmedEvent((ConfirmEvent) productEvent, productEventProcessor);
80-
} else {
81-
addEvent(productEvent.getSequenceId(), productEvent);
71+
for (int i = 0; i < MAX_EVENT_RETRY_COUNT; i++) {
72+
try {
73+
tryProcessEvent(event);
74+
// process succeeded
75+
return;
76+
} catch (ProductEventHandlerRepeatException repeatException) {
77+
// ignore this exception to retry the processing
8278
}
8379
}
80+
// the final processing retry
81+
tryProcessEvent(event);
8482
}
8583

8684
ITextProductEventProcessor addProcessor(ITextProductEventProcessor processor) {
@@ -138,6 +136,29 @@ void addEvent(SequenceId id, AbstractProductProcessITextEvent event) {
138136
}
139137
}
140138

139+
private void tryProcessEvent(AbstractContextBasedITextEvent event) {
140+
if (! (event instanceof AbstractProductProcessITextEvent)) {
141+
return;
142+
}
143+
final AbstractProductProcessITextEvent productEvent = (AbstractProductProcessITextEvent) event;
144+
final String productName = productEvent.getProductName();
145+
final ITextProductEventProcessor productEventProcessor = getActiveProcessor(productName);
146+
if (productEventProcessor == null) {
147+
throw new UnknownProductException(
148+
MessageFormatUtil.format(UnknownProductException.UNKNOWN_PRODUCT, productName));
149+
}
150+
151+
productEventProcessor.onEvent(productEvent);
152+
153+
if (productEvent.getSequenceId() != null) {
154+
if (productEvent instanceof ConfirmEvent) {
155+
wrapConfirmedEvent((ConfirmEvent) productEvent, productEventProcessor);
156+
} else {
157+
addEvent(productEvent.getSequenceId(), productEvent);
158+
}
159+
}
160+
}
161+
141162
private void wrapConfirmedEvent(ConfirmEvent event, ITextProductEventProcessor productEventProcessor) {
142163
synchronized (events) {
143164
final List<AbstractProductProcessITextEvent> eventsList = events.get(event.getSequenceId());

commons/src/main/java/com/itextpdf/commons/actions/data/CommonsProductData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ This file is part of the iText (R) project.
2828
public final class CommonsProductData {
2929
static final String COMMONS_PUBLIC_PRODUCT_NAME = "Commons";
3030
static final String COMMONS_PRODUCT_NAME = "commons";
31-
static final String COMMONS_VERSION = "7.2.0";
31+
static final String COMMONS_VERSION = "7.2.1";
3232
static final int COMMONS_COPYRIGHT_SINCE = 2000;
3333
static final int COMMONS_COPYRIGHT_TO = 2021;
3434

commons/src/main/java/com/itextpdf/commons/actions/data/ProductData.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public final class ProductData {
3131
private final String publicProductName;
3232
private final String productName;
3333
private final String version;
34+
private final String minimalCompatibleLicenseKeyVersion;
3435
private final int sinceCopyrightYear;
3536
private final int toCopyrightYear;
3637

@@ -45,9 +46,25 @@ public final class ProductData {
4546
*/
4647
public ProductData(String publicProductName, String productName, String version, int sinceCopyrightYear,
4748
int toCopyrightYear) {
49+
this(publicProductName, productName, version, null, sinceCopyrightYear, toCopyrightYear);
50+
}
51+
52+
/**
53+
* Creates a new instance of product data.
54+
*
55+
* @param publicProductName is a product name
56+
* @param productName is a technical name of the product
57+
* @param version is a version of the product
58+
* @param minimalCompatibleLicenseKeyVersion is a minimal compatible version of licensekey library
59+
* @param sinceCopyrightYear is the first year of a product development
60+
* @param toCopyrightYear is a last year of a product development
61+
*/
62+
public ProductData(String publicProductName, String productName, String version,
63+
String minimalCompatibleLicenseKeyVersion, int sinceCopyrightYear, int toCopyrightYear) {
4864
this.publicProductName = publicProductName;
4965
this.productName = productName;
5066
this.version = version;
67+
this.minimalCompatibleLicenseKeyVersion = minimalCompatibleLicenseKeyVersion;
5168
this.sinceCopyrightYear = sinceCopyrightYear;
5269
this.toCopyrightYear = toCopyrightYear;
5370
}
@@ -97,6 +114,15 @@ public int getToCopyrightYear() {
97114
return toCopyrightYear;
98115
}
99116

117+
/**
118+
* Getter for the minimal compatible licensekey version.
119+
*
120+
* @return minimal compatible version of licensekey library.
121+
*/
122+
public String getMinCompatibleLicensingModuleVersion() {
123+
return minimalCompatibleLicenseKeyVersion;
124+
}
125+
100126
@Override
101127
public boolean equals(Object o) {
102128
if (this == o) {

commons/src/main/java/com/itextpdf/commons/actions/processors/DefaultITextProductEventProcessor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ public void onEvent(AbstractProductProcessITextEvent event) {
9696
if (isNeededToLogMessage) {
9797
String message = new String(MESSAGE_FOR_LOGGING, StandardCharsets.ISO_8859_1);
9898
LOGGER.info(message);
99+
// System out added with purpose. This is not a debug code
99100
System.out.println(message);
100101
}
101102
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
This file is part of the iText (R) project.
3+
Copyright (c) 1998-2021 iText Group NV
4+
Authors: iText Software.
5+
6+
This program is offered under a commercial and under the AGPL license.
7+
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below.
8+
9+
AGPL licensing:
10+
This program is free software: you can redistribute it and/or modify
11+
it under the terms of the GNU Affero General Public License as published by
12+
the Free Software Foundation, either version 3 of the License, or
13+
(at your option) any later version.
14+
15+
This program is distributed in the hope that it will be useful,
16+
but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
GNU Affero General Public License for more details.
19+
20+
You should have received a copy of the GNU Affero General Public License
21+
along with this program. If not, see <https://www.gnu.org/licenses/>.
22+
*/
23+
package com.itextpdf.commons.exceptions;
24+
25+
/**
26+
* The class represents a signal to the event handler that it is necessary to repeat the handling of the current event.
27+
*/
28+
public final class ProductEventHandlerRepeatException extends ITextException {
29+
/**
30+
* Creates a new instance of {@link ProductEventHandlerRepeatException} based on message.
31+
*
32+
* @param message the detail message
33+
*/
34+
public ProductEventHandlerRepeatException(String message) {
35+
super(message);
36+
}
37+
}

commons/src/main/java/com/itextpdf/commons/utils/DateTimeUtil.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ This file is part of the iText (R) project.
4949
import java.util.Calendar;
5050
import java.util.Date;
5151
import java.util.GregorianCalendar;
52+
import java.util.TimeZone;
5253

5354
/**
5455
* This file is a helper class for internal usage only.
@@ -146,6 +147,11 @@ public static String format(Date date, String pattern) {
146147
return initParserSDF(pattern).format(date);
147148
}
148149

150+
public static long getCurrentTimeZoneOffset() {
151+
TimeZone tz = TimeZone.getDefault();
152+
return tz.getOffset(getCurrentTimeDate().getTime());
153+
}
154+
149155
private static DateFormat initParserSDF(String pattern) {
150156
final SimpleDateFormat parserSDF = new SimpleDateFormat(pattern);
151157
parserSDF.setCalendar(new GregorianCalendar());
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
This file is part of the iText (R) project.
3+
Copyright (c) 1998-2021 iText Group NV
4+
Authors: iText Software.
5+
6+
This program is offered under a commercial and under the AGPL license.
7+
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below.
8+
9+
AGPL licensing:
10+
This program is free software: you can redistribute it and/or modify
11+
it under the terms of the GNU Affero General Public License as published by
12+
the Free Software Foundation, either version 3 of the License, or
13+
(at your option) any later version.
14+
15+
This program is distributed in the hope that it will be useful,
16+
but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
GNU Affero General Public License for more details.
19+
20+
You should have received a copy of the GNU Affero General Public License
21+
along with this program. If not, see <https://www.gnu.org/licenses/>.
22+
*/
23+
package com.itextpdf.commons.utils;
24+
25+
/**
26+
* Class contains a process information, such as process exit code and process output.
27+
*/
28+
public final class ProcessInfo {
29+
30+
private final int exitCode;
31+
private final String processStdOutput;
32+
private final String processErrOutput;
33+
34+
/**
35+
* Create a new instance, containing a process information,
36+
* such as process exit code, process standard and error outputs.
37+
*
38+
* @param exitCode exit code of the process.
39+
* @param processStdOutput the standard output of the process.
40+
* @param processErrOutput the error output of the process.
41+
*/
42+
public ProcessInfo(int exitCode, String processStdOutput, String processErrOutput) {
43+
this.exitCode = exitCode;
44+
this.processStdOutput = processStdOutput;
45+
this.processErrOutput = processErrOutput;
46+
}
47+
48+
/**
49+
* Getter for a process exit code.
50+
*
51+
* @return Returns a process exit code.
52+
*/
53+
public int getExitCode() {
54+
return exitCode;
55+
}
56+
57+
/**
58+
* Getter for a standard process output.
59+
*
60+
* @return Returns a process standard output string.
61+
*/
62+
public String getProcessStdOutput() {
63+
return processStdOutput;
64+
}
65+
66+
/**
67+
* Getter for an error process output.
68+
*
69+
* @return Returns a process error output string.
70+
*/
71+
public String getProcessErrOutput() {
72+
return processErrOutput;
73+
}
74+
}

0 commit comments

Comments
 (0)