1 /* 2 * Copyright 2000-2001,2004 The Apache Software Foundation. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package org.apache.jetspeed.services; 18 19 //jetspeed stuff 20 import org.apache.jetspeed.portal.PortletSet; 21 import org.apache.jetspeed.portal.PortletSkin; 22 import org.apache.jetspeed.portal.PortletControl; 23 import org.apache.jetspeed.portal.PortletController; 24 import org.apache.jetspeed.om.profile.Control; 25 import org.apache.jetspeed.om.profile.Controller; 26 import org.apache.jetspeed.om.profile.Portlets; 27 import org.apache.jetspeed.om.profile.Skin; 28 import org.apache.jetspeed.services.portaltoolkit.PortalToolkitService; 29 import org.apache.turbine.services.TurbineServices; 30 import org.apache.jetspeed.om.SecurityReference; 31 import org.apache.jetspeed.om.profile.Profile; 32 33 /** 34 * Commodity static wrapper around the PortalToolit service 35 * 36 * @author <a HREF="mailto:raphael@apache.org">Raphaël Luta</a> 37 * @version $Id: PortalToolkit.java,v 1.5 2004/02/23 04:00:57 jford Exp $ 38 */ 39 public class PortalToolkit 40 { 41 42 /** 43 * Commodity method for getting a reference to the service 44 * singleton 45 */ 46 private static PortalToolkitService getService() 47 { 48 return (PortalToolkitService)TurbineServices 49 .getInstance() 50 .getService(PortalToolkitService.SERVICE_NAME); 51 } 52 53 /** 54 * Instanciates a PortletControl based on a Registry entry, if available 55 * or directly from a classname. 56 * 57 * @param name a PortletControl name available in the registry or a classname 58 * @return the created PortletControl 59 */ 60 public static PortletControl getControl( String name ) 61 { 62 return getService().getControl(name); 63 } 64 65 /** 66 * Instanciates a PortletControl based on a PSML Control object 67 * 68 * @param control the PSML control object 69 * @return the created PortletControl 70 */ 71 public static PortletControl getControl( Control control ) 72 { 73 return getService().getControl(control); 74 } 75 76 /** 77 * Instanciates a PortletController based on a Registry entry, if available 78 * or directly from a classname. 79 * 80 * @param name a PortletController name available in the registry or a classname 81 * @return the created PortletController 82 */ 83 public static PortletController getController( String name ) 84 { 85 return getService().getController(name); 86 } 87 88 /** 89 * Instanciates a PortletController based on a PSML Controller object 90 * 91 * @param control the PSML controller object 92 * @return the created PortletController 93 */ 94 public static PortletController getController( Controller controller ) 95 { 96 return getService().getController(controller); 97 } 98 99 /** 100 * Create a PortletSkin object based on a Registry entry if available 101 * 102 * @param name the skin name in the Registry 103 * @return the new PortletSkin object 104 */ 105 public static PortletSkin getSkin( String name ) 106 { 107 return getService().getSkin(name); 108 } 109 110 /** 111 * Create a PortletSkin object based on PSML skin description 112 * 113 * @param skin the PSML Skin object 114 * @return the new PortletSkin object 115 */ 116 public static PortletSkin getSkin( Skin skin ) 117 { 118 return getService().getSkin(skin); 119 } 120 121 /** 122 * Creates a PortletSet from a PSML portlets description 123 * 124 * @param portlets the PSML portlet set description 125 * @return a new instance of PortletSet 126 */ 127 public static PortletSet getSet( Portlets portlets ) 128 { 129 return getService().getSet(portlets); 130 } 131 132 /** 133 * Given a locator String path, returns a Portlets collecton 134 * 135 * @param locatorPath ProfileLocator resource path identifier 136 * @return a portlets collection from the PSML resource 137 */ 138 public static Portlets getReference(String locatorPath) 139 { 140 return getService().getReference(locatorPath); 141 } 142 143 /** 144 * Gets default security ref based on the profile type (user|role|group). Returns 145 * null if no default is defined. 146 * 147 * @param profile 148 * @return default security reference 149 */ 150 public static SecurityReference getDefaultSecurityRef(Profile profile) 151 { 152 return getService().getDefaultSecurityRef(profile); 153 } 154 155 /** 156 * Gets default security ref based on the profile type (user|role|group). Returns 157 * null if no default is defined. 158 * 159 * @param type of entity to return default security ref for 160 * @return default security reference 161 */ 162 public static SecurityReference getDefaultSecurityRef(String type) 163 { 164 return getService().getDefaultSecurityRef(type); 165 } 166 167 } 168 169