Exemple #1
0
  @Override
  public StateLRSResponse retrieveState(
      String id, Activity activity, Agent agent, UUID registration) {
    HashMap<String, String> queryParams = new HashMap<String, String>();
    queryParams.put("stateId", id);
    queryParams.put("activityId", activity.getId().toString());
    queryParams.put("agent", agent.toJSON(this.getVersion(), this.usePrettyJSON()));

    StateDocument stateDocument = new StateDocument();
    stateDocument.setId(id);
    stateDocument.setActivity(activity);
    stateDocument.setAgent(agent);

    LRSResponse lrsResp = getDocument("activities/state", queryParams, stateDocument);

    StateLRSResponse lrsResponse =
        new StateLRSResponse(lrsResp.getRequest(), lrsResp.getResponse());
    lrsResponse.setSuccess(lrsResp.getSuccess());

    if (lrsResponse.getResponse().getStatus() == 200) {
      lrsResponse.setContent(stateDocument);
    }

    return lrsResponse;
  }
Exemple #2
0
  @Override
  public LRSResponse updateState(StateDocument state) {
    HashMap<String, String> queryParams = new HashMap<String, String>();

    queryParams.put("stateId", state.getId());
    queryParams.put("activityId", state.getActivity().getId().toString());
    queryParams.put("agent", state.getAgent().toJSON(this.getVersion(), this.usePrettyJSON()));

    return updateDocument("activities/state", queryParams, state);
  }
Exemple #3
0
  @Override
  public LRSResponse deleteState(StateDocument state) {
    Map queryParams = new HashMap<String, String>();

    queryParams.put("stateId", state.getId());
    queryParams.put("activityId", state.getActivity().getId().toString());
    queryParams.put("agent", state.getAgent().toJSON());

    if (state.getRegistration() != null) {
      queryParams.put("registration", state.getRegistration().toString());
    }

    return deleteDocument("activities/state", queryParams);
  }