Skip to content

Commit

Permalink
[GOOGLEAPPS-25] #resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
ilgrosso committed Dec 9, 2024
1 parent 7c70829 commit 8fdde4c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,9 @@ public String handleResult(final Directory.Users.List request, final Users value
try {
Directory.Users.Get request =
configuration.getDirectory().users().get((String) key.getValue().get(0));
request.setFields(getFields(options, GoogleAppsUtil.ID_ATTR,
GoogleAppsUtil.ETAG_ATTR, GoogleAppsUtil.PRIMARY_EMAIL_ATTR));
request.setFields(getFields(options,
GoogleAppsUtil.ID_ATTR, GoogleAppsUtil.ETAG_ATTR,
GoogleAppsUtil.PRIMARY_EMAIL_ATTR, GoogleAppsUtil.SUSPENDED_ATTR));
request.setProjection(configuration.getProjection());

GoogleApiExecutor.execute(request,
Expand Down Expand Up @@ -398,8 +399,9 @@ public Boolean handleNotFound(final IOException e) {
request.setPageToken(options.getPagedResultsCookie());

// Implementation to support the 'OP_ATTRIBUTES_TO_GET'
String fields = getFields(options, GoogleAppsUtil.ID_ATTR,
GoogleAppsUtil.ETAG_ATTR, GoogleAppsUtil.EMAIL_ATTR);
String fields = getFields(options,
GoogleAppsUtil.ID_ATTR, GoogleAppsUtil.ETAG_ATTR,
GoogleAppsUtil.EMAIL_ATTR, GoogleAppsUtil.SUSPENDED_ATTR);
if (null != fields) {
request.setFields("nextPageToken,groups(" + fields + ")");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ public Object handleNotFound(final IOException e) {
}
}

// GOOGLEAPPS-9
// license management: if remove license param is true and __ENABLE__ is false perform delete license
// license read must be performed with the user primaryEmail, userId is not allowed
if (configuration.getRemoveLicenseOnDisable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public final class GoogleAppsUtil {

public static final String AGREED_TO_TERMS_ATTR = "agreedToTerms";

public static final String SUSPENDED_ATTR = "suspended";

public static final String SUSPENSION_REASON_ATTR = "suspensionReason";

public static final String ALIASES_ATTR = "aliases";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ public static Set<String> listGroups(final Directory.Groups service, final Strin
try {
Directory.Groups.List request = service.list().
setUserKey(userKey).
setFields("groups/email").
setFields("groups/id").
// 400 Bad Request if the Customer(my_customer or exact value) is set, only domain-userKey
// combination allowed. request.setCustomer(MY_CUSTOMER_ID);
setDomain(domain);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,10 +552,8 @@ public static Directory.Users.Insert createUser(
user.setExternalIds(buildObjs(Optional.ofNullable(attributes.findList(
GoogleAppsUtil.EXTERNAL_IDS_ATTR)).orElse(null), UserExternalId.class));

Boolean enable = attributes.findBoolean(OperationalAttributes.ENABLE_NAME);
if (null != enable) {
user.setSuspended(!enable);
}
Optional.ofNullable(attributes.findBoolean(OperationalAttributes.ENABLE_NAME)).
ifPresent(enable -> user.setSuspended(!enable));
user.setChangePasswordAtNextLogin(
attributes.findBoolean(GoogleAppsUtil.CHANGE_PASSWORD_AT_NEXT_LOGIN_ATTR));
user.setIpWhitelisted(attributes.findBoolean(GoogleAppsUtil.IP_WHITELISTED_ATTR));
Expand Down Expand Up @@ -941,9 +939,8 @@ public static ConnectorObject fromUser(
builder.setUid(user.getId());
}
builder.setName(user.getPrimaryEmail());
if (user.getSuspended() != null) {
builder.addAttribute(AttributeBuilder.build(OperationalAttributes.ENABLE_NAME, !user.getSuspended()));
}
Optional.ofNullable(user.getSuspended()).
ifPresent(suspended -> builder.addAttribute(AttributeBuilder.buildEnabled(!suspended)));

if ((null == attributesToGet || attributesToGet.contains(GoogleAppsUtil.ID_ATTR))) {
builder.addAttribute(AttributeBuilder.build(GoogleAppsUtil.ID_ATTR, user.getId()));
Expand Down

0 comments on commit 8fdde4c

Please sign in to comment.