test_class.declarator: log = LoggerFactory.getLogger(FileMetadataExtractorImplTest.class)
test_class.modifier: private static final
test_class.original_string: private static final Logger log = LoggerFactory.getLogger(FileMetadataExtractorImplTest.class);
test_class.type: Logger
test_class.var_name: log
test_class.declarator: file
test_class.modifier: private
test_class.original_string: private File file;
test_class.type: File
test_class.var_name: file
test_class.file: core/src/test/java/org/apache/sling/cms/core/internal/FileMetadataExtractorImplTest.java
test_class.identifier: FileMetadataExtractorImplTest
test_case.body: @Test
      public void testExtractMetadata() throws IOException {
          FileMetadataExtractor extractor = new FileMetadataExtractorImpl();
          Map<String, Object> metadata = extractor.extractMetadata(file);
  
          assertNotNull(metadata);
          assertTrue(metadata.size() > 0);
  
          log.info("Extracted metadata: {}", metadata);
      }
test_case.class_method_signature: FileMetadataExtractorImplTest.testExtractMetadata()
test_case.full_signature: @Test public void testExtractMetadata()
test_case.identifier: testExtractMetadata
test_case.invocations: extractMetadata assertNotNull assertTrue size info
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testExtractMetadata()
focal_class.declarator: METADATA_EXTRACTOR_BUNDLE_NAME = "org.apache.sling.cms.metadata-extractor"
focal_class.modifier: private static final
focal_class.original_string: private static final String METADATA_EXTRACTOR_BUNDLE_NAME = "org.apache.sling.cms.metadata-extractor";
focal_class.type: String
focal_class.var_name: METADATA_EXTRACTOR_BUNDLE_NAME
focal_class.declarator: log = LoggerFactory.getLogger(FileMetadataExtractorImpl.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger log = LoggerFactory.getLogger(FileMetadataExtractorImpl.class);
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: bcx
focal_class.modifier: private
focal_class.original_string: private BundleContext bcx;
focal_class.type: BundleContext
focal_class.var_name: bcx
focal_class.file: core/src/main/java/org/apache/sling/cms/core/internal/FileMetadataExtractorImpl.java
focal_class.identifier: FileMetadataExtractorImpl
focal_class.interfaces: implements FileMetadataExtractor
focal_class.class_method_signature: FileMetadataExtractorImpl.activate(ComponentContext context)
focal_class.full_signature: @Activate public void activate(ComponentContext context)
focal_class.identifier: activate
focal_class.modifiers: @Activate public
focal_class.parameters: (ComponentContext context)
focal_class.return: void
focal_class.signature: void activate(ComponentContext context)
focal_class.class_method_signature: FileMetadataExtractorImpl.extractMetadata(File file)
focal_class.full_signature: @Override public Map<String, Object> extractMetadata(File file)
focal_class.identifier: extractMetadata
focal_class.modifiers: @Override public
focal_class.parameters: (File file)
focal_class.return: Map<String, Object>
focal_class.signature: Map<String, Object> extractMetadata(File file)
focal_class.class_method_signature: FileMetadataExtractorImpl.updateMetadata(File file)
focal_class.full_signature: @Override public void updateMetadata(File file)
focal_class.identifier: updateMetadata
focal_class.modifiers: @Override public
focal_class.parameters: (File file)
focal_class.return: void
focal_class.signature: void updateMetadata(File file)
focal_class.class_method_signature: FileMetadataExtractorImpl.updateMetadata(File file, boolean persist)
focal_class.full_signature: @Override public void updateMetadata(File file, boolean persist)
focal_class.identifier: updateMetadata
focal_class.modifiers: @Override public
focal_class.parameters: (File file, boolean persist)
focal_class.return: void
focal_class.signature: void updateMetadata(File file, boolean persist)
focal_class.class_method_signature: FileMetadataExtractorImpl.extractMetadata(Resource resource)
focal_class.full_signature: public Map<String, Object> extractMetadata(Resource resource)
focal_class.identifier: extractMetadata
focal_class.modifiers: public
focal_class.parameters: (Resource resource)
focal_class.return: Map<String, Object>
focal_class.signature: Map<String, Object> extractMetadata(Resource resource)
focal_class.class_method_signature: FileMetadataExtractorImpl.putMetadata(Map<String, Object> properties, String name, Metadata metadata)
focal_class.full_signature: private void putMetadata(Map<String, Object> properties, String name, Metadata metadata)
focal_class.identifier: putMetadata
focal_class.modifiers: private
focal_class.parameters: (Map<String, Object> properties, String name, Metadata metadata)
focal_class.return: void
focal_class.signature: void putMetadata(Map<String, Object> properties, String name, Metadata metadata)
focal_method.body: @Override
      public Map<String, Object> extractMetadata(File file) throws IOException {
          try {
              return extractMetadata(file.getResource());
          } catch (NoClassDefFoundError ncdfe) {
  
              log.info("Caught exception: {}, Attempting to reload metadata extractor bundle", String.valueOf(ncdfe));
              Bundle metadataExtractorBundle = Arrays.stream(bcx.getBundles())
                      .filter(b -> METADATA_EXTRACTOR_BUNDLE_NAME.equals(b.getSymbolicName())).findFirst().orElse(null);
  
              if (metadataExtractorBundle != null) {
                  try {
                      log.debug("Reloading metadata bundle: {}", metadataExtractorBundle);
                      Bundle systemBundle = bcx.getBundle(0);
                      metadataExtractorBundle.stop();
                      metadataExtractorBundle.start();
  
                      FrameworkWiring frameworkWiring = systemBundle.adapt(FrameworkWiring.class);
                      frameworkWiring.refreshBundles(Collections.singleton(metadataExtractorBundle));
                      log.debug("Bundle reloaded successfully!");
                  } catch (Exception e) {
                      log.warn("Failed to refresh metadata exporter packages", e);
                  }
              }
              try {
                  return extractMetadata(file.getResource());
              } catch (SAXException | TikaException | NoClassDefFoundError e) {
                  throw new IOException("Failed to parse metadata after reloading metadata extractor bundle", e);
              }
          } catch (SAXException | TikaException e) {
              throw new IOException("Failed to parse metadata", e);
          }
      }
focal_method.class_method_signature: FileMetadataExtractorImpl.extractMetadata(File file)
focal_method.full_signature: @Override public Map<String, Object> extractMetadata(File file)
focal_method.identifier: extractMetadata
focal_method.invocations: extractMetadata getResource info valueOf orElse findFirst filter stream getBundles equals getSymbolicName debug getBundle stop start adapt refreshBundles singleton debug warn extractMetadata getResource
focal_method.modifiers: @Override public
focal_method.parameters: (File file)
focal_method.return: Map<String, Object>
focal_method.signature: Map<String, Object> extractMetadata(File file)