use of org.eclipse.che.api.workspace.server.devfile.FileContentProvider in project che-server by eclipse-che.
the class BitbucketServerAuthorizingFactoryParametersResolver method createFactory.
/**
* Create factory object based on provided parameters
*
* @param factoryParameters map containing factory data parameters provided through URL
* @throws BadRequestException when data are invalid
*/
@Override
public FactoryMetaDto createFactory(@NotNull final Map<String, String> factoryParameters) throws ApiException {
// no need to check null value of url parameter as accept() method has performed the check
final BitbucketUrl bitbucketUrl = bitbucketURLParser.parse(factoryParameters.get(URL_PARAMETER_NAME));
final FileContentProvider fileContentProvider = new BitbucketServerAuthorizingFileContentProvider(bitbucketUrl, urlFetcher, gitCredentialManager, personalAccessTokenManager);
// create factory from the following location if location exists, else create default factory
return urlFactoryBuilder.createFactoryFromDevfile(bitbucketUrl, fileContentProvider, extractOverrideParams(factoryParameters)).orElseGet(() -> newDto(FactoryDto.class).withV(CURRENT_VERSION).withSource("repo")).acceptVisitor(new BitbucketFactoryVisitor(bitbucketUrl));
}
use of org.eclipse.che.api.workspace.server.devfile.FileContentProvider in project devspaces-images by redhat-developer.
the class BitbucketServerAuthorizingFactoryParametersResolver method createFactory.
/**
* Create factory object based on provided parameters
*
* @param factoryParameters map containing factory data parameters provided through URL
* @throws BadRequestException when data are invalid
*/
@Override
public FactoryMetaDto createFactory(@NotNull final Map<String, String> factoryParameters) throws ApiException {
// no need to check null value of url parameter as accept() method has performed the check
final BitbucketUrl bitbucketUrl = bitbucketURLParser.parse(factoryParameters.get(URL_PARAMETER_NAME));
final FileContentProvider fileContentProvider = new BitbucketServerAuthorizingFileContentProvider(bitbucketUrl, urlFetcher, gitCredentialManager, personalAccessTokenManager);
// create factory from the following location if location exists, else create default factory
return urlFactoryBuilder.createFactoryFromDevfile(bitbucketUrl, fileContentProvider, extractOverrideParams(factoryParameters)).orElseGet(() -> newDto(FactoryDto.class).withV(CURRENT_VERSION).withSource("repo")).acceptVisitor(new BitbucketFactoryVisitor(bitbucketUrl));
}
use of org.eclipse.che.api.workspace.server.devfile.FileContentProvider in project devspaces-images by redhat-developer.
the class GithubAuthorizingFileContentProviderTest method shouldPreserveAbsolutePaths.
@Test
public void shouldPreserveAbsolutePaths() throws Exception {
URLFetcher urlFetcher = Mockito.mock(URLFetcher.class);
GithubUrl githubUrl = new GithubUrl().withUsername("eclipse").withRepository("che");
FileContentProvider fileContentProvider = new GithubAuthorizingFileContentProvider(githubUrl, urlFetcher, gitCredentialManager, personalAccessTokenManager);
String url = "https://raw.githubusercontent.com/foo/bar/devfile.yaml";
fileContentProvider.fetchContent(url);
verify(urlFetcher).fetch(eq(url));
}
use of org.eclipse.che.api.workspace.server.devfile.FileContentProvider in project devspaces-images by redhat-developer.
the class GithubAuthorizingFileContentProviderTest method shouldThrowNotFoundForPublicRepos.
@Test(expectedExceptions = FileNotFoundException.class)
public void shouldThrowNotFoundForPublicRepos() throws Exception {
URLFetcher urlFetcher = Mockito.mock(URLFetcher.class);
String url = "https://raw.githubusercontent.com/foo/bar/devfile.yaml";
when(urlFetcher.fetch(eq(url))).thenThrow(FileNotFoundException.class);
when(urlFetcher.fetch(eq("https://api.github.com/repos/eclipse/che"))).thenReturn("OK");
GithubUrl githubUrl = new GithubUrl().withUsername("eclipse").withRepository("che");
FileContentProvider fileContentProvider = new GithubAuthorizingFileContentProvider(githubUrl, urlFetcher, gitCredentialManager, personalAccessTokenManager);
fileContentProvider.fetchContent(url);
}
use of org.eclipse.che.api.workspace.server.devfile.FileContentProvider in project devspaces-images by redhat-developer.
the class GitlabAuthorizingFileContentProviderTest method shouldPreserveAbsolutePaths.
@Test
public void shouldPreserveAbsolutePaths() throws Exception {
URLFetcher urlFetcher = Mockito.mock(URLFetcher.class);
GitlabUrl gitlabUrl = new GitlabUrl().withHostName("gitlab.net").withUsername("eclipse").withProject("che");
FileContentProvider fileContentProvider = new GitlabAuthorizingFileContentProvider(gitlabUrl, urlFetcher, gitCredentialsManager, personalAccessTokenManager);
String url = "https://gitlab.net/api/v4/projects/eclipse%2Fche/repository/files/devfile.yaml/raw";
fileContentProvider.fetchContent(url);
verify(urlFetcher).fetch(eq(url));
}
Aggregations