Adds the given patch and returns true if collaborators should be notified.
(String id, String data, String secret, String token, String from, String to, String lastSecret)
| 416 | * Adds the given patch and returns true if collaborators should be notified. |
| 417 | */ |
| 418 | protected void addPatch(String id, String data, String secret, String token, |
| 419 | String from, String to, String lastSecret) |
| 420 | throws UnauthorizedException |
| 421 | { |
| 422 | if (secret != null && cache.remove(createTokenKey(id, secret), token)) |
| 423 | { |
| 424 | if (from != null && to != null && data != null |
| 425 | && data.length() < maxCacheSize) |
| 426 | { |
| 427 | // Checks if the last patch has a valid secret |
| 428 | checkPatch(id, from, lastSecret); |
| 429 | cache.put(createCacheEntryKey(id, from), |
| 430 | new CacheEntry(to, data, secret)); |
| 431 | |
| 432 | // Maps from current to last for keeping chain valid |
| 433 | if (secret != null) |
| 434 | { |
| 435 | cache.put(createLastVersionKey(id, to), from); |
| 436 | } |
| 437 | |
| 438 | debug("addPatch id=" + id + " from=" + from + " to=" + to |
| 439 | + " secret=" + secret + " token=" + token + " data=" |
| 440 | + data); |
| 441 | } |
| 442 | } |
| 443 | else if (data != null) |
| 444 | { |
| 445 | throw new UnauthorizedException(); |
| 446 | } |
| 447 | } |
| 448 | |
| 449 | /** |
| 450 | * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) |
no test coverage detected