Package org.eclipse.core.runtime

Examples of org.eclipse.core.runtime.Path.removeFirstSegments()


    IPath path = new Path(URI.create(makeResourceURIAbsolute(filename)).getPath());
    while (path.segmentCount() != 0 && !path.segment(0).equals("file")) {
      if (path.segment(0).equals("file")) {
        break;
      }
      path = path.removeFirstSegments(1);
    }
    String filePath = path.toString();
    if (filePath.startsWith("/")) {
      filePath = filePath.substring(1);
    }
View Full Code Here


    IPath path = new Path(URI.create(makeResourceURIAbsolute(filename)).getPath());
    while (path.segmentCount() != 0 && !path.segment(0).equals("file")) {
      if (path.segment(0).equals("file")) {
        break;
      }
      path = path.removeFirstSegments(1);
    }
    String filePath = path.toString();
    if (filePath.startsWith("/")) {
      filePath = filePath.substring(1);
    }
View Full Code Here

    final String filename = "foo.html";
    final String fileContent = "<html><body>This is a test file</body></html>";
    WebResponse createdFile = createFileOnServer("", filename, fileContent);
    URL fileLocation = createdFile.getURL();
    IPath filepath = new Path(fileLocation.getPath());
    filepath = filepath.removeFirstSegments(new Path(FILE_SERVLET_LOCATION).segmentCount()); // chop off leading /file/
    filepath = filepath.removeLastSegments(1); // chop off trailing /foo.html
    filepath = filepath.makeAbsolute();
    filepath = filepath.addTrailingSeparator();
    String parentFolder = filepath.toString();
View Full Code Here

  public boolean handleRequest(HttpServletRequest request, HttpServletResponse response, String path) throws ServletException {
    try {
      Path p = new Path(path);
      IPath filePath = p;
      if (p.segment(0).equals(Clone.RESOURCE) && p.segment(1).equals("file")) { //$NON-NLS-1$
        filePath = p.removeFirstSegments(1);
      } else if (p.segment(1).equals(Clone.RESOURCE) && p.segment(2).equals("file")) { //$NON-NLS-1$
        filePath = p.removeFirstSegments(2);
      }
      if (!AuthorizationService.checkRights(request.getRemoteUser(), "/" + filePath.toString(), request.getMethod())) {
        response.sendError(HttpServletResponse.SC_FORBIDDEN);
View Full Code Here

      Path p = new Path(path);
      IPath filePath = p;
      if (p.segment(0).equals(Clone.RESOURCE) && p.segment(1).equals("file")) { //$NON-NLS-1$
        filePath = p.removeFirstSegments(1);
      } else if (p.segment(1).equals(Clone.RESOURCE) && p.segment(2).equals("file")) { //$NON-NLS-1$
        filePath = p.removeFirstSegments(2);
      }
      if (!AuthorizationService.checkRights(request.getRemoteUser(), "/" + filePath.toString(), request.getMethod())) {
        response.sendError(HttpServletResponse.SC_FORBIDDEN);
        return true;
      }
View Full Code Here

      URISyntaxException, CoreException, ConfigInvalidException {
    Path p = new Path(path);
    URI baseLocation = getURI(request);
    if (p.segment(0).equals(Clone.RESOURCE) && p.segment(1).equals("file")) { //$NON-NLS-1$
      // expected path /gitapi/config/clone/file/{path}
      File gitDir = GitUtils.getGitDir(p.removeFirstSegments(1));
      if (gitDir == null)
        return statusHandler.handleRequest(request, response,
            new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_FOUND, NLS.bind("No repository found under {0}", p.removeFirstSegments(1)),
                null));
      Repository db = null;
View Full Code Here

    if (p.segment(0).equals(Clone.RESOURCE) && p.segment(1).equals("file")) { //$NON-NLS-1$
      // expected path /gitapi/config/clone/file/{path}
      File gitDir = GitUtils.getGitDir(p.removeFirstSegments(1));
      if (gitDir == null)
        return statusHandler.handleRequest(request, response,
            new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_FOUND, NLS.bind("No repository found under {0}", p.removeFirstSegments(1)),
                null));
      Repository db = null;
      try {
        db = FileRepositoryBuilder.create(gitDir);
        URI cloneLocation = BaseToCloneConverter.getCloneLocation(baseLocation, BaseToCloneConverter.CONFIG);
View Full Code Here

          db.close();
        }
      }
    } else if (p.segment(1).equals(Clone.RESOURCE) && p.segment(2).equals("file")) { //$NON-NLS-1$
      // expected path /gitapi/config/{key}/clone/file/{path}
      File gitDir = GitUtils.getGitDir(p.removeFirstSegments(2));
      if (gitDir == null)
        return statusHandler.handleRequest(request, response,
            new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_FOUND, NLS.bind("No repository found under {0}", p.removeFirstSegments(2)),
                null));
      URI cloneLocation = BaseToCloneConverter.getCloneLocation(baseLocation, BaseToCloneConverter.CONFIG_OPTION);
View Full Code Here

    } else if (p.segment(1).equals(Clone.RESOURCE) && p.segment(2).equals("file")) { //$NON-NLS-1$
      // expected path /gitapi/config/{key}/clone/file/{path}
      File gitDir = GitUtils.getGitDir(p.removeFirstSegments(2));
      if (gitDir == null)
        return statusHandler.handleRequest(request, response,
            new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_FOUND, NLS.bind("No repository found under {0}", p.removeFirstSegments(2)),
                null));
      URI cloneLocation = BaseToCloneConverter.getCloneLocation(baseLocation, BaseToCloneConverter.CONFIG_OPTION);
      Repository db = null;
      try {
        db = FileRepositoryBuilder.create(gitDir);
View Full Code Here

  private boolean handlePost(HttpServletRequest request, HttpServletResponse response, String path) throws CoreException, IOException, JSONException,
      ServletException, URISyntaxException, ConfigInvalidException {
    Path p = new Path(path);
    if (p.segment(0).equals(Clone.RESOURCE) && p.segment(1).equals("file")) { //$NON-NLS-1$
      // expected path /gitapi/config/clone/file/{path}
      File gitDir = GitUtils.getGitDir(p.removeFirstSegments(1));
      if (gitDir == null)
        return statusHandler.handleRequest(request, response,
            new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_FOUND, NLS.bind("No repository found under {0}", p.removeFirstSegments(1)),
                null));
      URI cloneLocation = BaseToCloneConverter.getCloneLocation(getURI(request), BaseToCloneConverter.CONFIG);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.