code: private void validateExtension(LocalExtension localExtension, boolean dependencies)
      {
          Collection<String> namespaces = DefaultInstalledExtension.getNamespaces(localExtension);
  
          if (namespaces == null) {
              if (dependencies || !DefaultInstalledExtension.isDependency(localExtension, null)) {
                  try {
                      validateExtension(localExtension, null, Collections.emptyMap());
                  } catch (InvalidExtensionException e) {
                      if (this.logger.isDebugEnabled()) {
                          this.logger.warn("Invalid extension [{}]", localExtension.getId(), e);
                      } else {
                          this.logger.warn("Invalid extension [{}] ({})", localExtension.getId(),
                              ExceptionUtils.getRootCauseMessage(e));
                      }
  
                      addInstalledExtension(localExtension, null, false);
                  }
              }
          } else {
              for (String namespace : namespaces) {
                  if (dependencies || !DefaultInstalledExtension.isDependency(localExtension, namespace)) {
                      try {
                          validateExtension(localExtension, namespace, Collections.emptyMap());
                      } catch (InvalidExtensionException e) {
                          if (this.logger.isDebugEnabled()) {
                              this.logger.warn("Invalid extension [{}] on namespace [{}]", localExtension.getId(),
                                  namespace, e);
                          } else {
                              this.logger.warn("Invalid extension [{}] on namespace [{}] ({})", localExtension.getId(),
                                  namespace, ExceptionUtils.getRootCauseMessage(e));
                          }
  
                          addInstalledExtension(localExtension, namespace, false);
                      }
                  }
              }
          }
      }
docs: Check extension validity and set it as not installed if not.
  
  @param localExtension the extension to validate
  @param dependencies true if dependencies should be validated
  @throws InvalidExtensionException when the passed extension is fond invalid