use of io.hops.hopsworks.persistence.entity.git.GitRepositoryRemote in project hopsworks by logicalclocks.
the class GitController method clone.
public GitOpExecution clone(CloneCommandConfiguration cloneConfigurationDTO, Project project, Users hopsworksUser) throws IllegalArgumentException, GitOpException, HopsSecurityException, DatasetException {
commandConfigurationValidator.verifyCloneOptions(cloneConfigurationDTO);
// create the repository dir. The go-git does not create a directory, so we need to create it before
String fullRepoDirPath = cloneConfigurationDTO.getPath() + File.separator + commandConfigurationValidator.getRepositoryName(cloneConfigurationDTO.getUrl());
DistributedFileSystemOps udfso = dfsService.getDfsOps(hdfsUsersController.getHdfsUserName(project, hopsworksUser));
try {
datasetController.createSubDirectory(project, new Path(fullRepoDirPath), udfso);
} finally {
// Close the udfso
dfsService.closeDfsClient(udfso);
}
Inode inode = inodeController.getInodeAtPath(fullRepoDirPath);
GitRepository repository = gitRepositoryFacade.create(inode, project, cloneConfigurationDTO.getProvider(), hopsworksUser);
// Create the default remote
gitRepositoryRemotesFacade.save(new GitRepositoryRemote(repository, Constants.REPOSITORY_DEFAULT_REMOTE_NAME, cloneConfigurationDTO.getUrl()));
GitCommandConfiguration configuration = new GitCommandConfigurationBuilder().setCommandType(GitCommandType.CLONE).setUrl(cloneConfigurationDTO.getUrl()).setProvider(cloneConfigurationDTO.getProvider()).setPath(fullRepoDirPath).setBranchName(cloneConfigurationDTO.getBranch()).build();
return executionController.createExecution(configuration, project, hopsworksUser, repository);
}
use of io.hops.hopsworks.persistence.entity.git.GitRepositoryRemote in project hopsworks by logicalclocks.
the class GitRepositoryRemoteBuilder method build.
public GitRepositoryRemoteDTO build(UriInfo uriInfo, ResourceRequest resourceRequest, Project project, GitRepository repository, String remoteName) throws GitOpException {
Optional<GitRepositoryRemote> optional = gitRepositoryRemotesFacade.findByNameAndRepository(repository, remoteName);
GitRepositoryRemote remote = optional.orElseThrow(() -> new GitOpException(RESTCodes.GitOpErrorCode.REMOTE_NOT_FOUND, Level.FINE, "Remote with name [" + remoteName + "] not found"));
return build(uriInfo, resourceRequest, project, repository, remote);
}
use of io.hops.hopsworks.persistence.entity.git.GitRepositoryRemote in project hopsworks by logicalclocks.
the class GitCommandOperationUtil method convertToRemote.
/**
* Converts [{"remoteName":"gibson","url":"https://github.com/logicalclocks/hops-hadoop-chef.git"},
* {"remoteName":"origin","url":"https://github.com/logicalclocks/hops-hadoop-chef.git"}] to List<GitRepositoryRemote>
*/
public List<GitRepositoryRemote> convertToRemote(GitRepository repository, String remotesJson) {
List<GitRepositoryRemote> remotes = new ArrayList<>();
try {
JSONArray array = new JSONArray(remotesJson);
for (int i = 0; i < array.length(); i++) {
JSONObject object = array.getJSONObject(i);
remotes.add(new GitRepositoryRemote(repository, object.getString("name"), object.getString("url")));
}
} catch (JSONException e) {
LOGGER.log(Level.SEVERE, "Could not convert json string ", e);
}
return remotes;
}
Aggregations