openSearchQuery.getTotalResults().toString());
}
}
private OpenSearchDescription buildOpenSearchDescriptor(String baseUri) {
OpenSearchDescription openSearchDescriptor = new OpenSearchDescription();
openSearchDescriptor.setShortName(SHORT_NAME);
openSearchDescriptor.setDescription(DESC);
openSearchDescriptor.setLongName(LONG_NAME);
openSearchDescriptor.setContact(CONTACT);
openSearchDescriptor.setDeveloper(DEVELOPER);
openSearchDescriptor.addLanguage(LANG);
openSearchDescriptor.setTags(TAGS);
openSearchDescriptor.addInputEncoding(ENCODING);
openSearchDescriptor.addOutputEncoding(ENCODING);
// set OpenSearch URL parameters
OpenSearchParameter severityParameter =
new OpenSearchParameter(SEVERIIY, URN_SEVERIIY, false);
OpenSearchParameter ftsParameter =
new OpenSearchParameter(FTS, OpenSearchParameter.OpenSearchParams.searchTerms
.toString(), false);
OpenSearchParameter assignedToParameter = new OpenSearchParameter();
assignedToParameter.setMandatory(false);
assignedToParameter.setParameterKey(ASSIGNED_TO);
assignedToParameter.setParameter(URN_ASSIGNED_TO);
// create Search URL & populate search parameters for browsers
OpenSearchUrl openSearchUrlForBrowsers = new OpenSearchUrl();
openSearchUrlForBrowsers.addOpenSearchParameter(ftsParameter);
openSearchUrlForBrowsers.setType(MediaType.TEXT_HTML);
// create Search URL & populate search parameters
OpenSearchUrl openSearchUrl = new OpenSearchUrl();
openSearchUrl.addOpenSearchParameter(severityParameter);
openSearchUrl.addOpenSearchParameter(ftsParameter);
openSearchUrl.addOpenSearchParameter(assignedToParameter);
openSearchUrl.setType(MediaType.TEXT_HTML);
// create open search base uri
StringBuilder openSearchUrlBuilder = new StringBuilder(baseUri);
if (baseUri.endsWith("/") && URL.startsWith("/")) {
openSearchUrlBuilder.append(URL.substring(1));
} else {
openSearchUrlBuilder.append(URL);
}
openSearchUrl.setBaseUri(openSearchUrlBuilder.toString());
openSearchUrlForBrowsers.setBaseUri(openSearchUrlBuilder.toString());
// add URLs to OpenSearch
openSearchDescriptor.addUrl(openSearchUrlForBrowsers);
openSearchDescriptor.addUrl(openSearchUrl);
// add OpenSearch Query element
OpenSearchQuery openSearchQuery = new OpenSearchQuery();
openSearchQuery.setCount(new BigInteger("10"));
openSearchQuery.setInputEncoding(ENCODING);
openSearchQuery.setLanguage(LANG);
openSearchQuery.setOutputEncoding(ENCODING);
openSearchQuery.setRole(OpenSearchQuery.QueryRole.example.toString());
openSearchQuery.setSearchTerms(SEARCH_TERM);
openSearchQuery.setStartIndex(new BigInteger(START_INDEX));
openSearchQuery.setStartPage(new BigInteger(START_PAGE));
openSearchQuery.setTitle(TITLE);
openSearchQuery.setTotalResults(new BigInteger(TOTAL_RESULT));
openSearchDescriptor.addQuery(openSearchQuery);
// add OpenSearch Images
OpenSearchImage openSearchImage;
openSearchImage =
OpenSearchUtils.createOpenSearchImage(MediaTypeUtils.IMAGE_JPEG, openSearchUrlBuilder
.toString() + "splash.jpg");
openSearchDescriptor.addNewImage(openSearchImage);
return openSearchDescriptor;
}