在Portal开发中,遇到需要获得用户、用户组信息时,就需要调用PUMA SPI(Portal User Management Architecture System programming interface)了。
PUMA SPI提供获得当前及系统任何用户、组profile的方法,并可对用户和组进行增、删、改。
PUMA SPI主要包括三个接口
PumaProfile:可以获得当前或其他用户、组的属性值(profile)
PumaLocator:可以查询任何用户、组的信息
PumaController:可以新增、修改、删除用户和组的信息
PUMA SPI的调用
PUMA SPI可以在各种Portal应用中调用,不同类型的应用分别调用不同的home接口,包括
标准(JSR168)portlet
com.ibm.portal.um.portletservice.PumaHome
IBM portlet
com.ibm.portal.um.portletservice.legacy.PumaHome
Portal应用(主要是theme和skin)
com.ibm.portal.um.PumaHome
以JSR 168 Portlet中调用为例,调用代码段如下所示,忽略异常处理,有异常就直接向上抛好了,反正这里也处理不了:
PumaHome service;
if ( service == null )
{
InitialContext ctx = new InitialContext(); // 初始化上下文
PortletServceHome psh = ctx.lookup("portletservice/com.ibm.portal.um.portletservice.PumaHome"); // 获得Home接口
service = (PumaHome)psh.getPortletService(PumaHome.class);//获得服务接口
}
PumaLocator locator = service.getLocator(request);//获得PumaLocator 接口
PumaProfile profile = service.getProfile(request);//获得PumaProfile接口
User user = profile.getCurrentUser();//获得当前用户
List groups = locator.findGroupsByPrincipal(user,true);//获得用户所处组
List userGroupNames = new ArrayList();//用于保存用户所处组的名称
List attr = new ArrayList();
attr.add("cn");//用于从Group对象中获得cn属性
Group group = null;
for ( Iterator it = groups.iterator(); it.hasNext() )
{
group = (Group) it.next();
userGroupNames.add(profile.getAttributes(group, attr).get("cn")); // 将Group对象列表中的组名置入一个新的List对象中
}
JavaDoc文档位于PortalServer安装路径的doc目录下.
如/opt/IBM/WebSphere/PortalServer/doc/Javadoc/spi_docs
如果使用RAD开发,IDE可以自动添加依赖的Portal包;如果不使用RAD,则开发时需要手工添加需要依赖的jar包到classpath以便进行编译,打包时则不要把这些jar包添加到war包中。相关jar包可以在/opt/IBM/WebSphere/PortalServer/shared/app目录中找到。在JSR 168的Portlet的开发环境中,需要依赖的包有wp.user.api.jar,wp.pe.api.standard.jar,wp.base.jar
哎,程序员容易吗?别人Happy的时候,我们还在TMD研究这些破技术。。。累了,上网看美女去。。。555
相关推荐
获取IBM WebSphere Portal当前用户组
The dictionary defines a portal as a grand or imposing door or entrance; hence, that picture on the cover. In this book, you will learn why the word portal has become a major buzzword in the world of ...
IBM演示WebSpherePortal教程
6、Portal中调用PUMA SPI管理用户和组信息 51 7、WCM内存溢出的解决方法 53 七、组件及其标签 53 (一)、标签 53 1、jsp组件 53 2、组件关联格式 54 3、IDCmpnt标签 55 4、workflowcmpnt标签 55 5、securitycmpnt...
WebSphere Portal Server 白皮书
websphere portal开发手册
WebspherePortal中的DB2数据库迁移Oracle
IBM WebSphere Portal 由用于构建和管理安全的企业对企业(B2B)、企业对客户(B2C)和企业对雇员(B2E)门户网站的中间件、应用程序(称为 portlet)和开发工具组成。WebSphere Portal 的基本产品提供个性化、web ...
IBM WebSphere Portal 解决方案
ibm websphere portal 学习资料让你对portal 有个入门的了解.写边有一些学习portal 的站点.
台湾友人Elvin分享的WebSphere Portal7入门教程
WebSphere Portal最佳实践.pdf
IBM WebSphere Portal 介绍,IBM门户解决方案,业务状况分析\门户解决方案
WebSphere Portal 集群详细安装文档。 数据仓库项目,做集群环境配置文档,非常详细!
IBM WebSphere Portal 6.0 安装手册,繁体中文
关于在Linux环境安装IBM WebSphere Portal详细描述
详细描述IBM WebSphere Portal 6.1的集群配置,包括迁移数据库,配置LDAP安全性以及配置WebServer
WebSphere Portal 是一个框架——包括运行时服务器、服务、工具和许多其他特性——您可以使用这些特性将企业集成到单个称为门户 的可自定义界面中。企业门户将各种来源的组件、应用程序、流程和内容组合到统一的表示...
中文版的Websphere Portal开发格式PDF格式
IBM演示-WebSpherePortal教程: