Example usage for javax.transaction NotSupportedException printStackTrace

List of usage examples for javax.transaction NotSupportedException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.unilever.audit.services2.VisitSync.java

@POST
@Produces("application/json")
@Consumes("text/plain")
public String postJson(byte[] jsonObj) throws IOException {
    JSONObject result = new JSONObject();
    JSONArray failedIds = new JSONArray();
    boolean status = true;
    byte[] buffer;
    try {// w w w.j a va  2s .  c om
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        GZIPInputStream in = new GZIPInputStream(new ByteArrayInputStream(jsonObj));
        IOUtils.copy(in, out);
        buffer = out.toByteArray();
        System.out.println("======================siiiize" + buffer.length);
        JSONObject obj = new JSONObject(new String(buffer));
        JSONArray visitsArr = obj.getJSONArray("visits");
        for (int i = 0; i < visitsArr.length(); i++) {

            try {
                utx.begin();
            } catch (javax.transaction.NotSupportedException ex) {
                ex.printStackTrace();
            } catch (SystemException ex) {
                ex.printStackTrace();
            }
            JSONObject visitObj = (JSONObject) visitsArr.get(i);
            Visit v = new Visit();

            v.setId(visitObj.getString("id"));

            Customers c = em.getReference(Customers.class, new BigDecimal(visitObj.getInt("customerid")));
            v.setCustomerid(c);

            Merchandisers m = em.getReference(Merchandisers.class, new BigDecimal(visitObj.getInt("merchid")));
            v.setMerchandiserid(m);

            try {
                Date date = new SimpleDateFormat("EEE MMM d HH:mm:ss zzz yyyy")
                        .parse(visitObj.getString("finishdate"));
                v.setVisitdate(date);
            } catch (java.text.ParseException ex) {
                ex.printStackTrace();
            }

            v.setSubmitteddate(new Date());
            try {
                em.persist(v);

                System.out.println("Timeeeeeeeeeeeeee ============= "
                        + (v.getSubmitteddate().getTime() - v.getVisitdate().getTime()));
                utx.commit();
            } catch (Exception ex) {
                status = false;
                failedIds.put(v.getId());
            }
        }

        result.put("status", status);
        result.put("failedIds", failedIds);
    } catch (JSONException ex) {
        ex.printStackTrace();
    }
    return result.toString();
}

From source file:it.drwolf.ridire.session.async.WordCounter.java

