Example usage for javax.transaction NotSupportedException getMessage

List of usage examples for javax.transaction NotSupportedException getMessage

Introduction

In this page you can find the example usage for javax.transaction NotSupportedException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:it.doqui.index.ecmengine.business.job.move.MoveAggregationJob.java

/**
 * Copies the permissions of the source node reference onto the destination node reference
 *
 * @param sourceNodeRef         the source node reference
 * @param destinationNodeRef   the destination node reference
 * @throws AuthenticationRuntimeException
 * @throws PermissionRuntimeException//from   w w w.j a  v  a2 s  .  c  om
 */
private void copyPermissions(NodeRef sourceNodeRef, NodeRef destinationNodeRef, String sourceRepo,
        String destRepo) throws PermissionRuntimeException, AuthenticationRuntimeException {
    try {
        logger.debug("[MoveAggregationJob::copyPermissions] BEGIN");

        UserTransaction userTxSource = transactionService.getNonPropagatingUserTransaction();

        UserTransaction userTxDest = transactionService.getNonPropagatingUserTransaction();

        userTxSource.begin();

        RepositoryManager.setCurrentRepository(sourceRepo);

        //authenticate as the system user
        authenticationComponent.setSystemUserAsCurrentUser();

        AccessStatus accessStatus = permissionService.hasPermission(sourceNodeRef,
                PermissionService.READ_PERMISSIONS);

        userTxSource.commit();

        if (accessStatus == AccessStatus.ALLOWED) {
            userTxSource = transactionService.getNonPropagatingUserTransaction();

            userTxSource.begin();

            // Get the permission details of the source node reference
            Set<AccessPermission> permissions = permissionService.getAllSetPermissions(sourceNodeRef);
            boolean includeInherited = permissionService.getInheritParentPermissions(sourceNodeRef);

            userTxSource.commit();

            userTxDest.begin();

            RepositoryManager.setCurrentRepository(destRepo);

            // authenticate as the system user
            authenticationComponent.setSystemUserAsCurrentUser();

            AccessStatus writePermission = permissionService.hasPermission(destinationNodeRef,
                    PermissionService.CHANGE_PERMISSIONS);
            if (writePermission.equals(AccessStatus.ALLOWED)
                    || authenticationService.isCurrentUserTheSystemUser()) {
                // Set the permission values on the destination node
                for (AccessPermission permission : permissions) {
                    permissionService.setPermission(destinationNodeRef, permission.getAuthority(),
                            permission.getPermission(),
                            permission.getAccessStatus().equals(AccessStatus.ALLOWED));
                }
                permissionService.setInheritParentPermissions(destinationNodeRef, includeInherited);
            }

            userTxDest.commit();
        }

    } catch (NotSupportedException e) {
        logger.error("[MoveAggregationJob::copyPermissions] Eccezione: " + e.getMessage());
        e.printStackTrace();
    } catch (SystemException e) {
        logger.error("[MoveAggregationJob::copyPermissions] Eccezione: " + e.getMessage());

        e.printStackTrace();
    } catch (SecurityException e) {
        logger.error("[MoveAggregationJob::copyPermissions] Eccezione: " + e.getMessage());

        e.printStackTrace();
    } catch (IllegalStateException e) {
        logger.error("[MoveAggregationJob::copyPermissions] Eccezione: " + e.getMessage());

        e.printStackTrace();
    } catch (RollbackException e) {
        logger.error("[MoveAggregationJob::copyPermissions] Eccezione: " + e.getMessage());

        e.printStackTrace();
    } catch (HeuristicMixedException e) {
        logger.error("[MoveAggregationJob::copyPermissions] Eccezione: " + e.getMessage());

        e.printStackTrace();
    } catch (HeuristicRollbackException e) {
        logger.error("[MoveAggregationJob::copyPermissions] Eccezione: " + e.getMessage());

        e.printStackTrace();
    } finally {
        logger.debug("[MoveAggregationJob::copyPermissions] END");
    }
}

