Skip to content

Commit

Permalink
Merge pull request #90 from RWS/update-docs-module
Browse files Browse the repository at this point in the history
Update docs module
  • Loading branch information
dxasupport authored Apr 9, 2024
2 parents e595af3 + a66d5cf commit 86c4ac1
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ protected String getAreaName() {
*
* @return The view resolver.
*/
/*
@Bean
public ViewResolver viewResolver() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
Expand All @@ -51,6 +52,7 @@ public ViewResolver viewResolver() {
viewResolver.setOrder(Ordered.LOWEST_PRECEDENCE);
return viewResolver;
}
*/

@Bean
public ObjectMapper objectMapper() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ public class DynamicDocumentationPageController extends BaseController {
@Autowired
private MainController mainController;

/*
@RequestMapping(value = {"/"}, method = GET)
public String home() {
return mainController.home();
}
*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ public IshController() {
*/
@RequestMapping(method = {GET, POST}, value = "/api/page/{publicationId}/{pageId}/**",
produces = {APPLICATION_JSON_VALUE})
public ModelAndView getPage(@PathVariable Integer publicationId,
@PathVariable Integer pageId,
public ModelAndView getPage(@PathVariable("publicationId") Integer publicationId,
@PathVariable("pageId") Integer pageId,
@RequestParam(value = "conditions", defaultValue = "") String conditions,
final HttpServletRequest request,
final HttpServletResponse response) throws ContentProviderException, IOException {
Expand Down Expand Up @@ -148,8 +148,8 @@ public ModelAndView getPage(@PathVariable Integer publicationId,
@RequestMapping(method = GET, value = "/binary/{publicationId}/{binaryId}/**", produces = MediaType.ALL_VALUE)
@ResponseBody
public void getBinaryResource(HttpServletResponse response,
@PathVariable String publicationId,
@PathVariable String binaryId) throws ContentProviderException, BadRequestException, NotFoundException, IOException {
@PathVariable("publicationId") String publicationId,
@PathVariable("binaryId") String binaryId) throws ContentProviderException, BadRequestException, NotFoundException, IOException {
int publicationIdInt = -1;
try {
publicationIdInt = Integer.parseInt(publicationId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ public class MainController {
*
* @return Home page for Docs (all the publications)
*/
/*
@RequestMapping(value = {"/home", "/publications/**", "/publications/{value:.+$}"}, method = GET)
public String home(){
return getHomeView();
}
*/

/**
* Home page.
Expand All @@ -71,12 +73,14 @@ public String home(){
* @return Publication home page content
* @throws ContentProviderException in case if data retrieving fails
*/
/*
@RequestMapping(value = "/{publicationId:[0-9]+}", method = GET)
public String home(@PathVariable("publicationId") String publicationId,
HttpServletRequest request) throws ContentProviderException {
setPageModelOnRequest(publicationId, null, request);
return getHomeView();
}
*/

/**
* Home page.
Expand All @@ -87,17 +91,21 @@ public String home(@PathVariable("publicationId") String publicationId,
* @return content of the page
* @throws ContentProviderException in case if data retrieving fails
*/
/*
@RequestMapping(value = "/{publicationId:[0-9]+}/{pageId}/**", method = GET)
public String home(@PathVariable("publicationId") String publicationId,
@PathVariable("pageId") String pageId,
HttpServletRequest request) throws ContentProviderException {
setPageModelOnRequest(publicationId, pageId, request);
return getHomeView();
}
*/

/*
private String getHomeView() {
return "home";
}
*/

private void setPageModelOnRequest(String publicationId, String pageId, HttpServletRequest request) throws ContentProviderException {
final DocsLocalization localization = (DocsLocalization) webRequestContext.getLocalization();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ public class TridionDocsPageController {
* @param response Http response
* @return Redirects to the home page.
*/
/*
@RequestMapping(method = RequestMethod.GET, value = "/ish/",
produces = {MediaType.TEXT_HTML_VALUE, MediaType.ALL_VALUE})
public String handleGetPage(HttpServletRequest request, HttpServletResponse response) {
return "redirect:home";
}
*/
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.sdl.dxa.modules.ish.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

@Data
public class CustomMeta {

@JsonProperty("Key")
private final String key;

@JsonProperty("Value")
private final String value;
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ public class Publication {

@JsonProperty("LogicalId")
private String logicalId;

@JsonProperty("CustomMetas")
private List<CustomMeta> customMetas;
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,13 @@ private com.sdl.dxa.modules.ish.model.Publication buildPublicationFrom(Publicati
CustomMetaConnection customMeta = publication.getCustomMetas();
if (customMeta == null) return result;

List<com.sdl.dxa.modules.ish.model.CustomMeta> customMetas = new ArrayList<>();

for (CustomMetaEdge customMetaEdge : customMeta.getEdges()) {
String value = customMetaEdge.getNode().getValue();
String key = customMetaEdge.getNode().getKey();
customMetas.add(new com.sdl.dxa.modules.ish.model.CustomMeta(key, value));

switch (key) {
case PublicationTitleMeta:
result.setTitle(value);
Expand Down Expand Up @@ -180,6 +184,8 @@ private com.sdl.dxa.modules.ish.model.Publication buildPublicationFrom(Publicati
}
}

result.setCustomMetas(customMetas);

return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ private List<Topic> getTopics(DynamicWidget dynamicWidget, List<Topic> topics, P
*/
@RequestMapping(method = GET, value ="/binary/{publicationId}/{binaryId}/**" ,produces = MediaType.ALL_VALUE)
@ResponseBody
public ResponseEntity<InputStreamResource> getBinaryResource(@PathVariable Integer publicationId,
@PathVariable Integer binaryId)
public ResponseEntity<InputStreamResource> getBinaryResource(@PathVariable("publicationId") Integer publicationId,
@PathVariable("binaryId") Integer binaryId)
throws ContentProviderException, IOException {

HttpHeaders responseHeaders = new HttpHeaders();
Expand Down

0 comments on commit 86c4ac1

Please sign in to comment.