Directory.members.delete突然给出404 Not Found

时间:2019-09-17 20:37:34

标签: java google-directory-api

从选定的Google网上论坛中添加和删除成员的Java程序突然出现404 Not Found错误。系统已经运行了几个月,在2019年9月16日的昨天突然改变。

自上次成功添加和删除成员以来,没有任何变化。

/**
 * Removes a set of members from a group
 *
 * @param groupKey the group to modify
 * @param memberKeys the set of members to remove
 * @return
 * @throws java.io.IOException
 */
public Set<String> removeMembers(String groupKey, Set<String> memberKeys) throws IOException {
    Set<String> removedMembers = new HashSet<>();

    for (String memberKey : memberKeys) {
        try {
            Member member = service.members().get(groupKey, memberKey).execute();

            if (member.getRole().equalsIgnoreCase("member")) {
                deleteMember(groupKey, memberKey);
                removedMembers.add(memberKey);
                Logger.getLogger(MembersService.class.getName()).log(Level.INFO, String.format("Removed %s from %s.\n", memberKey, groupKey));
            } else {
                String msg = String.format("Member, %s, is not a regular member of %s.", memberKey, groupKey);
                Logger.getLogger(MembersService.class.getName()).log(Level.INFO, msg);
            }
        } catch (IOException ex) {
            throw new IOException(String.format("Exception removing memberKey, %s, from %s.", memberKey, groupKey), ex);
        }
    }

    return new TreeSet<>(removedMembers);
}

/**
 * Removes a single member from a group
 *
 * @param groupKey the group to modify
 * @param memberKey the member to remove
 * @throws IOException
 */
public void deleteMember(String groupKey, String memberKey) throws IOException {
    for (int n = 0; n <= retries; n++) {
        try {
            service.members().delete(groupKey, memberKey).execute();
        } catch (IOException ex) {
            String exMessage = ex.getMessage();

            //Throw exception if retries have been exhausted
            if(n == retries) {
                throw ex;
            }

            //Wait 2^n + random_number_milliseconds seconds
            try {
                int millis = ((int) Math.round(Math.pow(2, n)) * 1000) + (r.nextInt(high - low) + low);
                String msg = String.format("Retry, backoff %sms", millis);

                Logger.getLogger(MembersService.class.getName()).log(Level.INFO, msg);
                Thread.sleep(millis);
            } catch (InterruptedException ignored) {
                //Nothing to see here
            }
        }
    }
}

删除成员和团体地址,今天早上跑步给了我以下内容。

2019年9月17日下午2:02:09 edu.csusb.ecs.groupsautosubscribe.Main main 严重:null java.io.IOException:从@ groups.csusb.edu中删除memberKey @ csusb.edu的异常。        在edu.csusb.ecs.groupsautosubscribe.gsuite.MembersService.removeMembers(MembersService.java:232)        在edu.csusb.ecs.groupsautosubscribe.Main.main(Main.java:111) 造成原因:com.google.api.client.googleapis.json.GoogleJsonResponseException:找不到404 {   “代码”:404,   “错误”:[{     “ domain”:“ global”,     “ message”:“找不到资源:memberKey”,     “ reason”:“ notFound”   }],   “ message”:“找不到资源:memberKey” }        在com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:150)        com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:113)        com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:40)        com.google.api.client.googleapis.services.AbstractGoogleClientRequest $ 1.interceptResponse(AbstractGoogleClientRequest.java:417)        在com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1132)        com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:515)        com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:448)        com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:565)        在edu.csusb.ecs.groupsautosubscribe.gsuite.MembersService.deleteMember(MembersService.java:249)        在edu.csusb.ecs.groupsautosubscribe.gsuite.MembersService.removeMembers(MembersService.java:224)        ...还有1个

0 个答案:

没有答案