Skip to content

Commit 03aca5f

Browse files
authored
Merge pull request #4792 from evolvedbinary/hotfix/small-jac-issues
Small fixes for the Java Admin Client
2 parents 9c86876 + f69a386 commit 03aca5f

File tree

2 files changed

+18
-26
lines changed

2 files changed

+18
-26
lines changed

exist-core/src/main/java/org/exist/client/ClientFrame.java

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@
7272
import java.nio.file.Files;
7373
import java.nio.file.Path;
7474
import java.nio.file.Paths;
75-
import java.text.DateFormat;
76-
import java.time.format.DateTimeFormatter;
7775
import java.util.*;
7876
import java.util.List;
7977
import java.util.concurrent.*;
@@ -83,7 +81,7 @@
8381
import java.util.stream.Collectors;
8482

8583
import static java.nio.charset.StandardCharsets.UTF_8;
86-
import static java.time.ZoneOffset.UTC;
84+
import static org.exist.client.InteractiveClient.DATE_TIME_FORMATTER;
8785
import static org.exist.util.FileUtils.humanSize;
8886

8987
/**
@@ -93,15 +91,15 @@ public class ClientFrame extends JFrame implements WindowFocusListener, KeyListe
9391

9492
private static final long serialVersionUID = 1L;
9593

96-
public final static String CUT = Messages.getString("ClientFrame.0"); //$NON-NLS-1$
97-
public final static String COPY = Messages.getString("ClientFrame.1"); //$NON-NLS-1$
98-
public final static String PASTE = Messages.getString("ClientFrame.2"); //$NON-NLS-1$
94+
public static final String CUT = Messages.getString("ClientFrame.0"); //$NON-NLS-1$
95+
public static final String COPY = Messages.getString("ClientFrame.1"); //$NON-NLS-1$
96+
public static final String PASTE = Messages.getString("ClientFrame.2"); //$NON-NLS-1$
9997

100-
public final static int MAX_DISPLAY_LENGTH = 512000;
101-
public final static int MAX_HISTORY = 50;
98+
public static final int MAX_DISPLAY_LENGTH = 512000;
99+
public static final int MAX_HISTORY = 50;
102100

103-
private final static SimpleAttributeSet promptAttrs = new SimpleAttributeSet();
104-
private final static SimpleAttributeSet defaultAttrs = new SimpleAttributeSet();
101+
private static final SimpleAttributeSet promptAttrs = new SimpleAttributeSet();
102+
private static final SimpleAttributeSet defaultAttrs = new SimpleAttributeSet();
105103
static {
106104
StyleConstants.setForeground(promptAttrs, Color.blue);
107105
StyleConstants.setBold(promptAttrs, true);
@@ -742,12 +740,6 @@ private void removeAction(final ActionEvent ev) {
742740
}
743741
}
744742

745-
try {
746-
removeRootCollection.close();
747-
} catch (final XMLDBException e) {
748-
showErrorMessage(e.getMessage(), e);
749-
}
750-
751743
ClientAction.call(client::getResources, e -> showErrorMessage(e.getMessage(), e));
752744
};
753745
client.newClientThread("remove", removeTask).start();
@@ -1262,8 +1254,6 @@ private void setPermAction(final ActionEvent ev) throws PermissionDeniedExceptio
12621254
ModeDisplay mode = null;
12631255
SimpleACLPermissionAider acl = null;
12641256

1265-
final DateFormat dateTimeFormat = DateFormat.getDateTimeInstance();
1266-
12671257
final List<ResourceDescriptor> selected = new ArrayList<>();
12681258

12691259
boolean firstPerm = true;
@@ -1283,7 +1273,7 @@ private void setPermAction(final ActionEvent ev) throws PermissionDeniedExceptio
12831273

12841274
if (selectedRow.isCollection()) {
12851275
final Collection coll = collection.getChildCollection(thisName.toString());
1286-
thisCreated = dateTimeFormat.format(coll.getCreationTime());
1276+
thisCreated = DATE_TIME_FORMATTER.format(coll.getCreationTime());
12871277
thisModified = NON_APPLICABLE;
12881278
thisMimeType = COLLECTION_MIME_TYPE;
12891279
thisMessageDigestType = NON_APPLICABLE;
@@ -1292,8 +1282,8 @@ private void setPermAction(final ActionEvent ev) throws PermissionDeniedExceptio
12921282
thisPerm = service.getPermissions(coll);
12931283
} else {
12941284
final Resource res = collection.getResource(thisName.toString());
1295-
thisCreated = dateTimeFormat.format(res.getCreationTime());
1296-
thisModified = dateTimeFormat.format(res.getLastModificationTime());
1285+
thisCreated = DATE_TIME_FORMATTER.format(res.getCreationTime());
1286+
thisModified = DATE_TIME_FORMATTER.format(res.getLastModificationTime());
12971287
thisMimeType = ((EXistResource) res).getMimeType();
12981288
if (res instanceof EXistBinaryResource) {
12991289
final MessageDigest messageDigest = ((EXistBinaryResource) res).getContentDigest(DigestType.BLAKE_256);
@@ -1596,8 +1586,6 @@ static class ResourceTableModel extends AbstractTableModel {
15961586

15971587
private List<ResourceDescriptor> rows = null;
15981588

1599-
private DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(UTC);
1600-
16011589
public void setData(final List<ResourceDescriptor> rows) {
16021590
rows.sort(new ResourceComparator());
16031591
this.rows = rows;
@@ -1651,7 +1639,7 @@ public Object getValueAt(final int rowIndex, final int columnIndex) {
16511639
case 0:
16521640
return row.getName().toString();
16531641
case 1:
1654-
return dateFormat.format(row.getInstant());
1642+
return DATE_TIME_FORMATTER.format(row.getInstant());
16551643
case 2:
16561644
return row.getOwner();
16571645
case 3:

exist-core/src/main/java/org/exist/client/InteractiveClient.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.nio.file.Path;
3333
import java.nio.file.Paths;
3434
import java.time.Instant;
35+
import java.time.format.DateTimeFormatter;
3536
import java.util.*;
3637
import java.util.concurrent.atomic.AtomicReference;
3738
import java.util.function.BinaryOperator;
@@ -89,6 +90,7 @@
8990
import se.softhouse.jargo.ArgumentException;
9091

9192
import static java.nio.charset.StandardCharsets.UTF_8;
93+
import static java.time.ZoneOffset.UTC;
9294
import static javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION;
9395
import static org.exist.storage.serializers.EXistOutputKeys.OMIT_ORIGINAL_XML_DECLARATION;
9496
import static org.exist.storage.serializers.EXistOutputKeys.OUTPUT_DOCTYPE;
@@ -101,6 +103,8 @@
101103
*/
102104
public class InteractiveClient {
103105

106+
static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(UTC);
107+
104108
// ANSI colors for ls display
105109
// private final static String ANSI_BLUE = "\033[0;34m";
106110
private static final String ANSI_CYAN = "\033[0;36m";
@@ -397,7 +401,7 @@ protected void getResources() throws XMLDBException {
397401
if ("true".equals(properties.getProperty(PERMISSIONS))) {
398402
resources[i] = 'c' + perm.toString() + '\t' + getOwnerName(perm)
399403
+ '\t' + getGroupName(perm) + '\t'
400-
+ created.toString() + '\t'
404+
+ DATE_TIME_FORMATTER.format(created) + '\t'
401405
+ collectionName;
402406
} else {
403407
resources[i] = collectionName;
@@ -431,7 +435,7 @@ protected void getResources() throws XMLDBException {
431435
if ("true".equals(properties.getProperty(PERMISSIONS))) {
432436
resources[i] = '-' + perm.toString() + '\t' + getOwnerName(perm)
433437
+ '\t' + getGroupName(perm) + '\t'
434-
+ lastModificationTime.toString() + '\t'
438+
+ DATE_TIME_FORMATTER.format(lastModificationTime) + '\t'
435439
+ resourceId;
436440
} else {
437441
resources[i] = resourceId;

0 commit comments

Comments
 (0)