Using Google Apps for Education, I create and share folders for pupils and staff. This is done using server-side-flow, since we may need to increase storage. When sharing some folders, it works, but when sharing others, I get Internal Error 500. Sometimes this happens for the vast majority of folders, but rarely for all.
As an example, I created folders for approx. 1000 users, and sharing each one failed. They are shared with type=user, role=writer.
Also, as happened today, there are days when sharing causes no errors at all, and I could create and share folders for all users.
Does anyone have any ideas? Thanks, Michael.
I call shareFolder like this: 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;
}