From e33b0819d466c067f7a8910d0bf05222507fee86 Mon Sep 17 00:00:00 2001 From: Ken ISHIMOTO Date: Mon, 23 Jul 2012 19:43:50 +0200 Subject: [PATCH] ERXEOAccessUtilities.isUniqueFailure Check added --- .../extensions/eof/ERXEOAccessUtilities.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Frameworks/Core/ERExtensions/Sources/er/extensions/eof/ERXEOAccessUtilities.java b/Frameworks/Core/ERExtensions/Sources/er/extensions/eof/ERXEOAccessUtilities.java index 7e2d89384dd..1681bb381c5 100644 --- a/Frameworks/Core/ERExtensions/Sources/er/extensions/eof/ERXEOAccessUtilities.java +++ b/Frameworks/Core/ERExtensions/Sources/er/extensions/eof/ERXEOAccessUtilities.java @@ -850,6 +850,29 @@ public static boolean isOptimisticLockingFailure(EOGeneralAdaptorException e) { return wasHandled; } + /** + * + * 例外エラーが重複エラーの場合は true を戻します。 + * + * @param e - saveChanges() から受けた例外エラーそのまま + * + * @return エラーが処理できた場合は true + * + */ + public static boolean isUniqueFailure(EOGeneralAdaptorException e) { + boolean wasHandled = false; + NSDictionary userInfo = e.userInfo(); + if(userInfo != null) { + EOAdaptorOperation adaptorOp = (EOAdaptorOperation) userInfo.objectForKey(EOAdaptorChannel.FailedAdaptorOperationKey); + + wasHandled = adaptorOp.toString().contains("UNIQUE"); + if (!wasHandled) { + log.error("UNIQUE Integrity constraint violation " + e + ": " + userInfo); + } + } + return wasHandled; + } + /** * Given an array of EOs, returns snapshot dictionaries for the given * related objects.