Welcome and thank you for joining our new OpenText forum. Your questions, responses, best practices, and tips shared with other members will help make this channel vibrant. We're glad you're joining us and look forward to collaborating with you online.

Check out the Getting Started With OpenText Forums for tips on personalizing your experience.

Documentum DFC to check if users exist in the docbase

Currently as part of a tool that has been designed to add users to a role we have been using the following code to add them. However, if it encounters a user that does not exist in the docbase it will stop running there, is there any way to check if the users exist before trying to add them and to then skip over the user that does not exist?

    private static void loadUsers(String userfile,IDfGroup group){
        System.out.println("Connecting.. and loading file," + userfile);
            String userName = null;

            try {
                FileReader fileReader = new FileReader(userfile);

                BufferedReader bufferedReader = new BufferedReader(fileReader);
                while((userName = bufferedReader.readLine()) != null) {
                                            System.out.println(userName);
                        group.addUser(userName);
                            group.save();
                }   

                bufferedReader.close();         
                }

Answers

  • edited February 9, 2018

    Simply Query on dm_user and if you get result then the user exists in doc base else he is not

    String dql = "SELECT * from dm_user where user_name =''";
    IDfQuery query = new DfQuery();
    query.setDQL(dql);
    collection = null;
    String docName = null;
    count = 0;
    try {
    collection = query.execute(session, IDfQuery.DF_READ_QUERY);
    while (collection.next()) {
    count++;
    break;
    }

    if(count>0)
    {
    //Add USER
    }
    else
    {
    //SKIP User
    }

    } finally {

    if (collection != null) {
    collection.close();
    }
    }

    Regards,
    Akshay

Sign In or Register to comment.