@Test public void testNotAllowedToSignPDF() throws Exception { CoreSession notAdminSession = CoreInstance.getCoreSession(session.getRepositoryName(), DEFAULT_USER_ID); try (OperationContext ctx = buildCtx(notAdminSession)) { Map<String, Object> params = buildParams(); try { automationService.run(ctx, SignPDF.ID, params); } catch (OperationException e) { assertNotNull(e.getMessage()); assertTrue(e.getMessage().contains("Not allowed")); } } }
@OperationMethod public Blob run(Blob blob) throws OperationException { if (!ctx.getPrincipal().isAdministrator()) { throw new OperationException("Not allowed. You must be administrator to use this operation"); } DocumentModel user = userManager.getUserModel(username); return signatureService.signPDF(blob, doc, user, password, reason); }
SignPDF { @OperationMethod public Blob run(Blob blob) throws OperationException { if (!ctx.getPrincipal().isAdministrator()) { throw new OperationException("Not allowed. You must be administrator to use this operation"); } DocumentModel user = userManager.getUserModel(username); return signatureService.signPDF(blob, doc, user, password, reason); } }
SignPDF { @OperationMethod public Blob run(Blob blob) throws OperationException { if (!ctx.getPrincipal().isAdministrator()) { throw new OperationException("Not allowed. You must be administrator to use this operation"); } DocumentModel user = userManager.getUserModel(username); return signatureService.signPDF(blob, doc, user, password, reason); }  }
SignPDF { @OperationMethod public Blob run(Blob blob) throws OperationException { if (!ctx.getPrincipal().isAdministrator()) { throw new OperationException("Not allowed. You must be administrator to use this operation"); } DocumentModel user = userManager.getUserModel(username); return signatureService.signPDF(blob, doc, user, password, reason); }  @OperationMethod Blob run(Blob blob); }
SignPDF { @OperationMethod public Blob run(Blob blob) throws OperationException { if (!ctx.getPrincipal().isAdministrator()) { throw new OperationException("Not allowed. You must be administrator to use this operation"); } DocumentModel user = userManager.getUserModel(username); return signatureService.signPDF(blob, doc, user, password, reason); }  @OperationMethod Blob run(Blob blob); static final String ID; }