From source file:it.doqui.index.ecmengine.business.job.move.MoveAggregationJob.java

/**
 * Copies the target associations onto the destination node reference.
 *
 * @param sourceNodeRef   the destination node reference
 * @param destinationNodeRef   the destination node reference    *
 * @throws NodeRuntimeException//from   w w  w  .  ja va 2  s. c om
 */
private void copyTargetAssociations(NodeRef sourceNodeRef, NodeRef destinationNodeRef, String sourceRepo,
        String destRepo) throws NodeRuntimeException {
    try {
        logger.debug("[MoveAggregationJob::copyTargetAssociations] BEGIN");

        UserTransaction userTxSource = transactionService.getNonPropagatingUserTransaction();

        UserTransaction userTxDest = transactionService.getNonPropagatingUserTransaction();

        userTxSource.begin();

        RepositoryManager.setCurrentRepository(sourceRepo);

        //authenticate as the system user
        authenticationComponent.setSystemUserAsCurrentUser();

        List<AssociationRef> nodeAssocRefs = nodeService.getTargetAssocs(sourceNodeRef,
                RegexQNamePattern.MATCH_ALL);

        userTxSource.commit();

        if (nodeAssocRefs != null) {

            userTxDest.begin();

            RepositoryManager.setCurrentRepository(destRepo);

            //authenticate as the system user
            authenticationComponent.setSystemUserAsCurrentUser();

            for (AssociationRef assocRef : nodeAssocRefs) {
                NodeRef targetRef = assocRef.getTargetRef();

                boolean exists = false;
                for (AssociationRef assocRef2 : nodeService.getTargetAssocs(destinationNodeRef,
                        assocRef.getTypeQName())) {
                    if (targetRef.equals(assocRef2.getTargetRef()) == true) {
                        exists = true;
                        break;
                    }
                }

                if (exists == false) {
                    // Add the association(aggiunge le associazioni di tipo reference verso il nodo che si trova
                    //nel corrente ma questo nodo non viene ricreato nel deposito; Cosa fare? )
                    //TODO:
                    // crea la relazione verso il nodo presente in corrente , ma non crea il nodo in deposito
                    nodeService.createAssociation(destinationNodeRef, targetRef, assocRef.getTypeQName());
                }
            }
            userTxDest.commit();
        }
    } catch (NotSupportedException e) {
        logger.error("[MoveAggregationJob::copyTargetAssociations] Eccezione: " + e.getMessage());

        e.printStackTrace();
    } catch (SystemException e) {
        logger.error("[MoveAggregationJob::copyTargetAssociations] Eccezione: " + e.getMessage());

        e.printStackTrace();
    } catch (SecurityException e) {
        logger.error("[MoveAggregationJob::copyTargetAssociations] Eccezione: " + e.getMessage());

        e.printStackTrace();
    } catch (IllegalStateException e) {
        logger.error("[MoveAggregationJob::copyTargetAssociations] Eccezione: " + e.getMessage());

        e.printStackTrace();
    } catch (RollbackException e) {
        logger.error("[MoveAggregationJob::copyTargetAssociations] Eccezione: " + e.getMessage());

        e.printStackTrace();
    } catch (HeuristicMixedException e) {
        logger.error("[MoveAggregationJob::copyTargetAssociations] Eccezione: " + e.getMessage());

        e.printStackTrace();
    } catch (HeuristicRollbackException e) {
        logger.error("[MoveAggregationJob::copyTargetAssociations] Eccezione: " + e.getMessage());

        e.printStackTrace();
    } finally {
        logger.debug("[MoveAggregationJob::copyTargetAssociations] END");
    }
}

From source file:it.doqui.index.ecmengine.business.job.move.MoveAggregationJob.java

