wt.org
Class OrganizationServicesMigrationHelper

java.lang.Object
  extended bywt.org.OrganizationServicesMigrationHelper

public final class OrganizationServicesMigrationHelper
extends Object

Provides utility methods for working with principals that do not require the method server to be running


Field Summary
static String ADMIN_GROUP
           
static String ADMIN_GROUP_SERVICE
           
static String[] ADMIN_NAMES
           
static String DEFAULT_DIRECTORY_USER
           
private static String RESOURCE
           
 
Constructor Summary
OrganizationServicesMigrationHelper()
           
 
Method Summary
static String createPrincipal(String name, String service, Class principal_class, Map attributes)
          Creates a principal with the given name in the given service
static String escapeRemoteObjectID(String dn)
          This method is copied directly from StandardOrganizationServicesManager._normalize().
static String getByInternetDomain(String internet_domain, String service)
          Get the dn of the organization with the given internet domain
static String getDNForPrincipal(String name, String service, Class principal_class)
          Searches for a principal with the given name in the given service
static String getInternetDomain(String org_dn, String service)
          Get the internet domain of an organization
private static String getObjectClass(Class principal_class, String service)
          Gets the object class for the principal subclass in the given service
static String getOrganizationName(String user_dn, String service)
          Queries ldap to determine what the organization name attribute is for the user with the given dn
static Map getServices(DirectiveServices ds)
          Creates a mapping of service names by querying the repository table for lastknowndomain and ida2a2.
private static String getUniqueIDAttribute(Class principal_class, String service)
          Gets the unique id attribute for the principal subclass in the given service
private static void safeClose(ResultSet rs)
          If the Statement is not null, try to close it, catching and smothering any SQLException that results.
private static void safeClose(Statement stmt)
          If the Statement is not null, try to close it, catching and smothering any SQLException that results.
static void setInternetDomain(String dn, String service, String internet_domain)
          Assigns the organization with the given dn a new internet domain
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE

DEFAULT_DIRECTORY_USER

public static final String DEFAULT_DIRECTORY_USER

ADMIN_NAMES

public static final String[] ADMIN_NAMES

ADMIN_GROUP

public static final String ADMIN_GROUP

ADMIN_GROUP_SERVICE

public static final String ADMIN_GROUP_SERVICE
Constructor Detail

OrganizationServicesMigrationHelper

public OrganizationServicesMigrationHelper()
Method Detail

createPrincipal

public static String createPrincipal(String name,
                                     String service,
                                     Class principal_class,
                                     Map attributes)
                              throws Exception
Creates a principal with the given name in the given service

Parameters:
name - The name of the principal to create
service - The name of the service to create the principal in
principal_class - The class of princpal to search for
attributes - An optional map of attributes to add to the principal. The attribute names should already be translated using DirContext.getMapping(String,String)
Returns:
The dn of the new principal
Throws:
WTException - If principal_class isn't user, group, or organization.
Exception

getInternetDomain

public static String getInternetDomain(String org_dn,
                                       String service)
                                throws Exception
Get the internet domain of an organization

Parameters:
org_dn - The dn of the organization to search for
service - The organization's service
Returns:
The organization's internet domain, or null if it doesn't have one.
Throws:
WTException - If no organization can be found with the given dn
Exception

getByInternetDomain

public static String getByInternetDomain(String internet_domain,
                                         String service)
                                  throws Exception
Get the dn of the organization with the given internet domain

Parameters:
internet_domain - The dn of the organization to search for
service - The service to look in
Returns:
The organization's dn, or null if there is no matching organization.
Throws:
Exception

setInternetDomain

public static void setInternetDomain(String dn,
                                     String service,
                                     String internet_domain)
                              throws Exception
Assigns the organization with the given dn a new internet domain

Parameters:
dn - The dn of the organization to modify
service - The organization's service
internet_domain - The new internet domain for the organization A value of null deletes the attribute
Throws:
Exception

getDNForPrincipal

public static String getDNForPrincipal(String name,
                                       String service,
                                       Class principal_class)
                                throws Exception
Searches for a principal with the given name in the given service

Parameters:
name - The name of the principal to search for
service - The name of the service to look in
principal_class - The class of princpal to search for
Returns:
The dn of the principal, or null if it wasn't found.
Throws:
WTException - If principal_class isn't user, group, or organization.
Exception

getOrganizationName

public static String getOrganizationName(String user_dn,
                                         String service)
                                  throws Exception
Queries ldap to determine what the organization name attribute is for the user with the given dn

Parameters:
user_dn - The dn of the user to find an organization attribute for
service - The name of the service to look in
Returns:
The value of the user's organization name attribute, or null if they don't have one.
Throws:
WTException - If the user can't be found
Exception

escapeRemoteObjectID

public static String escapeRemoteObjectID(String dn)
This method is copied directly from StandardOrganizationServicesManager._normalize(). It is used to create a normalized form of a dn, for use in the RemoteObjectInfo table.

Parameters:
dn - The dn to normalize
Returns:
The normalized dn

getObjectClass

private static final String getObjectClass(Class principal_class,
                                           String service)
                                    throws Exception
Gets the object class for the principal subclass in the given service

Parameters:
principal_class - A class that is assignable from WTPrincipal
service - The name of the service
Returns:
The objectClass attribute for the class
Throws:
WTException - If the principal class isn't user, group, or organization
Exception

getUniqueIDAttribute

private static final String getUniqueIDAttribute(Class principal_class,
                                                 String service)
                                          throws Exception
Gets the unique id attribute for the principal subclass in the given service

Parameters:
principal_class - A class that is assignable from WTPrincipal
service - The name of the service
Returns:
The uniqueIdAttribute attribute for the class
Throws:
WTException - If the principal class isn't user, group, or organization
Exception

getServices

public static final Map getServices(DirectiveServices ds)
                             throws Exception
Creates a mapping of service names by querying the repository table for lastknowndomain and ida2a2.

Returns:
A mapping of service names to Long versions of repository oids
Throws:
Exception

safeClose

private static void safeClose(Statement stmt)
If the Statement is not null, try to close it, catching and smothering any SQLException that results.

Parameters:
stmt - The Statement to close

safeClose

private static void safeClose(ResultSet rs)
If the Statement is not null, try to close it, catching and smothering any SQLException that results.

Parameters:
rs - The ResultSet to close