Bug 514165: [Interoperability][Rpy] Clean log and messages in oep.interoperability.rpy
 - merge the 2 messages classes and files from the plugin
 - remove the log File Not found" for files coming from Rpy installation
 - minors others changes
 
Change-Id: I3749b8bbb09d76b0ed0c38c39c911b8aacf5d872
Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
diff --git a/rpy/plugins/org.eclipse.papyrus.interoperability.rpy.blackboxes/src/org/eclipse/papyrus/interoperability/rpy/blackboxes/Rpy2PapyrusNotationBlackboxes.java b/rpy/plugins/org.eclipse.papyrus.interoperability.rpy.blackboxes/src/org/eclipse/papyrus/interoperability/rpy/blackboxes/Rpy2PapyrusNotationBlackboxes.java
index 8a9da32..dc86aa1 100644
--- a/rpy/plugins/org.eclipse.papyrus.interoperability.rpy.blackboxes/src/org/eclipse/papyrus/interoperability/rpy/blackboxes/Rpy2PapyrusNotationBlackboxes.java
+++ b/rpy/plugins/org.eclipse.papyrus.interoperability.rpy.blackboxes/src/org/eclipse/papyrus/interoperability/rpy/blackboxes/Rpy2PapyrusNotationBlackboxes.java
@@ -729,7 +729,7 @@
 	 * @param element
 	 *            a graphical element
 	 * @return
-	 * 		the value of the m_pParent field if it exits for the given object or <code>null</code> in other case
+	 * 		the value of the m_pParent field if it exists for the given object or <code>null</code> in other case
 	 */
 	private final GraphElementsType getParent(final GraphElementsType element) {
 		final EStructuralFeature paretnFeature = element.eClass().getEStructuralFeature("m_pParent"); //$NON-NLS-1$
@@ -747,7 +747,7 @@
 	 * @param element
 	 *            a graphical element
 	 * @return
-	 * 		the value of the m_Transform field if it exits for the given object or <code>null</code> in other case
+	 * 		the value of the m_Transform field if it exists for the given object or <code>null</code> in other case
 	 */
 	@SuppressWarnings("unchecked")
 	protected final List<String> getTransformList(final GraphElementsType element) {
@@ -793,7 +793,7 @@
 	 * @param element
 	 *            a graphical element
 	 * @return
-	 * 		the value of the m_Polygon field if it exits for the given object or <code>null</code> in other case
+	 * 		the value of the m_Polygon field if it exists for the given object or <code>null</code> in other case
 	 */
 	@SuppressWarnings("unchecked")
 	protected final List<String> getPolygonList(GraphElementsType element) {
diff --git a/rpy/plugins/org.eclipse.papyrus.interoperability.rpy/src/org/eclipse/papyrus/interoperability/rpy/importer/UMLRpyImporter.java b/rpy/plugins/org.eclipse.papyrus.interoperability.rpy/src/org/eclipse/papyrus/interoperability/rpy/importer/UMLRpyImporter.java
index b795c72..55050ea 100644
--- a/rpy/plugins/org.eclipse.papyrus.interoperability.rpy/src/org/eclipse/papyrus/interoperability/rpy/importer/UMLRpyImporter.java
+++ b/rpy/plugins/org.eclipse.papyrus.interoperability.rpy/src/org/eclipse/papyrus/interoperability/rpy/importer/UMLRpyImporter.java
@@ -14,16 +14,12 @@
 package org.eclipse.papyrus.interoperability.rpy.importer;
 
 import java.io.IOException;
-import java.net.URL;
-import java.nio.file.Path;
-import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.emf.common.util.URI;
 import org.eclipse.emf.ecore.EAnnotation;
 import org.eclipse.emf.ecore.EAttribute;
@@ -39,11 +35,11 @@
 import org.eclipse.emf.ecore.xmi.XMLResource;
 import org.eclipse.osgi.util.NLS;
 import org.eclipse.papyrus.interoperability.rpy.Activator;
-import org.eclipse.papyrus.interoperability.rpy.importer.utils.Messages;
 import org.eclipse.papyrus.interoperability.rpy.importer.utils.RpyFileHandler;
 import org.eclipse.papyrus.interoperability.rpy.importer.utils.RpyFileUtils;
 import org.eclipse.papyrus.interoperability.rpy.importer.utils.RpyProjectHandler;
 import org.eclipse.papyrus.interoperability.rpy.importer.utils.RpyUtil;
+import org.eclipse.papyrus.interoperability.rpy.messages.Messages;
 import org.eclipse.papyrus.interoperability.rpy.parser.rpySyntax.RpyContent;
 import org.eclipse.papyrus.interoperability.rpy.parser.rpySyntax.RpyFeature;
 import org.eclipse.papyrus.interoperability.rpy.parser.rpySyntax.RpyFeatureValue;
@@ -267,7 +263,9 @@
 					((EModelElement) receiver).getEAnnotations().add(eannotation);
 				}
 			} else {
-				Activator.log.error(NLS.bind(Messages.FeatureNotFound, new String[] { rpyFeature.getName(), receiver.eClass().getName(), RpyUtil.getNodeIndexInFile(sourceNode), projectHandler.getOwningFileHandler(sourceNode).getURI().toFileString() }), null);
+				Activator.log.error(
+						NLS.bind(Messages.UMLRpyImporter_FeatureNotFound, new String[] { rpyFeature.getName(), receiver.eClass().getName(), RpyUtil.getNodeIndexInFile(sourceNode), projectHandler.getOwningFileHandler(sourceNode).getURI().toFileString() }),
+						null);
 			}
 		}
 
