// Get DfpUser from "~/dfp.properties".
DfpUser user = new DfpUser();
// Get the UserTeamAssociationService.
UserTeamAssociationServiceInterface userTeamAssociationService =
user.getService(DfpService.V201306.USER_TEAM_ASSOCIATION_SERVICE);
// Set the users and team to add them to.
Long teamId = Long.parseLong("INSERT_TEAM_ID_HERE");
Long[] userIds = new Long[] {Long.parseLong("INSERT_USER_ID_HERE")};
// Create an array to store local user team association objects.
UserTeamAssociation[] userTeamAssociations = new UserTeamAssociation[userIds.length];
// For each user, associate it with the given team.
int i = 0;
for (Long userId : userIds) {
UserTeamAssociation userTeamAssociation = new UserTeamAssociation();
userTeamAssociation.setUserId(userId);
userTeamAssociation.setTeamId(teamId);
userTeamAssociations[i++] = userTeamAssociation;
}
// Create the user team associations on the server.
userTeamAssociations =
userTeamAssociationService.createUserTeamAssociations(userTeamAssociations);
if (userTeamAssociations != null) {
for (UserTeamAssociation userTeamAssociation : userTeamAssociations) {
System.out.println("A user team association between user with ID \""
+ userTeamAssociation.getUserId() + "\" and team with ID \""