Package org.apache.jetspeed.om.profile

Examples of org.apache.jetspeed.om.profile.Portlets


        super.buildCustomizeContext(controller, context, rundata);

        JetspeedRunData jdata = (JetspeedRunData)rundata;
        PortletSet set = (PortletSet)jdata.getCustomized();

        Portlets portlets = jdata.getCustomizedProfile()
                                 .getDocument()
                                 .getPortletsById(set.getID());

        List plist = new ArrayList();
        List work = new ArrayList();
        List filler = Collections.nCopies(portlets.getPortletsCount()+portlets.getEntryCount(),null);
        plist.addAll(filler);

        for (int i=0; i < portlets.getPortletsCount(); i++)
        {
            Portlets p = portlets.getPortlets(i);
            if (logger.isDebugEnabled())
            {
                logger.debug("RowColumnControllerAction: processing portlet: " + p.getTitle());
            }
            Layout layout = p.getLayout();
            if (layout == null)
            {
                // Pane should always have a layout with correct position
                if (logger.isDebugEnabled())
                {
                    logger.debug("RowColumnControllerAction: no layout, creating a new one");
                }
                layout = new PsmlLayout();
                layout.setPosition(i);
                p.setLayout(layout);
            }
            if (layout!=null)
            {
                try
                {
                    int pos = (int)layout.getPosition();
                    if (logger.isDebugEnabled())
                    {
                        logger.debug("RowColumnControllerAction: layout has position: " + pos);
                    }
                    if (pos >= 0 && pos < plist.size())
                    {
                        plist.set(pos,p);
                    }
                    else
                    {
                        work.add(p);
                    }
                }
                catch (Exception e)
                {
                    logger.error("Layout error", e);
                    layout.setPosition(-1);
                    work.add(p);
                }
            }
            else
            {
                work.add(p);
            }
        }

        for (int i=0; i < portlets.getEntryCount(); i++)
        {
            Entry p = portlets.getEntry(i);
            Layout layout = p.getLayout();
            if (layout!=null)
            {
                try
                {
                    int pos = (int)layout.getPosition();
                    if (pos>=0)
                    {
                        plist.set(pos,p);
                    }
                    else
                    {
                        work.add(p);
                    }
                }
                catch (Exception e)
                {
                    layout.setPosition(-1);
                    work.add(p);
                }
            }
            else
            {
                work.add(p);
            }
        }

        Iterator i = work.iterator();
        for(int idx=0;idx < plist.size(); idx++)
        {
            if (plist.get(idx)==null)
            {
                if (i.hasNext())
                {
                    plist.set(idx,i.next());
                }
                else
                {
                    plist.remove(idx);
                }
            }
        }

        Map titles = new HashMap();
        i = plist.iterator();
        while(i.hasNext())
        {
            Object obj = i.next();

            if (obj instanceof Portlets)
            {
                Portlets entry = (Portlets)obj;
                if ((entry.getMetaInfo()!=null)&&(entry.getMetaInfo().getTitle()!=null))
                {
                    titles.put(entry.getId(),entry.getMetaInfo().getTitle());
                }
            }
            else
            {
                Entry entry = (Entry)obj;
                if ((entry.getMetaInfo()!=null)&&(entry.getMetaInfo().getTitle()!=null))
                {
           titles.put(entry.getId(), entry.getMetaInfo().getTitle());
                }
                else
                {
                    RegistryEntry pentry = Registry.getEntry(Registry.PORTLET,entry.getParent());

                    if (pentry!=null)
                    {
            titles.put(entry.getId(), pentry.getTitle());
                    }
                }
            }
        }
