try {
UserProfile userProfile = profileManager.getUserProfile(getID(), true);
FolderIndex folderIndex = (FolderIndex) userProfile.getFileByPath(context.getFolder(), root);
if (!folderIndex.canWrite()) {
throw new ProcessExecutionException(String.format(
"Cannot share folder '%s' with read-only access.", folderIndex.getName()));
} else if (!folderIndex.getSharedFlag() && folderIndex.isSharedOrHasSharedChildren()) {
// restriction that disallows sharing folders within other shared folders
throw new ProcessExecutionException(String.format(