IBM bluepage API 查询

在IBM 做项目,总是免不了要和 bluepage 打交道。IBM 的BLUEPAGE 是什么? 其实是 Tivoli LDAP. 简称TDS,类似于微软的AD 或者其他OPEN LDAP 等。

这东西主要用来管理 组织架构,人员的信息的。如果在IBM混过的人,用过SAMETIME的都知道,可以直接看到人员的组织架构,其实就是通过bluepage 里的信息得到的。

ibm 为了简单,自己封装了一个JAR包,作为提供给其他系统调用,也就是API.
大家可以搜索下 bpjtk-v ... 后面是版本了,看有没有新版本。一般来说,要IBM内网才可以直接调用,否则要特殊处理。

一个简单的API调用:
程序代码 程序代码

import java.util.Enumeration;
import java.util.Hashtable;

import com.ibm.bluepages.BPResults;
import com.ibm.bluepages.BluePages;

/**
* <code>DumpPerson</code> displays all available information about a person
* specified by CNUM.
*
* <p>Syntax: <code>java com.ibm.bluepages.samples.DumpPerson CNUM [-d]
* [-u APILOCATORURL]</code>
*
* <p>Example: <code>java com.ibm.bluepages.samples.DumpPerson 091445897</code>
* <p>Example: <code>java com.ibm.bluepages.samples.DumpPerson 091445897 -u
* http://bluepages.ibm.com/BpHttpApisv3/apilocator
* <p>Example: <code>java com.ibm.bluepages.samples.DumpPerson 091445897 -d -u  
* http://bluepages.ibm.com/BpHttpApisv3/apilocator
* </code>
*
* @version 3.0 - Created on January 22, 1999.<br /><i>Last updated on January
* 6, 2009.</i>  
*
*/
public class DumpPerson {    
    public static void main(String args[]) {
        /*
         * Declarations.
         */
        BPResults results;          // Results of BluePages method
        Hashtable personRow;        // One row of the person's results
        Hashtable miscRow;          // One row of some other results
        Enumeration keys;           // Keys in hashtable
        Enumeration values;         // Values in hashtable
        String targetCnum;          // CNUM to find
        
        /*
         * Check the arguments.
         */
        if (args.length < 1) {
            System.err.println("Usage: java com.ibm.bluepages.samples.DumpPerson " +
                "CNUM [-u APILOCATORURL] [-d]");
            return;
        }
        
        targetCnum = args[0];
        
        // Check other arguments, if specified.
        for (int i = 1; i < args.length; i++) {
            if (args[i].equalsIgnoreCase("-u")) {
                // If specified, set API locator URL before calling BluePages functions.
                if (++i < args.length) {
                    System.setProperty("bluepages.api.locator", args[i]);
                 }
            } else if (args[i].equalsIgnoreCase("-d")) {
                // Turn on the debug..
                System.setProperty("bluepages.debug", "true");
            }
        }
                        
        long now = System.currentTimeMillis();
        
        /*
         * Call the method to retrieve the data from the persons table.
         */
        results = BluePages.getPersonByCnum(targetCnum);
        
        /*
         * Make sure the method didn't fail unexpectedly.
         */
        if (!results.succeeded()) {
            System.err.println("Error: " + results.getStatusMsg());
            return;
        }
        
        /*
         * Make sure the person is found.
         */
        if (results.rows() == 0) {
            System.err.println("Error: Unable to find person with CNUM " +
                    targetCnum + ".");
            return;
        }
        
        /*
         * Display the person-related information.
         */
        System.out.println("Person Information");
        System.out.println("------------------");
        personRow = results.getRow(0);
        for (keys = personRow.keys(), values = personRow.elements();
                keys.hasMoreElements(); )
            System.out.println((String) keys.nextElement() + ": " +
                    (String) values.nextElement());
        
        /*
         * Call the method to retrieve the data from the departments
         * table.
         */
        miscRow = BluePages.getDeptData((String) personRow.get("DIV"),
                (String) personRow.get("DEPT"));

        /*
         * Display information about the department.
         */
        System.out.println();
        System.out.println("Department Information");
        System.out.println("----------------------");
        
        if (miscRow.size() == 0) {
            System.err.println("Unable to find department information.");
        }
        else {
            for (keys = miscRow.keys(), values = miscRow.elements();
                    keys.hasMoreElements(); )
                System.out.println((String) keys.nextElement() + ": " +
                    (String) values.nextElement());
        }
        
        
        /*
         * Call the method to retrieve the data from the employee types
         * table.
         */
        miscRow = BluePages.getEmployeeCode(
                (String) personRow.get("EMPTYPE"));
        
        /*
         * Display information about the employee type.
         */
        System.out.println();
        System.out.println("Employee Type Information");
        System.out.println("-------------------------");

        if (miscRow.size() == 0) {
            System.err.println("Unable to find employee type information.");
        }
        else {
            for (keys = miscRow.keys(), values = miscRow.elements();
                    keys.hasMoreElements(); )
                System.out.println((String) keys.nextElement() + ": " +
                    (String) values.nextElement());
        }
                
        /*
         * Call the method to retrieve the data from the HR organization codes
         * table.
         */
        miscRow = BluePages.getOrganizationCode(
                (String) personRow.get("ORGCODE"));
        
        /*
         * Display information about the organization code.
         */
        System.out.println();
        System.out.println("Organization Code Information");
        System.out.println("-----------------------------");
        
        if (miscRow.size() == 0) {
            System.err.println("Unable to find organization code information.");
        }
        else {
            for (keys = miscRow.keys(), values = miscRow.elements();
                    keys.hasMoreElements(); )
                System.out.println((String) keys.nextElement() + ": " +
                    (String) values.nextElement());
        }
        
        /*
         * Call the method to retrieve the data from the work locations
         * table.
         */
        miscRow = BluePages.getWorkLocation(
                (String) personRow.get("WORKLOC"));
        
        /*
         * Display information about the work location.
         */
        System.out.println();
        System.out.println("Work Location Information");
        System.out.println("-------------------------");

        if (miscRow.size() == 0) {
            System.err.println("Unable to find work location information.");
        }
        else {
            for (keys = miscRow.keys(), values = miscRow.elements();
                    keys.hasMoreElements(); )
                System.out.println((String) keys.nextElement() + ": " +
                    (String) values.nextElement());
        }
        
        /*
         * Call the method to retrieve the data from the countries table.
         */
        miscRow = BluePages.getCountryCode(
                (String) personRow.get("EMPCC"));
        
        /*
         * Display information about the country.
         */
        System.out.println();
        System.out.println("Country Information");
        System.out.println("-------------------");

        if (miscRow.size() == 0) {
            System.err.println("Unable to find country information.");
        }
        else {
            for (keys = miscRow.keys(), values = miscRow.elements();
                    keys.hasMoreElements(); )
                System.out.println((String) keys.nextElement() + ": " +
                    (String) values.nextElement());
        }
                
        System.out.println("\nElapsed time= " +
            (System.currentTimeMillis() - now) + " ms.");
    }    
}



除非申明,文章均为一号门原创,转载请注明本文地址,谢谢!
[本日志由 轻舞肥羊 于 2012-07-16 02:49 PM 编辑]
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags: ibm bluepage tivoli LDAP
相关日志:
评论: 0 | 引用: 0 | 查看次数: -
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.