Skip to content

Commit eedddda

Browse files
committed
Catch exceptions of XMLEncoder
1 parent bc0d613 commit eedddda

File tree

4 files changed

+24
-17
lines changed

4 files changed

+24
-17
lines changed

logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/metadata/form/FormDetailsPanel.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ private void preparePropertiesTab(ChangedHandler changedHandler) {
141141
TextItem name = ItemFactory.newSimpleTextItem("name", form.getName());
142142
name.addChangedHandler(changedHandler);
143143
name.setRequired(true);
144-
name.setDisabled(form.getId() != 0L);
145144

146145
SelectItem template = ItemFactory.newTemplateSelector(true, null);
147146
template.addChangedHandler(changedHandler);

logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/reports/custom/ReportStandardProperties.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.smartgwt.client.widgets.form.fields.SelectItem;
1414
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
1515
import com.smartgwt.client.widgets.form.fields.TextAreaItem;
16+
import com.smartgwt.client.widgets.form.fields.TextItem;
1617
import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
1718
import com.smartgwt.client.widgets.layout.HLayout;
1819
import com.smartgwt.client.widgets.layout.Layout;
@@ -70,7 +71,8 @@ private void refresh() {
7071

7172
StaticTextItem id = ItemFactory.newStaticTextItem("id", Long.toString(report.getId()));
7273

73-
StaticTextItem name = ItemFactory.newStaticTextItem("name", report.getName());
74+
TextItem name = ItemFactory.newSimpleTextItem("name", report.getName());
75+
name.addChangedHandler(changedHandler);
7476

7577
TextAreaItem description = ItemFactory.newTextAreaItem("description", report.getDescription());
7678
description.setWidth(250);

logicaldoc-util/src/main/java/com/logicaldoc/util/io/IOUtil.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@
2222

2323
import org.apache.commons.io.IOUtils;
2424
import org.apache.commons.lang.StringUtils;
25+
import org.slf4j.Logger;
26+
import org.slf4j.LoggerFactory;
2527

2628
public class IOUtil {
29+
2730
private static final int DEFAULT_BUFFER_SIZE = 10240; // ..bytes = 10KB.
2831

32+
private static final Logger log = LoggerFactory.getLogger(IOUtil.class);
33+
2934
private IOUtil() {
3035
throw new IllegalStateException("Utility class");
3136
}
@@ -101,6 +106,7 @@ public static byte[] getBytesOfStream(InputStream stream) throws IOException {
101106
public static String serialize(Serializable object, String charset) {
102107
ByteArrayOutputStream baos = new ByteArrayOutputStream();
103108
try (XMLEncoder encoder = new XMLEncoder(baos, StringUtils.defaultString(charset, "UTF-8"), false, 0);) {
109+
encoder.setExceptionListener(e -> log.warn(e.getMessage(), e));
104110
encoder.writeObject(object);
105111
}
106112
return baos.toString().trim().replace("\n", "");
@@ -129,7 +135,8 @@ public static Object deserialize(String xml) {
129135
* @throws IOException I/O error
130136
* @throws URISyntaxException The URL is invalid
131137
*/
132-
public static void download(final String url, File dest, int timeout, int bufferSize) throws IOException, URISyntaxException {
138+
public static void download(final String url, File dest, int timeout, int bufferSize)
139+
throws IOException, URISyntaxException {
133140
if (url == null || url.isEmpty()) {
134141
throw new IOException("Url argument is not specified"); // URL
135142
// isn't

logicaldoc-util/src/main/java/com/logicaldoc/util/io/TarUtil.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,20 @@ public List<String> listEntries(File tarFile) throws IOException {
4545
try {
4646
try (FileInputStream fis = new FileInputStream(tarFile);
4747
BufferedInputStream bis = new BufferedInputStream(fis);
48-
ArchiveInputStream input = new ArchiveStreamFactory().createArchiveInputStream(bis);) {
49-
50-
if (input instanceof TarArchiveInputStream tarInput) {
51-
try {
52-
TarArchiveEntry entry = tarInput.getNextTarEntry();
53-
while (entry != null) {
54-
String name = entry.getName();
55-
if (name.endsWith("/"))
56-
name = name.substring(0, name.lastIndexOf('/'));
57-
entries.add(name);
58-
entry = tarInput.getNextTarEntry();
59-
}
60-
} finally {
61-
tarInput.close();
48+
ArchiveInputStream<TarArchiveEntry> tarInput = new ArchiveStreamFactory()
49+
.createArchiveInputStream(bis);) {
50+
51+
try {
52+
TarArchiveEntry entry = tarInput.getNextEntry();
53+
while (entry != null) {
54+
String name = entry.getName();
55+
if (name.endsWith("/"))
56+
name = name.substring(0, name.lastIndexOf('/'));
57+
entries.add(name);
58+
entry = tarInput.getNextEntry();
6259
}
60+
} finally {
61+
tarInput.close();
6362
}
6463
}
6564
} catch (ArchiveException e) {

0 commit comments

Comments
 (0)