feature: Adding OSEE-INF as searchable resource folder

Adding OSEE-INF to the list of files that are searchable when class
or resource loading from the client.

Change-Id: I9fe7f493e12ac616dace1cf805bf9afc4336f314
diff --git a/org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/core/OseeURLClassLoader.java b/org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/core/OseeURLClassLoader.java
index 3b0f20b..c245911 100644
--- a/org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/core/OseeURLClassLoader.java
+++ b/org.eclipse.osee.ote.core/src/org/eclipse/osee/ote/core/OseeURLClassLoader.java
@@ -13,6 +13,7 @@
 
 package org.eclipse.osee.ote.core;
 
+import java.io.InputStream;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.net.URLStreamHandlerFactory;
@@ -25,6 +26,7 @@
  */
 public class OseeURLClassLoader extends URLClassLoader {
 
+   private static final int RETRY_MAX = 10;
    private final String name;
    private final ExportClassLoader exportClassLoader;
 
@@ -33,7 +35,7 @@
       this.name = name;
       GCHelper.getGCHelper().addRefWatch(this);
       exportClassLoader = ExportClassLoader.getInstance();
-      
+
    }
 
    public OseeURLClassLoader(String name, URL[] urls) {
@@ -51,16 +53,17 @@
    }
 
    @Override
