public void elementEncode(XMLWriter writer, IPath projectPath, boolean newLine) {
    // Keeping this as a HashMap (not a Map) for the XMLWriter
    HashMap parameters = new HashMap();

    parameters.put(TAG_ENTRY_KIND, IncludePathEntry.entryKindToString(this.entryKind));
    parameters.put(TAG_CONTENT_KIND, IncludePathEntry.contentKindToString(this.contentKind));
    parameters.put(
        TAG_CREATEDREFERENCE, createdReference ? "true" : "false"); // $NON-NLS-1$ //$NON-NLS-2$

    IPath xmlPath = this.path;
    if (this.entryKind != IIncludePathEntry.IPE_VARIABLE
        && this.entryKind != IIncludePathEntry.IPE_CONTAINER) {
      // translate to project relative from absolute (unless a device path)
      if (projectPath != null && projectPath.isPrefixOf(xmlPath)) {
        if (xmlPath.segment(0).equals(projectPath.segment(0))) {
          xmlPath = xmlPath.removeFirstSegments(1);
          xmlPath = xmlPath.makeRelative();
        } else {
          xmlPath = xmlPath.makeAbsolute();
        }
      }
    }
    parameters.put(TAG_PATH, String.valueOf(xmlPath));
    if (resource != null) {
      parameters.put(TAG_RESOURCE, resource.getName());
    }
    if (this.isExported) {
      parameters.put(TAG_EXPORTED, "true"); // $NON-NLS-1$
    }

    writer.printTag(TAG_INCLUDEPATHENTRY, parameters);
    writer.endTag(TAG_INCLUDEPATHENTRY);
  }
  /* (non-Javadoc)
   * @see org.eclipse.ui.IMarkerResolutionGenerator#getResolutions(org.eclipse.core.resources.IMarker)
   */
  public IMarkerResolution[] getResolutions(IMarker marker) {
    final Shell shell = JavaPlugin.getActiveWorkbenchShell();
    if (!hasResolutions(marker) || shell == null) {
      return NO_RESOLUTION;
    }

    ArrayList<IMarkerResolution2> resolutions = new ArrayList<IMarkerResolution2>();

    final IJavaProject project = getJavaProject(marker);

    int id = marker.getAttribute(IJavaModelMarker.ID, -1);
    if (id == IJavaModelStatusConstants.CP_CONTAINER_PATH_UNBOUND) {
      String[] arguments = CorrectionEngine.getProblemArguments(marker);
      final IPath path = new Path(arguments[0]);

      if (path.segment(0).equals(JavaCore.USER_LIBRARY_CONTAINER_ID)) {
        String label = NewWizardMessages.UserLibraryMarkerResolutionGenerator_changetouserlib_label;
        Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
        resolutions.add(
            new UserLibraryMarkerResolution(label, image) {
              public void run(IMarker m) {
                changeToExistingLibrary(shell, path, false, project);
              }
            });
        if (path.segmentCount() == 2) {
          String label2 =
              Messages.format(
                  NewWizardMessages.UserLibraryMarkerResolutionGenerator_createuserlib_label,
                  path.segment(1));
          Image image2 = JavaPluginImages.get(JavaPluginImages.IMG_OBJS_LIBRARY);
          resolutions.add(
              new UserLibraryMarkerResolution(label2, image2) {
                public void run(IMarker m) {
                  createUserLibrary(shell, path);
                }
              });
        }
      }
      String label = NewWizardMessages.UserLibraryMarkerResolutionGenerator_changetoother;
      Image image = JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
      resolutions.add(
          new UserLibraryMarkerResolution(label, image) {
            public void run(IMarker m) {
              changeToExistingLibrary(shell, path, true, project);
            }
          });
    }

    if (project != null) {
      resolutions.add(new OpenBuildPathMarkerResolution(project));
    }

    return resolutions.toArray(new IMarkerResolution[resolutions.size()]);
  }
