Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1103 from haileyajohnson/hajohns/catalog-templates
Browse files Browse the repository at this point in the history
Hajohns/catalog templates
  • Loading branch information
haileyajohnson committed Jun 19, 2018
2 parents 42027b8 + 2e47930 commit 11b9d63
Show file tree
Hide file tree
Showing 22 changed files with 1,440 additions and 239 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
import thredds.client.catalog.Catalog;
import thredds.client.catalog.Dataset;
import thredds.core.CatalogManager;
import thredds.core.ConfigCatalogHtmlWriter;
import thredds.core.TdsRequestedDataset;

import java.io.FileNotFoundException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.*;

/**
* LocalCatalogServiceController using client/server catalogs
Expand All @@ -39,7 +39,7 @@ public class CatalogServiceController {
private CatalogManager catalogManager;

@Autowired
ConfigCatalogHtmlWriter writer;
CatalogViewContextParser parser;

@RequestMapping(value = "**", method = {RequestMethod.GET})
protected ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response, CatalogRequest params) throws Exception {
Expand All @@ -65,32 +65,37 @@ protected ModelAndView handleRequest(HttpServletRequest request, HttpServletResp
if (catalog == null)
throw new FileNotFoundException(request.getRequestURI());

// Otherwise, handle catalog as indicated by "command".
if (isHtml) {
return handleHTMLRequest(request, response, catalog, params);
} else {
return handleXMLRequest(request, response, catalog, params);
}
}

protected ModelAndView handleXMLRequest(HttpServletRequest request, HttpServletResponse response, Catalog catalog, CatalogRequest params) throws Exception {
if (params.dataset != null) {
Dataset dataset = catalog.findDatasetByID(params.dataset);
if (dataset == null)
throw new FileNotFoundException("Did not find dataset [" + params.dataset + "] in catalog [" + baseUriString + "].");

if (isHtml) {
int i = writer.showDataset(baseUriString, dataset, request, response, true);
return null;
throw new FileNotFoundException("Did not find dataset [" + params.dataset + "] in catalog [" + request.getRequestURL().toString() + "].");

} else {
Catalog subsetCat = catalog.subsetCatalogOnDataset(dataset);
return new ModelAndView("threddsInvCatXmlView", "catalog", subsetCat);
}
Catalog subsetCat = catalog.subsetCatalogOnDataset(dataset);
return new ModelAndView("threddsInvCatXmlView", "catalog", subsetCat);

} else {
if (isHtml) {
int i = writer.writeCatalog(request, response, catalog, true);
return null;

} else {
return new ModelAndView("threddsInvCatXmlView", "catalog", catalog);
}
return new ModelAndView("threddsInvCatXmlView", "catalog", catalog);
}
}

protected ModelAndView handleHTMLRequest(HttpServletRequest request, HttpServletResponse response, Catalog catalog, CatalogRequest params) throws Exception {
if (params.dataset != null) {
Dataset dataset = catalog.findDatasetByID(params.dataset);
if (dataset == null)
throw new FileNotFoundException("Did not find dataset [" + params.dataset + "] in catalog [" + request.getRequestURL().toString() + "].");
return new ModelAndView("templates/dataset", parser.getDatasetViewContext(dataset, request,true));
} else {
return new ModelAndView("templates/catalog", parser.getCatalogViewContext(catalog, true));
}
}

/* private ModelAndView handlePublicDocumentRequest(HttpServletRequest request, HttpServletResponse response, String path)
throws IOException, ServletException {
Expand Down
Loading

0 comments on commit 11b9d63

Please sign in to comment.