-   public Class<?> loadClass(String clazz) throws ClassNotFoundException{
+   public Class<?> loadClass(String clazz) throws ClassNotFoundException {
       try {
          return exportClassLoader.loadClass(clazz);
       } catch (Exception ex2) {
          int timesTriedToLoad = 0;
-         while(timesTriedToLoad < 10){
+         while (timesTriedToLoad < RETRY_MAX) {
             try {
-               return super.loadClass(clazz);
+               Class<?> loadClass = super.loadClass(clazz);
+               return loadClass;
             } catch (ClassNotFoundException ex) {
-               System.out.println("Retrying to load from OseeURLClassLoader for class = "+ clazz);
+               System.out.println("Retrying to load from OseeURLClassLoader for class = " + clazz);
                timesTriedToLoad++; //Try to load again
                try {
                   Thread.sleep(1);
@@ -72,7 +75,41 @@
          throw new ClassNotFoundException("Class = " + clazz);
       }
    }
-   
+
+   /**
+    * Tries to use the export class loader first then when that fails will use the URL listing to find and download the
+    * resource stream.
+    */
+   @Override
+   public InputStream getResourceAsStream(String name) {
+      InputStream resourceAsStream;
+      try {
+         resourceAsStream = exportClassLoader.getResourceAsStream(name);
+      } catch (Exception ex2) {
+         resourceAsStream = null;
+      }
+      if (resourceAsStream == null) {
+         URL findResource = super.findResource(name);
+         System.out.println(findResource);
+         int timesTriedToLoad = 0;
+         while (timesTriedToLoad < RETRY_MAX) {
+            InputStream stream = super.getResourceAsStream(name);
+            if (stream != null) {
+               return stream;
+            }
+            timesTriedToLoad++; //Try to load again
+            System.out.printf("Retry %d of %d to load from OseeURLClassLoader for resource = %s\n", timesTriedToLoad,
+               RETRY_MAX, name);
+            try {
+               Thread.sleep(1);
+            } catch (InterruptedException ex1) {
+               OseeLog.log(OseeURLClassLoader.class, Level.SEVERE, ex1.toString(), ex1);
+            }
+         }
+      }
+      return null;
+   }
+
    @Override
    public String toString() {
       return this.getClass().getName() + " [ " + name + " ] ";
diff --git a/org.eclipse.osee.ote.parent/buildLocal.sh b/org.eclipse.osee.ote.parent/buildLocal.sh
index 31a8dea..472b463 100644
--- a/org.eclipse.osee.ote.parent/buildLocal.sh
+++ b/org.eclipse.osee.ote.parent/buildLocal.sh
@@ -1,3 +1,4 @@
 #!/bin/sh
 export BASE_AREA=`pwd | sed 's/\/c\//\/c\:\//'`
-mvn clean verify -Dosee.x.core.p2=file://$BASE_AREA/../org.eclipse.osee.x.core.p2/target/repository -Dosee.base.p2=file://$BASE_AREA/../org.eclipse.osee.client.all.p2/target/repository 
\ No newline at end of file
+echo "mvn clean verify -Dosee.base.p2=file://$BASE_AREA/../org.eclipse.ote.build/dependencies/ote.dependencies.p2/target/repository/" 
+mvn clean verify -Dosee.base.p2=file://$BASE_AREA/../org.eclipse.ote.build/dependencies/ote.dependencies.p2/target/repository/ 
\ No newline at end of file
diff --git a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/ClassServerInst.java b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/ClassServerInst.java
index 14b018f..cfa9845 100644
--- a/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/ClassServerInst.java
+++ b/org.eclipse.osee.ote.ui.test.manager/src/org/eclipse/osee/ote/ui/test/manager/util/ClassServerInst.java
@@ -33,6 +33,7 @@
 import org.eclipse.jdt.core.IJavaProject;
 import org.eclipse.jdt.core.JavaCore;
 import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.osee.framework.core.util.OseeInf;
 import org.eclipse.osee.framework.logging.OseeLog;
 import org.eclipse.osee.framework.ui.ws.AWorkspace;
 import org.eclipse.osee.ote.classserver.ClassServer;
@@ -169,32 +170,40 @@
       try {
          IClasspathEntry[] paths = localGetResolvedClasspath(javaProject);
          for (int i = 0; i < paths.length; i++) {
-            if (paths[i].getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
-               if (paths[i].getPath().toFile().exists()) {
+            IClasspathEntry pathEntry = paths[i];
+            if (pathEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
+               if (pathEntry.getPath().toFile().exists()) {
                   //          urls.add(paths[i].getPath().toFile());
                } else {
                   File file = null;
-                  file = new File(AWorkspace.getWorkspacePath().concat(paths[i].getPath().toOSString()));
+                  file = new File(AWorkspace.getWorkspacePath().concat(pathEntry.getPath().toOSString()));
                   if (file.exists()) {
                      urls.add(file);
                   }
                }
-            } else if (paths[i].getEntryKind() == IClasspathEntry.CPE_PROJECT) {
+            } else if (pathEntry.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
                urls.add(new File(AWorkspace.getWorkspacePath().concat(
-                  paths[i].getPath().toFile().getPath().concat(File.separator + "bin" + File.separator))));
-            } else if (paths[i].getEntryKind() == IClasspathEntry.CPE_SOURCE) {
-               File projectlocation = javaProject.getProject().getLocation().toFile();
-               File projecttricky = javaProject.getProject().getFullPath().toFile();
-               IPath output = paths[i].getOutputLocation();
+                  pathEntry.getPath().toFile().getPath().concat(File.separator + "bin" + File.separator))));
+            } else if (pathEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
+               IProject project = javaProject.getProject();
+               File projectlocation = project.getLocation().toFile();
+
+               File projecttricky = project.getFullPath().toFile();
+               IPath output = pathEntry.getOutputLocation();
                File fileLocation;
                if (output == null) {
                   fileLocation = javaProject.getOutputLocation().toFile();
                } else {
-                  fileLocation = paths[i].getOutputLocation().toFile();
+                  fileLocation = pathEntry.getOutputLocation().toFile();
                }
                String realLocation =
                   fileLocation.toString().replace(projecttricky.toString(), projectlocation.toString());
+
+               File resourceFolder = new File(projectlocation, OseeInf.ROOT_DIR);
                urls.add(new File(realLocation));
+               if (resourceFolder.exists()) {
+                  urls.add(resourceFolder);
+               }
             }
          }