示例#3
0
 private boolean containsPublishedFiles(IStorage dir, IDesignerUser user, String timeStamp) {
   for (Version version : user.getVersions()) {
     if (!version.getTime().equals(timeStamp)) continue;
     for (String res : version.resources) {
       IPath resPath = new Path(res);
       while (resPath.segment(0).equals(".")) resPath = resPath.removeFirstSegments(1);
       if (dir.getName().equals(resPath.segment(0))) {
         return true;
       }
     }
   }
   return false;
 }
  public static IJavaProject findJavaProject(ITextViewer viewer) {

    if (viewer == null) return null;

    IStructuredModel existingModelForRead =
        StructuredModelManager.getModelManager().getExistingModelForRead(viewer.getDocument());

    if (existingModelForRead == null) return null;

    IJavaProject javaProject = null;
    try {
      String baseLocation = existingModelForRead.getBaseLocation();
      // 20041129 (pa) the base location changed for XML model
      // because of FileBuffers, so this code had to be updated
      // https://bugs.eclipse.org/bugs/show_bug.cgi?id=79686
      IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
      IPath filePath = new Path(baseLocation);
      IProject project = null;
      if (filePath.segmentCount() > 0) {
        project = root.getProject(filePath.segment(0));
      }
      if (project != null) {
        javaProject = JavaCore.create(project);
      }
    } catch (Exception ex) {
      MapperPlugin.getDefault().logException(ex);
    }
    return javaProject;
  }
示例#5
0
 public static boolean isController(IFile currentFile) {
   if (currentFile == null) return false;
   IPath controllerFilePath = currentFile.getProjectRelativePath();
   if (controllerFilePath.segmentCount() < 2) return false;
   return controllerFilePath.segment(controllerFilePath.segmentCount() - 2).equals(CONTROLLERS)
       && controllerFilePath.lastSegment().endsWith(CONTROLLER_FILE_SUFFIX);
 }
示例#6
0
 public IScriptFolder getScriptFolder(IPath path) {
   if (path.segmentCount() != 1) {
     return null;
   }
   String name = path.segment(0);
   return getScriptFolder(name);
 }
示例#7
0
  private boolean handleDelete(
      HttpServletRequest request, HttpServletResponse response, String pathString)
      throws GitAPIException, CoreException, IOException, ServletException {
    IPath path = pathString == null ? Path.EMPTY : new Path(pathString);
    // expected path format is /file/{workspaceId}/{projectId}[/{directoryPath}]
    if (path.segment(0).equals("file") && path.segmentCount() > 2) { // $NON-NLS-1$

      // make sure a clone is addressed
      WebProject webProject = GitUtils.projectFromPath(path);
      if (webProject != null && isAccessAllowed(request.getRemoteUser(), webProject)) {
        File gitDir = GitUtils.getGitDirs(path, Traverse.CURRENT).values().iterator().next();
        Repository repo = new FileRepository(gitDir);
        repo.close();
        FileUtils.delete(repo.getWorkTree(), FileUtils.RECURSIVE | FileUtils.RETRY);
        if (path.segmentCount() == 3)
          return statusHandler.handleRequest(
              request, response, removeProject(request.getRemoteUser(), webProject));
        return true;
      }
      String msg = NLS.bind("Nothing found for the given ID: {0}", path);
      return statusHandler.handleRequest(
          request,
          response,
          new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_FOUND, msg, null));
    }
    String msg = NLS.bind("Invalid delete request {0}", pathString);
    return statusHandler.handleRequest(
        request,
        response,
        new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST, msg, null));
  }
  public static IPath[] chooseExclusionPattern(
      Shell shell,
      IContainer currentSourceFolder,
      String title,
      String message,
      IPath initialPath,
      boolean multiSelection) {
    Class[] acceptedClasses = new Class[] {IFolder.class, IFile.class};
    ISelectionStatusValidator validator =
        new TypedElementSelectionValidator(acceptedClasses, multiSelection);
    ViewerFilter filter = new TypedViewerFilter(acceptedClasses);

    ILabelProvider lp = new WorkbenchLabelProvider();
    ITreeContentProvider cp = new WorkbenchContentProvider();

    IResource initialElement = null;
    if (initialPath != null) {
      IContainer curr = currentSourceFolder;
      int nSegments = initialPath.segmentCount();
      for (int i = 0; i < nSegments; i++) {
        IResource elem = curr.findMember(initialPath.segment(i));
        if (elem != null) {
          initialElement = elem;
        }
        if (elem instanceof IContainer) {
          curr = (IContainer) elem;
        } else {
          break;
        }
      }
    }

    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell, lp, cp);
    dialog.setTitle(title);
    dialog.setValidator(validator);
    dialog.setMessage(message);
    dialog.addFilter(filter);
    dialog.setInput(currentSourceFolder);
    dialog.setInitialSelection(initialElement);
    dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
    dialog.setHelpAvailable(false);

    if (dialog.open() == Window.OK) {
      Object[] objects = dialog.getResult();
      int existingSegments = currentSourceFolder.getFullPath().segmentCount();

      IPath[] resArr = new IPath[objects.length];
      for (int i = 0; i < objects.length; i++) {
        IResource currRes = (IResource) objects[i];
        IPath path = currRes.getFullPath().removeFirstSegments(existingSegments).makeRelative();
        if (currRes instanceof IContainer) {
          path = path.addTrailingSeparator();
        }
        resArr[i] = path;
      }
      return resArr;
    }
    return null;
  }
  /*
   * (non-Javadoc)
   * @see org.eclipse.jdt.core.ClasspathContainerInitializer#getComparisonID(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject)
   */
  @Override
  public Object getComparisonID(final IPath containerPath, final IJavaProject project) {
    if (containerPath == null || project == null) {
      return null;
    }

    return containerPath.segment(0) + "/" + project.getPath().segment(0); // $NON-NLS-1$
  }
