use of org.kuali.kfs.sys.rest.resource.responses.LookupResponse in project cu-kfs by CU-CommunityApps.
the class LookupResource method getLookup.
@GET
public Response getLookup() {
Class classForType = businessObjectEntry.getBusinessObjectClass();
if (!isAuthorizedForLookup(classForType)) {
Person user = getUserSessionFromRequest(this.servletRequest).getPerson();
AuthorizationException authorizationException = new AuthorizationException(user.getPrincipalName(), "lookup", classForType.getName());
Response.ResponseBuilder responseBuilder = Response.status(Response.Status.FORBIDDEN);
responseBuilder.entity(authorizationException);
throw new ForbiddenException(responseBuilder.build());
}
List<FormAttribute> lookupAttributes = getLookupAttributeForClass(classForType);
for (FormAttribute lookupAttribute : lookupAttributes) {
setNestedLookupFields(lookupAttribute, classForType);
}
String title = getLookupDictionary().getLookupTitle(classForType);
if (StringUtils.isEmpty(title)) {
title = businessObjectEntry.getObjectLabel() + " Lookup";
}
SearchService searchService = getLookupDictionary().getSearchService(classForType);
if (searchService == null) {
LOG.error(businessObjectEntry.getName() + " seems to be missing a SearchService! A lookup cannot " + "be queried without a SearchService.");
throw new InternalServerErrorException("The requested lookup is currently unavailable.");
}
LookupResponse.Create create = null;
if (shouldCreateNewUrlBeIncluded(classForType)) {
create = getCreateBlock(classForType);
}
LookupResponse.Results results = new LookupResponse.Results(searchService.getSearchResultsAttributes(classForType), getBusinessObjectDictionaryService().getLookupDefaultSortFieldNames(classForType));
LookupResponse lookupResponse = new LookupResponse(title, lookupAttributes, create, results);
return Response.ok(lookupResponse).build();
}
Aggregations