/**
 * Copies the child associations onto the destiantion node reference.
 * <p>/* w  ww .j av a  2s  .  c o m*/
 * If copyChildren is true then the nodes at the end of a primary assoc will be copied before they
 * are associated.
 *
 * @param sourceNodeRef         the source node reference
 * @param destinationNodeRef   the destination node reference
 * @param copyChildren         indicates whether to copy the primary children
 * @throws AuthenticationRuntimeException
 * @throws PermissionRuntimeException
 * @throws NodeRuntimeException
 */
private void copyChildAssociations(NodeRef sourceNodeRef, NodeRef destinationNodeRef, boolean copyChildren,
        Map<NodeRef, NodeRef> copiedChildren, String sourceRepo, String destRepo)
        throws NodeRuntimeException, PermissionRuntimeException, AuthenticationRuntimeException {

    try {
        logger.debug("[MoveAggregationJob::copyChildAssociations] BEGIN");

        UserTransaction userTxSource = transactionService.getNonPropagatingUserTransaction();

        UserTransaction userTxDest = transactionService.getNonPropagatingUserTransaction();

        userTxSource.begin();

        RepositoryManager.setCurrentRepository(sourceRepo);

        //authenticate as the system user
        authenticationComponent.setSystemUserAsCurrentUser();

        List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(sourceNodeRef);

        userTxSource.commit();

        if (childAssocs != null) {
            logger.debug(
                    "[MoveAggregationJob::copyChildAssociations] Nodi figli da ricreare in Repo Secondary: "
                            + childAssocs.size());
            for (ChildAssociationRef childAssoc : childAssocs) {
                if (copyChildren == true) {
                    if (childAssoc.isPrimary() == true) {
                        logger.debug("[MoveAggregationJob::copyChildAssociations]"
                                + " Nodo figlio primario da ricreare in Repo Secondary.");
                        // Do not recurse further, if we've already copied this node
                        if (copiedChildren.containsKey(childAssoc.getChildRef()) == false
                                && copiedChildren.containsValue(childAssoc.getChildRef()) == false) {
                            // Copy the child
                            recursiveCopy(childAssoc.getChildRef(), childAssoc.getParentRef(),
                                    destinationNodeRef, childAssoc.getTypeQName(), childAssoc.getQName(),
                                    copyChildren, copiedChildren, sourceRepo, destRepo);
                        }
                    } else {
                        logger.debug(
                                "[MoveAggregationJob::copyChildAssociations] Nodo figlio Non Primario da ricreare.");

                        //Add the child (I figli non primari non vengono ricreati nel deposito)Cosa fare??
                        //TODO: NB i figli secondari non vengono ricreati, ma solo viene creata la relazione
                        //tra padre e figlio( e il figlio si trova nel deposito)
                        NodeRef childRef = childAssoc.getChildRef();

                        userTxDest.begin();

                        RepositoryManager.setCurrentRepository(destRepo);

                        // authenticate as the system user
                        authenticationComponent.setSystemUserAsCurrentUser();

                        nodeService.addChild(destinationNodeRef, childRef, childAssoc.getTypeQName(),
                                childAssoc.getQName());

                        userTxDest.commit();
                    }
                }
            }
        }
    } catch (NotSupportedException e) {
        logger.error("[MoveAggregationJob::copyChildAssociations] Eccezione: " + e.getMessage());

        e.printStackTrace();
    } catch (SystemException e) {
        logger.error("[MoveAggregationJob::copyChildAssociations] Eccezione: " + e.getMessage());

        e.printStackTrace();
    } catch (SecurityException e) {
        logger.error("[MoveAggregationJob::copyChildAssociations] Eccezione: " + e.getMessage());

        e.printStackTrace();
    } catch (IllegalStateException e) {
        logger.error("[MoveAggregationJob::copyChildAssociations] Eccezione: " + e.getMessage());

        e.printStackTrace();
    } catch (RollbackException e) {
        logger.error("[MoveAggregationJob::copyChildAssociations] Eccezione: " + e.getMessage());

        e.printStackTrace();
    } catch (HeuristicMixedException e) {
        logger.error("[MoveAggregationJob::copyChildAssociations] Eccezione: " + e.getMessage());

        e.printStackTrace();
    } catch (HeuristicRollbackException e) {
        logger.error("[MoveAggregationJob::copyChildAssociations] Eccezione: " + e.getMessage());

        e.printStackTrace();
    } finally {
        logger.debug("[MoveAggregationJob::copyChildAssociations] END");
    }
}