示例#10
0
  private boolean isValidReviewPath(IPath path) {
    String designerName = path.segment(1);

    // Verify the user
    if (designerName == null) {
      return false;
    }
    IUser user = userManager.getUser(designerName);

    return null != user
        && path.segmentCount() > 8
        && path.segment(4).equals(".review")
        && path.segment(5).equals("snapshot")
        && path.segment(0).equals("user")
        && path.segment(2).equals("ws")
        && path.segment(3).equals("workspace");
  }
示例#11
0
  public static IPath adjustPath(IPath path, String ownerId, String version, String projectName) {
    // Map the request lib path stored in the snapshot to the actual system lib path
    // A path like: project1/./lib/dojo/dojo.js
    IReviewManager reviewManager = ReviewManager.getReviewManager();
    IDavinciProject project = new DavinciProject();
    project.setOwnerId(ownerId);
    project.setProjectName(projectName);
    ILibInfo[] sysLibs = reviewManager.getSystemLibs(project);
    ILibInfo[] versionLibs = reviewManager.getVersionLib(project, version);

    // If the lib path is not specified in the review version,
    // just return the path
    if (versionLibs == null) return path;

    IPath cp = new Path(path.toString());
    IPath newPath = new Path(cp.segment(0));
    cp = cp.removeFirstSegments(1);

    int c = 0;
    while (cp.segment(0).equals(".") || cp.segment(0).equals("..")) {
      c++;
    }
    cp = cp.removeFirstSegments(c);

    for (ILibInfo info : versionLibs) {
      if (info.getVirtualRoot() == null) {
        continue;
      }
      IPath versionVirtualRoot = new Path(info.getVirtualRoot());
      if (cp.matchingFirstSegments(versionVirtualRoot) == versionVirtualRoot.segmentCount()) {
        String virtualRoot = null;
        for (ILibInfo lib : sysLibs) {
          if (lib.getId().equals(info.getId())) {
            virtualRoot = lib.getVirtualRoot();
            break;
          }
        }
        if (virtualRoot != null) {
          IPath vr = newPath.append(virtualRoot);
          return vr.append(cp.removeFirstSegments(versionVirtualRoot.segmentCount()));
        }
        break;
      }
    }
    return path;
  }
 protected void createUserLibrary(final Shell shell, IPath unboundPath) {
   String name = unboundPath.segment(1);
   String id = UserLibraryPreferencePage.ID;
   HashMap<String, Object> data = new HashMap<String, Object>(3);
   data.put(UserLibraryPreferencePage.DATA_LIBRARY_TO_SELECT, name);
   data.put(UserLibraryPreferencePage.DATA_DO_CREATE, Boolean.TRUE);
   PreferencesUtil.createPreferenceDialogOn(shell, id, new String[] {id}, data).open();
 }
