1 16 package org.apache.cocoon.portal.components.modules.input; 17 18 import java.util.Map ; 19 20 import org.apache.avalon.framework.configuration.Configuration; 21 import org.apache.avalon.framework.configuration.ConfigurationException; 22 import org.apache.avalon.framework.service.ServiceException; 23 import org.apache.cocoon.environment.ObjectModelHelper; 24 import org.apache.cocoon.portal.Constants; 25 import org.apache.cocoon.portal.PortalService; 26 import org.apache.commons.jxpath.JXPathContext; 27 28 60 public class CopletModule 61 extends AbstractModule { 62 63 66 public Object getAttribute(String name, Configuration modeConf, Map objectModel) 67 throws ConfigurationException { 68 PortalService portalService = null; 69 try { 70 71 portalService = (PortalService)this.manager.lookup(PortalService.ROLE); 72 73 String copletId = null; 75 Map context = (Map )objectModel.get(ObjectModelHelper.PARENT_CONTEXT); 76 if (context != null) { 77 copletId = (String )context.get(Constants.COPLET_ID_KEY); 78 } else { 79 copletId = (String )objectModel.get(Constants.COPLET_ID_KEY); 80 } 81 82 if (copletId == null) { 83 return null; 84 } 85 86 if ( name.equals("#") ) { 88 return copletId; 89 } 90 JXPathContext jxpathContext = JXPathContext.newContext(portalService.getComponentManager().getProfileManager().getCopletInstanceData(copletId)); 91 return jxpathContext.getValue(name); 92 } catch (ServiceException e) { 93 throw new ConfigurationException("Unable to lookup portal service.", e); 94 } finally { 95 this.manager.release(portalService); 96 } 97 } 98 99 } 100 | Popular Tags |