Package org.eurekastreams.server.domain

Examples of org.eurekastreams.server.domain.Tab


     */
    @Test
    public void testAddTabSetsTabIndexToLast()
    {
        TabGroup tabGroup = jpaTabGroupMapper.findById(fordsStartPageId);
        Tab tab = new Tab("FooBar", Layout.THREECOLUMN);

        tabGroup.getTabs().add(tab);

        jpaTabGroupMapper.flush();
        jpaTabGroupMapper.clear();

        int expectedIndex = tabGroup.getTabs().size() - 1;
        long tabId = tab.getId();

        tab = jpaTabMapper.findById(tabId);

        assertEquals("Expected tabIndex to be tabs.size()-1 when adding a tab to a tabGroup, after flush()",
                expectedIndex, tab.getTabIndex());
    }
View Full Code Here


     */
    @Test
    public void testPerformSecurityCheck()
    {
        final long tabId = TAB_ID;
        final Tab tab = context.mock(Tab.class);

        context.checking(new Expectations()
        {
            {
                oneOf(tabMapper).findTabByGadgetId(GADGET_ID);
View Full Code Here

     */
    @Test(expected = AuthorizationException.class)
    public void testPerformSecurityCheckFailWithExecption()
    {
        final long tabId = TAB_ID;
        final Tab tab = context.mock(Tab.class);

        context.checking(new Expectations()
        {
            {
                oneOf(tabMapper).findTabByGadgetId(GADGET_ID);
View Full Code Here

    {
        AddGadgetRequest request = (AddGadgetRequest) inActionContext.getParams();
        Long tabId = request.getTabId();
        String gadgetDefUrl = request.getGadgetDefinitionUrl();
        Person owner = personMapper.findByAccountId(inActionContext.getPrincipal().getAccountId());
        Tab tab = owner.getTabs(TabGroupType.START).get(0);

        if (null != tabId)
        {
            tab = tabMapper.findById(tabId);
        }

        try
        {
            GadgetDefinition gadgetDef;

            // UUID identified by starting with { and ending with }
            if (gadgetDefUrl.startsWith("{") && gadgetDefUrl.substring(gadgetDefUrl.length() - 1).equals("}"))
            {
                // gadget def is identified by a UUID
                gadgetDef = gadgetDefinitionMapper.findByUUID(gadgetDefUrl.substring(1, gadgetDefUrl.length() - 1));
            }
            else
            {
                // gadget def is identified by a URL.
                gadgetDef = gadgetDefinitionMapper.findByUrl(gadgetDefUrl);
            }

            /*
             * If gadgetDef is not found, throw an exception, something went wrong, most likely a bad UUID or URL.
             */
            if (null == gadgetDef)
            {
                throw new ExecutionException("Unable to instantiate gadgetDef.");
            }

            // increment the indexes of any gadgets in that zone
            shiftGadget(tab.getGadgets());

            // get the owner

            // create the new gadget at the top of the last zone
            Gadget gadget = new Gadget(gadgetDef, 0, 0, owner, request.getUserPrefs() == null ? "" : request
                    .getUserPrefs());

            // insert the new gadget - room has been made for it
            tab.getGadgets().add(gadget);

            // commit our operations
            tabMapper.flush();

            deleteKeysMapper.execute(Collections.singleton(CacheKeys.PERSON_PAGE_PROPERTIES_BY_ID + owner.getId()));
View Full Code Here

     */
    public final Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException
    {
        String tabName = (String) inActionContext.getParams();

        Tab tab = new Tab(tabName, Layout.THREECOLUMN);

        Person person = personMapper.findByAccountId(inActionContext.getPrincipal().getAccountId());

        person.addTab(tab, TabGroupType.START);

        // because the caller relies on tabIndex being set properly, we have to
        // flush, then clear the entity manager so we can reget the updated
        // Tab's new tabIndex
        personMapper.flush();
        personMapper.clear();

        deleteKeysMapper.execute(Collections.singleton(CacheKeys.PERSON_PAGE_PROPERTIES_BY_ID + person.getId()));

        if (log.isDebugEnabled())
        {
            log.debug("Saved tab for " + person.getDisplayName());
        }

        return tabMapper.findById(tab.getId());
    }
View Full Code Here

    public Tab findById(final Long tabId)
    {
        Query q = entityManager.createQuery(
                "from Tab t left join fetch t.template where t.id = :tabId and t.deleted = 'false'").setParameter(
                "tabId", tabId);
        Tab tab = (Tab) q.getSingleResult();

        // Touch the gadgets so that they will be eagerly loaded.
        tab.getGadgets().size();

        return tab;
    }
View Full Code Here

    {
        Query q = entityManager.createQuery(
                "SELECT t FROM Tab t, Gadget g " + "WHERE g.id = :gadgetId " + "AND g.template.id = t.template.id")
                .setParameter("gadgetId", gadgetId);

        Tab tab = (Tab) q.getSingleResult();

        // Touch the gadgets so that they will be eagerly loaded.
        tab.getGadgets().size();

        return tab;
    }
View Full Code Here

    @Override
    public void authorize(final PrincipalActionContext inActionContext) throws AuthorizationException
    {
        Long gadgetId = (Long) inActionContext.getParams();

        Tab tab = tabMapper.findTabByGadgetId(gadgetId);

        // This will throw AuthorizationException if user doesn't have permissions.
        if (!tabPermission.canModifyGadgets(inActionContext.getPrincipal().getAccountId(), tab.getId(), true))
        {
            throw new AuthorizationException("Failed to authorize deleting of the supplied gadget.");
        }
    }
View Full Code Here

        Integer targetZoneNumber = request.getTargetZoneNumber();
        Integer targetZoneIndex = request.getTargetZoneIndex();

        TabTemplate sourceTemplate = tabMapper.findByGadgetId(gadgetId);

        Tab destinationTab = tabMapper.findById(targetTabId);

        // Ensure that the destination tab exists.
        if (destinationTab == null)
        {
            vex.addError("invalidTab", "Destination zone does not exist.");
            throw vex;
        }

        TabTemplate destinationTemplate = destinationTab.getTemplate();
        Layout destinationLayout = destinationTemplate.getTabLayout();

        // Save the Source and Destination TabTemplate to state so they can be reused in execution.
        inActionContext.getState().put("destinationTemplate", destinationTemplate);
        inActionContext.getState().put("sourceTemplate", sourceTemplate);
View Full Code Here

        try
        {
            Long tabId = (Long) inActionContext.getParams();

            // will throw NoResultException if no tab by that ID
            Tab tab = tabMapper.findById(tabId);

            tabGroupMapper.deleteTab(tab);

            deleteKeysMapper.execute(Collections.singleton(CacheKeys.PERSON_PAGE_PROPERTIES_BY_ID
                    + inActionContext.getPrincipal().getId()));
View Full Code Here

TOP

Related Classes of org.eurekastreams.server.domain.Tab

Copyright © 2018 www.massapicom. 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.