Package com.google.wave.api

Examples of com.google.wave.api.OperationRequest


  public static ProtocolVersion getProtocolVersion(List<OperationRequest> operations) {
    if (operations.size() == 0) {
      return ProtocolVersion.DEFAULT;
    }

    OperationRequest firstOperation = operations.get(0);
    if (firstOperation.getMethod().equals(OperationType.ROBOT_NOTIFY.method())) {
      String versionString = (String) firstOperation.getParameter(ParamsProperty.PROTOCOL_VERSION);
      if (versionString != null) {
        return ProtocolVersion.fromVersionString(versionString);
      }
    }
    return ProtocolVersion.DEFAULT;
View Full Code Here


        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;
View Full Code Here

    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;
View Full Code Here

  public OperationRequest deserialize(JsonElement json, Type type, JsonDeserializationContext ctx)
      throws JsonParseException {
    JsonObject jsonObject = json.getAsJsonObject();
    JsonObject parameters = jsonObject.getAsJsonObject(RequestProperty.PARAMS.key());

    OperationRequest request = new OperationRequest(
        jsonObject.get(RequestProperty.METHOD.key()).getAsString(),
        jsonObject.get(RequestProperty.ID.key()).getAsString(),
        getPropertyAsStringThenRemove(parameters, ParamsProperty.WAVE_ID),
        getPropertyAsStringThenRemove(parameters, ParamsProperty.WAVELET_ID),
        getPropertyAsStringThenRemove(parameters, ParamsProperty.BLIP_ID));

    for (Entry<String, JsonElement> parameter : parameters.entrySet()) {
      ParamsProperty parameterType = ParamsProperty.fromKey(parameter.getKey());
      if (parameterType != null) {
        Object object;
        if (parameterType == ParamsProperty.RAW_DELTAS) {
          object = ctx.deserialize(parameter.getValue(), GsonFactory.RAW_DELTAS_TYPE);
        } else {
          object = ctx.deserialize(parameter.getValue(), parameterType.clazz());
        }
        request.addParameter(Parameter.of(parameterType, object));
      }
    }

    return request;
  }
View Full Code Here

            return ((JsonPrimitive) (invocation.getArguments()[0])).getAsString();
          }
        });

    OperationRequestGsonAdaptor adaptor = new OperationRequestGsonAdaptor();
    OperationRequest result = adaptor.deserialize(jsonElement, null, mockContext);
    assertEquals("op1", result.getId());
    assertEquals("wavelet.setTitle", result.getMethod());
    assertEquals("1", result.getWaveId());
    assertEquals("2", result.getWaveletId());
    assertNull(result.getBlipId());
    assertEquals(1, result.getParams().size());
    assertEquals("Title", result.getParameter(ParamsProperty.WAVELET_TITLE));
  }
View Full Code Here

  public OperationRequest deserialize(JsonElement json, Type type, JsonDeserializationContext ctx)
      throws JsonParseException {
    JsonObject jsonObject = json.getAsJsonObject();
    JsonObject parameters = jsonObject.getAsJsonObject(RequestProperty.PARAMS.key());

    OperationRequest request = new OperationRequest(
        jsonObject.get(RequestProperty.METHOD.key()).getAsString(),
        jsonObject.get(RequestProperty.ID.key()).getAsString(),
        getPropertyAsStringThenRemove(parameters, ParamsProperty.WAVE_ID),
        getPropertyAsStringThenRemove(parameters, ParamsProperty.WAVELET_ID),
        getPropertyAsStringThenRemove(parameters, ParamsProperty.BLIP_ID));

    for (Entry<String, JsonElement> parameter : parameters.entrySet()) {
      ParamsProperty parameterType = ParamsProperty.fromKey(parameter.getKey());
      Object object = ctx.deserialize(parameter.getValue(), parameterType.clazz());
      request.addParameter(Parameter.of(parameterType, object));
    }

    return request;
  }
View Full Code Here

        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;
View Full Code Here

  public OperationRequest deserialize(JsonElement json, Type type, JsonDeserializationContext ctx)
      throws JsonParseException {
    JsonObject jsonObject = json.getAsJsonObject();
    JsonObject parameters = jsonObject.getAsJsonObject(RequestProperty.PARAMS.key());

    OperationRequest request = new OperationRequest(
        jsonObject.get(RequestProperty.METHOD.key()).getAsString(),
        jsonObject.get(RequestProperty.ID.key()).getAsString(),
        getPropertyAsStringThenRemove(parameters, ParamsProperty.WAVE_ID),
        getPropertyAsStringThenRemove(parameters, ParamsProperty.WAVELET_ID),
        getPropertyAsStringThenRemove(parameters, ParamsProperty.BLIP_ID));

    for (Entry<String, JsonElement> parameter : parameters.entrySet()) {
      ParamsProperty parameterType = ParamsProperty.fromKey(parameter.getKey());
      if (parameterType != null) {
        Object object = ctx.deserialize(parameter.getValue(), parameterType.clazz());
        request.addParameter(Parameter.of(parameterType, object));
      }
    }

    return request;
  }
View Full Code Here

    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;
View Full Code Here

  public static ProtocolVersion getProtocolVersion(List<OperationRequest> operations) {
    if (operations.size() == 0) {
      return ProtocolVersion.DEFAULT;
    }

    OperationRequest firstOperation = operations.get(0);
    if (firstOperation.getMethod().equals(OperationType.ROBOT_NOTIFY.method())) {
      String versionString = (String) firstOperation.getParameter(ParamsProperty.PROTOCOL_VERSION);
      if (versionString != null) {
        return ProtocolVersion.fromVersionString(versionString);
      }
    }
    return ProtocolVersion.DEFAULT;
View Full Code Here

TOP

Related Classes of com.google.wave.api.OperationRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.