use of io.hops.hopsworks.persistence.entity.git.config.GitCommandConfiguration in project hopsworks by logicalclocks.
the class GitController method commit.
public GitOpExecution commit(CommitCommandConfiguration commitConfigurationDTO, Project project, Users hopsworksUser, Integer repositoryId) throws IllegalArgumentException, GitOpException, HopsSecurityException {
commandConfigurationValidator.verifyCommitOptions(commitConfigurationDTO);
String userFullName = hopsworksUser.getFname() + " " + hopsworksUser.getLname();
GitRepository repository = commandConfigurationValidator.verifyRepository(project, repositoryId);
String repositoryFullPath = inodeController.getPath(repository.getInode());
GitCommandConfiguration commandConfiguration = new GitCommandConfigurationBuilder().setCommandType(GitCommandType.COMMIT).setMessage(commitConfigurationDTO.getMessage()).setFiles(commitConfigurationDTO.getFiles()).setAll(commitConfigurationDTO.isAll()).setCommitter(new CommitterSignature(userFullName, hopsworksUser.getEmail())).setPath(repositoryFullPath).build();
return executionController.createExecution(commandConfiguration, project, hopsworksUser, repository);
}
use of io.hops.hopsworks.persistence.entity.git.config.GitCommandConfiguration 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.config.GitCommandConfiguration in project hopsworks by logicalclocks.
the class GitController method push.
public GitOpExecution push(PushCommandConfiguration configurationDTO, Project project, Users hopsworksUser, Integer repositoryId) throws GitOpException, HopsSecurityException, IllegalArgumentException {
commandConfigurationValidator.verifyRemoteNameAndBranch(configurationDTO.getRemoteName(), configurationDTO.getBranchName());
GitRepository repository = commandConfigurationValidator.verifyRepository(project, repositoryId);
String repositoryFullPath = inodeController.getPath(repository.getInode());
GitCommandConfiguration pushCommandConfiguration = new GitCommandConfigurationBuilder().setCommandType(GitCommandType.PUSH).setRemoteName(configurationDTO.getRemoteName()).setBranchName(configurationDTO.getBranchName()).setForce(configurationDTO.isForce()).setPath(repositoryFullPath).build();
return executionController.createExecution(pushCommandConfiguration, project, hopsworksUser, repository);
}
use of io.hops.hopsworks.persistence.entity.git.config.GitCommandConfiguration in project hopsworks by logicalclocks.
the class GitCommandConfigurationBuilder method build.
public GitCommandConfiguration build() throws GitOpException {
GitCommandConfiguration commandConfiguration = new GitCommandConfiguration();
commandConfiguration.setRemoteName(this.remoteName);
commandConfiguration.setRemoteUrl(this.remoteUrl);
commandConfiguration.setBranchName(this.branchName);
commandConfiguration.setForce(this.force);
commandConfiguration.setCommit(this.commit);
commandConfiguration.setUrl(this.url);
commandConfiguration.setProvider(this.provider);
commandConfiguration.setMessage(this.message);
commandConfiguration.setCommitter(this.committer);
commandConfiguration.setAll(this.all);
commandConfiguration.setFiles(this.files);
commandConfiguration.setCheckout(this.checkout);
commandConfiguration.setDeleteOnRemote(this.deleteOnRemote);
commandConfiguration.setCommandType(this.commandType);
commandConfiguration.setPath(this.path);
if (Strings.isNullOrEmpty(this.path) || this.commandType == null) {
throw new GitOpException(RESTCodes.GitOpErrorCode.INVALID_GIT_COMMAND_CONFIGURATION, Level.FINE, "Path and " + "command type in command configuration cannot be null");
}
return commandConfiguration;
}
use of io.hops.hopsworks.persistence.entity.git.config.GitCommandConfiguration in project hopsworks by logicalclocks.
the class GitCommandConfigurationConverter method convertToEntityAttribute.
@Override
public GitCommandConfiguration convertToEntityAttribute(String jsonConfig) {
if (Strings.isNullOrEmpty(jsonConfig)) {
return null;
}
try {
Unmarshaller unmarshaller = commandConfigurationContext.createUnmarshaller();
StreamSource json = new StreamSource(new StringReader(jsonConfig));
unmarshaller.setProperty(MarshallerProperties.JSON_INCLUDE_ROOT, false);
unmarshaller.setProperty(MarshallerProperties.MEDIA_TYPE, MediaType.APPLICATION_JSON);
return unmarshaller.unmarshal(json, GitCommandConfiguration.class).getValue();
} catch (JAXBException e) {
throw new IllegalStateException(e);
}
}
Aggregations