Package org.apache.jetspeed.om.page

Examples of org.apache.jetspeed.om.page.Page


     * @param requestContext RequestContext of the current portal request.
     * @return PageActionAccess for the current user request.
     */
    protected PageActionAccess getPageActionAccess(RequestContext requestContext)
    {
        Page page = requestContext.getPage();
        String key = page.getId();
        boolean loggedOn = requestContext.getRequest().getUserPrincipal() != null;
        boolean anonymous = !loggedOn;
        PageActionAccess pageActionAccess = null;

        Map sessionActions = null;
View Full Code Here


                return success;
            }
            resultMap.put(PORTLETID, portletId);
            if (false == checkAccess(requestContext, JetspeedActions.EDIT))
            {
                Page page = requestContext.getPage();
                Fragment fragment = page.getFragmentById(portletId);
                if (fragment == null)
                {
                    success = false;
                    resultMap.put(REASON, "Fragment not found");
                    return success;                   
                }
                int column = fragment.getLayoutColumn();
                int row = fragment.getLayoutRow();
                if (!createNewPageOnEdit(requestContext))
                {               
                    success = false;
                    resultMap.put(REASON, "Insufficient access to edit page");
                    return success;
                }
                status = "refresh";               
                // translate old portlet id to new portlet id
                Fragment newFragment = getFragmentIdFromLocation(row, column, requestContext.getPage());
                if (newFragment == null)
                {
                    success = false;
                    resultMap.put(REASON, "Failed to find new fragment");
                    return success;                   
                }
                portletId = newFragment.getId();
            }
           
            // Use the Portlet Placement Manager to accomplish the removal
            PortletPlacementContext placement = new PortletPlacementContextImpl(requestContext);
            Fragment fragment = placement.getFragmentById(portletId);
            if (fragment == null)
            {
                success = false;
                resultMap.put(REASON, "Fragment not found");
                return success;               
            }
            placement.remove(fragment);
            Page page = placement.syncPageFragments();
            page.removeFragmentById(fragment.getId());
            if (!batch)
            {
                if (pageManager != null)
                    pageManager.updatePage(page);
            }
