@Test public void TestGetItemsetPreviewUrl2() throws Exception { String contentNodeString = "{\"identifier\":\"do_11292666508456755211\",\"objectType\":\"Content\",\"code\":\"Test_PDF\",\"channel\":\"channel-1\",\"mimeType\":\"application/pdf\",\"versionKey\":\"1578381263182\",\"name\":\"Test_PDF\",\"status\":\"Live\",\"children\":[{\"identifier\":\"do_11292667205373132811\"}]}"; Map<String, Object> contentNodeMap = mapper.readValue(contentNodeString, HashMap.class); DefinitionDTO contentDefinition = new ControllerUtil().getDefinition("domain", "Content"); Node contentNode = ConvertToGraphNode.convertToGraphNode(contentNodeMap, contentDefinition, null); PublishFinalizer publishFinalizer = new PublishFinalizer("/tmp", "do_11292666508456755211"); String url = publishFinalizer.getItemsetPreviewUrl(contentNode); Assert.assertNull(url); }
protected String getItemsetPreviewUrl(Node node) throws Exception { List<Relation> outRelations = node.getOutRelations(); if(CollectionUtils.isEmpty(outRelations)) { return null; } List<String> itemSetRelations = outRelations.stream() .filter(r -> StringUtils.equalsIgnoreCase(r.getEndNodeObjectType(), "ItemSet")) .map(x -> x.getEndNodeId()).collect(Collectors.toList()); if(CollectionUtils.isNotEmpty(itemSetRelations)){ String questionBankHtml = itemsetPublishManager.publish(itemSetRelations); if(StringUtils.isNotBlank(questionBankHtml)) { if(ITEMSET_GENERATE_PDF) { Response generateResponse = HttpRestUtil.makePostRequest(PRINT_SERVICE_BASE_URL + "/v1/print/preview/generate?fileUrl=" + questionBankHtml, new HashMap<>(), new HashMap<>()); if (generateResponse.getResponseCode() == ResponseCode.OK) { String itemsetPreviewUrl = (String)generateResponse.getResult().get(ContentAPIParams.pdfUrl.name()); if(StringUtils.isNotBlank(itemsetPreviewUrl)) return publishFinalizeUtil.uploadFile(itemsetPreviewUrl, node, basePath); else throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Itemset generated previewUrl is empty. Please Try Again After Sometime!"); }else { if (generateResponse.getResponseCode() == ResponseCode.CLIENT_ERROR) { TelemetryManager.error("Client Error during Generate Itemset previewUrl: " + generateResponse.getParams().getErrmsg() + " :: " + generateResponse.getResult()); throw new ClientException(generateResponse.getParams().getErr(), generateResponse.getParams().getErrmsg()); } else { TelemetryManager.error("Server Error during Generate Itemset preiewUrl: " + generateResponse.getParams().getErrmsg() + " :: " + generateResponse.getResult()); throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Error During generate Itemset previewUrl. Please Try Again After Sometime!"); } } }else { return publishFinalizeUtil.uploadFile(questionBankHtml, node, basePath); } } } return null; }
PublishFinalizer extends BaseFinalizer { protected String getItemsetPreviewUrl(Node node) throws Exception { List<Relation> outRelations = node.getOutRelations(); if(CollectionUtils.isEmpty(outRelations)) { return null; } List<String> itemSetRelations = outRelations.stream() .filter(r -> StringUtils.equalsIgnoreCase(r.getEndNodeObjectType(), "ItemSet")) .map(x -> x.getEndNodeId()).collect(Collectors.toList()); if(CollectionUtils.isNotEmpty(itemSetRelations)){ String questionBankHtml = itemsetPublishManager.publish(itemSetRelations); if(StringUtils.isNotBlank(questionBankHtml)) { if(ITEMSET_GENERATE_PDF) { Response generateResponse = HttpRestUtil.makePostRequest(PRINT_SERVICE_BASE_URL + "/v1/print/preview/generate?fileUrl=" + questionBankHtml, new HashMap<>(), new HashMap<>()); if (generateResponse.getResponseCode() == ResponseCode.OK) { String itemsetPreviewUrl = (String)generateResponse.getResult().get(ContentAPIParams.pdfUrl.name()); if(StringUtils.isNotBlank(itemsetPreviewUrl)) return publishFinalizeUtil.uploadFile(itemsetPreviewUrl, node, basePath); else throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Itemset generated previewUrl is empty. Please Try Again After Sometime!"); }else { if (generateResponse.getResponseCode() == ResponseCode.CLIENT_ERROR) { TelemetryManager.error("Client Error during Generate Itemset previewUrl: " + generateResponse.getParams().getErrmsg() + " :: " + generateResponse.getResult()); throw new ClientException(generateResponse.getParams().getErr(), generateResponse.getParams().getErrmsg()); } else { TelemetryManager.error("Server Error during Generate Itemset preiewUrl: " + generateResponse.getParams().getErrmsg() + " :: " + generateResponse.getResult()); throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Error During generate Itemset previewUrl. Please Try Again After Sometime!"); } } }else { return publishFinalizeUtil.uploadFile(questionBankHtml, node, basePath); } } } return null; } }
PublishFinalizer extends BaseFinalizer { protected String getItemsetPreviewUrl(Node node) throws Exception { List<Relation> outRelations = node.getOutRelations(); if(CollectionUtils.isEmpty(outRelations)) { return null; } List<String> itemSetRelations = outRelations.stream() .filter(r -> StringUtils.equalsIgnoreCase(r.getEndNodeObjectType(), "ItemSet")) .map(x -> x.getEndNodeId()).collect(Collectors.toList()); if(CollectionUtils.isNotEmpty(itemSetRelations)){ String questionBankHtml = itemsetPublishManager.publish(itemSetRelations); if(StringUtils.isNotBlank(questionBankHtml)) { if(ITEMSET_GENERATE_PDF) { Response generateResponse = HttpRestUtil.makePostRequest(PRINT_SERVICE_BASE_URL + "/v1/print/preview/generate?fileUrl=" + questionBankHtml, new HashMap<>(), new HashMap<>()); if (generateResponse.getResponseCode() == ResponseCode.OK) { String itemsetPreviewUrl = (String)generateResponse.getResult().get(ContentAPIParams.pdfUrl.name()); if(StringUtils.isNotBlank(itemsetPreviewUrl)) return publishFinalizeUtil.uploadFile(itemsetPreviewUrl, node, basePath); else throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Itemset generated previewUrl is empty. Please Try Again After Sometime!"); }else { if (generateResponse.getResponseCode() == ResponseCode.CLIENT_ERROR) { TelemetryManager.error("Client Error during Generate Itemset previewUrl: " + generateResponse.getParams().getErrmsg() + " :: " + generateResponse.getResult()); throw new ClientException(generateResponse.getParams().getErr(), generateResponse.getParams().getErrmsg()); } else { TelemetryManager.error("Server Error during Generate Itemset preiewUrl: " + generateResponse.getParams().getErrmsg() + " :: " + generateResponse.getResult()); throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Error During generate Itemset previewUrl. Please Try Again After Sometime!"); } } }else { return publishFinalizeUtil.uploadFile(questionBankHtml, node, basePath); } } } return null; } PublishFinalizer(String basePath, String contentId); }
PublishFinalizer extends BaseFinalizer { protected String getItemsetPreviewUrl(Node node) throws Exception { List<Relation> outRelations = node.getOutRelations(); if(CollectionUtils.isEmpty(outRelations)) { return null; } List<String> itemSetRelations = outRelations.stream() .filter(r -> StringUtils.equalsIgnoreCase(r.getEndNodeObjectType(), "ItemSet")) .map(x -> x.getEndNodeId()).collect(Collectors.toList()); if(CollectionUtils.isNotEmpty(itemSetRelations)){ String questionBankHtml = itemsetPublishManager.publish(itemSetRelations); if(StringUtils.isNotBlank(questionBankHtml)) { if(ITEMSET_GENERATE_PDF) { Response generateResponse = HttpRestUtil.makePostRequest(PRINT_SERVICE_BASE_URL + "/v1/print/preview/generate?fileUrl=" + questionBankHtml, new HashMap<>(), new HashMap<>()); if (generateResponse.getResponseCode() == ResponseCode.OK) { String itemsetPreviewUrl = (String)generateResponse.getResult().get(ContentAPIParams.pdfUrl.name()); if(StringUtils.isNotBlank(itemsetPreviewUrl)) return publishFinalizeUtil.uploadFile(itemsetPreviewUrl, node, basePath); else throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Itemset generated previewUrl is empty. Please Try Again After Sometime!"); }else { if (generateResponse.getResponseCode() == ResponseCode.CLIENT_ERROR) { TelemetryManager.error("Client Error during Generate Itemset previewUrl: " + generateResponse.getParams().getErrmsg() + " :: " + generateResponse.getResult()); throw new ClientException(generateResponse.getParams().getErr(), generateResponse.getParams().getErrmsg()); } else { TelemetryManager.error("Server Error during Generate Itemset preiewUrl: " + generateResponse.getParams().getErrmsg() + " :: " + generateResponse.getResult()); throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Error During generate Itemset previewUrl. Please Try Again After Sometime!"); } } }else { return publishFinalizeUtil.uploadFile(questionBankHtml, node, basePath); } } } return null; } PublishFinalizer(String basePath, String contentId); void setItemsetPublishManager(ItemsetPublishManager itemsetPublishManager); void setPublishFinalizeUtil(PublishFinalizeUtil publishFinalizeUtil); Response finalize(Map<String, Object> parameterMap); void enrichCollection(Node node, List<Map<String, Object>> children); String generateTOC(Node node, Map<String, Object> content); }
PublishFinalizer extends BaseFinalizer { protected String getItemsetPreviewUrl(Node node) throws Exception { List<Relation> outRelations = node.getOutRelations(); if(CollectionUtils.isEmpty(outRelations)) { return null; } List<String> itemSetRelations = outRelations.stream() .filter(r -> StringUtils.equalsIgnoreCase(r.getEndNodeObjectType(), "ItemSet")) .map(x -> x.getEndNodeId()).collect(Collectors.toList()); if(CollectionUtils.isNotEmpty(itemSetRelations)){ String questionBankHtml = itemsetPublishManager.publish(itemSetRelations); if(StringUtils.isNotBlank(questionBankHtml)) { if(ITEMSET_GENERATE_PDF) { Response generateResponse = HttpRestUtil.makePostRequest(PRINT_SERVICE_BASE_URL + "/v1/print/preview/generate?fileUrl=" + questionBankHtml, new HashMap<>(), new HashMap<>()); if (generateResponse.getResponseCode() == ResponseCode.OK) { String itemsetPreviewUrl = (String)generateResponse.getResult().get(ContentAPIParams.pdfUrl.name()); if(StringUtils.isNotBlank(itemsetPreviewUrl)) return publishFinalizeUtil.uploadFile(itemsetPreviewUrl, node, basePath); else throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Itemset generated previewUrl is empty. Please Try Again After Sometime!"); }else { if (generateResponse.getResponseCode() == ResponseCode.CLIENT_ERROR) { TelemetryManager.error("Client Error during Generate Itemset previewUrl: " + generateResponse.getParams().getErrmsg() + " :: " + generateResponse.getResult()); throw new ClientException(generateResponse.getParams().getErr(), generateResponse.getParams().getErrmsg()); } else { TelemetryManager.error("Server Error during Generate Itemset preiewUrl: " + generateResponse.getParams().getErrmsg() + " :: " + generateResponse.getResult()); throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Error During generate Itemset previewUrl. Please Try Again After Sometime!"); } } }else { return publishFinalizeUtil.uploadFile(questionBankHtml, node, basePath); } } } return null; } PublishFinalizer(String basePath, String contentId); void setItemsetPublishManager(ItemsetPublishManager itemsetPublishManager); void setPublishFinalizeUtil(PublishFinalizeUtil publishFinalizeUtil); Response finalize(Map<String, Object> parameterMap); void enrichCollection(Node node, List<Map<String, Object>> children); String generateTOC(Node node, Map<String, Object> content);  }