@Test public void testSignPDFDocument() throws Exception { try (OperationContext ctx = buildCtx(session)) { Map<String, Object> params = buildParams(); Blob signedBlob = (Blob) automationService.run(ctx, SignPDFDocument.ID, params); assertNotNull(signedBlob); } }
@OperationMethod public Blob run(DocumentModel doc) throws OperationException { if (!ctx.getPrincipal().isAdministrator()) { throw new OperationException("Not allowed. You must be administrator to use this operation"); } DocumentModel user = userManager.getUserModel(username); Blob originalBlob = doc.getAdapter(BlobHolder.class).getBlob(); boolean originalIsPdf = MIME_TYPE_PDF.equals(originalBlob.getMimeType()); boolean pdfa = SignatureHelper.getPDFA(); SigningDisposition disposition = SignatureHelper.getDisposition(originalIsPdf); String filename = originalBlob.getFilename(); String archiveFilename = SignatureHelper.getArchiveFilename(filename); return signatureService.signDocument(doc, user, password, reason, pdfa, disposition, archiveFilename); }
SignPDFDocument { @OperationMethod public Blob run(DocumentModel doc) throws OperationException { if (!ctx.getPrincipal().isAdministrator()) { throw new OperationException("Not allowed. You must be administrator to use this operation"); } DocumentModel user = userManager.getUserModel(username); Blob originalBlob = doc.getAdapter(BlobHolder.class).getBlob(); boolean originalIsPdf = MIME_TYPE_PDF.equals(originalBlob.getMimeType()); boolean pdfa = SignatureHelper.getPDFA(); SigningDisposition disposition = SignatureHelper.getDisposition(originalIsPdf); String filename = originalBlob.getFilename(); String archiveFilename = SignatureHelper.getArchiveFilename(filename); return signatureService.signDocument(doc, user, password, reason, pdfa, disposition, archiveFilename); } }
SignPDFDocument { @OperationMethod public Blob run(DocumentModel doc) throws OperationException { if (!ctx.getPrincipal().isAdministrator()) { throw new OperationException("Not allowed. You must be administrator to use this operation"); } DocumentModel user = userManager.getUserModel(username); Blob originalBlob = doc.getAdapter(BlobHolder.class).getBlob(); boolean originalIsPdf = MIME_TYPE_PDF.equals(originalBlob.getMimeType()); boolean pdfa = SignatureHelper.getPDFA(); SigningDisposition disposition = SignatureHelper.getDisposition(originalIsPdf); String filename = originalBlob.getFilename(); String archiveFilename = SignatureHelper.getArchiveFilename(filename); return signatureService.signDocument(doc, user, password, reason, pdfa, disposition, archiveFilename); }  }
SignPDFDocument { @OperationMethod public Blob run(DocumentModel doc) throws OperationException { if (!ctx.getPrincipal().isAdministrator()) { throw new OperationException("Not allowed. You must be administrator to use this operation"); } DocumentModel user = userManager.getUserModel(username); Blob originalBlob = doc.getAdapter(BlobHolder.class).getBlob(); boolean originalIsPdf = MIME_TYPE_PDF.equals(originalBlob.getMimeType()); boolean pdfa = SignatureHelper.getPDFA(); SigningDisposition disposition = SignatureHelper.getDisposition(originalIsPdf); String filename = originalBlob.getFilename(); String archiveFilename = SignatureHelper.getArchiveFilename(filename); return signatureService.signDocument(doc, user, password, reason, pdfa, disposition, archiveFilename); }  @OperationMethod Blob run(DocumentModel doc); }
SignPDFDocument { @OperationMethod public Blob run(DocumentModel doc) throws OperationException { if (!ctx.getPrincipal().isAdministrator()) { throw new OperationException("Not allowed. You must be administrator to use this operation"); } DocumentModel user = userManager.getUserModel(username); Blob originalBlob = doc.getAdapter(BlobHolder.class).getBlob(); boolean originalIsPdf = MIME_TYPE_PDF.equals(originalBlob.getMimeType()); boolean pdfa = SignatureHelper.getPDFA(); SigningDisposition disposition = SignatureHelper.getDisposition(originalIsPdf); String filename = originalBlob.getFilename(); String archiveFilename = SignatureHelper.getArchiveFilename(filename); return signatureService.signDocument(doc, user, password, reason, pdfa, disposition, archiveFilename); }  @OperationMethod Blob run(DocumentModel doc); static final String ID; }