示例#13
0
 public static boolean isModel(IFile currentFile) {
   if (currentFile == null) return false;
   IPath modelFilePath = currentFile.getProjectRelativePath();
   if (modelFilePath.segmentCount() < 2) return false;
   boolean isModel =
       modelFilePath.segment(modelFilePath.segmentCount() - 2).equalsIgnoreCase(MODELS)
           && modelFilePath.lastSegment().endsWith(PHP);
   return isModel;
 }
 private IDiffContainer getFileParent(IDiffContainer root, String filePath) {
   IPath path = new Path(filePath);
   IDiffContainer child = root;
   if (diffRoots.isEmpty()) {
     for (int i = 0; i < path.segmentCount() - 1; i++)
       child = getOrCreateChild(child, path.segment(i));
     return child;
   } else {
     for (Entry<IPath, IDiffContainer> entry : diffRoots.entrySet()) {
       if (entry.getKey().isPrefixOf(path)) {
         for (int i = entry.getKey().segmentCount(); i < path.segmentCount() - 1; i++)
           child = getOrCreateChild(child, path.segment(i));
         return child;
       }
     }
     return null;
   }
 }
 /**
  * Respects images residing in any plug-in. If path is relative, then this bundle is looked up for
  * the image, otherwise, for absolute path, first segment is taken as id of plug-in with image
  *
  * @generated
  * @param path the path to image, either absolute (with plug-in id as first segment), or relative
  *     for bundled images
  * @return the image descriptor
  */
 public static ImageDescriptor findImageDescriptor(String path) {
   final IPath p = new Path(path);
   if (p.isAbsolute() && p.segmentCount() > 1) {
     return AbstractUIPlugin.imageDescriptorFromPlugin(
         p.segment(0), p.removeFirstSegments(1).makeAbsolute().toString());
   } else {
     return getBundledImageDescriptor(p.makeAbsolute().toString());
   }
 }
示例#16
0
  // We need this as a separate method, as we'll put dependent projects' output
  // on the classpath
  private static void addProjectClasspath(
      IWorkspaceRoot root,
      IJavaProject otherJavaProject,
      Set<IJavaProject> projectsProcessed,
      Set<String> classpath) {

    // Check for cycles. If we've already seen this project,
    // no need to go any further.
    if (projectsProcessed.contains(otherJavaProject)) {
      return;
    }
    projectsProcessed.add(otherJavaProject);

    try {
      // Add the output directory first as a binary entry for other projects
      IPath binPath = otherJavaProject.getOutputLocation();
      IResource binPathResource = root.findMember(binPath);
      String binDirString;
      if (binPathResource != null) {
        binDirString = root.findMember(binPath).getLocation().toOSString();
      } else {
        binDirString = binPath.toOSString();
      }
      classpath.add(binDirString);

      // Now the rest of the classpath
      IClasspathEntry[] classpathEntries = otherJavaProject.getResolvedClasspath(true);
      for (IClasspathEntry entry : classpathEntries) {
        if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
          IPath cpPath = entry.getPath();

          IResource res = root.findMember(cpPath);

          // If res is null, the path is absolute (it's an external jar)
          if (res == null) {
            classpath.add(cpPath.toOSString());
          } else {
            // It's relative
            classpath.add(res.getLocation().toOSString());
          }
        } else if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
          IPath otherProjectPath = entry.getPath();
          IProject otherProject = root.getProject(otherProjectPath.segment(0));
          IJavaProject yetAnotherJavaProject = JavaCore.create(otherProject);
          if (yetAnotherJavaProject != null) {
            addProjectClasspath(root, yetAnotherJavaProject, projectsProcessed, classpath);
          }
        }
        // Ignore source types
      }
    } catch (JavaModelException jme) {
      AptPlugin.log(
          jme,
          "Failed to get the classpath for the following project: "
              + otherJavaProject); //$NON-NLS-1$
    }
  }
 private boolean isNonProjectSpecificContainer(IPath containerPath) {
   if (containerPath.segmentCount() > 0) {
     String id = containerPath.segment(0);
     if (id.equals(JavaCore.USER_LIBRARY_CONTAINER_ID) || id.equals(JavaRuntime.JRE_CONTAINER)) {
       return true;
     }
   }
   return false;
 }