diff --git a/rpy/plugins/org.eclipse.papyrus.interoperability.rpy/src/org/eclipse/papyrus/interoperability/rpy/importer/utils/Messages.java b/rpy/plugins/org.eclipse.papyrus.interoperability.rpy/src/org/eclipse/papyrus/interoperability/rpy/importer/utils/Messages.java
deleted file mode 100644
index 6a0793f..0000000
--- a/rpy/plugins/org.eclipse.papyrus.interoperability.rpy/src/org/eclipse/papyrus/interoperability/rpy/importer/utils/Messages.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2015 CEA LIST.
- *
- *
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *  Sebastien Revol (CEA LIST) sebastien.revol@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.interoperability.rpy.importer.utils;
-
-import org.eclipse.osgi.util.NLS;
-
-public class Messages extends NLS {
-
-	static {
-		NLS.initializeMessages("org.eclipse.papyrus.interoperability.rpy.importer.utils.messages", Messages.class); //$NON-NLS-1$
-	}
-
-	private Messages() {
-	}
-
-
-	public static String IgnoredSubFile;
-//
-//	public static String FailedToLoadProject;
-//	public static String FailedToLoadTable;
-//	public static String FailedToLoadResource;
-//
-//	public static String RpyNotFound;
-//
-//	public static String RpyHome;
-//	public static String ResourceLoading;
-//
-//	public static String GenericFileNotFound;
-	public static String FileNotFoundHandleReference;
-//
-	public static String NotFoundIDReference;
-//
-	public static String FileNotFoundElementReference;
-//
-//	public static String FileAliasNotResolved;
-//
-	public static String UnknownExtension;
-//
-//	public static String IDNotFoundInHandleRefAndInFileTable;
-	public static String FeatureNotFound;
-
-}
\ No newline at end of file
diff --git a/rpy/plugins/org.eclipse.papyrus.interoperability.rpy/src/org/eclipse/papyrus/interoperability/rpy/importer/utils/RpyProjectHandler.java b/rpy/plugins/org.eclipse.papyrus.interoperability.rpy/src/org/eclipse/papyrus/interoperability/rpy/importer/utils/RpyProjectHandler.java
index 4be4cb8..a935214 100644
--- a/rpy/plugins/org.eclipse.papyrus.interoperability.rpy/src/org/eclipse/papyrus/interoperability/rpy/importer/utils/RpyProjectHandler.java
+++ b/rpy/plugins/org.eclipse.papyrus.interoperability.rpy/src/org/eclipse/papyrus/interoperability/rpy/importer/utils/RpyProjectHandler.java
@@ -29,6 +29,7 @@
 import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
 import org.eclipse.osgi.util.NLS;
 import org.eclipse.papyrus.interoperability.rpy.Activator;
