Package com.linkedin.restli.server

Examples of com.linkedin.restli.server.UpdateResponse


  }

  @Override
  public UpdateResponse delete(Integer id)
  {
    return new UpdateResponse(S_204_NO_CONTENT);
  }
View Full Code Here


      return null;
    }
    else
    {
      //Return an UpdateResponse with a null HttpStatus
      return new UpdateResponse(null);
    }
  }
View Full Code Here

  @RestMethod.BatchUpdate
  public BatchUpdateResult<Long, Greeting> batchUpdate(BatchUpdateRequest<Long, Greeting> entities)
  {
    final Map<Long, UpdateResponse> responseMap = new HashMap<Long, UpdateResponse>();
    responseMap.put(3l, new UpdateResponse(HttpStatus.S_201_CREATED));
    final Map<Long, RestLiServiceException> errorsMap = new HashMap<Long, RestLiServiceException>();
    errorsMap.put(8l, new RestLiServiceException(HttpStatus.S_202_ACCEPTED));
    if (entities.getData().containsKey(1l))
    {
      //Return a null BatchUpdateResult
      return null;
    }
    else if (entities.getData().containsKey(2l))
    {
      //Return a BatchUpdateResult with a null results Map
      return new BatchUpdateResult<Long, Greeting>(null);
    }
    else if (entities.getData().containsKey(3l))
    {
      //Return a BatchUpdateResult with a null errors Map
      return new BatchUpdateResult<Long, Greeting>(responseMap, null);
    }
    else if (entities.getData().containsKey(4l))
    {
      //Return a BatchUpdateResult with a errors Map that has a null key in it
      errorsMap.put(null, new RestLiServiceException(HttpStatus.S_202_ACCEPTED));
      return new BatchUpdateResult<Long, Greeting>(responseMap, errorsMap);
    }
    else if (entities.getData().containsKey(5l))
    {
      //Return a BatchUpdateResult with a errors Map that has a null value in it
      errorsMap.put(9l, null);
      return new BatchUpdateResult<Long, Greeting>(responseMap, errorsMap);
    }
    else
    {
      //Return a BatchUpdateResult with a map that has a null key in it
      responseMap.put(null, new UpdateResponse(HttpStatus.S_201_CREATED));
      return new BatchUpdateResult<Long, Greeting>(responseMap);
    }
  }
View Full Code Here

  @RestMethod.BatchPartialUpdate
  public BatchUpdateResult<Long, Greeting> batchUpdate(BatchPatchRequest<Long, Greeting> entityUpdates)
  {
    final Map<Long, UpdateResponse> responseMap = new HashMap<Long, UpdateResponse>();
    responseMap.put(3l, new UpdateResponse(HttpStatus.S_201_CREATED));
    if (entityUpdates.getData().containsKey(1l))
    {
      //Return a null BatchUpdateResult
      return null;
    }
    else if (entityUpdates.getData().containsKey(2l))
    {
      //Return a BatchUpdateResult with a null results Map
      return new BatchUpdateResult<Long, Greeting>(null);
    }
    else if (entityUpdates.getData().containsKey(3l))
    {
      //Return a BatchUpdateResult with a null errors Map
      return new BatchUpdateResult<Long, Greeting>(responseMap, null);
    }
    else
    {
      //Return a BatchUpdateResult with a map that has a null key in it
      responseMap.put(null, new UpdateResponse(HttpStatus.S_201_CREATED));
      return new BatchUpdateResult<Long, Greeting>(responseMap);
    }
  }
View Full Code Here

    {
      _dataProvider.partialUpdate(key, patch);
    }
    catch(DataProcessingException e)
    {
      return new UpdateResponse(HttpStatus.S_400_BAD_REQUEST);
    }

    return new UpdateResponse(HttpStatus.S_204_NO_CONTENT);
  }
View Full Code Here

  private BatchUpdateResult<CompoundKey, Message> buildUpdateResult(Set<CompoundKey> keys)
  {
    Map<CompoundKey, UpdateResponse> result = new HashMap<CompoundKey, UpdateResponse>();
    for (CompoundKey key: keys)
    {
      result.put(key, new UpdateResponse(HttpStatus.S_204_NO_CONTENT));
    }
    return new BatchUpdateResult<CompoundKey, Message>(result);
  }
View Full Code Here

    for (Map.Entry<ComplexResourceKey<TwoPartKey, TwoPartKey>, Message> entry : entities.getData().entrySet())
    {
      if (_db.containsKey(keyToString(entry.getKey().getKey())))
      {
        _db.put(keyToString(entry.getKey().getKey()), entry.getValue());
        results.put(entry.getKey(), new UpdateResponse(HttpStatus.S_200_OK));
      }
      else
      {
        errors.put(entry.getKey(), new RestLiServiceException(HttpStatus.S_404_NOT_FOUND));
      }
View Full Code Here

    for (Map.Entry<ComplexResourceKey<TwoPartKey, TwoPartKey>, PatchRequest<Message>> patch : patches.getData().entrySet())
    {
      try
      {
        this.partialUpdate(patch.getKey(), patch.getValue());
        results.put(patch.getKey(), new UpdateResponse(HttpStatus.S_204_NO_CONTENT));
      }
      catch (DataProcessingException e)
      {
        results.put(patch.getKey(), new UpdateResponse(HttpStatus.S_400_BAD_REQUEST));
      }
    }

    return new BatchUpdateResult<ComplexResourceKey<TwoPartKey, TwoPartKey>, Message>(results);
  }
View Full Code Here

        new HashMap<ComplexResourceKey<TwoPartKey, TwoPartKey>, UpdateResponse>();

    for (ComplexResourceKey<TwoPartKey, TwoPartKey> id : ids.getKeys())
    {
      _db.remove(keyToString(id.getKey()));
      results.put(id, new UpdateResponse(HttpStatus.S_204_NO_CONTENT));
    }

    return new BatchUpdateResult<ComplexResourceKey<TwoPartKey, TwoPartKey>, Message>(results);
  }
View Full Code Here

    Map<CompoundKey, UpdateResponse> responseMap = new HashMap<CompoundKey, UpdateResponse>();
    Map<CompoundKey, RestLiServiceException> errorMap = new HashMap<CompoundKey, RestLiServiceException>();

    for(CompoundKey key : keys)
    {
      responseMap.put(key, new UpdateResponse(HttpStatus.S_201_CREATED));
    }
    return new BatchUpdateResult<CompoundKey, Greeting>(responseMap);
  }
View Full Code Here

TOP

Related Classes of com.linkedin.restli.server.UpdateResponse

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.