示例#18
0
 /**
  * Returns the existing WebProject corresponding to the provided path, or <code>null</code> if no
  * such project exists.
  *
  * @param path path in the form /file/{workspaceId}/{projectName}/[filePath]
  * @return the web project, or <code>null</code>
  */
 public static ProjectInfo projectFromPath(IPath path) {
   if (path == null || path.segmentCount() < 3) return null;
   String workspaceId = path.segment(1);
   String projectName = path.segment(2);
   try {
     return OrionConfiguration.getMetaStore().readProject(workspaceId, projectName);
   } catch (CoreException e) {
     return null;
   }
 }
示例#19
0
  /**
   * If the value starts with a path variable such as %ROOT%, replace it with the absolute path.
   *
   * @param value the value of a -Akey=value command option
   */
  private static String resolveVarPath(IJavaProject jproj, String value) {
    if (value == null) {
      return null;
    }
    // is there a token to substitute?
    if (!Pattern.matches(PATHVAR_TOKEN, value)) {
      return value;
    }
    IPath path = new Path(value);
    String firstToken = path.segment(0);
    // If it matches %ROOT%/project, it is a project-relative path.
    if (PATHVAR_ROOT.equals(firstToken)) {
      IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
      IResource proj = root.findMember(path.segment(1));
      if (proj == null) {
        return value;
      }
      // all is well; do the substitution
      IPath relativePath = path.removeFirstSegments(2);
      IPath absoluteProjPath = proj.getLocation();
      IPath absoluteResPath = absoluteProjPath.append(relativePath);
      return absoluteResPath.toOSString();
    }

    // If it matches %PROJECT.DIR%/project, the path is relative to the current project.
    if (jproj != null && PATHVAR_PROJECTROOT.equals(firstToken)) {
      // all is well; do the substitution
      IPath relativePath = path.removeFirstSegments(1);
      IPath absoluteProjPath = jproj.getProject().getLocation();
      IPath absoluteResPath = absoluteProjPath.append(relativePath);
      return absoluteResPath.toOSString();
    }

    // otherwise it's a classpath-var-based path.
    String cpvName = firstToken.substring(1, firstToken.length() - 1);
    IPath cpvPath = JavaCore.getClasspathVariable(cpvName);
    if (cpvPath != null) {
      IPath resolved = cpvPath.append(path.removeFirstSegments(1));
      return resolved.toOSString();
    } else {
      return value;
    }
  }
  public static boolean isExternalFolderPath(IPath externalPath) {
    if (externalPath == null) return false;
    if (ResourcesPlugin.getWorkspace().getRoot().getProject(externalPath.segment(0)).exists())
      return false;
    File externalFolder = externalPath.toFile();
    if (externalFolder.isFile()) return false;
    if (externalPath.getFileExtension() != null /*
													 * likely a .jar, .zip, .rar
													 * or other file
													 */ && !externalFolder.exists()) return false;
    return true;
  }
 private String getNameDelta(IFolder parent, IScriptFolder fragment) {
   IPath prefix = parent.getFullPath();
   IPath fullPath = fragment.getPath();
   if (prefix.isPrefixOf(fullPath)) {
     StringBuffer buf = new StringBuffer();
     for (int i = prefix.segmentCount(); i < fullPath.segmentCount(); i++) {
       if (buf.length() > 0) buf.append(IScriptFolder.PACKAGE_DELIMITER);
       buf.append(fullPath.segment(i));
     }
     return buf.toString();
   }
   return fragment.getElementName();
 }
