WEB开发网
开发学院数据库DB2 雇员工作空间系列: 配置和开发DB2 Content Manage... 阅读

雇员工作空间系列: 配置和开发DB2 Content Manager 8.2的单点登录portlet

 2010-05-14 15:00:25 来源:WEB开发网   
核心提示:为了使用 TConnect.java 中的新 connect() 方法,还需要修改 TListEntities.java 的 main() 函数,雇员工作空间系列: 配置和开发DB2 Content Manager 8.2的单点登录portlet(4),下面是新的 main() 方法的代码:public static

为了使用 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. --->");
...

上一页  1 2 3 4 5  下一页

Tags:雇员 工作 空间

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接