/**
   * preparing data to send to applet for sign process
   *
   * @param dataFromApplet encoded64 data received from applet certificate choice
   * @return the data to passa to sign applet
   */
  protected void prepareDataToAppletSign() {

    // calcolo impronte documenti selezionati
    SinekartaUtility su = SinekartaUtility.getCurrentInstance();

    try {

      // copio il file per la conversione
      NodeRef folder = su.getNodeService().getPrimaryParent(selectedDocumentNode).getParentRef();

      FileInfo newFile =
          su.getFileFolderService().copy(selectedDocumentNode, folder, documentNamePdf);

      selectedDocumentNodePdf = newFile.getNodeRef();

      // conversione documento in PDF/A
      Action documentToPDFA =
          su.getActionService().createAction(DocumentToPDFA.ACTION_NAME_DOCUMENT_TO_PDFA);
      try {
        su.getActionService().executeAction(documentToPDFA, selectedDocumentNodePdf, false, false);
      } catch (Throwable t) {
        tracer.error("Unable to execute PDF/A conversion : " + t.getMessage(), t);
        throw new SignFailedException("Unable to execute PDF/A conversion : " + t.getMessage(), t);
      }

      Action digitalSignaturePrepareAndAddDocument =
          su.getActionService()
              .createAction(
                  DocumentDigitalSignaturePrepareAndAddDocument
                      .ACTION_NAME_DOCUMENT_DIGITAL_SIGNATURE_PREPARE_AND_ADD_DOCUMENT);
      digitalSignaturePrepareAndAddDocument.setParameterValue(
          DocumentDigitalSignaturePrepareAndAddDocument.PARAM_SIGN_DESCRIPTION, description);
      digitalSignaturePrepareAndAddDocument.setParameterValue(
          DocumentDigitalSignaturePrepareAndAddDocument.PARAM_SIGN_LOCATION,
          Constants.SIGN_LOCATION_ITALY);
      digitalSignaturePrepareAndAddDocument.setParameterValue(
          DocumentDigitalSignaturePrepareAndAddDocument.PARAM_CLIENT_AREA,
          su.getDataFromAppletCertificateChoice());
      try {
        su.getActionService()
            .executeAction(
                digitalSignaturePrepareAndAddDocument, selectedDocumentNodePdf, false, false);
      } catch (Throwable t) {
        tracer.error("Unable to prepare data for document sign : " + t.getMessage(), t);
        throw new SignFailedException(
            "Unable to prepare data for document sign : " + t.getMessage(), t);
      }
      su.setDataToAppletSign(
          (String)
              digitalSignaturePrepareAndAddDocument.getParameterValue(
                  DocumentDigitalSignaturePrepareAndAddDocument.PARAM_RESULT));
    } catch (SignFailedException e) {
      tracer.error(e.getMessage(), e);
      throw e;
    } catch (Exception e) {
      tracer.error("Unable to calculate document fingerprint.", e);
      throw new SignFailedException(
          "Unable to calculate document fingerprint : " + e.getMessage(), e);
    }
  }
  /** this method is called when finish button is pressed applying the sign returned from applet */
  protected String finishImpl(FacesContext context, String outcome) throws Exception {
    SinekartaUtility su = SinekartaUtility.getCurrentInstance();

    // applicao firma ai documenti selezionati

    try {

      // invoking generic sign apply action
      Action documentDigitalSignatureApply =
          su.getActionService()
              .createAction(
                  DocumentDigitalSignatureApply.ACTION_NAME_DOCUMENT_DIGITAL_SIGNATURE_APPLY);
      documentDigitalSignatureApply.setParameterValue(
          DocumentDigitalSignatureApply.PARAM_CLIENT_AREA, su.getDataFromAppletSign());
      try {
        su.getActionService()
            .executeAction(documentDigitalSignatureApply, selectedDocumentNodeParent, false, false);
      } catch (Throwable t) {
        tracer.error("Unable to apply sign to document : " + t.getMessage(), t);
        throw new SignFailedException("Unable to apply sign to document : " + t.getMessage(), t);
      }

      su.getNodeService()
          .setProperty(selectedDocumentNodePdf, ContentModel.PROP_NAME, documentName);

    } catch (SignFailedException e) {
      tracer.error(e.getMessage(), e);
      throw e;
    } catch (Exception e) {
      tracer.error("Unable to apply sign to document : " + e.getMessage(), e);
      throw new SignFailedException("Unable to apply sign to document : " + e.getMessage(), e);
    }

    return outcome;
  }
예제 #3
0
  @Override
  protected void executeImpl(Action action, NodeRef actionedUponNodeRef) {
    if (tracer.isDebugEnabled()) tracer.debug("DocumentAEMarkDocumentAdd action, execution init");

    String markArea = (String) action.getParameterValue(PARAM_MARK_AREA);
    if (markArea == null) {
      tracer.error("no markFileName specified for RCS mark prepare.");
      throw new MarkFailedException("no markFileName specified for RCS mark prepare.");
    }

    MarkDocumentArea markDocumentArea = MarkDocumentArea.fromBase64String(markArea);

    List<MarkDocument> docs = markDocumentArea.getDocuments();
    if (docs == null) {
      docs = new ArrayList<MarkDocument>();
      markDocumentArea.setDocuments(docs);
    }

    MarkDocument doc = new MarkDocument();
    doc.setNodeRefId(actionedUponNodeRef.getId());
    if (!docs.contains(doc)) docs.add(doc);

    action.setParameterValue(PARAM_RESULT, markDocumentArea.toBase64String());

    if (tracer.isDebugEnabled()) tracer.debug("DocumentAEMarkDocumentAdd action, execution end");
  }
예제 #4
0
 /**
  * Sends an invitation email.
  *
  * @param properties A Map containing the properties needed to send the email.
  */
 public void sendMail(Map<String, String> properties) {
   checkProperties(properties);
   ParameterCheck.mandatory("Properties", properties);
   NodeRef inviter = personService.getPerson(properties.get(wfVarInviterUserName));
   String inviteeName = properties.get(wfVarInviteeUserName);
   NodeRef invitee = personService.getPerson(inviteeName);
   Action mail = actionService.createAction(MailActionExecuter.NAME);
   mail.setParameterValue(MailActionExecuter.PARAM_FROM, getEmail(inviter));
   mail.setParameterValue(MailActionExecuter.PARAM_TO, getEmail(invitee));
   mail.setParameterValue(MailActionExecuter.PARAM_SUBJECT, buildSubject(properties));
   mail.setParameterValue(MailActionExecuter.PARAM_TEMPLATE, getEmailTemplateNodeRef());
   mail.setParameterValue(
       MailActionExecuter.PARAM_TEMPLATE_MODEL,
       (Serializable) buildMailTextModel(properties, inviter, invitee));
   mail.setParameterValue(MailActionExecuter.PARAM_IGNORE_SEND_FAILURE, true);
   actionService.executeAction(mail, getWorkflowPackage(properties));
 }