← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7190: centralized reference error reporting

 

------------------------------------------------------------
revno: 7190
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-06-05 09:58:08 +0200
message:
  centralized reference error reporting
modified:
  dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java'
--- dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java	2012-06-04 13:38:24 +0000
+++ dhis-2/dhis-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/importers/DefaultIdentifiableObjectImporter.java	2012-06-05 07:58:08 +0000
@@ -717,16 +717,7 @@
 
             if ( ref == null )
             {
-                String referenceName = idObject != null ? idObject.getClass().getSimpleName() : "null";
-                String objectName = object != null ? object.getClass().getSimpleName() : "null";
-
-                String logMsg = "Unknown reference to " + idObject + " (" + referenceName + ")" +
-                    " on object " + object + " (" + objectName + ").";
-
-                log.warn( logMsg );
-
-                ImportConflict importConflict = new ImportConflict( getDisplayName( object ), logMsg );
-                importConflicts.add( importConflict );
+                reportReferenceError(object, importConflicts, idObject);
             }
 
             if ( !options.isDryRun() )
@@ -781,16 +772,7 @@
                 }
                 else
                 {
-                    String referenceName = idObject != null ? idObject.getClass().getSimpleName() : "null";
-                    String objectName = object != null ? object.getClass().getSimpleName() : "null";
-
-                    String logMsg = "Unknown reference to " + idObject + " (" + referenceName + ")" +
-                        " on object " + object + " (" + objectName + ").";
-
-                    log.warn( logMsg );
-
-                    ImportConflict importConflict = new ImportConflict( getDisplayName( object ), logMsg );
-                    importConflicts.add( importConflict );
+                    reportReferenceError( object, importConflicts, idObject );
                 }
             }
 
@@ -802,4 +784,18 @@
 
         return importConflicts;
     }
+
+    private void reportReferenceError( Object object, List<ImportConflict> importConflicts, Object idObject )
+    {
+        String referenceName = idObject != null ? idObject.getClass().getSimpleName() : "null";
+        String objectName = object != null ? object.getClass().getSimpleName() : "null";
+
+        String logMsg = "Unknown reference to " + idObject + " (" + referenceName + ")" +
+            " on object " + object + " (" + objectName + ").";
+
+        log.warn( logMsg );
+
+        ImportConflict importConflict = new ImportConflict( getDisplayName( object ), logMsg );
+        importConflicts.add( importConflict );
+    }
 }