/** * Retrieve the decoded content that is stored at this location. * * <p> * Due to the nature of GitHub's API, you're not guaranteed that * the content will already be populated, so this may trigger * network activity, and can throw an IOException. * * @deprecated * Use {@link #read()} */ public String getContent() throws IOException { return new String(DatatypeConverter.parseBase64Binary(getEncodedContent())); }
/** * Retrieve the decoded content that is stored at this location. * * <p> * Due to the nature of GitHub's API, you're not guaranteed that * the content will already be populated, so this may trigger * network activity, and can throw an IOException. * * @deprecated * Use {@link #read()} */ @SuppressFBWarnings("DM_DEFAULT_ENCODING") public String getContent() throws IOException { return new String(Base64.decodeBase64(getEncodedContent())); }
/** * Retrieve the decoded content that is stored at this location. * * <p> * Due to the nature of GitHub's API, you're not guaranteed that * the content will already be populated, so this may trigger * network activity, and can throw an IOException. * * @deprecated * Use {@link #read()} */ @SuppressFBWarnings("DM_DEFAULT_ENCODING") public String getContent() throws IOException { return new String(Base64.decodeBase64(getEncodedContent())); }
@Override protected void readDocumentsFromListingFile(GitHubLocation location, List<String> documents, String listingFileName) { try { final GHRepository repo = openRepo(location); final GHBranch branch = selectBranch(location, repo); try { final GHContent content = repo.getFileContent(listingFileName, branch.getName()); final byte[] data = Base64.decodeBase64(content .getEncodedContent().getBytes()); try (Reader in = new InputStreamReader( new ByteArrayInputStream(data))) { final Listing listing = parser.parse(in); for (final String file : listing.getFiles()) { documents.add(MountPointUtil.apply(location, file)); } } } catch (Exception e) { log.debug( "Could not read listing file. That's propably ok if it's missing. msg={}, file={}", e.getMessage(), listingFileName); } } catch (final Exception e) { log.error("failed", e); } }
@Override protected ResourceInfo getResource(final GitHubLocation location, final String path) throws FileNotFoundException { GitHub github = null; GHRepository repo = null; GHBranch branch = null; try { github = location.open(); repo = github.getRepository(location.getRepoName()); log.debug("Using branch={}", location.getBranch()); branch = repo.getBranches().get(location.getBranch()); final GHContent content = repo.getFileContent(path, branch.getName()); final byte[] data = Base64.decodeBase64(content.getEncodedContent() .getBytes()); return new ResourceInfo(path, location, new ByteArrayInputStream( data)); } catch (final FileNotFoundException e) { throw e; } catch (final IOException e) { if (e.getMessage().contains("too_large")) { return getLargeResource(github, repo, branch, location, path); } throw new FileNotFoundException( "Could not locate the file at path " + path + ". e"); } }