示例#22
0
  @Override
  protected boolean handleLibraryRequest(
      HttpServletRequest req, HttpServletResponse resp, IPath path, IUser user)
      throws ServletException, IOException {
    // Remove the follow URL prefix
    // /user/heguyi/ws/workspace/.review/snapshot/20100101/project1/lib/dojo/dojo.js
    // to
    // project1/lib/dojo/dojo.js
    String version = null;
    String ownerId = null;
    String projectName = null;

    if (isValidReviewPath(path)) {
      ownerId = path.segment(1);
      version = path.segment(6);
      projectName = path.segment(7);
      path = path.removeFirstSegments(7);
      // So that each snapshot can be mapped to its virtual lib path correctly.
      path = ReviewManager.adjustPath(path, ownerId, version, projectName);
    }
    return super.handleLibraryRequest(req, resp, path, user);
  }
示例#23
0
 public boolean hasSubfolders() throws ModelException {
   IModelElement[] packages = ((IProjectFragment) getParent()).getChildren();
   int namesLength = this.path.segmentCount();
   nextPackage:
   for (int i = 0, length = packages.length; i < length; i++) {
     IPath otherNames = ((ScriptFolder) packages[i]).path;
     if (otherNames.segmentCount() <= namesLength) continue nextPackage;
     for (int j = 0; j < namesLength; j++)
       if (!this.path.segment(j).equals(otherNames.segment(j))) continue nextPackage;
     return true;
   }
   return false;
 }
示例#24
0
 public int matchingFirstSegments(IPath anotherPath) {
   Assert.isNotNull(anotherPath);
   int anotherPathLen = anotherPath.segmentCount();
   int max = Math.min(segments.length, anotherPathLen);
   int count = 0;
   for (int i = 0; i < max; i++) {
     if (!segments[i].equals(anotherPath.segment(i))) {
       return count;
     }
     count++;
   }
   return count;
 }
示例#25
0
  public boolean isPrefixOf(IPath anotherPath) {
    if (anotherPath.getDevice().equals(device)) {
      if (segmentCount() <= anotherPath.segmentCount()) {
        int i = 0;
        for (String s : segments()) {
          if (!s.equals(anotherPath.segment(i++))) return false;
        }
        return true;
      }
    }

    return false;
  }
