From 6a588fa992b35eb3e31a3f183cbb7639288d2a57 Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Wed, 7 May 2014 09:27:33 +0200 Subject: XML Elements renaming for SOAP service --- .../at/gv/egiz/pdfas/web/ws/PDFASSigningImpl.java | 45 ++++++++++++++-------- 1 file changed, 28 insertions(+), 17 deletions(-) (limited to 'pdf-as-web/src/main/java/at/gv') diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASSigningImpl.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASSigningImpl.java index 01f9205a..c8283d28 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASSigningImpl.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/ws/PDFASSigningImpl.java @@ -10,6 +10,8 @@ import javax.xml.ws.soap.MTOM; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import at.gv.egiz.pdfas.api.ws.PDFASBulkSignRequest; +import at.gv.egiz.pdfas.api.ws.PDFASBulkSignResponse; import at.gv.egiz.pdfas.api.ws.PDFASSignParameters; import at.gv.egiz.pdfas.api.ws.PDFASSignRequest; import at.gv.egiz.pdfas.api.ws.PDFASSignResponse; @@ -23,14 +25,15 @@ public class PDFASSigningImpl implements PDFASSigning { private static final Logger logger = LoggerFactory .getLogger(PDFASSigningImpl.class); - + public byte[] signPDFDokument(byte[] inputDocument, PDFASSignParameters parameters) { try { - return PdfAsHelper.synchornousServerSignature(inputDocument, parameters); - } catch(Throwable e) { + return PdfAsHelper.synchornousServerSignature(inputDocument, + parameters); + } catch (Throwable e) { logger.error("Server Signature failed.", e); - if(WebConfiguration.isShowErrorDetails()) { + if (WebConfiguration.isShowErrorDetails()) { throw new WebServiceException("Server Signature failed.", e); } else { throw new WebServiceException("Server Signature failed."); @@ -39,15 +42,16 @@ public class PDFASSigningImpl implements PDFASSigning { } public PDFASSignResponse signPDFDokument(PDFASSignRequest request) { - if(request == null) { + if (request == null) { logger.warn("SOAP Sign Request is null!"); return null; } PDFASSignResponse response = new PDFASSignResponse(); try { - response.setSignedPDF(signPDFDokument(request.getInputData(), request.getParameters())); - } catch(Throwable e) { - if(e.getCause() != null) { + response.setSignedPDF(signPDFDokument(request.getInputData(), + request.getParameters())); + } catch (Throwable e) { + if (e.getCause() != null) { response.setError(e.getCause().getMessage()); } else { response.setError(e.getMessage()); @@ -57,19 +61,26 @@ public class PDFASSigningImpl implements PDFASSigning { return response; } - public PDFASSignResponse[] signPDFDokument(PDFASSignRequest[] request) { + public PDFASBulkSignResponse signPDFDokument(PDFASBulkSignRequest request) { List responses = new ArrayList(); - for(int i = 0; i < request.length; i++) { - PDFASSignResponse response = signPDFDokument(request[i]); - if(response != null) { - responses.add(response); + if (request.getSignRequests() != null) { + for (int i = 0; i < request.getSignRequests().size(); i++) { + PDFASSignResponse response = signPDFDokument(request + .getSignRequests().get(i)); + if (response != null) { + responses.add(response); + } } + PDFASBulkSignResponse response = new PDFASBulkSignResponse(); + response.setSignResponses(responses); + return response; } - PDFASSignResponse[] array = new PDFASSignResponse[responses.size()]; - for(int i = 0; i < responses.size(); i++) { - array[i] = responses.get(i); + logger.error("Server Signature failed. [PDFASBulkSignRequest is NULL]"); + if (WebConfiguration.isShowErrorDetails()) { + throw new WebServiceException("PDFASBulkSignRequest is NULL"); + } else { + throw new WebServiceException("Server Signature failed."); } - return array; } } -- cgit v1.2.3