class OperationsApiServiceImpl implements OperationsApiService {

    @Override
    public ResponseEntity<Operation> getOperation(String spaceGuid, String operationId, String embed) {
        Operation operation = getOperation(operationId);
        if (!operation.getSpaceId()
                      .equals(spaceGuid)) {
            LOGGER.info(MessageFormat.format(org.cloudfoundry.multiapps.controller.core.Messages.OPERATION_SPACE_MISMATCH, operationId,
                                             operation.getSpaceId(), spaceGuid));
            throw new NotFoundException(org.cloudfoundry.multiapps.controller.persistence.Messages.OPERATION_NOT_FOUND, operationId);
        }
        if ("messages".equals(embed)) {
            operation = ImmutableOperation.copyOf(operation)
                                          .withMessages(getOperationMessages(operation));
            if (operation.getState() == Operation.State.ERROR && !hasErrorMessage(operation)) {
                LOGGER.error("MTA operation \"{}\" is in error state, but has no error messages.", operation.getProcessId());
            }
        }
        return ResponseEntity.ok()
                             .body(operation);
    }

}