+import org.eclipse.papyrus.interoperability.rpy.messages.Messages;
 import org.eclipse.papyrus.interoperability.rpy.parser.rpySyntax.RpyFeature;
 import org.eclipse.papyrus.interoperability.rpy.parser.rpySyntax.RpyFeatureValue;
 import org.eclipse.papyrus.interoperability.rpy.parser.rpySyntax.RpyFile;
@@ -154,13 +155,9 @@
 
 
 	private Resource getResource(URI uri) {
-		// Activator.log.info(NLS.bind(Messages.ResourceLoading, uri.toFileString()));
-
-		File resourceFile = new File(uri.toFileString());
-		if (resourceFile.exists()) {
+		if (this.resSet.getURIConverter().exists(uri, null)) {
 			return resSet.getResource(uri, true);
 		} else {
-			// Activator.log.info(NLS.bind(Messages.GenericFileNotFound, uri.toFileString()));
 			return null;
 		}
 	}
@@ -187,7 +184,7 @@
 						uriToHandler.put(subFileURI.toFileString(), getRpyFileHandler(subFileURI.toFileString()));
 					}
 				} else {
-					Activator.log.info(NLS.bind(Messages.IgnoredSubFile, subFileURI.toFileString()));
+					Activator.log.info(NLS.bind(Messages.RpyProjectHandler_IgnoredSubFile, subFileURI.toFileString()));
 				}
 			}
 		}
@@ -256,7 +253,7 @@
 	private URI getNormalizedURI(String fileString) {
 		// TODO : improve me
 		if (fileString.startsWith(OM_ROOT)) {
-				return null;
+			return null;
 		}
 
 		fileString = fileString.replaceAll("\\\\\\\\", "\\\\");
@@ -362,8 +359,11 @@
 				}
 				RpyFileHandler handler = getRpyFileHandler(referencedFileName);
 				if (handler == null) {
-					String filePathWithWrongRef = node.eResource().getURI().toFileString();
-					Activator.log.error(NLS.bind(Messages.FileNotFoundElementReference, new String[] { referencedFileName, RpyUtil.getNodeIndexInFile(node), filePathWithWrongRef }), null);
+					if (false == referencedFileName.startsWith(OM_ROOT)) {
+						//we log only in other case, because file starting with OMROOT are licenced file, so we don't read them
+						String filePathWithWrongRef = node.eResource().getURI().toFileString();
+						Activator.log.error(NLS.bind(Messages.RpyProjectHandler_FileNotFoundElementReference, new String[] { referencedFileName, RpyUtil.getNodeIndexInFile(node), filePathWithWrongRef }), null);
+					}
 				} else {
 					return getReferencedNodeInFileHandler(node, handler, true);
 				}
