// Get the UserTeamAssociationService.
UserTeamAssociationServiceInterface userTeamAssociationService =
dfpServices.get(session, UserTeamAssociationServiceInterface.class);
// Get the UserTeamAssociation.
UserTeamAssociation userTeamAssociation =
userTeamAssociationService.getUserTeamAssociation(userId, teamId);
// Update the user's access type on the team.
userTeamAssociation.setOverriddenTeamAccessType(TeamAccessType.READ_ONLY);
// Update the user team associations on the server.
UserTeamAssociation[] userTeamAssociations = userTeamAssociationService
.updateUserTeamAssociations(new UserTeamAssociation[] {userTeamAssociation});