Google Drive API:错误500共享文件夹

时间:2014-07-25 11:56:35

标签: java internal-server-error google-drive-api

使用Google Apps for Education,我为学生和员工创建和共享文件夹。 这是使用服务器端流程完成的,因为我们可能需要增加存储空间。 共享某些文件夹时,它可以正常工作,但在共享其他文件夹时,我会收到内部错误500。 有时这种情况发生在绝大多数文件夹中,但很少发生。

作为一个例子,我创建了大约的文件夹。 1000个用户,并分享每个用户失败。 它们与type = user,role = writer。

共享

此外,正如今天发生的那样,有几天共享导致没有任何错误,而且我 可以为所有用户创建和共享文件夹。

有没有人有任何想法? 谢谢, 迈克尔。

我这样调用shareFolder:     shareFolder(,," user"," writer",true);

public boolean shareFolder(String fileId, String sharerEmail, String type, String role, boolean forcesharing) {

    if (sharerEmail == null || sharerEmail.length() == 0) {
        return true;
    }

    sharerEmail = sharerEmail.toLowerCase();
    Permission perm = sharedAlready(fileId, sharerEmail, type, role);

    if (forcesharing && perm == null) {
        logger.info("File id " + fileId + " will be force shared with " + sharerEmail + ".");
        Permission permission = new Permission();
        permission.setValue(sharerEmail);
        permission.setEmailAddress(sharerEmail);
        permission.setType(type);
        permission.setRole(role);

        return insertSharingperm(fileId, permission);
    } else if (forcesharing) {
        // I do this in the hope that it my have an effect, but I'm beginning to doubt it.
        // There seems to be a problem with sharing the class folders with the class email, as readers.
        return updateSharingperm(fileId, perm);
    } else {
        if (perm != null) {
            logger.info("File " + fileId + " already shared with " + sharerEmail + ".");
            return true;
        } else {
            Permission permission = new Permission();
            permission.setValue(sharerEmail);
            permission.setEmailAddress(sharerEmail);
            permission.setType(type);
            permission.setRole(role);

            return insertSharingperm(fileId, permission);
        }
    }
}



public boolean insertSharingperm(String fileId, Permission perm) {
    try {
        if (null != executeWithEB(service.permissions().insert(fileId, perm))) {
            logger.info("File id " + fileId + " shared with " + perm.getEmailAddress() + ".");
            return true;
        } else {
            logger.warning("File id " + fileId + " not shared with " + perm.getEmailAddress() + ".");
            return false;
        }

    } catch (GoogleJsonResponseException e) {
        logger.severe("Failed. Code: "
                + e.getDetails().getCode() + "\nMessage: "
                + e.getDetails().getMessage() + " FileID=" + fileId
                + " SharerEmail=" + perm.getEmailAddress() + " Type=" + perm.getType()
                + " Role=" + perm.getRole());
    } catch (IOException e) {
        logger.severe("Failed:" + e.getMessage());
    } catch (InterruptedException e) {
        logger.severe("Failed:" + e.getMessage());
    }

    return false;

}

0 个答案:

没有答案