@Asynchronous
public void countWords(Integer jobId) {
    try {/* www .  ja va2 s. co m*/
        this.userTx = (UserTransaction) org.jboss.seam.Component
                .getInstance("org.jboss.seam.transaction.transaction");
        String resourcesDir = null;
        if (!this.userTx.isActive()) {
            this.userTx.begin();
        }
        this.entityManager.joinTransaction();
        String dir = this.entityManager.find(Parameter.class, Parameter.JOBS_DIR.getKey()).getValue();
        Job curJ = this.entityManager.find(Job.class, jobId);
        if (curJ.getChildJobName() != null && !curJ.isMappedResources()) {
            resourcesDir = dir + JobMapperMonitor.FILE_SEPARATOR + curJ.getChildJobName()
                    + JobMapperMonitor.FILE_SEPARATOR + "arcs" + JobMapperMonitor.FILE_SEPARATOR
                    + JobMapperMonitor.RESOURCESDIR;
        } else {
            resourcesDir = dir + JobMapperMonitor.FILE_SEPARATOR + curJ.getName()
                    + JobMapperMonitor.FILE_SEPARATOR + "arcs" + JobMapperMonitor.FILE_SEPARATOR
                    + JobMapperMonitor.RESOURCESDIR;
        }

        // back compatibility with Heritrix 2
        File resourcesDirFile = new File(resourcesDir);
        if (resourcesDirFile == null || !resourcesDirFile.isDirectory()) {
            resourcesDir = "completed-" + resourcesDir;
        }
        this.entityManager.flush();
        this.userTx.commit();
        Integer jobWords = 0;
        for (CrawledResource cr : curJ.getCrawledResources()) {
            if (!this.userTx.isActive()) {
                this.userTx.begin();
            }
            this.entityManager.joinTransaction();
            this.entityManager.refresh(cr);
            String digest = cr.getDigest();
            if (digest != null) {
                File posFile = new File(resourcesDir + JobMapperMonitor.FILE_SEPARATOR + digest + ".txt.pos");
                if (posFile != null && posFile.exists() && posFile.canRead()) {
                    try {
                        Integer countWordsFromPoSTagResource = this.countWordsFromPoSTagResource(posFile);
                        jobWords += countWordsFromPoSTagResource;
                        cr.setWordsNumber(countWordsFromPoSTagResource);
                        File f = new File(FilenameUtils.getFullPath(cr.getArcFile())
                                + JobMapperMonitor.RESOURCESDIR + cr.getDigest() + ".txt");
                        if (f.exists() && f.canRead()) {
                            cr.setExtractedTextHash(MD5DigestCreator.getMD5Digest(f));
                        }
                        this.entityManager.merge(cr);
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (NoSuchAlgorithmException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
            }
            this.entityManager.flush();
            this.userTx.commit();
        }
        if (!this.userTx.isActive()) {
            this.userTx.begin();
        }
        this.entityManager.joinTransaction();
        Job j = this.entityManager.find(Job.class, jobId);
        j.setWordsNumber(jobWords);
        this.entityManager.persist(j);
        this.entityManager.flush();
        this.userTx.commit();
    } catch (NotSupportedException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    } catch (SystemException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    } catch (SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (RollbackException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (HeuristicMixedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (HeuristicRollbackException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:gwap.game.quiz.PlayNHighscoreCommunicationResource.java

private void doWork(HttpServletRequest request, HttpServletResponse response) throws IOException {

    this.response = response;
    QuizHighscore quizHighscore = readOutJSONData(request);
    try {/* w  w  w  .ja va  2 s .  c  o  m*/

        Transaction.instance().begin();

        QuizHighscoreBean quizHighscoreBean = (QuizHighscoreBean) Component.getInstance("quizHighscoreBean");

        int placeAllTime = 0;
        int placeThisWeek = 0;
        List<QuizHighscore> highscores = new ArrayList<QuizHighscore>();

        if (action.equals("GetEvaluation")) {

            placeAllTime = quizHighscoreBean.getPlaceAllTime(quizHighscore.getScore()) + 1;
            placeThisWeek = quizHighscoreBean.getPlaceThisWeek(quizHighscore.getScore()) + 1;
        } else if (action.equals("Store")) {
            if (quizHighscore != null) {
                quizHighscoreBean.addHighscore(quizHighscore);

            }
        } else if (action.equals("GetHighscores")) {
            if (mode.equals("All Time")) {
                highscores = quizHighscoreBean.getHighScoresAllTime();
            } else {
                highscores = quizHighscoreBean.getHighScoresThisWeek();
            }
        }

        JSONObject jsonObject = createJSONForFeedback(highscores, placeAllTime, placeThisWeek);

        sendJSONObject(jsonObject);

        Transaction.instance().commit();

    } catch (NotSupportedException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    } catch (SystemException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    } catch (SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (RollbackException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (HeuristicMixedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (HeuristicRollbackException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:gwap.game.quiz.PlayNRatingCommunicationResource.java

private void doWork(HttpServletRequest request, HttpServletResponse response) throws IOException {

    this.response = response;
    UserPerceptionRating userPerceptionRating = readOutJSONData(request);

    try {/*  w w  w .  j  a v a 2s. co  m*/
        logger.info("Create perception rating for resource #0, question #1 with pairs #2",
                userPerceptionRating.getResourceId(), userPerceptionRating.getQuestionNumber(),
                userPerceptionRating.getPairs());

        // get Session
        HttpSession ses = SessionTracker.instance().getSession(sessionID);

        Transaction.instance().begin();

        QuizSessionBean quizSession = (QuizSessionBean) ses.getAttribute("quizSession");

        QuizQuestionBean quizQuestion = quizSession.getQuizQuestion(userPerceptionRating.getQuestionNumber());

        // create PerceptionRating
        PerceptionRating perceptionRating = new PerceptionRating();
        perceptionRating.setCreated(new Date());
        perceptionRating.setResource(quizQuestion.getArtResource());
        perceptionRating.setFillOutTimeMs(userPerceptionRating.getFillOutTimeMs());
        userPerceptionRating.setPerceptionRating(perceptionRating);

        RatingEvaluator ratingEvaluator = (RatingEvaluator) Component.getInstance("ratingEvaluator");

        // give Feedback and calculate Bonus

        int[] avgUserRating = ratingEvaluator.calcAvgUserRating(quizQuestion);

        int[] feedback = ratingEvaluator.calculateRecommendationForFeedbackJoker(quizQuestion,
                userPerceptionRating, avgUserRating);

        int bonus = ratingEvaluator.calculateBonus(quizQuestion, userPerceptionRating, avgUserRating);

        JSONObject jsonObject = createJSONForFeedback(feedback, bonus);

        sendJSONObject(jsonObject);

        // save in DB
        PerceptionBean perceptionBean = (PerceptionBean) Component.getInstance("perceptionBean");
        perceptionBean.addUserPerceptionRating(userPerceptionRating);
        Transaction.instance().commit();
        logger.info("Created perception ratings");

    } catch (NotSupportedException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    } catch (SystemException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    } catch (SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (RollbackException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (HeuristicMixedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (HeuristicRollbackException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.p6spy.engine.spy.XADataSourceTest.java

@Test
public void twoPhaseCommitDataPersistedOnCommit() {
    try {/*w  w  w.j av  a2s.c o m*/
        tm.begin();
        insertData(new JndiDataSourceLookup().getDataSource("jdbc/inTestDs"));
        insertData(new JndiDataSourceLookup().getDataSource("jdbc/fixedDs"));
        tm.commit();

        tm.begin();
        assertEquals(1, queryForInt(new JndiDataSourceLookup().getDataSource("jdbc/inTestDs")));
        assertEquals(1, queryForInt(new JndiDataSourceLookup().getDataSource("jdbc/fixedDs")));
        tm.commit();

    } catch (NotSupportedException e) {
        e.printStackTrace();
        Assert.fail();
    } catch (SystemException e) {
        e.printStackTrace();
        Assert.fail();
    } catch (IllegalStateException e) {
        e.printStackTrace();
        Assert.fail();
    } catch (SecurityException e) {
        e.printStackTrace();
        Assert.fail();
    } catch (HeuristicMixedException e) {
        e.printStackTrace();
        Assert.fail();
    } catch (HeuristicRollbackException e) {
        e.printStackTrace();
        Assert.fail();
    } catch (RollbackException e) {
        e.printStackTrace();
        Assert.fail();
    }
}

From source file:com.p6spy.engine.spy.XADataSourceTest.java

@Test
public void twoPhaseCommitDataNotPersistedOnRollback() {
    try {//from w w  w.j a va  2  s .  c  o  m
        tm.begin();
        insertData(new JndiDataSourceLookup().getDataSource("jdbc/inTestDs"));
        insertData(new JndiDataSourceLookup().getDataSource("jdbc/fixedDs"));
        tm.rollback();

        tm.begin();
        assertEquals(0, queryForInt(new JndiDataSourceLookup().getDataSource("jdbc/inTestDs")));
        assertEquals(0, queryForInt(new JndiDataSourceLookup().getDataSource("jdbc/fixedDs")));
        tm.commit();

    } catch (NotSupportedException e) {
        e.printStackTrace();
        Assert.fail();
    } catch (SystemException e) {
        e.printStackTrace();
        Assert.fail();
    } catch (IllegalStateException e) {
        e.printStackTrace();
        Assert.fail();
    } catch (SecurityException e) {
        e.printStackTrace();
        Assert.fail();
    } catch (HeuristicMixedException e) {
        e.printStackTrace();
        Assert.fail();
    } catch (HeuristicRollbackException e) {
        e.printStackTrace();
        Assert.fail();
    } catch (RollbackException e) {
        e.printStackTrace();
        Assert.fail();
    }
}

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  ww w.j a va2  s. co m*/
 */
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   www. j av a2 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>//from   w ww.  j  a v  a  2  s. 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/*from   ww w.  ja va  2 s  .com*/
 *
 * @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;
}