View Full Code Here

        this.pageManager = pageManager;
    }

    public boolean checkAccess(RequestContext context, String action)
    {
        Page page = context.getPage();
        String path = page.getPath();
        if (path == null)
            return false;
        if (path.indexOf(Folder.ROLE_FOLDER) > -1 || path.indexOf(Folder.GROUP_FOLDER) > -1)
        {
            if (action.equals(JetspeedActions.VIEW))
View Full Code Here

        return true;
    }

    public boolean createNewPageOnEdit(RequestContext context)
    {
        Page page = context.getPage();       
        String path = page.getPath();
        try
        {       
            if (path == null)
                return false;
            // make sure we are not copying from user area
View Full Code Here

        }
    }

    public boolean checkAccess(RequestContext context, String action)
    {
        Page page = context.getPage();
        try
        {
            page.checkAccess(action);           
        }
        catch (Exception e)
        {
            Principal principal = context.getRequest().getUserPrincipal();
            String userName = this.guest;
            if (principal != null)
                userName = principal.getName();
            log.warn("Insufficient access to page " + page.getPath() + " by user " + userName);
            return false;
        }    
        return true;
    }
View Full Code Here

            Fragment currentLayoutFragment = null;
            Fragment moveToLayoutFragment = null;
            // when layoutId is null we use old behavior, ignoring everything to do with multiple layout fragments
            if ( layoutId != null && layoutId.length() > 0 && iMoveType != CARTESIAN )
            {
                Page page = requestContext.getPage();
                currentLayoutFragment = page.getFragmentById( layoutId );
                if ( currentLayoutFragment == null )
                {
                    throw new Exception("layout id not found: " + layoutId );
                }
                else
                {
                    // determine if layoutId parameter refers to the current or the move target layout fragment
                    moveToLayoutFragment = currentLayoutFragment;
                    Iterator layoutChildIter = moveToLayoutFragment.getFragments().iterator();
                    while ( layoutChildIter.hasNext() )
                    {
                        Fragment childFrag = (Fragment)layoutChildIter.next();
                        if ( childFrag != null )
                        {
                            if ( moveFragmentId.equals( childFrag.getId() ) )
                            {
                                moveToLayoutFragment = null;
                                break;
                            }
                        }
                    }
                    if ( moveToLayoutFragment != null )
                    {
                        // figure out the current layout fragment - must know to be able to find the portlet
                        //    fragment by row/col when a new page is created
                        Fragment root = requestContext.getPage().getRootFragment();
                        currentLayoutFragment = getParentFragmentById(moveFragmentId, root);
                    }
                }
                if ( currentLayoutFragment == null )
                {
                    // report error
                    throw new Exception("parent layout id not found for portlet id:" + moveFragmentId );
                }
            }
           
            if (false == checkAccess(requestContext, JetspeedActions.EDIT))
            {
                Page page = requestContext.getPage();
                Fragment fragment = page.getFragmentById(moveFragmentId);
                if (fragment == null)
                {
                    success = false;
                    resultMap.put(REASON, "Fragment not found");
                    return success;
                }
               
                // remember current row/column of porlet fragment
                int column = fragment.getLayoutColumn();
                int row = fragment.getLayoutRow();
               
                // rememeber current row/column of parent layout fragment and move-to layout fragment
                int layoutColumn = -1, layoutRow = -1;
                int moveToLayoutColumn = -1, moveToLayoutRow = -1;
                if ( currentLayoutFragment != null )
                {
                    layoutColumn = currentLayoutFragment.getLayoutColumn();
                    layoutRow = currentLayoutFragment.getLayoutRow();
                    if ( moveToLayoutFragment != null )
                    {
                        moveToLayoutColumn = moveToLayoutFragment.getLayoutColumn();
                        moveToLayoutRow = moveToLayoutFragment.getLayoutRow();
                    }
                }
               
                if (!createNewPageOnEdit(requestContext))
                {
                    success = false;
                    resultMap.put(REASON, "Insufficient access to edit page");
                    return success;
                }
                status = "refresh";
               
                // translate old portlet id to new portlet id
                Fragment newFragment = getFragmentIdFromLocation(row, column, requestContext.getPage());
                if (newFragment == null)
                {
                    success = false;
                    resultMap.put( REASON, "Failed to find new fragment for portlet id: " + moveFragmentId );
                    return success;                   
                }
                moveFragmentId = newFragment.getId();
               
                if ( currentLayoutFragment != null )
                {
                    newFragment = getFragmentIdFromLocation(layoutRow, layoutColumn, requestContext.getPage());
                    if (newFragment == null)
                    {
                        success = false;
                        resultMap.put( REASON, "Failed to find new parent layout fragment id: " + currentLayoutFragment.getId() + " for portlet id: " + moveFragmentId );
                        return success;
                    }
                    currentLayoutFragment = newFragment;
                    if ( moveToLayoutFragment != null )
                    {
                        newFragment = getFragmentIdFromLocation(moveToLayoutRow, moveToLayoutColumn, requestContext.getPage());
                        if (newFragment == null)
                        {
                            success = false;
                            resultMap.put( REASON, "Failed to find new move-to layout fragment id: " + moveToLayoutFragment.getId() + " for portlet id: " + moveFragmentId );
                            return success;
                        }
                        moveToLayoutFragment = newFragment;
                    }
                }
            }
           
            if ( moveToLayoutFragment != null )
            {
                success = moveFragment( requestContext,
                                        pageManager,
                                        batch,
                                        resultMap,
                                        moveFragmentId,
                                        moveToLayoutFragment,
                                        currentLayoutFragment ) ;
            }
            else
            {
                PortletPlacementContext placement = null;
                if ( currentLayoutFragment != null )
                    placement = new PortletPlacementContextImpl(requestContext, currentLayoutFragment, 1);
                else
                {
                    placement = new PortletPlacementContextImpl(requestContext);
                }
                Fragment fragment = placement.getFragmentById(moveFragmentId);
                if (fragment == null)
                {
                    success = false;
                    resultMap.put(REASON, "Failed to find fragment for portlet id: " + moveFragmentId );
                    return success;
                }
                Coordinate returnCoordinate = null;
                float oldX = 0f, oldY = 0f, oldZ = 0f, oldWidth = 0f, oldHeight = 0f;
                float x = -1f, y = -1f, z = -1f, width = -1f, height = -1f;
                boolean absHeightChanged = false;
               
                String posExtended = getActionParameter(requestContext, DESKTOP_EXTENDED);
                if ( posExtended != null )
                {
                    Map fragmentProperties = fragment.getProperties();
                    if ( fragmentProperties == null )
                    {
                        success = false;
                        resultMap.put(REASON, "Failed to acquire fragment properties map for portlet id: " + moveFragmentId );
                        return success;
                    }
                    String oldDeskExt = (String)fragmentProperties.get( DESKTOP_EXTENDED );
                    resultMap.put( OLD_DESKTOP_EXTENDED, ( (oldDeskExt != null) ? oldDeskExt : "" ) );
                    fragmentProperties.put( DESKTOP_EXTENDED, posExtended );
                }
               
                // Only required for moveabs
                if (iMoveType == ABS)
                {
                    Coordinate a_oCoordinate = getCoordinateFromParams(requestContext);
                    returnCoordinate = placement.moveAbsolute(fragment, a_oCoordinate);
                    String sHeight = getActionParameter(requestContext, HEIGHT);
                    if ( sHeight != null && sHeight.length() > 0 )
                    {
                        oldHeight = fragment.getLayoutHeight();
                        height = Float.parseFloat(sHeight);
                        fragment.setLayoutHeight(height);
                        absHeightChanged = true;
                    }
                }
                else if (iMoveType == LEFT)
                {
                    returnCoordinate = placement.moveLeft(fragment);
                }
                else if (iMoveType == RIGHT)
                {
                    returnCoordinate = placement.moveRight(fragment);
                }
                else if (iMoveType == UP)
                {
                    returnCoordinate = placement.moveUp(fragment);
                }
                else if (iMoveType == DOWN)
                {
                    returnCoordinate = placement.moveDown(fragment);
                }
                else if (iMoveType == CARTESIAN)
                {
                    String sx = getActionParameter(requestContext, X);
                    String sy = getActionParameter(requestContext, Y);
                    String sz = getActionParameter(requestContext, Z);
                    String sWidth = getActionParameter(requestContext, WIDTH);
                    String sHeight = getActionParameter(requestContext, HEIGHT);
                    if (sx != null)
                    {
                        oldX = fragment.getLayoutX();
                        x = Float.parseFloat(sx);
                        fragment.setLayoutX(x);
                    }
                    if (sy != null)
                    {
                        oldY = fragment.getLayoutY();                   
                        y = Float.parseFloat(sy);
                        fragment.setLayoutY(y);
                    }               
                    if (sz != null)
                    {
                        oldZ = fragment.getLayoutZ();                   
                        z = Float.parseFloat(sz);
                        fragment.setLayoutZ(z);
                    }               
                    if (sWidth != null)
                    {
                        oldWidth = fragment.getLayoutWidth();                   
                        width = Float.parseFloat(sWidth);
                        fragment.setLayoutWidth(width);
                    }
                    if (sHeight != null)
                    {
                        oldHeight = fragment.getLayoutHeight();                   
                        height = Float.parseFloat(sHeight);
                        fragment.setLayoutHeight(height);
                    }
                }
                // synchronize back to the page layout root fragment
                Page page = placement.syncPageFragments();
           
                if (pageManager != null && !batch)
                {
                    pageManager.updatePage(page);
                }
View Full Code Here

                success = false;
                resultMap.put( REASON, "Failed to find fragment to move to another layout for fragment id: " + moveFragmentId );
                return success;
            }
            placement.remove( placeFragment );
            Page page = placement.syncPageFragments();
            page.removeFragmentById( moveFragmentId );
        }
        if ( placeFragment != null )
        {
            return placeFragment( requestContext,
                                  pageManager,
View Full Code Here

        }
               
        // add fragment
        PortletPlacementContext placement = new PortletPlacementContextImpl( requestContext, placeInLayoutFragment, 1 );
        Coordinate returnCoordinate = placement.add( placeFragment, getCoordinateFromParams( requestContext ) );
        Page page = placement.syncPageFragments();

        placeInLayoutFragment.getFragments().add( placeFragment );
        if ( pageManager != null && ! batch )
        {
            pageManager.updatePage( page );
View Full Code Here

    {
        String layoutDecorationTemplatePath = null;
        boolean layoutDecorationTemplatePathWasAssigned = false;
        try
        {
            Page page = request.getPage();
           
            // enable desktop
            request.setAttribute( JetspeedDesktop.DESKTOP_ENABLED_REQUEST_ATTRIBUTE, Boolean.TRUE );
           
            // get decorations
View Full Code Here

           
            // Run the Decoration valve to get actions
            decorationValve.invoke(requestContext, null);
           
            //String filter = getActionParameter(requestContext, FILTER);           
            Page page = requestContext.getPage();
            String pageName = getActionParameter(requestContext, PAGE);
            if (pageName != null)
            {
                page = retrievePage(requestContext, pageName);
            }
            resultMap.put(STATUS, status);
            resultMap.put(PAGE, page);
           
            Theme theme = (Theme)requestContext.getAttribute(PortalReservedParameters.PAGE_THEME_ATTRIBUTE);
            String pageDecoratorName = null;
            if ( theme != null )
            {
                pageDecoratorName = theme.getPageLayoutDecoration().getName();
            }
            else
            {
                pageDecoratorName = page.getDefaultDecorator( LAYOUT );
            }
            if ( pageDecoratorName != null )
                resultMap.put( DEFAULT_LAYOUT, pageDecoratorName );
                   
            PortalSiteRequestContext siteRequestContext = (PortalSiteRequestContext)requestContext.getAttribute(ProfilerValveImpl.PORTAL_SITE_REQUEST_CONTEXT_ATTR_KEY);
            if (siteRequestContext == null)
            {
                success = false;
                resultMap.put(REASON, "Missing portal site request context from ProfilerValve");
                return success;
            }
           
            resultMap.put(PROFILED_PATH, siteRequestContext.getPage().getPath() )// requestContext.getPath());
            putSecurityInformation(resultMap, page);                       
            String fragments = getActionParameter(requestContext, FRAGMENTS);
            if (fragments == null)
            {
                resultMap.put(FRAGMENTS, "true");
            }
            else
            {
                if (fragments.equalsIgnoreCase("true"))
                {
                    resultMap.put(FRAGMENTS, "true");
                }
                else
                {
                    resultMap.put(FRAGMENTS, "false");
                    return success;
                }
            }
           
            Map fragSizes = new HashMap();
            Map portletIcons = new HashMap();
           
            String singleLayoutId = getActionParameter(requestContext, LAYOUTID);
            if ( singleLayoutId != null )
            {   // build page representation with single layout
                Fragment currentLayoutFragment = page.getFragmentById( singleLayoutId );
                if ( currentLayoutFragment == null )
                {
                    throw new Exception("layout id not found: " + singleLayoutId );
                }
                Fragment currentPortletFragment = null;
               
                String singlePortletId = getActionParameter(requestContext, PORTLETENTITY);
                if ( singlePortletId != null )
                {
                    Iterator layoutChildIter = currentLayoutFragment.getFragments().iterator();
                    while ( layoutChildIter.hasNext() )
                    {
                        Fragment childFrag = (Fragment)layoutChildIter.next();
                        if ( childFrag != null )
                        {
                            if ( singlePortletId.equals( childFrag.getId() ) )
                            {
                                currentPortletFragment = childFrag;
                                break;
                            }
                        }
                    }
                    if ( currentPortletFragment == null )
                    {
                        throw new Exception("portlet id " + singlePortletId + " not found in layout " + singleLayoutId );
                    }
                    resultMap.put( "portletsingleId", currentPortletFragment.getId() );
                }
               
                retrieveFragmentSpecialProperties( requestContext, currentLayoutFragment, fragSizes, portletIcons );
                resultMap.put( "layoutsingle", currentLayoutFragment );
            }
            else
            {
                retrieveFragmentSpecialProperties( requestContext, page.getRootFragment(), fragSizes, portletIcons );
            }
            resultMap.put( SIZES, fragSizes );
            resultMap.put( "portletIcons", portletIcons );
        }
        catch (Exception e)
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.om.page.Page

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.