1 16 package org.apache.cocoon.portal.coplets.basket; 17 18 import java.util.Map ; 19 20 import org.apache.cocoon.environment.ObjectModelHelper; 21 import org.apache.cocoon.environment.Request; 22 import org.apache.cocoon.environment.Session; 23 import org.apache.cocoon.portal.PortalService; 24 import org.apache.cocoon.portal.coplet.CopletInstanceData; 25 import org.apache.cocoon.portal.profile.ProfileManager; 26 27 32 public class UserConfiguration { 33 34 35 public static final String ATTR_NAME = "basket-config"; 36 37 protected boolean basketEnabled = true; 38 protected boolean briefcaseEnabled = false; 39 protected boolean folderEnabled = false; 40 41 44 public static UserConfiguration get(Map objectModel, 45 PortalService service) { 46 final Request req = ObjectModelHelper.getRequest(objectModel); 47 final Session session = req.getSession(); 48 UserConfiguration uc = (UserConfiguration)session.getAttribute(ATTR_NAME); 49 if ( uc == null ) { 50 final ProfileManager pm = service.getComponentManager().getProfileManager(); 51 final CopletInstanceData cid = pm.getCopletInstanceData("basket"); 52 if ( cid != null ) { 53 uc = new UserConfiguration(cid.getAttributes()); 54 session.setAttribute(ATTR_NAME, uc); 55 } 56 } 57 return uc; 58 } 59 60 64 public UserConfiguration(Map attributes) { 65 final String enabledKinds = (String )attributes.get("basket:enabled-storages"); 66 if ( enabledKinds != null ) { 67 this.basketEnabled = (enabledKinds.indexOf("basket") != -1); 68 this.briefcaseEnabled = (enabledKinds.indexOf("briefcase") != -1); 69 this.folderEnabled = (enabledKinds.indexOf("folder") != -1); 70 } 71 } 72 73 public boolean isBasketEnabled() { 74 return this.basketEnabled; 75 } 76 77 public boolean isBriefcaseEnabled() { 78 return this.briefcaseEnabled; 79 } 80 81 public boolean isFolderEnabled() { 82 return this.folderEnabled; 83 } 84 } 85 | Popular Tags |