@Override
  protected void executeImpl(Action action, NodeRef nodeRef) {
    String usernameAuth = authenticate();
    NodeService nodeService = serviceRegistry.getNodeService();
    NodeRef parentNodeRef = nodeService.getPrimaryParent(nodeRef).getParentRef();

    if (nodeService.hasAspect(nodeRef, documentSimpleRM)) {
      if (nodeService.hasAspect(parentNodeRef, expedientRM)) {
        updateExpedient(nodeService, nodeRef, parentNodeRef);

      } else if (nodeService.hasAspect(parentNodeRef, agregacioRM)) {
        updateAgregacio(nodeService, nodeRef, parentNodeRef);
      }

    } else if (nodeService.hasAspect(nodeRef, expedientRM)) {
      updateSerie(nodeService, nodeRef, parentNodeRef);

    } else if (nodeService.hasAspect(nodeRef, agregacioRM)) {
      updateSerie(nodeService, nodeRef, parentNodeRef);

    } else if (nodeService.hasAspect(nodeRef, serieRM)) {
      updateFons(nodeService, nodeRef, parentNodeRef);
    }

    AuthenticationUtil.setRunAsUser(usernameAuth);
    AuthenticationUtil.setFullyAuthenticatedUser(usernameAuth);
  }
 @Override
 public Set<NodeRef> findFrom(NodeRef thisNode) {
   Set<NodeRef> result = Collections.emptySet();
   if (nodeService.exists(thisNode)
       && (WebSiteModel.TYPE_INDEX_PAGE.equals(nodeService.getType(thisNode)))) {
     result = new HashSet<NodeRef>();
     result.add(nodeService.getPrimaryParent(thisNode).getParentRef());
   }
   return result;
 }
  @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");
  }