/** * Fetches multiple profiles using Data API. */ private FetchProfilesResult fetchProfilesFromService(ParticipantId user, List<String> addresses) { OperationQueue opQueue = new OperationQueue(); FetchProfilesRequest request = new FetchProfilesRequest(addresses); opQueue.fetchProfiles(request); OperationContextImpl context = new OperationContextImpl(waveletProvider, converterManager.getEventDataConverter(ProtocolVersion.DEFAULT), conversationUtil); OperationRequest operationRequest = opQueue.getPendingOperations().get(0); String opId = operationRequest.getId(); OperationUtil.executeOperation(operationRequest, operationRegistry, context, user); JsonRpcResponse jsonRpcResponse = context.getResponses().get(opId); FetchProfilesResult profileResults = (FetchProfilesResult) jsonRpcResponse.getData().get(ParamsProperty.FETCH_PROFILES_RESULT); return profileResults; }
waveletProvider, converterManager.getEventDataConverter(version), conversationUtil);
/** * Applies the operations within the context of the wavelet. * * @param operations the operations to apply * @param wavelet the wavelet which is the context in which this operation is * performed. * @param hashedVersion the version of the wavelet to which to apply the * operations to. * @param account the account for which to apply robot operations. */ void applyOperations(List<OperationRequest> operations, ReadableWaveletData wavelet, HashedVersion hashedVersion, RobotAccountData account) { // The robots we support should be sending us their version in their first // operation ProtocolVersion protocolVersion = OperationUtil.getProtocolVersion(operations); OperationContextImpl context = new OperationContextImpl(waveletProvider, converterManager.getEventDataConverter(protocolVersion), conversationUtil, new RobotWaveletData(wavelet, hashedVersion)); executeOperations(context, operations, account); handleResults(context, account); }
/** * Performs search using Data API. */ protected SearchResult performSearch(SearchRequest searchRequest, ParticipantId user) { OperationQueue opQueue = new OperationQueue(); opQueue.search(searchRequest.getQuery(), searchRequest.getIndex(), searchRequest.getNumResults()); OperationContextImpl context = new OperationContextImpl(waveletProvider, converterManager.getEventDataConverter(ProtocolVersion.DEFAULT), conversationUtil); LOG.fine( "Performing query: " + searchRequest.getQuery() + " [" + searchRequest.getIndex() + ", " + (searchRequest.getIndex() + searchRequest.getNumResults()) + "]"); OperationRequest operationRequest = opQueue.getPendingOperations().get(0); String opId = operationRequest.getId(); OperationUtil.executeOperation(operationRequest, operationRegistry, context, user); JsonRpcResponse jsonRpcResponse = context.getResponses().get(opId); SearchResult searchResult = (SearchResult) jsonRpcResponse.getData().get(ParamsProperty.SEARCH_RESULTS); return searchResult; } }
EventMessageBundle messages = eventGenerator.generateEvents(wavelet, capabilities.getCapabilitiesMap(), converterManager.getEventDataConverter(capabilities.getProtocolVersion()));