// Get DfpUser from "~/dfp.properties".
DfpUser user = new DfpUser();
// Get the UserTeamAssociationService.
UserTeamAssociationServiceInterface userTeamAssociationService =
user.getService(DfpService.V201306.USER_TEAM_ASSOCIATION_SERVICE);
// Set the user to set to read only access within its teams.
Long userId = Long.parseLong("INSERT_USER_ID_HERE");
// Create filter text to select user team associations by the user ID.
String statementText = "WHERE userId = :userId LIMIT 500";
Statement filterStatement =
new StatementBuilder("")
.putValue("userId", userId)
.toStatement();
// Get user team associations by statement.
UserTeamAssociationPage page =
userTeamAssociationService.getUserTeamAssociationsByStatement(filterStatement);
if (page.getResults() != null) {
UserTeamAssociation[] userTeamAssociations = page.getResults();
// Update each local user team association to read only access.
for (UserTeamAssociation userTeamAssociation : userTeamAssociations) {
userTeamAssociation.setOverriddenTeamAccessType(TeamAccessType.READ_ONLY);
}
// Update the user team associations on the server.
userTeamAssociations =
userTeamAssociationService.updateUserTeamAssociations(userTeamAssociations);
if (userTeamAssociations != null) {
for (UserTeamAssociation userTeamAssociation : userTeamAssociations) {
System.out.println("User team association between user with ID \""
+ userTeamAssociation.getUserId() + "\" and team with ID \""