From source file:it.doqui.index.ecmengine.business.job.move.MoveAggregationJob.java

/**
 * Recursive copy algorithm//  w ww.  ja v a2  s. co  m
 *
 * @throws NodeRuntimeException
 * @throws AuthenticationRuntimeException
 * @throws PermissionRuntimeException
 */
private NodeRef recursiveCopy(NodeRef sourceNodeRef, NodeRef sourceParentRef, NodeRef destinationParentRef,
        QName destinationAssocTypeQName, QName destinationQName, boolean copyChildren,
        Map<NodeRef, NodeRef> copiedChildren, String sourceRepo, String destRepo)
        throws NodeRuntimeException, PermissionRuntimeException, AuthenticationRuntimeException {

    NodeRef destinationNodeRef = null;

    UserTransaction userTxSource = null;

    UserTransaction userTxDest = null;

    try {

        logger.debug("[MoveAggregationJob::recursiveCopy] BEGIN");

        userTxSource = transactionService.getNonPropagatingUserTransaction();

        userTxSource.begin();

        Map<QName, Serializable> properties = null;
        Set<QName> sourceAspects = null;

        RepositoryManager.setCurrentRepository(sourceRepo);

        //authenticate as the system user
        authenticationComponent.setSystemUserAsCurrentUser();

        QName sourceType = nodeService.getType(sourceNodeRef);
        properties = nodeService.getProperties(sourceNodeRef);
        sourceAspects = nodeService.getAspects(sourceNodeRef);

        userTxSource.commit();

        // Create the new node
        userTxDest = transactionService.getNonPropagatingUserTransaction();

        userTxDest.begin();

        RepositoryManager.setCurrentRepository(destRepo);

        //authenticate as the system user
        authenticationComponent.setSystemUserAsCurrentUser();

        boolean esisteStore = nodeService.exists(destinationParentRef.getStoreRef());

        logger.debug("[MoveAggregationJob::recursiveCopy] Lo Store Destination esiste ? : " + esisteStore);

        final boolean destExists = nodeService.exists(destinationParentRef);

        logger.debug("[MoveAggregationJob::recursiveCopy] " + "Repository di Destinazione : "
                + RepositoryManager.getCurrentRepository());
        logger.debug(
                "[MoveAggregationJob::recursiveCopy] '" + destinationParentRef + "' esiste: " + destExists);

        ChildAssociationRef destinationChildAssocRef = nodeService.createNode(destinationParentRef,
                destinationAssocTypeQName, destinationQName, sourceType, null);

        destinationNodeRef = destinationChildAssocRef.getChildRef();

        logger.debug("[MoveAggregationJob::recursiveCopy] Nodo spostato: " + destinationNodeRef.getId());

        copiedChildren.put(sourceNodeRef, destinationNodeRef);

        for (QName aspect : sourceAspects) {
            nodeService.addAspect(destinationNodeRef, aspect, null);
            logger.debug("[MoveAggregationJob::recursiveCopy] Aspect copiato: " + aspect);
        }

        //setto sul nuovo nodo appena creato tutte le properties, anche quelle degli aspects
        nodeService.setProperties(destinationNodeRef, properties);
        logger.debug("[MoveAggregationJob::recursiveCopy] Property copiate: " + properties.size());

        // Prevent any rules being fired on the new destination node
        //ruleService.disableRules(destinationNodeRef);

        //   Apply the copy aspect to the new node
        //Map<QName, Serializable> copyProperties = new HashMap<QName, Serializable>();
        //copyProperties.put(ContentModel.PROP_COPY_REFERENCE, sourceNodeRef);
        //nodeService.addAspect(destinationNodeRef, ContentModel.ASPECT_COPIEDFROM, copyProperties);

        // Copy the aspects
        //copyAspects(destinationNodeRef, copyDetails);

        userTxDest.commit();

        // Copy the associations
        copyAssociations(sourceNodeRef, destinationNodeRef, copyChildren, copiedChildren, sourceRepo, destRepo);

        // Copy permissions
        copyPermissions(sourceNodeRef, destinationNodeRef, sourceRepo, destRepo);

    } catch (NotSupportedException e) {
        logger.error("[MoveAggregationJob::recursiveCopy] Eccezione: " + e.getMessage());
    } catch (SystemException e) {
        logger.error("[MoveAggregationJob::recursiveCopy] Eccezione: " + e.getMessage());
        e.printStackTrace();
    } catch (SecurityException e) {
        logger.error("[MoveAggregationJob::recursiveCopy] Eccezione: " + e.getMessage());
        e.printStackTrace();
    } catch (IllegalStateException e) {
        logger.error("[MoveAggregationJob::recursiveCopy] Eccezione: " + e.getMessage());
        e.printStackTrace();
    } catch (RollbackException e) {
        logger.error("[MoveAggregationJob::recursiveCopy] Eccezione: " + e.getMessage());
        e.printStackTrace();
    } catch (HeuristicMixedException e) {
        logger.error("[MoveAggregationJob::recursiveCopy] Eccezione: " + e.getMessage());
        e.printStackTrace();
    } catch (HeuristicRollbackException e) {
        logger.error("[MoveAggregationJob::recursiveCopy] Eccezione: " + e.getMessage());
        e.printStackTrace();
    } finally {
        //ruleService.enableRules(destinationNodeRef);
        logger.debug("[MoveAggregationJob::recursiveCopy] END");
    }
    return destinationNodeRef;
}