View Full Code Here


        if (customizedSet == null) return;

        if (position > -1)
        {
            Portlets set = profile.getDocument()
                                  .getPortletsById(customizedSet.getID());
            if (set != null)
            {
                // first try explicit portlets position
                for(int i=0; i < set.getPortletsCount(); i++)
                {
                    Portlets p = set.getPortlets(i);
                    Layout layout = p.getLayout();
//
//                    if (layout == null)
//                    {
//                      Layout nl = new Layout ();
//                      nl.setPosition (String.valueOf(i));
//
//                    }
                    if ((layout!=null) && (layout.getPosition() != -1))
                    {

                        int lpos = (int)layout.getPosition();
                        if (lpos==position)
                        {
                            set.removePortlets(i);

                            updateLayoutPositions(set);

                            // MODIFIED: Save changes for wml profiles
                            //if (isWML)
                            //  doSave(data, null);

                            return;
                        }
                    }
                }

                // try explicit entry position
                for(int i=0; i < set.getEntryCount(); i++)
                {
                    Entry p = set.getEntry(i);
                    Layout layout = p.getLayout();

                    if ((layout!=null) && (layout.getPosition() != -1))
                    {
                        int lpos = (int)layout.getPosition();
View Full Code Here

    {
        // Load the panes into a list
        List list = new ArrayList();
        for(int i = 0; i < set.getPortletsCount(); i++)
        {
            Portlets pane = set.getPortlets(i);
            list.add(pane);
        }

        // Sort list using the current layout position
        Collections.sort(list,
                         new Comparator()
                         {
                             public int compare(Object pane1, Object pane2)
                             {
                                 Long pos1 = new Long(((Portlets) pane1).getLayout().getPosition());
                                 Long pos2 = new Long(((Portlets) pane2).getLayout().getPosition());
                                 return pos1.compareTo(pos2);
                             }
                         });

        // Update the layout position based on the physical order within the sorted list
        int position = 0;
        for (Iterator iter = list.iterator(); iter.hasNext();)
        {
            Portlets pane = (Portlets) iter.next();
            Layout layout = pane.getLayout();
            layout.setPosition(position++);
        }
    }
View Full Code Here

        if (position > -1)
        {
            int target = -1;

            Portlets set = profile.getDocument()
                                  .getPortletsById(customizedSet.getID());
            Layout targetLayout = null;
            Layout baseLayout = null;

            if (set != null)
            {
                // check if we can possibly move as requested and calculate
                // target position
                if ( moveUp )
                {
                    if ( (position >= set.getPortletsCount())
                         && (position >= set.getEntryCount()) ) return;
                    target = position + 1;
                }
                else
                {
                    if (position ==0) return;
                    target = position - 1;
                }

                // first find objects at explicit portlets position
                for(int i=0; i < set.getPortletsCount(); i++)
                {
                    if ((targetLayout!=null) && (baseLayout!=null)) break;

                    Portlets p = set.getPortlets(i);
                    Layout layout = p.getLayout();
                    if ((layout!=null)&&(layout.getPosition()!=-1))
                    {
                        int lpos = (int)layout.getPosition();
                        if ((baseLayout == null) && (lpos==position))
                        {
                            baseLayout = layout;
                        }

                        if ((targetLayout == null) && (lpos==target))
                        {
                            targetLayout = layout;
                        }
                    }
                }

                // try explicit entry position
                for(int i=0; i < set.getEntryCount(); i++)
                {
                    if ((targetLayout!=null) && (baseLayout!=null)) break;

                    Entry p = set.getEntry(i);
                    Layout layout = p.getLayout();
                    if ((layout!=null)&&(layout.getPosition()!=-1))
                    {
                        int lpos = (int)layout.getPosition();
                        if ((baseLayout == null) && (lpos==position))
                        {
                            baseLayout = layout;
                        }

                        if ((targetLayout == null) && (lpos==target))
                        {
                            targetLayout = layout;
                        }
                    }
                }

                //else use implicit position
                if (baseLayout == null)
                {
                    if (position < set.getPortletsCount())
                    {
                        Portlets p = set.getPortlets(position);
                        if (p.getLayout()==null)
                        {
                            p.setLayout(new PsmlLayout());
                        }
                        baseLayout=p.getLayout();
                    }

                    if (position < set.getEntryCount())
                    {
                        Entry p = set.getEntry(position);
                        if (p.getLayout()==null)
                        {
                            p.setLayout(new PsmlLayout());
                        }
                        baseLayout=p.getLayout();
                    }
                }

                if (targetLayout == null)
                {
                    if (target < set.getPortletsCount())
                    {
                        Portlets p = set.getPortlets(target);
                        if (p.getLayout()==null)
                        {
                            p.setLayout(new PsmlLayout());
                        }
                        targetLayout=p.getLayout();
                    }

                    if (target < set.getEntryCount())
                    {
                        Entry p = set.getEntry(target);
                        if (p.getLayout()==null)
                        {
                            p.setLayout(new PsmlLayout());
                        }
                        targetLayout=p.getLayout();
                    }
                }

                //we should now have found both baseLayout and targetLayout, swap
                //their positions using explicit positioning
View Full Code Here

     * @see PortalPersistenceService#getInstances(Portlet, Profile)
     */
    public List getInstances( Profile profile) throws PortletException
    {
        PSMLDocument doc = profile.getDocument();
        Portlets portlets =  doc.getPortlets();
        ArrayList pList = new ArrayList();
      
       buildAllEntries(portlets, pList, profile);
       
        return pList;
View Full Code Here

        if(portlets.getPortletsCount() > 0)
        {
            Iterator pItr = portlets.getPortletsIterator();
            while(pItr.hasNext())
            {
                Portlets childPortlets = (Portlets)pItr.next();
                buildAllEntries(childPortlets, entries, profile);
            }
           
            return;
        }
View Full Code Here

   
    public PSMLDocument getDocumentFromPath(String psmlFile)
    {
        print("Loading portlets from PSML file "+psmlFile);
     
        Portlets rootset = null;
           
        PSMLDocument doc = PsmlManager.getDocument(psmlFile);       
        rootset = doc.getPortlets();
       
         return doc;
View Full Code Here

        Mapping mapping = null;
        String mapFile = getProfileMappingFileName();
        print("Locating PSML file "+mapFile+"...");
        File map = new File(mapFile);
        print("PSML file exists????: "+map.exists());
        Portlets rootset = null;
        FileReader reader = null;
        if (map.exists() && map.isFile() && map.canRead())
        {
               
                try
View Full Code Here

            if (doc == null)
            {
                return null;
            }
            Portlets portlets = doc.getPortlets();
            PortletSet ps = PortalToolkit.getSet(portlets);
            return ps.getContent(rundata);
        }
        catch (Exception e)
        {
View Full Code Here

            if(baseProfile != null)
            {
                PSMLDocument doc = baseProfile.getDocument();
                if(doc != null)
                {
                    Portlets portlets = doc.getPortlets();
                   
                    Portlets clonedPortlets = (Portlets) SerializationUtils.clone(portlets);
                    org.apache.jetspeed.util.PortletUtils.regenerateIds(clonedPortlets);
                    profile = Profiler.createProfile(locator, clonedPortlets);
                }
                else
                {
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.om.profile.Portlets

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.