From c11c062cfc0c401d09111ac69ffccfc3b4d66644 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 10 Dec 2020 13:50:49 +0100 Subject: [ListArchive] Add more data to output --- .../org/openslx/taskmanager/tasks/ListArchive.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/openslx/taskmanager/tasks/ListArchive.java b/src/main/java/org/openslx/taskmanager/tasks/ListArchive.java index 38c2227..b45c0ed 100644 --- a/src/main/java/org/openslx/taskmanager/tasks/ListArchive.java +++ b/src/main/java/org/openslx/taskmanager/tasks/ListArchive.java @@ -8,6 +8,7 @@ import java.util.List; import org.apache.commons.compress.archivers.ArchiveEntry; import org.apache.commons.compress.archivers.ArchiveException; import org.apache.commons.compress.archivers.ArchiveInputStream; +import org.apache.commons.compress.archivers.tar.TarArchiveEntry; import org.apache.commons.io.FilenameUtils; import org.openslx.satserver.util.Archive; import org.openslx.satserver.util.Util; @@ -25,8 +26,7 @@ public class ListArchive extends AbstractTask * Own vars/constants not being deserialized */ - protected static final String[] ALLOWED_DIRS = - { "/tmp/", "/opt/openslx/" }; + protected static final String[] ALLOWED_DIRS = { "/tmp/", "/opt/openslx/" }; private Output status = new Output(); @@ -65,6 +65,15 @@ public class ListArchive extends AbstractTask Output.Entry entry = new Output.Entry(); entry.name = archiveEntry.getName(); entry.isdir = archiveEntry.isDirectory(); + if ( archiveEntry instanceof TarArchiveEntry ) { + entry.user = ( (TarArchiveEntry)archiveEntry ).getUserName(); + entry.userId = ( (TarArchiveEntry)archiveEntry ).getLongUserId(); + entry.group = ( (TarArchiveEntry)archiveEntry ).getGroupName(); + entry.groupId = ( (TarArchiveEntry)archiveEntry ).getLongGroupId(); + if ( ( (TarArchiveEntry)archiveEntry ).isSymbolicLink() ) { + entry.linkTarget = ( (TarArchiveEntry)archiveEntry ).getLinkName(); + } + } entry.size = archiveEntry.getSize(); entries.add( entry ); } @@ -109,7 +118,12 @@ public class ListArchive extends AbstractTask public static class Entry { protected String name = null; + protected String linkTarget = null; protected boolean isdir = false; + protected String user; + protected long userId = -1; + protected long groupId = -1; + protected String group; protected long size = -1; } } -- cgit v1.2.3-55-g7522