Skip to content

Commit

Permalink
improved logs
Browse files Browse the repository at this point in the history
  • Loading branch information
car031 committed Jul 2, 2024
1 parent b46116b commit 8cfbc64
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,16 @@ public byte[] getBytes(long docId, String resource) throws IOException {
@Override
public void writeToStream(long docId, String resource, OutputStream output, long start, long length)
throws IOException {
IOUtils.copyLarge(getStream(docId, resource), output, start, length);
try (InputStream input = getStream(docId, resource)) {
IOUtils.copyLarge(input, output, start, length);
}
}

@Override
public void writeToStream(long docId, String resource, OutputStream output) throws IOException {
IOUtils.copyLarge(getStream(docId, resource), output);
try (InputStream input = getStream(docId, resource)) {
IOUtils.copyLarge(input, output);
}
}

@Override
Expand All @@ -227,8 +231,8 @@ public void writeToFile(long docId, String resource, File out) throws IOExceptio
@Override
public String getString(long docId, String resource) {
StringWriter writer = new StringWriter();
try {
IOUtils.copy(getStream(docId, resource), writer, StandardCharsets.UTF_8);
try (InputStream input = getStream(docId, resource)) {
IOUtils.copy(input, writer, StandardCharsets.UTF_8);
return writer.toString();
} catch (Exception e) {
log.error(e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,22 @@ public FSStorer() {
@Override
public void delete(long docId) {
File docDir = getContainer(docId);
if (FileUtil.delete(docDir))
logDeletion(docId, docDir.getAbsolutePath());

for (File file : docDir.listFiles()) {
log.info("Deleting stored file {}", file.getAbsolutePath());
if (FileUtil.delete(file))
logDeletion(docId, file.getAbsolutePath());
}

log.info("Deleting stored folder {}", docDir.getAbsolutePath());
FileUtil.delete(docDir);
logDeletion(docId, docDir.getAbsolutePath());
}

@Override
public void delete(long docId, String resource) {
File file = new File(getContainer(docId), resource);
log.info("Deleting stored file {}", file.getAbsolutePath());
if (FileUtil.delete(file))
logDeletion(docId, file.getAbsolutePath());
}
Expand Down
3 changes: 2 additions & 1 deletion logicaldoc-i18n/src/main/resources/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2570,4 +2570,5 @@ bfaalert = A possible Brute Force Attack has been detected on {0}
suspectedusername = Suspected username
suspectedip = Suspected IP
digsignedby = Digitally signed by
changelog = Changelog
changelog = Changelog
repositorysize = Repository size
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,6 @@ updatepackagefound=An update package is available
updatepackagenotfound=There are currently no updates available
downloadprogress=Download progress
updatenotes=Update Notes
changelog=Change Log
confirmupdatequestion=Before confirming the update, please make sure to have a valid backup and to have done all the actions described in the PRE-UPDATE section of the update notes. Do you want to confirm the update?
customreports=Custom reports
selectareport=Select a report
Expand Down Expand Up @@ -2571,4 +2570,5 @@ bfaalert = A possible Brute Force Attack has been detected on {0}
suspectedusername = Suspected username
suspectedip = Suspected IP
digsignedby = Digitally signed by
changelog = Changelog
changelog = Changelog
repositorysize = Repository size
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,6 @@ updatepackagefound=An update package is available
updatepackagenotfound=There are currently no updates available
downloadprogress=Download progress
updatenotes=Update Notes
changelog=Change Log
confirmupdatequestion=Before confirming the update, please make sure to have a valid backup and to have done all the actions described in the PRE-UPDATE section of the update notes. Do you want to confirm the update?
customreports=Custom reports
selectareport=Select a report
Expand Down Expand Up @@ -2571,4 +2570,5 @@ bfaalert = A possible Brute Force Attack has been detected on {0}
suspectedusername = Suspected username
suspectedip = Suspected IP
digsignedby = Digitally signed by
changelog = Changelog
changelog = Changelog
repositorysize = Repository size
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

public class SoapWorkbench {

final static String BASE = "http://localhost:9080/services";
final static String BASE = "http://localhost:8080/services";

public static void main(String[] args) throws Exception {

Expand All @@ -40,7 +40,7 @@ public static void main(String[] args) throws Exception {
SoapDocumentMetadataClient metadataClient = new SoapDocumentMetadataClient(BASE + "/DocumentMetadata");

// Open a session
String sid = auth.login("admin", "12345678");
String sid = auth.login("admin", "admin");
System.out.println("Server date: " + systemClient.getInfo().getDate());
System.out.println("Sid: " + sid);

Expand All @@ -55,12 +55,12 @@ public static void main(String[] args) throws Exception {

// securityStuff(sid);

// documentStuff(sid);
documentStuff(sid);

// This will search by filename using LIKE %filename%
// searchByFilename(sid, "simply");

folderStuff(sid);
// folderStuff(sid);

// searchStuff(sid);

Expand Down Expand Up @@ -152,7 +152,7 @@ public static void main(String[] args) throws Exception {
private static void folderStuff(String sid) throws Exception {
SoapFolderClient folderClient = new SoapFolderClient(BASE + "/Folder", 1, false, 50);

List<WSFolder> folders = folderClient.list(sid, 4L, "creation asc", 18, 3);
List<WSFolder> folders = folderClient.list(sid, 4L, "creation asc", 6, 3);
for (WSFolder folder : folders) {
System.out.println(folder.getName() + "\t" + folder.getCreation());
}
Expand Down Expand Up @@ -523,7 +523,7 @@ private static void documentStuff(String sid) throws Exception {

SoapDocumentClient documentClient = new SoapDocumentClient(BASE + "/Document");

List<WSDocument> documents = documentClient.list(sid, 4L, null, "date desc", 56, 3);
List<WSDocument> documents = documentClient.list(sid, 103L, null, "fileName desc", 1, 3);
for (WSDocument doc : documents) {
System.out.println(doc.getFileName() + "\t" + doc.getDate());
}
Expand Down

0 comments on commit 8cfbc64

Please sign in to comment.