Changeset 4315
- Timestamp:
- 01/21/14 13:28:41 (10 years ago)
- Location:
- vlo/trunk/vlo_web_app/src/main/java/eu/clarin/cmdi/vlo
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
vlo/trunk/vlo_web_app/src/main/java/eu/clarin/cmdi/vlo/dao/SolrDao.java
r4182 r4315 34 34 return solrServer; 35 35 } 36 36 37 37 /** 38 * Basic sanitising of Solr queries. 39 * 40 * Query is based on the URL to the VLO web application. Also, explain 41 * about the URL and ?fq=language:dutch 42 * Assume filters have the form a:b 43 * like for example language:dutch 44 * 38 * Basic sanitising of Solr queries. 39 * 40 * Query is based on the URL to the VLO web application. Also, explain about 41 * the URL and ?fq=language:dutch Assume filters have the form a:b like for 42 * example language:dutch 43 * 45 44 * @param query 46 * @return 45 * @return 47 46 */ 48 private SolrQuery sanitise (SolrQuery query){49 47 private SolrQuery sanitise(SolrQuery query) { 48 50 49 // String [] facetsFromConfig; 51 52 50 // try and get the filters facets from the query 53 String 51 String[] filtersInQuery; 54 52 filtersInQuery = query.getFilterQueries(); 55 53 56 54 if (filtersInQuery == null) { 57 55 // the query does not contain filters … … 67 65 for (String filter : filtersInQuery) { 68 66 // split up a filter, look at the string preceeding the semicolon 69 String facetInFilter = filter.split(":") 70 67 String facetInFilter = filter.split(":")[0]; 68 71 69 if (facetsDefined.contains(facetInFilter)) { 72 70 // facet in the filter is in the set that is defined by the config file … … 98 96 99 97 public SolrDocument getSolrDocument(String docId) { 98 if (docId == null) { 99 throw new NullPointerException("Cannot get SOLR document for null docId"); 100 } 100 101 SolrDocument result = null; 101 102 SolrQuery query = new SolrQuery(); -
vlo/trunk/vlo_web_app/src/main/java/eu/clarin/cmdi/vlo/pages/ShowResultPage.java
r4307 r4315 21 21 import org.apache.wicket.Component; 22 22 import org.apache.wicket.MarkupContainer; 23 import org.apache.wicket.RestartResponseException; 23 24 import org.apache.wicket.ajax.AjaxRequestTarget; 24 25 import org.apache.wicket.request.mapper.parameter.PageParameters; … … 74 75 75 76 final StringValue docIdParam = getPageParameters().get(PARAM_DOC_ID); 76 if (docIdParam == null) { 77 throw new RuntimeException("No document id was specified. Cannot construct result page."); 78 } 79 //Document ID is assumed to have been encoded (typcially in DocumentLinkPanel) decode here 80 final String docId = UrlDecoder.QUERY_INSTANCE.decode( 81 docIdParam.toString(), 82 Application.get().getRequestCycleSettings().getResponseRequestEncoding()); // get current character set from request cycle 83 SolrDocument solrDocument = DaoLocator.getSearchResultsDao().getSolrDocument(docId); 84 85 if (solrDocument != null) { 86 final SearchPageQuery query = new SearchPageQuery(currentParam); 87 88 // create parameters from the query, and add them with session related parameters 89 PageParameters newParam = new PageParameters(query.getPageParameters()); 90 // add the session persistent parameters 91 newParam.mergeWith(VloSession.get().getVloSessionPageParameters()); 92 93 BookmarkablePageLink<String> backLink = new BookmarkablePageLink<String>("backLink", FacetedSearchPage.class, newParam); 94 add(backLink); 95 String href = getHref(docId); 96 if (href != null) { 97 add(new ExternalLink("openBrowserLink", href, new ResourceModel(Resources.OPEN_IN_ORIGINAL_CONTEXT).getObject())); 77 if (docIdParam == null || docIdParam.isNull()) { 78 LOG.warn("No document id was specified. Cannot construct result page."); 79 throw new RestartResponseException(new ResultNotFoundPage(currentParam)); 80 } else { 81 //Document ID is assumed to have been encoded (typcially in DocumentLinkPanel) decode here 82 final String docId = UrlDecoder.QUERY_INSTANCE.decode( 83 docIdParam.toString(), 84 Application.get().getRequestCycleSettings().getResponseRequestEncoding()); // get current character set from request cycle 85 86 final SolrDocument solrDocument = DaoLocator.getSearchResultsDao().getSolrDocument(docId); 87 if (solrDocument != null) { 88 final SearchPageQuery query = new SearchPageQuery(currentParam); 89 90 // create parameters from the query, and add them with session related parameters 91 PageParameters newParam = new PageParameters(query.getPageParameters()); 92 // add the session persistent parameters 93 newParam.mergeWith(VloSession.get().getVloSessionPageParameters()); 94 95 BookmarkablePageLink<String> backLink = new BookmarkablePageLink<String>("backLink", FacetedSearchPage.class, newParam); 96 add(backLink); 97 String href = getHref(docId); 98 if (href != null) { 99 add(new ExternalLink("openBrowserLink", href, new ResourceModel(Resources.OPEN_IN_ORIGINAL_CONTEXT).getObject())); 100 } else { 101 add(new Label("openBrowserLink", new ResourceModel(Resources.ORIGINAL_CONTEXT_NOT_AVAILABLE).getObject())); 102 } 103 addAttributesTable(solrDocument); 104 105 /* If there are any, add the link or links to landing pages 106 * contained in the solr document. 107 */ 108 addLandingPageLinks(solrDocument); 109 110 // also, if there are any, add the link or links to search pages 111 addSearchPageLinks(solrDocument); 112 113 // add the rest of the resource links to the result page 114 addResourceLinks(solrDocument); 115 116 addSearchServiceForm(solrDocument); 117 118 addCompleteCmdiView(solrDocument); 119 120 add(new AjaxLazyLoadPanel("prevNextHeader") { 121 122 @Override 123 public Component getLazyLoadComponent(String markupId) { 124 return new PrevNextHeaderPanel(markupId, docId, query); 125 } 126 127 @Override 128 public Component getLoadingComponent(String markupId) { 129 return new PrevNextHeaderPanel(markupId); 130 } 131 }); 98 132 } else { 99 add(new Label("openBrowserLink", new ResourceModel(Resources.ORIGINAL_CONTEXT_NOT_AVAILABLE).getObject())); 100 } 101 addAttributesTable(solrDocument); 102 103 /* If there are any, add the link or links to landing pages 104 * contained in the solr document. 105 */ 106 addLandingPageLinks(solrDocument); 107 108 // also, if there are any, add the link or links to search pages 109 addSearchPageLinks(solrDocument); 110 111 // add the rest of the resource links to the result page 112 addResourceLinks(solrDocument); 113 114 addSearchServiceForm(solrDocument); 115 116 addCompleteCmdiView(solrDocument); 117 118 add(new AjaxLazyLoadPanel("prevNextHeader") { 119 120 @Override 121 public Component getLazyLoadComponent(String markupId) { 122 return new PrevNextHeaderPanel(markupId, docId, query); 123 } 124 125 @Override 126 public Component getLoadingComponent(String markupId) { 127 return new PrevNextHeaderPanel(markupId); 128 } 129 }); 130 } else { 131 setResponsePage(new ResultNotFoundPage(currentParam)); 133 setResponsePage(new ResultNotFoundPage(currentParam)); 134 } 132 135 } 133 136
Note: See TracChangeset
for help on using the changeset viewer.