use of com.adobe.acs.commons.quickly.results.Result in project acs-aem-commons by Adobe-Consulting-Services.
the class QuicklyEngineImpl method getJSONResults.
private JSONObject getJSONResults(Command cmd, SlingHttpServletRequest request, final Collection<Result> results) throws JSONException {
final JSONObject json = new JSONObject();
json.put(KEY_RESULTS, new JSONArray());
final ValueMap requestConfig = new ValueMapDecorator(new HashMap<String, Object>());
// Collect all items collected from OSGi Properties
requestConfig.putAll(this.config);
// Add Request specific configurations
requestConfig.put(AuthoringUIMode.class.getName(), authoringUIModeService.getAuthoringUIMode(request));
for (final Result result : results) {
final JSONObject tmp = resultBuilder.toJSON(cmd, result, requestConfig);
if (tmp != null) {
json.accumulate(KEY_RESULTS, tmp);
}
}
return json;
}
use of com.adobe.acs.commons.quickly.results.Result in project acs-aem-commons by Adobe-Consulting-Services.
the class LastModifiedOperationImpl method withoutParams.
@Override
protected List<Result> withoutParams(final SlingHttpServletRequest request, final SlingHttpServletResponse response, final Command cmd) {
final List<Result> results = new ArrayList<Result>();
final Result infoResult = new Result.Builder("lastmod [ userId ] [ 1s | 2m | 3h | 4d | 5w | 6M | 7y ]").description("Returns the last modified Pages. Defaults to: me 1d").build();
results.add(infoResult);
// Default to "lastmod me 1d"
results.addAll(this.withParams(request, response, cmd));
return results;
}
use of com.adobe.acs.commons.quickly.results.Result in project acs-aem-commons by Adobe-Consulting-Services.
the class DuckDuckGoDocsOperationImpl method withoutParams.
@Override
protected List<Result> withoutParams(final SlingHttpServletRequest request, final SlingHttpServletResponse response, final Command cmd) {
final List<Result> results = new ArrayList<Result>();
final Result result = new Result.Builder("docs.adobe.com").description("http://docs.adobe.com").action(new Action.Builder().uri("http://docs.adobe.com").target(Action.Target.BLANK).build()).build();
results.add(result);
return results;
}
use of com.adobe.acs.commons.quickly.results.Result in project acs-aem-commons by Adobe-Consulting-Services.
the class DuckDuckGoDocsOperationImpl method withParams.
@Override
protected List<Result> withParams(final SlingHttpServletRequest request, final SlingHttpServletResponse response, final Command cmd) {
final List<Result> results = new ArrayList<Result>();
final Map<String, String> params = new HashMap<String, String>();
params.put("q", "site:docs.adobe.com/docs/en/" + productName + "/" + aemVersion + " AND " + cmd.getParam());
final Result result = new Result.Builder("Search AEM documentation").description("Search for: " + cmd.getParam()).action(new Action.Builder().uri("https://duckduckgo.com").target(Action.Target.BLANK).params(params).build()).build();
results.add(result);
return results;
}
use of com.adobe.acs.commons.quickly.results.Result in project acs-aem-commons by Adobe-Consulting-Services.
the class LastModifiedOperationImpl method withParams.
@Override
protected List<Result> withParams(final SlingHttpServletRequest request, final SlingHttpServletResponse response, final Command cmd) {
final long start = System.currentTimeMillis();
final List<Result> results = new ArrayList<Result>();
final ResourceResolver resourceResolver = request.getResourceResolver();
final PageManager pageManager = resourceResolver.adaptTo(PageManager.class);
final List<Resource> pages = this.getLastModifiedPages(resourceResolver, cmd);
log.debug("LastModified pages -- [ {} ] results", pages.size());
for (final Resource resource : pages) {
final Page page = pageManager.getContainingPage(resource);
if (page == null) {
continue;
}
final String title = TextUtil.getFirstNonEmpty(page.getTitle(), page.getPageTitle(), page.getNavigationTitle(), page.getName());
final String description = page.getPath() + " by " + page.getLastModifiedBy() + " at " + DATE_FORMAT.format(page.getLastModified().getTime());
results.add(new Result.Builder(title).path(page.getPath()).description(description).resultType(OpenResultSerializerImpl.TYPE).build());
}
log.debug("Lastmod - Execution time: {} ms", System.currentTimeMillis() - start);
return results;
}
Aggregations