diff --git a/src/main/kotlin/de/gmuth/ipp/client/CupsClient.kt b/src/main/kotlin/de/gmuth/ipp/client/CupsClient.kt index 2ea2c352..80f3bf6f 100644 --- a/src/main/kotlin/de/gmuth/ipp/client/CupsClient.kt +++ b/src/main/kotlin/de/gmuth/ipp/client/CupsClient.kt @@ -294,7 +294,8 @@ class CupsClient( job.getOriginatingUserNameOrAppleJobOwnerOrNull()?.let { jobOwners.add(it) } } .onEach { job -> // keep stats and save documents - if (job.numberOfDocumentsOrDocumentCount == 0) numberOfJobsWithoutDocuments.incrementAndGet() + if (job.getNumberOfDocumentsOrDocumentCount() == 0) + numberOfJobsWithoutDocuments.incrementAndGet() else getAndSaveDocuments(job, optionalCommandToHandleFile = commandToHandleSavedFile) .apply { numberOfSavedDocuments.addAndGet(size) } } diff --git a/src/main/kotlin/de/gmuth/ipp/client/IppJob.kt b/src/main/kotlin/de/gmuth/ipp/client/IppJob.kt index f04f2085..d7d7e3e6 100644 --- a/src/main/kotlin/de/gmuth/ipp/client/IppJob.kt +++ b/src/main/kotlin/de/gmuth/ipp/client/IppJob.kt @@ -131,12 +131,11 @@ class IppJob( else -> null } - val numberOfDocumentsOrDocumentCount: Int - get() = when { - attributes.containsKey("number-of-documents") -> numberOfDocuments - attributes.containsKey("document-count") -> attributes.getValue("document-count") - else -> throw IppException("number-of-documents or document-count not found") - } + fun getNumberOfDocumentsOrDocumentCount(): Int = when { + attributes.containsKey("number-of-documents") -> numberOfDocuments + attributes.containsKey("document-count") -> attributes.getValue("document-count") + else -> throw IppException("number-of-documents or document-count not found") + } //------------------- // Get-Job-Attributes @@ -326,7 +325,7 @@ class IppJob( save: Boolean = false, optionalCommandToHandleFile: String? = null ) = - (1..numberOfDocumentsOrDocumentCount) + (1..getNumberOfDocumentsOrDocumentCount()) .map { cupsGetDocument(it) } .onEach { document -> if (save) with(document) { @@ -377,7 +376,7 @@ class IppJob( if (containsKey("job-originating-host-name")) append(", originating-host-name=$originatingHostName") if (containsKey("job-originating-user-name")) append(", originating-user-name=$originatingUserName") if (containsKey("com.apple.print.JobInfo.PMJobOwner")) append(", appleJobOwner=$appleJobOwner") - if (containsKey("number-of-documents") || containsKey("document-count")) append(", $numberOfDocumentsOrDocumentCount documents") + if (containsKey("number-of-documents") || containsKey("document-count")) append(", ${getNumberOfDocumentsOrDocumentCount()} documents") if (containsKey("job-printer-uri")) append(", printer-uri=$printerUri") if (containsKey("job-uri")) append(", uri=$uri") toString()