@Override /* package */ void validateSaveEventually() throws ParseException { if (isDirty(KEY_PASSWORD)) { // TODO(mengyan): Unify the exception we throw when validate fails throw new ParseException( ParseException.OTHER_CAUSE, "Unable to saveEventually on a ParseUser with dirty password"); } }
@Override /* package */ void validateDelete() { synchronized (mutex) { super.validateDelete(); if (!isAuthenticated() && isDirty()) { throw new IllegalArgumentException("Cannot delete a ParseUser that is not authenticated."); } } }
@Override /* package */ void validateSave() { synchronized (mutex) { if (getObjectId() == null) { throw new IllegalArgumentException( "Cannot save a ParseUser until it has been signed up. Call signUp first."); } if (isAuthenticated() || !isDirty() || isCurrentUser()) { return; } } if (!Parse.isLocalDatastoreEnabled()) { // This might be a different of instance of the currentUser, so we need to check objectIds ParseUser current = ParseUser.getCurrentUser(); //TODO (grantland): possible blocking disk i/o if (current != null && getObjectId().equals(current.getObjectId())) { return; } } throw new IllegalArgumentException("Cannot save a ParseUser that is not authenticated."); }
assertFalse(user.isDirty()); assertTrue(user.isDirty()); assertTrue(saveCountDown1.await(5, TimeUnit.SECONDS)); assertNull(exceptionCapture.get()); assertFalse(user.isDirty()); assertTrue(user.isDirty()); assertEquals(ParseException.SCRIPT_ERROR, ((ParseException) exceptionCapture.get()).getCode()); assertEquals("Save is not allowed", exceptionCapture.get().getMessage()); assertTrue(user.isDirty()); assertTrue(user.isDirty()); assertFalse(user.isDirty());