Examples of URIish


Examples of org.eclipse.jgit.transport.URIish

  public void testCloneOverSshWithBadPassword() throws Exception {
    Assume.assumeTrue(sshRepo != null);
    Assume.assumeTrue(knownHosts != null);

    createWorkspace(SimpleMetaStore.DEFAULT_WORKSPACE_NAME);
    URIish uri = new URIish(sshRepo);
    IPath workspacePath = new Path("workspace").append(getWorkspaceId(workspaceLocation)).makeAbsolute();
    WebRequest request = new PostGitCloneRequest().setURIish(uri).setWorkspacePath(workspacePath).setKnownHosts(knownHosts).setPassword("I'm bad".toCharArray()).getWebRequest();

    // cloning
    WebResponse response = webConversation.getResponse(request);
View Full Code Here

Examples of org.eclipse.jgit.transport.URIish

    createWorkspace(SimpleMetaStore.DEFAULT_WORKSPACE_NAME);
    JSONObject project = createProjectOrLink(workspaceLocation, getMethodName().concat("Project"), null);
    String workspaceId = workspaceIdFromLocation(workspaceLocation);
    IPath clonePath = getClonePath(workspaceId, project);
    URIish uri = new URIish(sshRepo);
    WebRequest request = new PostGitCloneRequest().setURIish(uri).setFilePath(clonePath).setKnownHosts(knownHosts).setPassword(password).getWebRequest();
    String contentLocation = clone(request);
    File file = getRepositoryForContentLocation(contentLocation).getDirectory().getParentFile();
    assertTrue(file.exists());
    assertTrue(file.isDirectory());
View Full Code Here

Examples of org.eclipse.jgit.transport.URIish

    createWorkspace(SimpleMetaStore.DEFAULT_WORKSPACE_NAME);
    String workspaceId = workspaceIdFromLocation(workspaceLocation);
    JSONObject project = createProjectOrLink(workspaceLocation, getMethodName().concat("Project"), null);
    IPath clonePath = getClonePath(workspaceId, project);
    URIish uri = new URIish(sshRepo2);
    WebRequest request = new PostGitCloneRequest().setURIish(uri).setFilePath(clonePath).setKnownHosts(knownHosts2).setPrivateKey(privateKey).setPublicKey(publicKey).setPassphrase(passphrase).getWebRequest();
    String contentLocation = clone(request);

    File file = getRepositoryForContentLocation(contentLocation).getDirectory().getParentFile();
    assertTrue(file.exists());
View Full Code Here

Examples of org.eclipse.jgit.transport.URIish

    assertNotNull(bobProjectId);

    IPath bobClonePath = getClonePath(bobWorkspaceId, bobProject);

    // bob's clone
    URIish uri = new URIish(gitDir.toURI().toURL());
    request = getPostGitCloneRequest(uri, null, bobClonePath, null, null, null);
    setAuthentication(request, "bob", "bob");
    response = webConversation.getResponse(request);
    ServerStatus status = waitForTask(response, "bob", "bob");
    String cloneLocation = status.getJsonData().getString(ProtocolConstants.KEY_LOCATION);
View Full Code Here

Examples of org.eclipse.jgit.transport.URIish

    JSONObject project = createProjectOrLink(workspaceLocation, getMethodName().concat("Project"), null);
    clone(workspaceId, project);

    // clone again into the same path
    IPath clonePath = getClonePath(workspaceId, project);
    WebRequest request = getPostGitCloneRequest(new URIish(gitDir.toURI().toURL()).toString(), clonePath);
    WebResponse response = webConversation.getResponse(request);
    ServerStatus status = waitForTask(response);

    assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, status.getHttpCode());
View Full Code Here

Examples of org.eclipse.jgit.transport.URIish

  }

  // Convenience methods for creating requests

  private WebRequest getPostGitCloneRequest(String uri, IPath path) throws JSONException, UnsupportedEncodingException, URISyntaxException {
    return getPostGitCloneRequest(new URIish(uri), null, path, null, null, null);
  }
