Examples of TabUndeletionException


Examples of org.eurekastreams.server.persistence.exceptions.TabUndeletionException

                will(returnValue(1L));

                allowing(deleteCacheKeysMapper).execute(with(any(Set.class)));

                oneOf(tabGroupMapper).undeleteTab(with(tabId.longValue()));
                will(throwException(new TabUndeletionException("string", tabId)));
            }
        });

        sut.execute(actionContext);
View Full Code Here

Examples of org.eurekastreams.server.persistence.exceptions.TabUndeletionException

            tabGroup = getTabGroupByTabId(tabId, true);
            logger.debug("***Done getting tab group by tab Id (" + (System.currentTimeMillis() - start) + "ms");
        }
        catch (Exception ex)
        {
            throw new TabUndeletionException("Could not find either the specified Tab or tabGroup for TabId=" + tabId,
                    tabId);
        }

        start = System.currentTimeMillis();
        logger.debug("***Getting tab to undelete by tab Id and status");
        /* get the deleted Tab from the tab group */
        Tab tabToUndelete = (Tab) getEntityManager().createQuery("from Tab where id = :TabId and deleted = true")
                .setParameter("TabId", tabId).getSingleResult();
        logger.debug("***Done Getting tab to undelete by tab Id and status (" + (System.currentTimeMillis() - start)
                + "ms");

        if (tabToUndelete == null)
        {
            throw new TabUndeletionException("Failure when trying to get Tab with id=" + tabId, tabId);
        }

        try
        {
            /*
             * re-insert the undeleted tab into the collection
             */
            tabGroup.getTabs().add(tabToUndelete.getTabIndex(), tabToUndelete);

            /* update the status of the undeleted Tab in the database */
            start = System.currentTimeMillis();
            logger.debug("***Update tab status");
            getEntityManager()
                    .createQuery(
                            "update versioned Tab set deleted = false, "
                                    + "dateDeleted = null, tabGroupId = :tabGroupId " + "where id = :TabId")
                    .setParameter("TabId", tabToUndelete.getId()).setParameter("tabGroupId", tabGroup.getId())
                    .executeUpdate();
            logger.debug("***Done Update tab status (" + (System.currentTimeMillis() - start) + "ms)");

            logger.debug("Un-deleted the tab with id=" + tabToUndelete.getId());

            /* update the status of the template of the undeleted Tab */
            start = System.currentTimeMillis();
            logger.debug("***Update tab template status");
            getEntityManager()
                    .createQuery(
                            "update versioned TabTemplate set deleted = false, " + "dateDeleted = null "
                                    + "where id = :TabTemplateId")
                    .setParameter("TabTemplateId", tabToUndelete.getTemplate().getId()).executeUpdate();
            logger.debug("***Done Update tab template status (" + (System.currentTimeMillis() - start) + "ms)");

            logger.debug("Un-deleted the tab template with id=" + tabToUndelete.getTemplate().getId());

            /* update the status of the template's gadgets of the undeleted Tab */
            start = System.currentTimeMillis();
            logger.debug("***Update tab template's gadgets status");
            getEntityManager()
                    .createQuery(
                            "update versioned Gadget set deleted = false, " + "dateDeleted = null "
                                    + "where template.id = :TabTemplateId")
                    .setParameter("TabTemplateId", tabToUndelete.getTemplate().getId()).executeUpdate();
            logger.debug(//
            "***Done Update tab template's gadgets status (" + (System.currentTimeMillis() - start) + "ms)");

            logger.debug("Un-deleted gadgets belonging to tab template with id=" + tabToUndelete.getTemplate().getId());

            // refresh the restored tab to reload previously deleted components
            start = System.currentTimeMillis();
            logger.debug("***entity manager flush");
            // NOTE: DO NOT use entitymanager.refresh! It's far far faster to throw away object and re-query for it.
            // getEntityManager().refresh(tabToUndelete);
            getEntityManager().flush();
            getEntityManager().clear();
            logger.debug("***Done entity manager flush (" + (System.currentTimeMillis() - start) + "ms)");

            start = System.currentTimeMillis();
            logger.debug("***Getting tab to return by tab Id and status");
            /* get the deleted Tab from the tab group */
            tabToUndelete = (Tab) getEntityManager()
                    .createQuery("from Tab t left join fetch t.template where t.id = :tabId and t.deleted = 'false'")
                    .setParameter("tabId", tabId).getSingleResult();
            // Touch the gadgets so that they will be eagerly loaded.
            tabToUndelete.getGadgets().size();
            logger.debug("***Done Getting tab to return by tab Id and status (" + (System.currentTimeMillis() - start)
                    + "ms)");

            return tabToUndelete;
        }
        catch (Exception ex)
        {
            throw new TabUndeletionException("An error occurred while trying to undelete the Tab with TabId=" + tabId,
                    tabId);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.