code: public static boolean isWriteEnabled(Resource resource, String relPath) throws RepositoryException {
  
          ResourceResolver resolver = resource.getResourceResolver();
          Session session = resolver.adaptTo(Session.class);
          AccessControlManager accessManager = AccessControlUtil.getAccessControlManager(session);
  
          String resourcePath = resource.getPath();
          Privilege[] addPrivileges = new Privilege[]{
                  accessManager.privilegeFromName(Privilege.JCR_ADD_CHILD_NODES)
          };
          boolean result = accessManager.hasPrivileges(resourcePath, addPrivileges);
  
          if (StringUtils.isNotBlank(relPath)) {
              if (!resourcePath.endsWith("/")) {
                  resourcePath += "/";
              }
              resourcePath += relPath;
          }
          Privilege[] changePrivileges = new Privilege[]{
                  accessManager.privilegeFromName(Privilege.JCR_MODIFY_PROPERTIES)
          };
          try {
              result = result && accessManager.hasPrivileges(resourcePath, changePrivileges);
          } catch (PathNotFoundException pnfex) {
              // ok, let's create it
          }
  
          return result;
      }
docs: Checks the access control policies for enabled changes (node creation and property change).
  
  @param resource
  @param relPath
  @return
  @throws RepositoryException