Sample Code
Writing a Custom Delegate
A custom delegate would implement the PrincipaMatchDelegate and override the match(…) API to provide some custom logic. The following example shows the logic for finding a match by user name:
public WTPrincipal match(WTPrincipal querySpec) throws WTException {

if (querySpec == null || !(querySpec instanceof WTUser)) {
if (logger.isDebugEnabled()) logger.debug("Input principal is null");
return null;
}

// Clone right away to avoid auto-inflate when calling getters
WTUser querySpecClone = (WTUser) querySpec.cloneAsInflated();

String userName = ((WTUser) querySpecClone).getName();
if (userName == null || userName.trim().isEmpty()) return null;

WTPrincipal result = null;
String userNames[] = new String[] { userName };

result = OrganizationServicesHelper.manager.findPersistedUser
userNames, null /* email */, null /* fullName */, null /* surname
*/, null /* status */, null /* internal */, Boolean.FALSE /* disabled */);

return result;
}
Examples of Usage in Windchill Code
<Windchill>\codebase\service.properties
<Windchill>\codebase\wt\org\delegate\PrincipalMatchDelegate.class
<Windchill>\codebase\wt\org\delegate\ImportedUserByUserNameMatchDelegate.class
<Windchill>\codebase\wt\org\delegate\ImportedUserByEmailIdMatchDelegate.class
<Windchill>\\codebase\wt\org\delegate\ImportedUserByUserNameMatchDelegate.class
<Windchill>\codebase\wt\org\delegate\ReplicatedUserForActivationByUserNameMatchDelegate.class
<Windchill>\codebase\wt\org\delegate\ReplicatedUserForActivationByEmailIdMatchDelegate.class
Packaged Samples
<Windchill>\prog_examples\principal\principalmatchdelegate\ImportedUserByUserNameMatchDelegate.java
<Windchill>\prog_examples\principal\principalmatchdelegate\ReplicatedUserForActivationByUserNameMatchDelegate.java
Related Package/Class Javadoc
wt.org.delegate
도움이 되셨나요?