1 package org.apache.jetspeed.modules.parameters; 2 3 18 19 import java.util.Hashtable ; 21 import java.util.Iterator ; 22 import java.util.Map ; 23 24 import org.apache.jetspeed.om.profile.Profile; 26 import org.apache.jetspeed.om.profile.QueryLocator; 27 import org.apache.jetspeed.services.Profiler; 28 import org.apache.jetspeed.services.logging.JetspeedLogFactoryService; 29 import org.apache.jetspeed.services.logging.JetspeedLogger; 30 import org.apache.jetspeed.services.rundata.JetspeedRunData; 31 import org.apache.jetspeed.util.PortletUtils; 32 import org.apache.jetspeed.modules.actions.portlets.PsmlManagerAction; 33 34 import org.apache.turbine.util.RunData; 36 37 import org.apache.velocity.context.Context; 39 40 45 46 public class MyPagesListBox extends VelocityParameterPresentationStyle 47 { 48 49 52 private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(MyPagesListBox.class.getName()); 53 54 63 public void buildContext(RunData rundata, String name, String value, Map parms, Context context) 64 { 65 Map entries = null; 66 67 try 68 { 69 entries = (Map ) rundata.getUser().getTemp(PsmlManagerAction.CACHED_PSML); 70 if (entries == null) 71 { 72 QueryLocator ql = new QueryLocator(QueryLocator.QUERY_USER); 74 75 JetspeedRunData jdata = (JetspeedRunData) rundata; 76 ql.setUser(jdata.getJetspeedUser()); 77 entries = new Hashtable (); 79 Iterator i = Profiler.query(ql); 80 while (i.hasNext()) 81 { 82 Profile profile = (Profile) i.next(); 83 84 String mediaType = profile.getMediaType(); 85 if (mediaType != null && mediaType.equals(jdata.getCapability().getPreferredMediaType())) 86 { 87 if (PortletUtils.canAccessProfile(rundata, profile)) 88 { 89 if (logger.isDebugEnabled()) 90 { 91 logger.debug("MyPagesListBox: refreshing user profile list: " + profile.getPath()); 92 } 93 String title = profile.getName(); 94 if (profile.getRootSet() != null && profile.getRootSet().getTitle() != null) 95 { 96 title = profile.getRootSet().getTitle(); 97 } 98 entries.put(profile, title); 99 } 100 } 101 } 102 103 rundata.getUser().setTemp(PsmlManagerAction.CACHED_PSML, entries); 104 } 105 106 context.put("pages", entries); 107 } 108 catch (Exception e) 109 { 110 logger.error("Exception", e); 111 } 112 113 } 114 115 } | Popular Tags |