雇员工作空间系列: 配置和开发DB2 Content Manager 8.2的单点登录portlet
2010-05-14 15:00:25 来源:WEB开发网为了使用 TConnect.java 中的新 connect() 方法,还需要修改 TListEntities.java 的 main() 函数。下面是新的 main() 方法的代码:
public static void main(String[] args) throws Exception {
if (args.length < 3) {
System.out.println(
"Displays details on types of entities defined on the server. n"
+ "Syntax: n"
+ " java TListEntities <dstype> <server> <ltpaToken> [<entity>] n"
+ "where: n"
+ " <dstype> is the type of server (Fed, ICM, DL, OD, DB2) n"
+ " <server> is the name of the server or database. This can be n"
+ " followed by a connect string in parenthesis. n"
+ " <ltpaToken> is the ltpaToken n"
+ " <entity> optional, the name of a particular entity. Detailed n"
+ " information will be displayed about the entity. n"
+ "Examples: n"
+ " java TListEntities ICM icmnlsdb ltpaToken n"
+ " java TListEntities ICM icmnlsdb ltpaToken 'Document (for Document data model)' n"
+ " java TListEntities DL libsrvrn ltpaToken n"
+ " java TListEntities Fed cmbdb ltpaToken n"
+ " java TListEntities DB2 sample ltpaToken emp_photo n"
+ " java TListEntities OD odserver ltpaToekn n"
+ "where single quotes are used around entity and attribute names that contain spaces");
System.exit(0);
}
String dstype = args[0];
String server = args[1];
String ltpaToken = args[2];
String entity = null;
int nextArg = 4;
if (nextArg < args.length && args[nextArg] != null) {
if (args[nextArg].startsWith("'"))
{
String arg = args[nextArg];
while (nextArg <args.length && !arg.endsWith("'"))
{
nextArg++;
arg += " "+args[nextArg];
}
entity = arg.substring(1,arg.length()-1);
}
else
entity = args[nextArg];
}
CMBConnection connection = new CMBConnection();
CMBSchemaManagement schemaManagement = connection.getSchemaManagement();
schemaManagement.setChildComponentsAsAttributes(childComponentsAsAttributes);
TConnect.connect(connection, dstype, server, ltpaToken);
if (entity == null) {
listEntities(schemaManagement);
} else {
printEntityDetails(schemaManagement.getEntity(entity), 1, true);
}
TConnect.disconnect(connection);
}
为了调用 TListEntities.java 的新 main() 方法,需要修改 CMSSOPortlet.java 的 actionPerformed() 方法。首先,获取 LTPA 令牌。然后将它传递给 main() 函数。LTPA 令牌是一个 cookie,可以从 PortletRequest Java 对象中检索它。下面是用来检索 LTPA 令牌和调用 TListEntities.main() 的代码:
...
Cookie[] cookies = request.getCookies();
String LtpaToken = null;
if (cookies != null && cookies.length > 0) {
for (int i = 0; i < cookies.length; i++) {
if (cookies[i].getName().equalsIgnoreCase("LtpaToken")) {
LtpaToken = cookies[i].getValue();
}
}
}
String [] args ={"ICM","ICMNLSDB",""};
args[2] = LtpaToken;
try {
TListEntities.main(args);
} catch (Exception e) {
e.printStackTrace(System.out);
}
System.out.println("<------ Submit button pressed. --->");
...
- ››工作中的C++:基本原理,重点推荐和结束语
- ››工作流编程循序渐进(5:状态机工作流)
- ››工作流编程循序渐进(1:代码活动与时间延迟活动)...
- ››工作流编程循序渐进(2:IfElseActivity活动)
- ››工作流编程循序渐进(3:While活动)
- ››工作流编程循序渐进(4:InvokeWorkflowActivity活...
- ››工作组环境下WPAD部署的另类解决--WINS解析
- ››空间商限制功能阻止SEO优化
- ››雇员工作空间系列: 配置和开发DB2 Content Manage...
- ››工作负载分区(WPAR)中的资源控制
- ››工作娱乐两不误 听歌就用E音乐盒
- ››工作中常用的高效的CSS代码
更多精彩
赞助商链接