Clones the project.
@param projectUri - URI of the project
@return file where the project was cloned
486390
File cloneProject(URI projectUri) {
		try {
			log.info("Cloning repo from [" + projectUri + "] to [" + this.basedir + "]");
			Git git = cloneToBasedir(projectUri, this.basedir);
			if (git != null) {
				git.close();
			}
			File clonedRepo = git.getRepository().getWorkTree();
			log.info("Cloned repo to [" + clonedRepo + "]");
			return clonedRepo;
		}
		catch (Exception e) {
			throw new IllegalStateException("Exception occurred while cloning repo", e);
		}
	}
1095307
@Override
    public InputStream getDocument(URI documentUri) throws DocumentException {

        if (!documentExists(documentUri)) {
            return null;
        }

        File dir = new File(this.getDocumentInternalUri(documentUri));
        for (File file : dir.listFiles()) {
            if (file.getName().matches("^index\\..*")) {
                InputStream result = null;
                try {
                    result = new FileInputStream(file);
                } catch (IOException e) {
                    throw new DocumentException(e);
                }
                return result;
            }
        }
        return null;
    }
833420
def _clone(self):
        '''
        
        '''
        instance = super(Bungiesearch, self)._clone()
        instance._raw_results_only = self._raw_results_only
        return instance
1158754
function (project_id, copy_options, cb) {

            _util.buildQuery('projects/' + project_id + '/copy', copy_options, function (error, data) {

                return cb(error, data);

            });

        }
1154878
private Path createPath(PathUri uri) {

    PathProvider provider = getProvider(uri);
    if (provider == null) {
      if (uri.getSchemePrefix() == null) {
        return Paths.get(uri.getPath());
      } else {
        try {
          return Paths.get(new URI(uri.getUri()));
        } catch (URISyntaxException e) {
          throw new ResourceUriUndefinedException(e, uri.getUri());
        }
      }
    }
    return provider.createResource(uri);
  }
137651
public static UriComponentsBuilder fromUri(URI uri) {
		UriComponentsBuilder builder = new UriComponentsBuilder();
		builder.uri(uri);
		return builder;
	}
391202
@Override
  public String getVersion(URI uri)
  {
    return StringUtils.format("%d", buildFileObject(uri).getLastModified());
  }
786222
public DTMIterator cloneWithReset() throws CloneNotSupportedException
  {

    OneStepIterator clone = (OneStepIterator) super.cloneWithReset();
    clone.m_iterator = m_iterator;

    return clone;
  }
1255462
@Override
  public File getFile() throws IOException {
    String realPath = RequestUtils.getRealPath(this.servletContext, this.path);
    return new File(realPath);
  }
522217
public static GitService cloneSiteRepo(Status status) throws Exception {
    File tmpDir = File.createTempFile("site", "git");
    GitService git = null;
    if(tmpDir.delete()) {
      try {
        git = GitService.cloneRepo(status.getRepo(), tmpDir.getAbsolutePath());
        if(status.getBranch() != null && !git.getBranchName().equals(status.getBranch())) {
          git.switchBranch(status.getBranch());
        }
        if(status.getRevision() != null && !git.getCurrentRevision().equals(status.getRevision())) {
          git.resetToRev(status.getRevision());
        }
      } catch(Exception e) {
        System.err.println("Failed to clone repo "+status.getRepo()+" branch "+status.getBranch()+ "["+tmpDir+"]");
        e.printStackTrace();
        if(git != null) {
          git.close();
          git = null;
        }
      }
    }
    return git;
  }
906547
@Trivial
    private static URI getURI(final File file) {
        return AccessController.doPrivileged( new PrivilegedAction<URI>() {
            @Override
            public URI run() {
                return file.toURI();
            }
        } );
    }
321589
public ProjectBuilder read(final URI file) throws IOException {
        try (InputStream in = file.toURL().openStream()) {
            return read(in, file);
        }
    }
899449
public static Project getProject(Resource resource) {
		Project retval = new Project();
		retval.setUri(resource.getUri());
		retval.setUsername(resource.getUsername());
		retval.setPassword(resource.getPassword());
		retval.setBranchTagName(resource.getBranchTagName());
		return retval;
	}
620351
public static boolean sameResource(URI uri, String otherResource) {
        try {
            return createUri(otherResource).equals(uri);
        } catch(DataSourceException e) {
            return false;
        }
    }
994178
public static File uriToFile(URI u) throws IOException {
    if (!u.getScheme().equals(NNStorage.LOCAL_URI_SCHEME)) {
      throw new IOException("URI does not represent a file");
    }
    return new File(u.getPath());
  }
665797
public File cloneRepository() {
        String scmTempFolder = new FilesUtils().createTmpFolder(false, TempFolders.UNIQUE_SCM_TEMP_FOLDER);
        cloneDirectory = new File(scmTempFolder, getType().toString().toLowerCase() + Constants.UNDERSCORE +
                getUrlName() + Constants.UNDERSCORE + getBranch());
        FilesUtils.deleteDirectory(cloneDirectory); // delete just in case it's not empty

        logger.info("Cloning repository {} ...this may take a few minutes", getUrl());
        File branchDirectory = cloneRepository(cloneDirectory);
        return branchDirectory;
    }
1178041
private void copyToLocal(AlluxioURI srcPath, AlluxioURI dstPath) throws AlluxioException,
      IOException {
    URIStatus srcStatus = mFileSystem.getStatus(srcPath);
    File dstFile = new File(dstPath.getPath());
    if (srcStatus.isFolder()) {
      // make a local directory
      if (!dstFile.exists()) {
        if (!dstFile.mkdirs()) {
          throw new IOException("mkdir failure for directory: " + dstPath);
        } else {
          System.out.println("Create directory: " + dstPath);
        }
      }

      List<URIStatus> statuses;
      try {
        statuses = mFileSystem.listStatus(srcPath);
      } catch (AlluxioException e) {
        throw new IOException(e.getMessage());
      }

      List<String> errorMessages = new ArrayList<>();
      for (URIStatus status : statuses) {
        try {
          File subDstFile = new File(dstFile.getAbsolutePath(), status.getName());
          copyToLocal(
              new AlluxioURI(srcPath.getScheme(), srcPath.getAuthority(), status.getPath()),
              new AlluxioURI(dstPath.getScheme(), dstPath.getAuthority(), subDstFile.getPath()));
        } catch (IOException e) {
          errorMessages.add(e.getMessage());
        }
      }

      if (errorMessages.size() != 0) {
        throw new IOException(Joiner.on('\n').join(errorMessages));
      }
    } else {
      copyFileToLocal(srcPath, dstPath);
    }
  }