protected IBundleProvider toResourceList(Object response) throws InternalErrorException { if (response == null) { return BundleProviders.newEmptyList(); } else if (response instanceof IBundleProvider) { return (IBundleProvider) response; } else if (response instanceof IBaseResource) { return BundleProviders.newList((IBaseResource) response); } else if (response instanceof Collection) { List<IBaseResource> retVal = new ArrayList<IBaseResource>(); for (Object next : ((Collection<?>) response)) { retVal.add((IBaseResource) next); } return BundleProviders.newList(retVal); } else if (response instanceof MethodOutcome) { IBaseResource retVal = ((MethodOutcome) response).getOperationOutcome(); if (retVal == null) { retVal = getContext().getResourceDefinition("OperationOutcome").newInstance(); } return BundleProviders.newList(retVal); } else { throw new InternalErrorException("Unexpected return type: " + response.getClass().getCanonicalName()); } }
if (response.getOperationOutcome() == null) { return Constants.STATUS_HTTP_204_NO_CONTENT;
@Override public Object invokeServer(IRestfulServer<?> theServer, RequestDetails theRequest) throws BaseServerResponseException, IOException { Object[] params = createParametersForServerRequest(theRequest); addParametersForServerRequest(theRequest, params); /* * No need to catch and handle exceptions here, we already handle them one level up including invoking interceptors * on them */ MethodOutcome response; Object methodReturn = invokeServerMethod(theServer, theRequest, params); if (methodReturn instanceof IBaseOperationOutcome) { response = new MethodOutcome(); response.setOperationOutcome((IBaseOperationOutcome) methodReturn); } else { response = (MethodOutcome) methodReturn; } if (response != null && response.getId() != null && response.getId().hasResourceType()) { if (getContext().getResourceDefinition(response.getId().getResourceType()) == null) { throw new InternalErrorException("Server method returned invalid resource ID: " + response.getId().getValue()); } } IBaseOperationOutcome outcome = response != null ? response.getOperationOutcome() : null; IBaseResource resource = response != null ? response.getResource() : null; return returnResponse(theServer, theRequest, response, outcome, resource); }
protected IBundleProvider toResourceList(Object response) throws InternalErrorException { if (response == null) { return BundleProviders.newEmptyList(); } else if (response instanceof IBundleProvider) { return (IBundleProvider) response; } else if (response instanceof IBaseResource) { return BundleProviders.newList((IBaseResource) response); } else if (response instanceof Collection) { List<IBaseResource> retVal = new ArrayList<IBaseResource>(); for (Object next : ((Collection<?>) response)) { retVal.add((IBaseResource) next); } return BundleProviders.newList(retVal); } else if (response instanceof MethodOutcome) { IBaseResource retVal = ((MethodOutcome) response).getOperationOutcome(); if (retVal == null) { retVal = getContext().getResourceDefinition("OperationOutcome").newInstance(); } return BundleProviders.newList(retVal); } else { throw new InternalErrorException("Unexpected return type: " + response.getClass().getCanonicalName()); } }
if (response.getOperationOutcome() == null) { return Constants.STATUS_HTTP_204_NO_CONTENT;
OperationOutcome oo = (OperationOutcome) outcome.getOperationOutcome();
@Override public boolean enrichAuditDatasetFromResponse(GenericFhirAuditDataset auditDataset, Object response, AuditContext auditContext) { // Domain Resource in the request? Extract Patient ID and Sensitivity at this point if (response instanceof IDomainResource) { addResourceData(auditDataset, (T) response); } if (response instanceof MethodOutcome) { MethodOutcome methodOutcome = (MethodOutcome) response; if (methodOutcome.getCreated() != null && methodOutcome.getCreated()) { auditDataset.setEventOutcomeIndicator(EventOutcomeIndicator.Success); } if (methodOutcome.getOperationOutcome() != null) { super.enrichAuditDatasetFromResponse(auditDataset, methodOutcome.getOperationOutcome(), auditContext); } else { auditDataset.setEventOutcomeIndicator(EventOutcomeIndicator.Success); } if (methodOutcome.getResource() != null && methodOutcome.getResource() instanceof IDomainResource) { addResourceData(auditDataset, (T) methodOutcome.getResource()); } else if (methodOutcome.getId() != null) { auditDataset.setResourceId(methodOutcome.getId()); if (methodOutcome.getId().hasResourceType()) { auditDataset.setAffectedResourceType(methodOutcome.getId().getResourceType()); } } } return super.enrichAuditDatasetFromResponse(auditDataset, response, auditContext); }
@Override public boolean enrichAuditDatasetFromResponse(GenericFhirAuditDataset auditDataset, Object response, AuditContext auditContext) { // Domain Resource in the request? Extract Patient ID and Sensitivity at this point if (response instanceof IDomainResource) { addResourceData(auditDataset, (T) response); } if (response instanceof MethodOutcome) { MethodOutcome methodOutcome = (MethodOutcome) response; if (methodOutcome.getCreated() != null && methodOutcome.getCreated()) { auditDataset.setEventOutcomeIndicator(EventOutcomeIndicator.Success); } if (methodOutcome.getOperationOutcome() != null) { super.enrichAuditDatasetFromResponse(auditDataset, methodOutcome.getOperationOutcome(), auditContext); } else { auditDataset.setEventOutcomeIndicator(EventOutcomeIndicator.Success); } if (methodOutcome.getResource() != null && methodOutcome.getResource() instanceof IDomainResource) { addResourceData(auditDataset, (T) methodOutcome.getResource()); } else if (methodOutcome.getId() != null) { auditDataset.setResourceId(methodOutcome.getId()); if (methodOutcome.getId().hasResourceType()) { auditDataset.setAffectedResourceType(methodOutcome.getId().getResourceType()); } } } return super.enrichAuditDatasetFromResponse(auditDataset, response, auditContext); }
@Override public Object invokeServer(IRestfulServer<?> theServer, RequestDetails theRequest) throws BaseServerResponseException, IOException { Object[] params = createParametersForServerRequest(theRequest); addParametersForServerRequest(theRequest, params); /* * No need to catch and handle exceptions here, we already handle them one level up including invoking interceptors * on them */ MethodOutcome response; Object methodReturn = invokeServerMethod(theServer, theRequest, params); if (methodReturn instanceof IBaseOperationOutcome) { response = new MethodOutcome(); response.setOperationOutcome((IBaseOperationOutcome) methodReturn); } else { response = (MethodOutcome) methodReturn; } if (response != null && response.getId() != null && response.getId().hasResourceType()) { if (getContext().getResourceDefinition(response.getId().getResourceType()) == null) { throw new InternalErrorException("Server method returned invalid resource ID: " + response.getId().getValue()); } } IBaseOperationOutcome outcome = response != null ? response.getOperationOutcome() : null; IBaseResource resource = response != null ? response.getResource() : null; return returnResponse(theServer, theRequest, response, outcome, resource); }