@@ -491,7 +491,7 @@
 	 */
 	private void logFileNodeFound(RpyNode node, String filePath) {
 		String filePathWithWrongRef = node.eResource().getURI().toFileString();
-		Activator.log.error(NLS.bind(Messages.FileNotFoundHandleReference, new String[] { filePath, RpyUtil.getNodeIndexInFile(node), filePathWithWrongRef }), null);
+		Activator.log.error(NLS.bind(Messages.RpyProjectHandler_FileNotFoundHandleReference, new String[] { filePath, RpyUtil.getNodeIndexInFile(node), filePathWithWrongRef }), null);
 	}
 
 	/**
@@ -545,7 +545,7 @@
 	private void logIDNotFound(RpyFileHandler handler, RpyNode node) {
 		String id = RpyUtil.getReferencedID(node);
 		String filePathWithWrongRef = node.eResource().getURI().toFileString();
-		Activator.log.error(NLS.bind(Messages.NotFoundIDReference, new String[] { id, handler.getRpyFile().eResource().getURI().toFileString(), RpyUtil.getNodeIndexInFile(node), filePathWithWrongRef }), null);
+		Activator.log.error(NLS.bind(Messages.RpyProjectHandler_NotFoundIDReference, new String[] { id, handler.getRpyFile().eResource().getURI().toFileString(), RpyUtil.getNodeIndexInFile(node), filePathWithWrongRef }), null);
 	}
 
 	public Collection<RpyNode> getAllProxies() {
diff --git a/rpy/plugins/org.eclipse.papyrus.interoperability.rpy/src/org/eclipse/papyrus/interoperability/rpy/importer/utils/RpyUtil.java b/rpy/plugins/org.eclipse.papyrus.interoperability.rpy/src/org/eclipse/papyrus/interoperability/rpy/importer/utils/RpyUtil.java
index f4a0f21..2aa40e3 100644
--- a/rpy/plugins/org.eclipse.papyrus.interoperability.rpy/src/org/eclipse/papyrus/interoperability/rpy/importer/utils/RpyUtil.java
+++ b/rpy/plugins/org.eclipse.papyrus.interoperability.rpy/src/org/eclipse/papyrus/interoperability/rpy/importer/utils/RpyUtil.java
@@ -24,6 +24,7 @@
 import org.eclipse.emf.ecore.util.EcoreUtil;
 import org.eclipse.osgi.util.NLS;
 import org.eclipse.papyrus.interoperability.rpy.Activator;
+import org.eclipse.papyrus.interoperability.rpy.messages.Messages;
 import org.eclipse.papyrus.interoperability.rpy.parser.rpySyntax.RpyContent;
 import org.eclipse.papyrus.interoperability.rpy.parser.rpySyntax.RpyFeature;
 import org.eclipse.papyrus.interoperability.rpy.parser.rpySyntax.RpyFeatureValue;
@@ -222,7 +223,7 @@
 				fileName += "." + extension; //$NON-NLS-1$
 				return fileName;
 			} else {
-				Activator.log.error(NLS.bind(Messages.UnknownExtension, new String[] { nodeType, fileName, getNodeIndexInFile(node), node.eResource().getURI().toFileString() }), null);
+				Activator.log.error(NLS.bind(Messages.RpyUtil_UnknownExtension, new String[] { nodeType, fileName, getNodeIndexInFile(node), node.eResource().getURI().toFileString() }), null);
 			}
 
 
diff --git a/rpy/plugins/org.eclipse.papyrus.interoperability.rpy/src/org/eclipse/papyrus/interoperability/rpy/importer/utils/messages.properties b/rpy/plugins/org.eclipse.papyrus.interoperability.rpy/src/org/eclipse/papyrus/interoperability/rpy/importer/utils/messages.properties
deleted file mode 100644
index cb764b6..0000000
--- a/rpy/plugins/org.eclipse.papyrus.interoperability.rpy/src/org/eclipse/papyrus/interoperability/rpy/importer/utils/messages.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-FailedToLoadTable = Could not load Rpy fileTable {0}.
-FailedToLoadResource =  Could not load Rpy resource {0}. It doesn't seem to be a Rpy resource.
-IgnoredSubFile = Rpy unsupported extension: {0}, this file is not loaded
-ResourceLoading = Loading resource {0}
-GenericFileNotFound =Failed to load resource {0}
-FileNotFoundHandleReference = Could not find the file {0} referenced by an IHandle at line {1} of file {2}
-FileNotFoundElementReference = Could not find the file {0} referenced by an Element at line {1} of file {2}
-NotFoundIDReference = Could not find the element with ID {0} in file {1} referenced by an Object at line {2} of file {3}
-FileAliasNotResolved = Could not resolve alias {0} referenced by an Element at line {1} of file {2}
-UnknownExtension = Unknown extension for NodeType {0}, while looking for referenced file  {1} at line {2} of file {3}
-IDNotFoundInHandleRefAndInFileTable = Element with ID {0} not found in file {1} and could not find any corresponding alias for {2} in fileTable.dat, referenced by an IHandle at line {3} of file {4}. Creating a proxy node for it.
-
-FeatureNotFound = Could not find feature {0} in EClass {1}, coming from line {2} in file  {3}  
diff --git a/rpy/plugins/org.eclipse.papyrus.interoperability.rpy/src/org/eclipse/papyrus/interoperability/rpy/messages/Messages.java b/rpy/plugins/org.eclipse.papyrus.interoperability.rpy/src/org/eclipse/papyrus/interoperability/rpy/messages/Messages.java
index cc9cbde..06e424a 100644
--- a/rpy/plugins/org.eclipse.papyrus.interoperability.rpy/src/org/eclipse/papyrus/interoperability/rpy/messages/Messages.java
+++ b/rpy/plugins/org.eclipse.papyrus.interoperability.rpy/src/org/eclipse/papyrus/interoperability/rpy/messages/Messages.java
@@ -23,7 +23,7 @@
 public class Messages extends NLS {
 	private static final String BUNDLE_NAME = "org.eclipse.papyrus.interoperability.rpy.messages.messages"; //$NON-NLS-1$
 
-	public static String TransformationRpyWizard_WizardTitle;
+
 	static {
 		// initialize resource bundle
 		NLS.initializeMessages(BUNDLE_NAME, Messages.class);
@@ -31,4 +31,12 @@
 
 	private Messages() {
 	}
+	
+	public static String TransformationRpyWizard_WizardTitle;
+	public static String RpyProjectHandler_IgnoredSubFile;
+	public static String RpyProjectHandler_FileNotFoundHandleReference;
+	public static String RpyProjectHandler_NotFoundIDReference;
+	public static String RpyProjectHandler_FileNotFoundElementReference;
+	public static String RpyUtil_UnknownExtension;
+	public static String UMLRpyImporter_FeatureNotFound;
 }
diff --git a/rpy/plugins/org.eclipse.papyrus.interoperability.rpy/src/org/eclipse/papyrus/interoperability/rpy/messages/messages.properties b/rpy/plugins/org.eclipse.papyrus.interoperability.rpy/src/org/eclipse/papyrus/interoperability/rpy/messages/messages.properties
index 98cc309..b1ffa85 100644
--- a/rpy/plugins/org.eclipse.papyrus.interoperability.rpy/src/org/eclipse/papyrus/interoperability/rpy/messages/messages.properties
+++ b/rpy/plugins/org.eclipse.papyrus.interoperability.rpy/src/org/eclipse/papyrus/interoperability/rpy/messages/messages.properties
@@ -1 +1,7 @@
+RpyProjectHandler_IgnoredSubFile = Rpy unsupported extension: {0}, this file is not loaded
+RpyProjectHandler_FileNotFoundHandleReference = Could not find the file {0} referenced by an IHandle at line {1} of file {2}
+RpyProjectHandler_FileNotFoundElementReference = Could not find the file {0} referenced by an Element at line {1} of file {2}
+RpyProjectHandler_NotFoundIDReference = Could not find the element with ID {0} in file {1} referenced by an Object at line {2} of file {3}
+RpyUtil_UnknownExtension = Unknown extension for NodeType {0}, while looking for referenced file  {1} at line {2} of file {3}
+UMLRpyImporter_FeatureNotFound = Could not find feature {0} in EClass {1}, coming from line {2} in file  {3}  
 TransformationRpyWizard_WizardTitle=Rpy Transformation Wizard