@Test public void testGetClientForPageWithInheritedIdentifier() { Resource root = context.resourceResolver().getResource("/content/pageB/pageC"); ResourceProvider<?> provider = factory.createResourceProvider(root); Assert.assertNotNull(provider); checkResourceProviderInternals(provider); }
@Override public GraphqlResourceProvider createResourceProvider(Resource root) { LOGGER.debug("Creating resource provider for resource at path {}", root.getPath()); ConfigurationBuilder configurationBuilder = root.adaptTo(ConfigurationBuilder.class); ValueMap properties = configurationBuilder.name(CONFIGURATION_NAME) .asValueMap(); Map<String, String> collectedProperties = new HashMap<>(); if (properties.size() == 0) { collectedProperties = readFallbackConfiguration(root); } else { for (String key : properties.keySet()) { collectedProperties.put(key, properties.get(key, "")); } } String catalogIdentifier = collectedProperties.get(GraphqlDataServiceConfiguration.CQ_CATALOG_IDENTIFIER); if (StringUtils.isEmpty(catalogIdentifier)) { LOGGER.warn("Could not find cq:catalogIdentifier property for given resource at " + root.getPath()); return null; } String rootCategoryId = collectedProperties.get(Constants.MAGENTO_ROOT_CATEGORY_ID_PROPERTY); try { Integer.valueOf(rootCategoryId); } catch (NumberFormatException x) { LOGGER.warn("Invalid {} {} at {}", Constants.MAGENTO_ROOT_CATEGORY_ID_PROPERTY, rootCategoryId, root.getPath()); return null; } GraphqlDataService client = clients.get(catalogIdentifier); if (client == null) { LOGGER.warn("No MagentoGraphqlClient instance available for catalog identifier " + catalogIdentifier); return null; } GraphqlResourceProvider resourceProvider = new GraphqlResourceProvider(root.getPath(), client, collectedProperties); return resourceProvider; }
GraphqlResourceProviderFactory implements CatalogDataResourceProviderFactory<Object>, CatalogIdentifier { @Override public GraphqlResourceProvider createResourceProvider(Resource root) { LOGGER.debug("Creating resource provider for resource at path {}", root.getPath()); ConfigurationBuilder configurationBuilder = root.adaptTo(ConfigurationBuilder.class); ValueMap properties = configurationBuilder.name(CONFIGURATION_NAME) .asValueMap(); Map<String, String> collectedProperties = new HashMap<>(); if (properties.size() == 0) { collectedProperties = readFallbackConfiguration(root); } else { for (String key : properties.keySet()) { collectedProperties.put(key, properties.get(key, "")); } } String catalogIdentifier = collectedProperties.get(GraphqlDataServiceConfiguration.CQ_CATALOG_IDENTIFIER); if (StringUtils.isEmpty(catalogIdentifier)) { LOGGER.warn("Could not find cq:catalogIdentifier property for given resource at " + root.getPath()); return null; } String rootCategoryId = collectedProperties.get(Constants.MAGENTO_ROOT_CATEGORY_ID_PROPERTY); try { Integer.valueOf(rootCategoryId); } catch (NumberFormatException x) { LOGGER.warn("Invalid {} {} at {}", Constants.MAGENTO_ROOT_CATEGORY_ID_PROPERTY, rootCategoryId, root.getPath()); return null; } GraphqlDataService client = clients.get(catalogIdentifier); if (client == null) { LOGGER.warn("No MagentoGraphqlClient instance available for catalog identifier " + catalogIdentifier); return null; } GraphqlResourceProvider resourceProvider = new GraphqlResourceProvider(root.getPath(), client, collectedProperties); return resourceProvider; } }
GraphqlResourceProviderFactory implements CatalogDataResourceProviderFactory<Object>, CatalogIdentifier { @Override public GraphqlResourceProvider createResourceProvider(Resource root) { LOGGER.debug("Creating resource provider for resource at path {}", root.getPath()); ConfigurationBuilder configurationBuilder = root.adaptTo(ConfigurationBuilder.class); ValueMap properties = configurationBuilder.name(CONFIGURATION_NAME) .asValueMap(); Map<String, String> collectedProperties = new HashMap<>(); if (properties.size() == 0) { collectedProperties = readFallbackConfiguration(root); } else { for (String key : properties.keySet()) { collectedProperties.put(key, properties.get(key, "")); } } String catalogIdentifier = collectedProperties.get(GraphqlDataServiceConfiguration.CQ_CATALOG_IDENTIFIER); if (StringUtils.isEmpty(catalogIdentifier)) { LOGGER.warn("Could not find cq:catalogIdentifier property for given resource at " + root.getPath()); return null; } String rootCategoryId = collectedProperties.get(Constants.MAGENTO_ROOT_CATEGORY_ID_PROPERTY); try { Integer.valueOf(rootCategoryId); } catch (NumberFormatException x) { LOGGER.warn("Invalid {} {} at {}", Constants.MAGENTO_ROOT_CATEGORY_ID_PROPERTY, rootCategoryId, root.getPath()); return null; } GraphqlDataService client = clients.get(catalogIdentifier); if (client == null) { LOGGER.warn("No MagentoGraphqlClient instance available for catalog identifier " + catalogIdentifier); return null; } GraphqlResourceProvider resourceProvider = new GraphqlResourceProvider(root.getPath(), client, collectedProperties); return resourceProvider; }  }
GraphqlResourceProviderFactory implements CatalogDataResourceProviderFactory<Object>, CatalogIdentifier { @Override public GraphqlResourceProvider createResourceProvider(Resource root) { LOGGER.debug("Creating resource provider for resource at path {}", root.getPath()); ConfigurationBuilder configurationBuilder = root.adaptTo(ConfigurationBuilder.class); ValueMap properties = configurationBuilder.name(CONFIGURATION_NAME) .asValueMap(); Map<String, String> collectedProperties = new HashMap<>(); if (properties.size() == 0) { collectedProperties = readFallbackConfiguration(root); } else { for (String key : properties.keySet()) { collectedProperties.put(key, properties.get(key, "")); } } String catalogIdentifier = collectedProperties.get(GraphqlDataServiceConfiguration.CQ_CATALOG_IDENTIFIER); if (StringUtils.isEmpty(catalogIdentifier)) { LOGGER.warn("Could not find cq:catalogIdentifier property for given resource at " + root.getPath()); return null; } String rootCategoryId = collectedProperties.get(Constants.MAGENTO_ROOT_CATEGORY_ID_PROPERTY); try { Integer.valueOf(rootCategoryId); } catch (NumberFormatException x) { LOGGER.warn("Invalid {} {} at {}", Constants.MAGENTO_ROOT_CATEGORY_ID_PROPERTY, rootCategoryId, root.getPath()); return null; } GraphqlDataService client = clients.get(catalogIdentifier); if (client == null) { LOGGER.warn("No MagentoGraphqlClient instance available for catalog identifier " + catalogIdentifier); return null; } GraphqlResourceProvider resourceProvider = new GraphqlResourceProvider(root.getPath(), client, collectedProperties); return resourceProvider; }  @Override GraphqlResourceProvider createResourceProvider(Resource root); @Override Collection<String> getAllCatalogIdentifiers(); @Override String getCommerceProviderName(); }
GraphqlResourceProviderFactory implements CatalogDataResourceProviderFactory<Object>, CatalogIdentifier { @Override public GraphqlResourceProvider createResourceProvider(Resource root) { LOGGER.debug("Creating resource provider for resource at path {}", root.getPath()); ConfigurationBuilder configurationBuilder = root.adaptTo(ConfigurationBuilder.class); ValueMap properties = configurationBuilder.name(CONFIGURATION_NAME) .asValueMap(); Map<String, String> collectedProperties = new HashMap<>(); if (properties.size() == 0) { collectedProperties = readFallbackConfiguration(root); } else { for (String key : properties.keySet()) { collectedProperties.put(key, properties.get(key, "")); } } String catalogIdentifier = collectedProperties.get(GraphqlDataServiceConfiguration.CQ_CATALOG_IDENTIFIER); if (StringUtils.isEmpty(catalogIdentifier)) { LOGGER.warn("Could not find cq:catalogIdentifier property for given resource at " + root.getPath()); return null; } String rootCategoryId = collectedProperties.get(Constants.MAGENTO_ROOT_CATEGORY_ID_PROPERTY); try { Integer.valueOf(rootCategoryId); } catch (NumberFormatException x) { LOGGER.warn("Invalid {} {} at {}", Constants.MAGENTO_ROOT_CATEGORY_ID_PROPERTY, rootCategoryId, root.getPath()); return null; } GraphqlDataService client = clients.get(catalogIdentifier); if (client == null) { LOGGER.warn("No MagentoGraphqlClient instance available for catalog identifier " + catalogIdentifier); return null; } GraphqlResourceProvider resourceProvider = new GraphqlResourceProvider(root.getPath(), client, collectedProperties); return resourceProvider; }  @Override GraphqlResourceProvider createResourceProvider(Resource root); @Override Collection<String> getAllCatalogIdentifiers(); @Override String getCommerceProviderName();  }