@Override public Object apply(FileResource resource, Input input) throws OrmException { ReviewDb db = dbProvider.get(); AccountPatchReview apr = getExisting(db, resource); if (apr != null) { db.accountPatchReviews().delete(Collections.singleton(apr)); } return Response.none(); }
public Response<String> apply(IdentifiedUser user, String newPassword) throws ResourceNotFoundException, ResourceConflictException, OrmException { if (user.getUserName() == null) { throw new ResourceConflictException("username must be set"); } AccountExternalId id = dbProvider .get() .accountExternalIds() .get(new AccountExternalId.Key(SCHEME_USERNAME, user.getUserName())); if (id == null) { throw new ResourceNotFoundException(); } id.setPassword(newPassword); dbProvider.get().accountExternalIds().update(Collections.singleton(id)); accountCache.evict(user.getAccountId()); return Strings.isNullOrEmpty(newPassword) ? Response.<String>none() : Response.ok(newPassword); }