use of org.craftercms.studio.model.rest.PaginatedResultList in project studio by craftercms.
the class AuditController method getAuditLog.
@GetMapping("/api/2/audit")
public ResponseBody getAuditLog(@RequestParam(value = REQUEST_PARAM_SITEID, required = false) String siteId, @RequestParam(value = REQUEST_PARAM_SITE_NAME, required = false) String siteName, @RequestParam(value = REQUEST_PARAM_OFFSET, required = false, defaultValue = "0") int offset, @RequestParam(value = REQUEST_PARAM_LIMIT, required = false, defaultValue = "10") int limit, @RequestParam(value = REQUEST_PARAM_USER, required = false, defaultValue = "") String user, @RequestParam(value = REQUEST_PARAM_OPERATIONS, required = false) List<String> operations, @RequestParam(value = REQUEST_PARAM_INCLUDE_PARAMETERS, required = false) boolean includeParameters, @RequestParam(value = REQUEST_PARAM_DATE_FROM, required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) ZonedDateTime dateFrom, @RequestParam(value = REQUEST_PARAM_DATE_TO, required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) ZonedDateTime dateTo, @RequestParam(value = REQUEST_PARAM_TARGET, required = false) String target, @RequestParam(value = REQUEST_PARAM_ORIGIN, required = false) String origin, @RequestParam(value = REQUEST_PARAM_CLUSTER_NODE_ID, required = false) String clusterNodeId, @RequestParam(value = REQUEST_PARAM_SORT, required = false) String sort, @RequestParam(value = REQUEST_PARAM_ORDER, required = false) String order) throws SiteNotFoundException {
if (StringUtils.isNotEmpty(siteId) && !siteService.existsById(siteId)) {
throw new SiteNotFoundException("Site " + siteId + " not found.");
}
if (StringUtils.isNotEmpty(siteName) && !siteService.existsByName(siteName)) {
throw new SiteNotFoundException("Site " + siteName + " not found.");
}
int total = auditService.getAuditLogTotal(siteId, siteName, user, operations, includeParameters, dateFrom, dateTo, target, origin, clusterNodeId);
List<AuditLog> auditLog = auditService.getAuditLog(siteId, siteName, offset, limit, user, operations, includeParameters, dateFrom, dateTo, target, origin, clusterNodeId, sort, order);
ResponseBody responseBody = new ResponseBody();
PaginatedResultList<AuditLog> result = new PaginatedResultList<>();
result.setTotal(total);
result.setLimit(CollectionUtils.isEmpty(auditLog) ? 0 : auditLog.size());
result.setOffset(offset);
result.setEntities(RESULT_KEY_AUDIT_LOG, auditLog);
result.setResponse(ApiResponse.OK);
responseBody.setResult(result);
return responseBody;
}
use of org.craftercms.studio.model.rest.PaginatedResultList in project studio by craftercms.
the class CmisController method list.
@GetMapping("/api/2/cmis/list")
public ResponseBody list(@RequestParam(value = "siteId", required = true) String siteId, @RequestParam(value = "cmisRepoId", required = true) String cmisRepoId, @RequestParam(value = "path", required = false, defaultValue = StringUtils.EMPTY) String path, @RequestParam(value = "offset", required = false, defaultValue = "0") int offset, @RequestParam(value = "limit", required = false, defaultValue = "10") int limit) throws CmisRepositoryNotFoundException, CmisTimeoutException, CmisUnavailableException, ConfigurationException {
List<CmisContentItem> cmisContentItems = cmisService.list(siteId, cmisRepoId, path);
List<CmisContentItem> paginatedItems = PaginationUtils.paginate(cmisContentItems, offset, limit, StringUtils.EMPTY);
ResponseBody responseBody = new ResponseBody();
PaginatedResultList<CmisContentItem> result = new PaginatedResultList<>();
result.setTotal(cmisContentItems.size());
result.setOffset(offset);
result.setLimit(paginatedItems.size());
result.setResponse(OK);
responseBody.setResult(result);
result.setEntities(RESULT_KEY_ITEMS, paginatedItems);
return responseBody;
}
use of org.craftercms.studio.model.rest.PaginatedResultList in project studio by craftercms.
the class CmisController method search.
@GetMapping("/api/2/cmis/search")
public ResponseBody search(@RequestParam(value = "siteId", required = true) String siteId, @RequestParam(value = "cmisRepoId", required = true) String cmisRepoId, @RequestParam(value = "searchTerm", required = true) String searchTerm, @RequestParam(value = "path", required = false, defaultValue = StringUtils.EMPTY) String path, @RequestParam(value = "offset", required = false, defaultValue = "0") int offset, @RequestParam(value = "limit", required = false, defaultValue = "10") int limit) throws CmisRepositoryNotFoundException, CmisTimeoutException, CmisUnavailableException, ConfigurationException {
List<CmisContentItem> cmisContentItems = cmisService.search(siteId, cmisRepoId, searchTerm, path);
List<CmisContentItem> paginatedItems = PaginationUtils.paginate(cmisContentItems, offset, limit, StringUtils.EMPTY);
ResponseBody responseBody = new ResponseBody();
PaginatedResultList<CmisContentItem> result = new PaginatedResultList<>();
result.setTotal(cmisContentItems.size());
result.setOffset(offset);
result.setLimit(paginatedItems.size());
result.setResponse(OK);
responseBody.setResult(result);
result.setEntities(RESULT_KEY_ITEMS, paginatedItems);
return responseBody;
}
use of org.craftercms.studio.model.rest.PaginatedResultList in project studio by craftercms.
the class GroupsController method getAllGroups.
/**
* Get groups API
*
* @param offset offset parameter
* @param limit limit parameter
* @param sort sort parameter
* @return Response containing list of groups
*/
@GetMapping("/api/2/groups")
public ResponseBody getAllGroups(@RequestParam(value = REQUEST_PARAM_OFFSET, required = false, defaultValue = "0") int offset, @RequestParam(value = REQUEST_PARAM_LIMIT, required = false, defaultValue = "10") int limit, @RequestParam(value = REQUEST_PARAM_SORT, required = false, defaultValue = StringUtils.EMPTY) String sort) throws ServiceLayerException, OrganizationNotFoundException {
int total = 0;
total = groupService.getAllGroupsTotal(DEFAULT_ORGANIZATION_ID);
List<Group> groups = groupService.getAllGroups(DEFAULT_ORGANIZATION_ID, offset, limit, sort);
ResponseBody responseBody = new ResponseBody();
PaginatedResultList<Group> result = new PaginatedResultList<>();
result.setTotal(total);
result.setOffset(offset);
result.setLimit(CollectionUtils.isEmpty(groups) ? 0 : groups.size());
result.setResponse(OK);
result.setEntities(RESULT_KEY_GROUPS, groups);
responseBody.setResult(result);
return responseBody;
}
use of org.craftercms.studio.model.rest.PaginatedResultList in project studio by craftercms.
the class MarketplaceController method searchPlugins.
@SuppressWarnings("unchecked")
@GetMapping("/search")
public ResponseBody searchPlugins(@RequestParam(required = false) String type, @RequestParam(required = false) String keywords, @RequestParam(required = false, defaultValue = "false") boolean showIncompatible, @RequestParam(required = false, defaultValue = "0") long offset, @RequestParam(required = false, defaultValue = "10") long limit) throws MarketplaceException {
Map<String, Object> page = marketplaceService.searchPlugins(type, keywords, showIncompatible, offset, limit);
ResponseBody response = new ResponseBody();
PaginatedResultList<Map<String, Object>> result = new PaginatedResultList<>();
result.setResponse(ApiResponse.OK);
result.setEntities(RESULT_KEY_PLUGINS, (List<Map<String, Object>>) page.get(Constants.RESULT_ITEMS));
result.setTotal((int) page.get(Constants.RESULT_TOTAL));
result.setOffset((int) offset);
result.setLimit((int) limit);
response.setResult(result);
return response;
}
Aggregations