[170775] Avoiding NPEs when migrating enumeration literals between profile definitions.
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/PackageOperations.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/PackageOperations.java
index 5c7d754..1c8017b 100644
--- a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/PackageOperations.java
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/internal/operations/PackageOperations.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2005, 2007 IBM Corporation and others.
  * All rights reserved.   This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -8,7 +8,7 @@
  * Contributors:
  *   IBM - initial API and implementation
  *
- * $Id: PackageOperations.java,v 1.27.2.1 2006/09/29 18:10:06 khussey Exp $
+ * $Id: PackageOperations.java,v 1.27.2.2 2007/01/17 18:24:20 khussey Exp $
  */
 package org.eclipse.uml2.uml.internal.operations;
 
@@ -184,20 +184,32 @@
 					EList values = (EList) eObject.eGet(eAttribute);
 
 					for (int i = 0, size = values.size(); i < size; i++) {
-						copyValues.add(i, targetEEnum.getEEnumLiteral(
-							((EEnumLiteral) values.get(i)).getName())
-							.getInstance());
+						EEnumLiteral value = targetEEnum
+							.getEEnumLiteral(((EEnumLiteral) values.get(i))
+								.getName());
+
+						if (value != null) {
+							copyValues.add(value.getInstance());
+						}
 					}
 				} else {
-					copyValues.add(targetEEnum.getEEnumLiteral(
-						((EEnumLiteral) eObject.eGet(eAttribute)).getName())
-						.getInstance());
+					EEnumLiteral value = targetEEnum
+						.getEEnumLiteral(((EEnumLiteral) eObject
+							.eGet(eAttribute)).getName());
+
+					if (value != null) {
+						copyValues.add(value.getInstance());
+					}
 				}
 			} else {
-				copyEObject.eSet(targetEAttribute, targetEEnum.getEEnumLiteral(
-					((EEnumLiteral) (eAttribute.isMany()
+				EEnumLiteral value = targetEEnum
+					.getEEnumLiteral(((EEnumLiteral) (eAttribute.isMany()
 						? ((EList) eObject.eGet(eAttribute)).get(0)
-						: eObject.eGet(eAttribute))).getName()).getInstance());
+						: eObject.eGet(eAttribute))).getName());
+
+				if (value != null) {
+					copyEObject.eSet(targetEAttribute, value.getInstance());
+				}
 			}
 		}