org.eclipse.egit.github.core.service.ContentsService Java Examples

The following examples show how to use org.eclipse.egit.github.core.service.ContentsService. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ContentTask.java    From Bitocle with Apache License 2.0 6 votes vote down vote up
@Override
protected void onPreExecute() {
    mainFragment.setRefreshStatus(true);

    context = mainFragment.getContentView().getContext();

    refreshType = mainFragment.getRefreshType();

    GitHubClient gitHubClient = mainFragment.getGitHubClient();
    contentsService = new ContentsService(gitHubClient);
    String repoOwner = mainFragment.getRepoOwner();
    String repoName = mainFragment.getRepoName();
    repositoryId = RepositoryId.create(repoOwner, repoName);
    repoPath = mainFragment.getRepoPath();

    contentItemAdapter = mainFragment.getContentItemAdapter();
    contentItemList = mainFragment.getContentItemList();
    contentItemListBuffer = mainFragment.getContentItemListBuffer();

    mainFragment.setContentShown(false);
}
 
Example #2
Source File: GithubImporter.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
private String getReadmeContent(GitHubClient client, Repository rep) throws Exception {
	ContentsService contentService = new ContentsService(client);
	RepositoryContents content = contentService.getReadme(rep);
	// TODO handle exception
	String fileConent = content.getContent();
	return new String(Base64.decodeBase64(fileConent.getBytes()));
}
 
Example #3
Source File: GithubImporter.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
private List<String> getGradleDependencies(GitHubClient client, Repository rep, List<String> gradlePath) {
	List<String> result = new ArrayList<>();
	ContentsService contentService = new ContentsService(client);
	for (String gradleFile : gradlePath) {
		List<RepositoryContents> test;
		try {
			test = contentService.getContents(rep, gradleFile);
			String valueDecoded = "";
			for (RepositoryContents content : test) {
				String fileConent = content.getContent();
				valueDecoded = new String(Base64.decodeBase64(fileConent.getBytes()));
				valueDecoded += System.getProperty("line.separator");
			}
			AstBuilder builder = new AstBuilder();
			List<ASTNode> nodes = builder.buildFromString(valueDecoded);
			DependencyVisitor visitor = new DependencyVisitor();
			walkScript(visitor, nodes);

			List<String> partialResult = visitor.getDependencies();
			if (partialResult != null)
				result.addAll(partialResult);
		} catch (Exception e) {
			logger.error(e.getMessage());
		}

	}
	return result;
}
 
Example #4
Source File: GitHubRepositoryCreationTest.java    From tool.accelerate.core with Apache License 2.0 5 votes vote down vote up
@Test
public void testGitHubRepositoryCreation() throws Exception {
    String oAuthToken = System.getProperty("gitHubOauth");
    assumeTrue(oAuthToken != null && !oAuthToken.isEmpty());
    String name = "TestAppAcceleratorProject";
    String port = System.getProperty("liberty.test.port");
    URI baseUri = new URI("http://localhost:" + port + "/start");
    ServiceConnector serviceConnector = new MockServiceConnector(baseUri);
    Services services = new Services();
    Service service = new Service();
    service.setId("wibble");
    List<Service> serviceList = Collections.singletonList(service);
    services.setServices(serviceList);
    ProjectConstructionInputData inputData = new ProjectConstructionInputData(services, serviceConnector, name, ProjectConstructor.DeployType.LOCAL, ProjectConstructor.BuildType.MAVEN, null, null, null, null, null, false);

    ProjectConstructor constructor = new ProjectConstructor(inputData);
    GitHubConnector connector = new GitHubConnector(oAuthToken);
    GitHubWriter writer = new GitHubWriter(constructor.buildFileMap(), inputData.appName, connector);
    writer.createProjectOnGitHub();

    RepositoryService repositoryService = new RepositoryService();
    repositoryService.getClient().setOAuth2Token(oAuthToken);
    UserService userService = new UserService();
    userService.getClient().setOAuth2Token(oAuthToken);
    ContentsService contentsService = new ContentsService();
    contentsService.getClient().setOAuth2Token(oAuthToken);
    Repository repository = repositoryService.getRepository(userService.getUser().getLogin(), name);
    checkFileExists(contentsService, repository, "pom.xml");
    checkFileExists(contentsService, repository, "README.md");
}
 
Example #5
Source File: GitHubRepositoryCreationTest.java    From tool.accelerate.core with Apache License 2.0 4 votes vote down vote up
private void checkFileExists(ContentsService contentsService, Repository repository, String path) throws IOException {
    List<RepositoryContents> file = contentsService.getContents(repository, path);
    assertThat(file, hasSize(1));
    assertThat(file.get(0).getSize(), greaterThan(0L));
}