コード例 #1
0
  private void init() {
    error = false;
    SinekartaUtility su = SinekartaUtility.getCurrentInstance();

    su.setDataToAppletCertificateChoice(null);
    su.setDataFromAppletCertificateChoice(null);
    su.setDataToAppletSign(null);
    su.setDataFromAppletSign(null);
    description = null;
    selectedDocumentNodePdf = null;

    selectedDocumentNode = browseBean.getActionSpace().getNodeRef();

    documentName =
        (String) su.getNodeService().getProperty(selectedDocumentNode, ContentModel.PROP_NAME);

    documentPath =
        NodeTools.translatePath(
            su.getNodeService(), su.getNodeService().getPath(selectedDocumentNode));
    documentPath = documentPath.substring(0, documentPath.indexOf(documentName));

    // verify if a signed document version of this document already exists
    selectedDocumentNodeParent =
        su.getNodeService().getPrimaryParent(selectedDocumentNode).getParentRef();

    NodeRef exist = null;
    int i = 0;
    do {
      // calculating new filename
      documentNamePdf =
          (String) su.getNodeService().getProperty(selectedDocumentNode, ContentModel.PROP_NAME);
      int dotIdx = documentNamePdf.lastIndexOf('.');
      if (i == 0) {
        documentNamePdf =
            documentNamePdf.substring(0, dotIdx)
                + Configuration.getInstance().getSignedSuffix()
                + documentNamePdf.substring(dotIdx);
      } else {
        documentNamePdf =
            documentNamePdf.substring(0, dotIdx)
                + " ("
                + i
                + ")"
                + Configuration.getInstance().getSignedSuffix()
                + documentNamePdf.substring(dotIdx);
      }

      // adjust documentName
      documentName = PDFTools.calculatePdfName(documentNamePdf);

      exist = su.getFileFolderService().searchSimple(selectedDocumentNodeParent, documentName);
      i++;
    } while (exist != null);

    // preparazione area di input per applet

    prepareDataToAppletCertificateChoice();

    su.setDataFromAppletCertificateChoice(null);
  }
コード例 #2
0
  @Override
  protected void executeImpl(Action action, NodeRef actionedUponNodeRef) {
    if (tracer.isDebugEnabled()) tracer.debug("DocumentAcquiring action, execution init");

    // the document has already the documentAcquiring aspect? if yes, nothing to do
    if (nodeService.hasAspect(actionedUponNodeRef, SinekartaModel.ASPECT_QNAME_DOCUMENT_ACQUIRING))
      return;

    // the document has the timestamp mark aspect? if yes, nothing to do
    if (nodeService.hasAspect(actionedUponNodeRef, SinekartaModel.ASPECT_QNAME_TIMESTAMP_MARK))
      return;

    // the node to add is an archive, we don't need any acquire processing
    if (nodeService.getType(actionedUponNodeRef).equals(SinekartaModel.TYPE_QNAME_ARCHIVE)) return;

    // Someone is rendering the document (by ie in share), the document must not be acquired
    // if the document is a child of an acquired document and is not to render, it's a working copy
    // for displaying
    if (nodeService.hasAspect(
        nodeService.getPrimaryParent(actionedUponNodeRef).getParentRef(),
        SinekartaModel.ASPECT_QNAME_DOCUMENT_ACQUIRING)) return; // &&
    // nodeService.hasAspect(actionedUponNodeRef,
    // org.alfresco.model.RenditionModel.ASPECT_HIDDEN_RENDITION))

    Integer documentTypeId = (Integer) action.getParameterValue(PARAM_DOCUMENT_TYPE);
    DocumentType documentType = null;
    if (documentTypeId != null) {
      try {
        documentType = sinekartaDao.getDocumentType(documentTypeId);
      } catch (Exception e) {
        tracer.error("wrong documentType for mark folder prepare.", e);
        throw new DocumentAcquiringException("wrong documentType for mark folder prepare.", e);
      }
    }

    Date documentDate = (Date) action.getParameterValue(PARAM_DOCUMENT_DATE);

    String documentLanguage = (String) action.getParameterValue(PARAM_DOCUMENT_LANGUAGE);

    // getting sinekarta admin user
    String sinekartaAdminUserId =
        NodeTools.getSinekartaAdminUserId(nodeService, searchService, companyHomePath);

    DocumentAcquiringWorker execAsSinekartaAdmin =
        new DocumentAcquiringWorker(
            nodeService,
            contentService,
            actionedUponNodeRef,
            actionService,
            documentType,
            documentDate,
            documentLanguage);

    // running core of action as sinekarta admin
    Boolean result = AuthenticationUtil.runAs(execAsSinekartaAdmin, sinekartaAdminUserId);
    if (!result) {
      tracer.error(
          "document acquiring failed, please verify if the document already exists on archive : "
              + execAsSinekartaAdmin.getKoReason());
      throw new DocumentAcquiringException(
          "document acquiring failed, please verify if the document already exists on archive : "
              + execAsSinekartaAdmin.getKoReason());
    }

    if (tracer.isDebugEnabled()) tracer.debug("DocumentAcquiring action, execution end");
  }