@Test public void testImageResourceProductError() throws IOException, CommerceException { Utils.setupHttpResponse("magento-graphql-categorylist-empty.json", httpClient, HttpStatus.SC_OK, "{categoryList(filters:{url_key:{eq:\"image\""); Utils.setupHttpResponse("magento-graphql-categorylist-coats.json", httpClient, HttpStatus.SC_OK, "{categoryList(filters:{url_key:{eq:\"coats\""); Utils.setupHttpResponse("magento-graphql-no-product.json", httpClient, HttpStatus.SC_INTERNAL_SERVER_ERROR, "{product"); Resource resource = provider.getResource(resolveContext, PRODUCT_PATH + "/image", null, null); assertNull(resource); }
@Override public Resource getResource(ResolveContext<Object> ctx, String path, ResourceContext resourceContext, Resource parent) { LOGGER.debug("getResource called for " + path); if (path.equals(root)) { Resource resource = ctx.getParentResourceProvider().getResource( (ResolveContext) ctx.getParentResolveContext(), path, resourceContext, parent); if (resource == null) { return null; } else { return new RootCategoryResource(resource, rootCategoryId); } } if (path.contains(JcrConstants.JCR_CONTENT) || path.endsWith(".jpg") || path.contains("assets") || path.contains("thumbnail") || path.contains("rep:policy")) { return null; } ResourceResolver resolver = ctx.getResourceResolver(); CategoryResource category = resourceMapper.resolveCategory(resolver, path); if (category != null) { return category; } else { Resource resource; if (path.endsWith("/image")) { resource = resourceMapper.resolveProductImage(resolver, path); } else { resource = resourceMapper.resolveProduct(resolver, path); } return resource; } }
GraphqlResourceProvider extends ResourceProvider<Object> { @Override public Resource getResource(ResolveContext<Object> ctx, String path, ResourceContext resourceContext, Resource parent) { LOGGER.debug("getResource called for " + path); if (path.equals(root)) { Resource resource = ctx.getParentResourceProvider().getResource( (ResolveContext) ctx.getParentResolveContext(), path, resourceContext, parent); if (resource == null) { return null; } else { return new RootCategoryResource(resource, rootCategoryId); } } if (path.contains(JcrConstants.JCR_CONTENT) || path.endsWith(".jpg") || path.contains("assets") || path.contains("thumbnail") || path.contains("rep:policy")) { return null; } ResourceResolver resolver = ctx.getResourceResolver(); CategoryResource category = resourceMapper.resolveCategory(resolver, path); if (category != null) { return category; } else { Resource resource; if (path.endsWith("/image")) { resource = resourceMapper.resolveProductImage(resolver, path); } else { resource = resourceMapper.resolveProduct(resolver, path); } return resource; } } }
GraphqlResourceProvider extends ResourceProvider<Object> { @Override public Resource getResource(ResolveContext<Object> ctx, String path, ResourceContext resourceContext, Resource parent) { LOGGER.debug("getResource called for " + path); if (path.equals(root)) { Resource resource = ctx.getParentResourceProvider().getResource( (ResolveContext) ctx.getParentResolveContext(), path, resourceContext, parent); if (resource == null) { return null; } else { return new RootCategoryResource(resource, rootCategoryId); } } if (path.contains(JcrConstants.JCR_CONTENT) || path.endsWith(".jpg") || path.contains("assets") || path.contains("thumbnail") || path.contains("rep:policy")) { return null; } ResourceResolver resolver = ctx.getResourceResolver(); CategoryResource category = resourceMapper.resolveCategory(resolver, path); if (category != null) { return category; } else { Resource resource; if (path.endsWith("/image")) { resource = resourceMapper.resolveProductImage(resolver, path); } else { resource = resourceMapper.resolveProduct(resolver, path); } return resource; } } GraphqlResourceProvider(String root, GraphqlDataService graphqlDataService, Map<String, String> properties); }
GraphqlResourceProvider extends ResourceProvider<Object> { @Override public Resource getResource(ResolveContext<Object> ctx, String path, ResourceContext resourceContext, Resource parent) { LOGGER.debug("getResource called for " + path); if (path.equals(root)) { Resource resource = ctx.getParentResourceProvider().getResource( (ResolveContext) ctx.getParentResolveContext(), path, resourceContext, parent); if (resource == null) { return null; } else { return new RootCategoryResource(resource, rootCategoryId); } } if (path.contains(JcrConstants.JCR_CONTENT) || path.endsWith(".jpg") || path.contains("assets") || path.contains("thumbnail") || path.contains("rep:policy")) { return null; } ResourceResolver resolver = ctx.getResourceResolver(); CategoryResource category = resourceMapper.resolveCategory(resolver, path); if (category != null) { return category; } else { Resource resource; if (path.endsWith("/image")) { resource = resourceMapper.resolveProductImage(resolver, path); } else { resource = resourceMapper.resolveProduct(resolver, path); } return resource; } } GraphqlResourceProvider(String root, GraphqlDataService graphqlDataService, Map<String, String> properties); @Override Resource getResource(ResolveContext<Object> ctx, String path, ResourceContext resourceContext, Resource parent); @Override Iterator<Resource> listChildren(ResolveContext<Object> ctx, Resource parent); @Override GraphqlQueryLanguageProvider getQueryLanguageProvider(); }
GraphqlResourceProvider extends ResourceProvider<Object> { @Override public Resource getResource(ResolveContext<Object> ctx, String path, ResourceContext resourceContext, Resource parent) { LOGGER.debug("getResource called for " + path); if (path.equals(root)) { Resource resource = ctx.getParentResourceProvider().getResource( (ResolveContext) ctx.getParentResolveContext(), path, resourceContext, parent); if (resource == null) { return null; } else { return new RootCategoryResource(resource, rootCategoryId); } } if (path.contains(JcrConstants.JCR_CONTENT) || path.endsWith(".jpg") || path.contains("assets") || path.contains("thumbnail") || path.contains("rep:policy")) { return null; } ResourceResolver resolver = ctx.getResourceResolver(); CategoryResource category = resourceMapper.resolveCategory(resolver, path); if (category != null) { return category; } else { Resource resource; if (path.endsWith("/image")) { resource = resourceMapper.resolveProductImage(resolver, path); } else { resource = resourceMapper.resolveProduct(resolver, path); } return resource; } } GraphqlResourceProvider(String root, GraphqlDataService graphqlDataService, Map<String, String> properties); @Override Resource getResource(ResolveContext<Object> ctx, String path, ResourceContext resourceContext, Resource parent); @Override Iterator<Resource> listChildren(ResolveContext<Object> ctx, Resource parent); @Override GraphqlQueryLanguageProvider getQueryLanguageProvider();  }