View Full Code Here

Examples of org.eclipse.jgit.transport.URIish

      initOnly = true;
    else {
      initOnly = false;
      if (!validateCloneUrl(url, request, response))
        return true;
      clone.setUrl(new URIish(url));
    }
    String cloneName = toAdd.optString(ProtocolConstants.KEY_NAME, null);
    if (cloneName == null)
      cloneName = request.getHeader(ProtocolConstants.HEADER_SLUG);
    // expected path /workspace/{workspaceId}
    String workspacePath = ServletResourceHandler.toOrionLocation(request, toAdd.optString(ProtocolConstants.KEY_LOCATION, null));
    // expected path /file/{workspaceId}/{projectName}[/{path}]
    String filePathString = ServletResourceHandler.toOrionLocation(request, toAdd.optString(ProtocolConstants.KEY_PATH, null));
    IPath filePath = filePathString == null ? null : new Path(filePathString);
    if (filePath != null && filePath.segmentCount() < 3)
      filePath = null;
    if (filePath == null && workspacePath == null) {
      String msg = NLS.bind("Either {0} or {1} should be provided: {2}",
          new Object[] { ProtocolConstants.KEY_PATH, ProtocolConstants.KEY_LOCATION, toAdd });
      return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST, msg, null));
    }
    // only during init operation filePath or cloneName must be provided
    // during clone operation, name can be obtained from URL
    if (initOnly && filePath == null && cloneName == null) {
      String msg = NLS.bind("Either {0} or {1} should be provided: {2}", new Object[] { ProtocolConstants.KEY_PATH, GitConstants.KEY_NAME, toAdd });
      return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST, msg, null));
    }
    if (!validateCloneName(cloneName, request, response))
      return true;

    // prepare the WebClone object, create a new project if necessary
    ProjectInfo project = null;
    boolean webProjectExists = false;
    if (filePath != null) {
      // path format is /file/{workspaceId}/{projectName}/[filePath]
      clone.setId(filePath.toString());
      project = GitUtils.projectFromPath(filePath);
      // workspace path format needs to be used if project does not exist
      if (project == null) {
        String msg = NLS.bind("Specified project does not exist: {0}", filePath.segment(2));
        return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST, msg, null));
      }
      webProjectExists = true;
      clone.setContentLocation(project.getProjectStore().getFileStore(filePath.removeFirstSegments(3)).toURI());
      if (cloneName == null)
        cloneName = filePath.segmentCount() > 2 ? filePath.lastSegment() : project.getFullName();
    } else if (workspacePath != null) {
      IPath path = new Path(workspacePath);
      // TODO: move this to CloneJob
      // if so, modify init part to create a new project if necessary
      final IMetaStore metaStore = OrionConfiguration.getMetaStore();
      WorkspaceInfo workspace = metaStore.readWorkspace(path.segment(1));
      if (cloneName == null)
        cloneName = new URIish(url).getHumanishName();
      cloneName = getUniqueProjectName(workspace, cloneName);
      webProjectExists = false;
      project = new ProjectInfo();
      project.setFullName(cloneName);
      project.setWorkspaceId(workspace.getUniqueId());

      try {
        // creating project in the backing store will assign a project id
        metaStore.createProject(project);
      } catch (CoreException e) {
        return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
            "Error persisting project state", e));
      }
      try {
        WorkspaceResourceHandler.computeProjectLocation(request, project, null, false);
        metaStore.updateProject(project);
      } catch (CoreException e) {
        // delete the project so we don't end up with a project in a bad location
        try {
          metaStore.deleteProject(workspace.getUniqueId(), project.getFullName());
        } catch (CoreException e1) {
          // swallow secondary error
          LogHelper.log(e1);
        }
        // we are unable to write in the platform location!
        String msg = NLS.bind("Failed to create project: {0}", project.getFullName());
        return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg, e));
      }

      URI baseLocation = getURI(request);
      baseLocation = new URI(baseLocation.getScheme(), baseLocation.getUserInfo(), baseLocation.getHost(), baseLocation.getPort(), workspacePath,
          baseLocation.getQuery(), baseLocation.getFragment());
      clone.setId(GitUtils.pathFromProject(workspace, project).toString());
      clone.setContentLocation(project.getProjectStore().toURI());
    }
    clone.setName(cloneName);
    clone.setBaseLocation(getURI(request));
    JSONObject cloneObject = clone.toJSON();
    String cloneLocation = cloneObject.getString(ProtocolConstants.KEY_LOCATION);

    String gitUserName = toAdd.optString(GitConstants.KEY_NAME, null);
    String gitUserMail = toAdd.optString(GitConstants.KEY_MAIL, null);
    Boolean initProject = toAdd.optBoolean(GitConstants.KEY_INIT_PROJECT, false);
    if (initOnly) {
      // git init
      InitJob job = new InitJob(clone, TaskJobHandler.getUserId(request), request.getRemoteUser(), cloneLocation, gitUserName, gitUserMail);
      return TaskJobHandler.handleTaskJob(request, response, job, statusHandler, JsonURIUnqualificationStrategy.ALL_NO_GIT);
    }
    // git clone
    // prepare creds
    GitCredentialsProvider cp = GitUtils.createGitCredentialsProvider(toAdd);
    cp.setUri(new URIish(clone.getUrl()));

    // if all went well, clone
    // check for SSO token
    Object cookie = request.getAttribute(GitConstants.KEY_SSO_TOKEN);
    CloneJob job = new CloneJob(clone, TaskJobHandler.getUserId(request), cp, request.getRemoteUser(), cloneLocation,
View Full Code Here

Examples of org.eclipse.jgit.transport.URIish

      statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST,
          "Clone URL cannot be empty", null)); //$NON-NLS-1$
      return false;
    }
    try {
      URIish uri = new URIish(url);
      if (GitUtils.isForbiddenGitUri(uri)) {
        statusHandler.handleRequest(
            request,
            response,
            new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST, NLS.bind(
                "Clone URL {0} does not appear to be a git repository", EncodingUtils.encodeForHTML(uri.toString())), null)); //$NON-NLS-1$
        return false;
      }
    } catch (URISyntaxException e) {
      statusHandler
          .handleRequest(
View Full Code Here

Examples of org.eclipse.jgit.transport.URIish

    Assume.assumeTrue(privateKey != null);
    Assume.assumeTrue(passphrase != null);

    createWorkspace(SimpleMetaStore.DEFAULT_WORKSPACE_NAME);
    String workspaceId = workspaceIdFromLocation(workspaceLocation);
    URIish uri = new URIish(sshRepo2);

    // clone1: create
    JSONObject project1 = createProjectOrLink(workspaceLocation, getMethodName().concat("Project1"), null);
    IPath clonePath = getClonePath(workspaceId, project1);
    WebRequest request = new PostGitCloneRequest().setURIish(uri).setFilePath(clonePath).setKnownHosts(knownHosts2).setPrivateKey(privateKey).setPublicKey(publicKey).setPassphrase(passphrase).getWebRequest();
View Full Code Here

Examples of org.eclipse.jgit.transport.URIish

    final Map<URIish, Map<String, Set<ProjectReference>>> repositories = new LinkedHashMap<URIish, Map<String, Set<ProjectReference>>>();
    getRepositories(referenceStrings, repositories);
    final ArrayList<IProject> importedProjects = new ArrayList<IProject>();
    for (final Map.Entry<URIish, Map<String, Set<ProjectReference>>> entry : repositories
        .entrySet()) {
      final URIish gitUrl = entry.getKey();
      final Map<String, Set<ProjectReference>> branches = entry
          .getValue();

      for (final Map.Entry<String, Set<ProjectReference>> branchEntry : branches
          .entrySet()) {
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.