1 16 17 package org.apache.jetspeed.util; 18 19 import org.apache.jetspeed.om.profile.Portlets; 20 import org.apache.jetspeed.om.profile.Entry; 21 import org.apache.jetspeed.om.profile.Reference; 22 import org.apache.jetspeed.services.idgenerator.JetspeedIdGenerator; 23 24 import org.apache.jetspeed.om.profile.Profile; 26 import org.apache.jetspeed.services.security.PortalResource; 27 import org.apache.jetspeed.om.security.JetspeedUser; 28 import org.apache.jetspeed.services.JetspeedSecurity; 29 30 import org.apache.turbine.util.RunData; 32 33 40 public class PortletUtils 41 { 42 48 public static void regenerateIds(Portlets topPortlets) 49 throws Exception 50 { 51 Portlets[] portlets = topPortlets.getPortletsArray(); 53 for (int i = 0; i < portlets.length; i++) 54 { 55 portlets[i].setId(JetspeedIdGenerator.getNextPeid()); 56 57 Entry[] entries = portlets[i].getEntriesArray(); 58 for (int j = 0; j < entries.length; j++) 59 { 60 entries[j].setId(JetspeedIdGenerator.getNextPeid()); 61 } 62 63 Reference[] refs = portlets[i].getReferenceArray(); 64 for (int k = 0; k < refs.length; k++) 65 { 66 refs[k].setId(JetspeedIdGenerator.getNextPeid()); 67 } 68 69 regenerateIds(portlets[i]); 70 } 71 } 72 73 80 public static boolean canAccessProfile(RunData rundata, Profile profile) 81 { 82 boolean result = true; 83 84 if (profile != null && profile.getRootSet() != null) 85 { 86 PortalResource portalResource = new PortalResource(profile.getRootSet()); 87 String owner = null; 88 if (profile.getUserName() != null) 89 { 90 owner = profile.getUserName(); 91 } 92 portalResource.setOwner(owner); 93 94 result = JetspeedSecurity.checkPermission((JetspeedUser) rundata.getUser(), 95 portalResource, 96 JetspeedSecurity.PERMISSION_CUSTOMIZE); 97 } 98 99 return result; 100 101 } 102 103 } 104 | Popular Tags |