Skip Headers
Oracle® Fusion Middleware Integration Guide for Oracle Enterprise Repository
11g Release 1 (11.1.1.7)

Part Number E15754-15
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

31 User API

This chapter provides a use case for the User API that describes how to create, retrieve, update, and deactivate users or query for users.

This chapter includes the following sections:

31.1 Overview

The User Subsystem provides a web services-based mechanism that is used to create, read, update, query, and otherwise manipulate Oracle Enterprise Repository User accounts.

Related Subsystem

For more information, see Chapter 28, "Role API".

Additional Import(s) Required

import com.flashline.registry.openapi.entity.RegistryUser;
import com.flashline.registry.openapi.query.UserCriteria;

31.2 Use Case

This section describes the use cases using the User API. It contains the following topics:

31.2.1 Use Case: Manipulating Users

Description

  • Create a new user.

  • Retrieve an existing user.

  • Update a user.

  • Deactivate a user.

  • Query for users.

Sample Code

Example 31-1 Use Case: Manipulate User

package com.flashline.sample.userapi;
import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.Calendar;
import javax.xml.rpc.ServiceException;
import com.flashline.registry.openapi.base.OpenAPIException;
import com.flashline.registry.openapi.entity.AuthToken;
import com.flashline.registry.openapi.entity.RegistryUser;
import com.flashline.registry.openapi.query.UserCriteria;
import com.flashline.registry.openapi.service.v300.FlashlineRegistry;
import
 com.flashline.registry.openapi.service.v300.FlashlineRegistryServiceLocator;
public class Users {
  public static void main(String pArgs[]) throws OpenAPIException,
 RemoteException,
      ServiceException {
    try {
      ///////////////////////////////////////////////////////////
      // Connect to Oracle Enterprise Repository
      ///////////////////////////////////////////////////////////
      URL lURL = null;
      lURL = new URL(pArgs[0]);
      FlashlineRegistry repository = new FlashlineRegistryServiceLocator()
          .getFlashlineRegistry(lURL);
      // //////////////////////////////
      // Authenticate with OER
      // //////////////////////////////
      AuthToken authToken = repository.authTokenCreate(pArgs[1],
          pArgs[2]);
      // -----------------------------------------
      // Create a new user
      String lUserName = "testUserCreate
_"+Calendar.getInstance().getTimeInMillis();
      String lFirstName = "testUserCreate_FirstName";
      String lLastName = "testUserCreate_LastName";
      String lEmail = lUserName+"@example.com";
      String lPassword = "testUserCreate_Password";
      boolean lMustChangePassword = false;
      boolean lPasswordNeverExpires = false;
      boolean lAssignDefafultRoles = true;
      RegistryUser RbacRegistrySecUser = repository.userCreate(
          authToken, lUserName, lFirstName, lLastName, lEmail, lPassword,
          lMustChangePassword, lPasswordNeverExpires, lAssignDefafultRoles);
      // -----------------------------------------
      // Read a User
      long lId = 50000; // user id must exist in OER
      RegistryUser lUser1 = repository.userRead(authToken,
          lId);
      // -----------------------------------------
      // Update a User
      lUser1.setActiveStatus(10);
      lUser1.setUserName("xxx");
      lUser1.setPhoneNumber("412-521-4914");
      lUser1.setMustChangePassword(true);
      lUser1.setPasswordNeverExpires(false);
      lUser1.setPassword("changed_password");
      lUser1.setEmail("newaddress@bea.com");
      try {
        lUser1 = repository.userUpdate(authToken,
            lUser1);
      } catch (OpenAPIException e) {
        e.printStackTrace();
      }
      // -----------------------------------------
      // Deactivate a User
      RegistryUser lUser2 = null;
      try {
        lUser2 = repository.userDeactivate(authToken, lId);
      } catch (OpenAPIException e) {
        e.printStackTrace();
      }
      // -----------------------------------------
      // Query for Users
      RegistryUser lUsers[] = null;
      UserCriteria lUserCriteria = null;
      lUserCriteria = new UserCriteria();
      lUserCriteria.setNameCriteria("testname");
      lUsers = repository.userQuery(authToken,
          lUserCriteria);
    } catch (OpenAPIException lEx) {
      System.out.println("ServerCode = " + lEx.getServerErrorCode());
      System.out.println("Message    = " + lEx.getMessage());
      System.out.println("StackTrace:");
      lEx.printStackTrace();
    } catch (RemoteException lEx) {
      lEx.printStackTrace();
    } catch (ServiceException lEx) {
      lEx.printStackTrace();
    } catch (MalformedURLException lEx) {
      lEx.printStackTrace();
    }
  }
}