From source file:it.doqui.index.ecmengine.business.job.move.MoveAggregationJob.java

private void moveAggregation() throws MoveException {

    logger.debug("[MoveAggregationJob::moveAggregation] BEGIN");

    start(); // Avvia stopwatch

    try {//  ww w  . ja v a 2  s.c  om

        //bisogna ricercare nel repository quei nodi marcati come "spostabili"
        //solo questi dovranno essere spostati
        // 1) ricerca dei nodi spostabili
        // 2) ciclo per ogni nodo trovato, effettuare lo spostamento
        // 3) nodo spostato viene cancellato dalla source oppure viene marcato
        // come non visibile (aspect state valore riclassificato)

        List<NodeRef> listaNodi = searchNodeWithProp();
        int size = (listaNodi != null ? listaNodi.size() : 0);
        dumpElapsed("MoveAggregationJob", "moveAggregation", "Numero Nodi da Spostare: " + size,
                "Fine SearchNodeWithProp");

        logger.debug("[MoveAggregationJob::moveAggregation] Numero Nodi da Spostare: " + size);

        if (listaNodi != null) {

            MoveAggregation aggregation = null;

            String idDestinationParent = null;
            String idSourceNode = null;
            String destinationRepository = null;
            String sourceRepository = null;

            for (NodeRef sourceNodeRef : listaNodi) {

                aggregation = getPropertiesFromAspect(sourceNodeRef);

                if (aggregation != null) {
                    idDestinationParent = aggregation.getIdDestinationParent();
                    idSourceNode = aggregation.getIdSourceNode();

                    destinationRepository = aggregation.getDestinationRepository();
                    sourceRepository = aggregation.getSourceRepository();
                }

                boolean crossRepo = isCrossRepository(sourceRepository, destinationRepository);

                if (crossRepo) {
                    //spostamento da corrente a deposito
                    logger.debug("[MoveAggregationJob::moveAggregation] Spostamento da corrente a deposito");
                    long start = System.currentTimeMillis();
                    moveCrossRepo(sourceRepository, idSourceNode, destinationRepository, idDestinationParent,
                            sourceNodeRef);
                    long finished = System.currentTimeMillis();
                    logger.debug(
                            "[MoveAggregationJob::moveAggregation] Tempo Spostamento da corrente a deposito: "
                                    + (finished - start) + " ms");
                    dumpElapsed("MoveAggregationJob", "moveAggregation",
                            "Spostamento Cross Repository da " + idSourceNode + " a " + idDestinationParent,
                            "Fine Move Cross Repository");

                } else {

                    //spostamento da corrente a corrente
                    logger.debug("[MoveAggregationJob::moveAggregation] Spostamento da corrente a corrente");
                    long start = System.currentTimeMillis();
                    moveIntraRepo(sourceNodeRef, sourceRepository, idSourceNode, idDestinationParent);
                    long finished = System.currentTimeMillis();
                    logger.debug(
                            "[MoveAggregationJob::moveAggregation] Tempo Spostamento da corrente a corrente: "
                                    + (finished - start) + " ms");
                    dumpElapsed("MoveAggregationJob", "moveAggregation",
                            "Spostamento da " + idSourceNode + " a " + idDestinationParent,
                            "Fine Move Intra Repository");

                }
            }
        }
        // prima di fare una modifica bisogna controllare se il nodo padre possiede l'aspect state
        // con valore spostabile;  se e` cosi non e` possibile effettuare nessuna modifica al nodo
        // bisogna modificare i servizi fin qui fatti inserendo prima di tutto questo controllo
        // Quando poi l'aspect diventa spostato , il nodo e i suoi figli non sono visibili
    } catch (NotSupportedException e) {
        logger.error("[MoveAggregationJob::moveAggregation] " + "FATAL: transaction not supported: "
                + e.getMessage());
        throw new MoveException("Transaction not supported.", e);
    } catch (SystemException e) {
        logger.error("[MoveAggregationJob::moveAggregation] " + "FATAL: transaction manager error: "
                + e.getMessage());
        throw new MoveException("Transaction manager error.", e);
    } catch (EcmEngineFoundationException e) {
        logger.error("[MoveAggregationJob::moveAggregation] " + "FATAL: backend services error: "
                + e.getClass().getName() + " - " + e.getCode());
        throw new MoveException("Backend services error: " + e.getClass().getName() + " - " + e.getCode());
    } catch (SecurityException e) {
        logger.error(
                "[MoveAggregationJob::moveAggregation] " + "FATAL: SecurityException error: " + e.getMessage());
        throw new MoveException("SecurityException.", e);
    } catch (IllegalStateException e) {
        logger.error("[MoveAggregationJob::moveAggregation] " + "FATAL: IllegalStateException error: "
                + e.getMessage());
        throw new MoveException("IllegalStateException.", e);
    } catch (RollbackException e) {
        logger.error("[MoveAggregationJob::moveAggregation] " + "Transaction rolled back: " + e.getMessage());
        throw new MoveException("Transaction rolled back.", e);
    } catch (HeuristicMixedException e) {
        logger.error("[MoveAggregationJob::moveAggregation] "
                + "Transaction partially rolled back (heuristic rollback): " + e.getMessage());
        throw new MoveException("Transaction partially rolled back (heuristic rollback).", e);
    } catch (HeuristicRollbackException e) {
        logger.error("[MoveAggregationJob::moveAggregation] " + "Transaction rolled back (heuristic rollback): "
                + e.getMessage());
        throw new MoveException("Transaction rolled back (heuristic rollback).", e);
    } finally {
        stop(); // Ferma stopwatch
        logger.debug("[MoveAggregationJob::moveAggregation] END");
    }
}