示例#26
0
  /** Returns the name of the Eclipse application launcher. */
  private static String getLauncherName(String name, String os, File installFolder) {
    if (os == null) {
      EnvironmentInfo info =
          (EnvironmentInfo)
              ServiceHelper.getService(Activator.getContext(), EnvironmentInfo.class.getName());
      if (info == null) return null;
      os = info.getOS();
    }

    if (os.equals(org.eclipse.osgi.service.environment.Constants.OS_WIN32)) {
      IPath path = new Path(name);
      if ("exe".equals(path.getFileExtension())) // $NON-NLS-1$
      return name;
      return name + ".exe"; // $NON-NLS-1$
    }
    if (os.equals(Constants.MACOSX_BUNDLED)) {
      return "/Contents/MacOS/" + name; // $NON-NLS-1$
    }

    if (os.equals(org.eclipse.osgi.service.environment.Constants.OS_MACOSX)) {
      IPath path = new Path(name);
      if (path.segment(0).endsWith(".app")) // $NON-NLS-1$
      return name;

      String appName = null;
      if (installFolder != null) {
        File appFolder = new File(installFolder, name + ".app"); // $NON-NLS-1$
        if (appFolder.exists()) {
          try {
            appName = appFolder.getCanonicalFile().getName();
          } catch (IOException e) {
            appName = appFolder.getName();
          }
        }
      }

      StringBuffer buffer = new StringBuffer();
      if (appName != null) {
        buffer.append(appName);
      } else {
        buffer.append(name.substring(0, 1).toUpperCase());
        buffer.append(name.substring(1));
        buffer.append(".app"); // $NON-NLS-1$
      }
      buffer.append("/Contents/MacOS/"); // $NON-NLS-1$
      buffer.append(name);
      return buffer.toString();
    }
    return name;
  }
 @Override
 protected void service(HttpServletRequest req, HttpServletResponse resp)
     throws ServletException, IOException {
   traceRequest(req);
   String pathInfoString = req.getPathInfo();
   String queryString = getQueryString(req);
   IPath pathInfo =
       new Path(
           null /*don't parse host:port as device*/,
           pathInfoString == null ? "" : pathInfoString); // $NON-NLS-1$
   if (pathInfo.segmentCount() > 0) {
     String hostedHost = pathInfo.segment(0);
     IHostedSite site = HostingActivator.getDefault().getHostingService().get(hostedHost);
     if (site != null) {
       IPath path = pathInfo.removeFirstSegments(1);
       IPath contextPath = new Path(req.getContextPath());
       IPath contextlessPath = path.makeRelativeTo(contextPath).makeAbsolute();
       URI[] mappedPaths;
       try {
         mappedPaths = getMapped(site, contextlessPath, queryString);
       } catch (URISyntaxException e) {
         handleException(
             resp,
             new ServerStatus(
                 IStatus.ERROR,
                 HttpServletResponse.SC_BAD_REQUEST,
                 "Could not create target URI	",
                 e));
         return;
       }
       if (mappedPaths != null) {
         serve(req, resp, site, mappedPaths);
       } else {
         handleException(
             resp,
             new ServerStatus(
                 IStatus.ERROR,
                 HttpServletResponse.SC_NOT_FOUND,
                 NLS.bind("No mappings matched {0}", path),
                 null));
       }
     } else {
       String msg = NLS.bind("Hosted site {0} is stopped", hostedHost);
       handleException(
           resp, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_FOUND, msg, null));
     }
   } else {
     super.doGet(req, resp);
   }
 }
  /**
   * Returns the cheatsheet collection child object corresponding to the passed path (relative to
   * this object), or <code>null</code> if such an object could not be found.
   *
   * @param searchPath org.eclipse.core.runtime.IPath
   * @return CheatSheetCollectionElement
   */
  public CheatSheetCollectionElement findChildCollection(IPath searchPath) {
    Object[] children = getChildren();
    String searchString = searchPath.segment(0);
    for (int i = 0; i < children.length; ++i) {
      CheatSheetCollectionElement currentCategory = (CheatSheetCollectionElement) children[i];
      if (currentCategory.getLabel(null).equals(searchString)) {
        if (searchPath.segmentCount() == 1) return currentCategory;

        return currentCategory.findChildCollection(searchPath.removeFirstSegments(1));
      }
    }

    return null;
  }
 private IResource createSourceResource(IResourceDelta delta) {
   IPath sourcePath = delta.getMovedFromPath();
   IResource resource = delta.getResource();
   IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
   switch (resource.getType()) {
     case IResource.PROJECT:
       return wsRoot.getProject(sourcePath.segment(0));
     case IResource.FOLDER:
       return wsRoot.getFolder(sourcePath);
     case IResource.FILE:
       return wsRoot.getFile(sourcePath);
   }
   return null;
 }
  public ModelWorkspaceItem getWorkspaceItem(final IPath path, int resourceType) {
    CoreArgCheck.isNotNull(path);
    try {
      // first get all the projects
      ModelProject[] projects = getModelProjects();
      for (int i = 0; i < projects.length; i++) {
        ModelProject project = projects[i];
        if (resourceType == IResource.PROJECT) {
          if (project.getPath().equals(path)) {
            return project;
          }
        } else {
          if (!project.isOpen()) {
            continue;
          }

          // If the path only contains the project then we cannot match it
          // to a non-project type so return null
          if (path.segmentCount() < 2) {
            return null;
          }
          // If the first segment is not this project's name then skip it
          if (!path.segment(0).equals(project.getProject().getName())) {
            continue;
          }
          // Iterate over all the path segments navigating to the child by name
          ModelWorkspaceItem item = project;
          final String[] segments = path.segments();
          for (int j = 1; j < segments.length; j++) {
            final String segment = segments[j];
            if (!item.exists()) {
              // Must be in the process of closing (see defect 10957) ...
              return null;
            }
            item = item.getChild(segment);
            if (item == null) {
              break;
            } else if (item.getPath().makeRelative().equals(path.makeRelative())) {
              return item;
            }
          }
          // ModelWorkspaceItem[] children = project.getChildren();
          // return recursiveLookUp(children, path);
        }
      }
    } catch (ModelWorkspaceException e) {
      // do nothing
    }
    return null;
  }