@Override public List<ExtRepositoryFileVersion> getExtRepositoryFileVersions( ExtRepositoryFileEntry extRepositoryFileEntry) throws PortalException { try { Drive drive = getDrive(); Drive.Revisions driveRevisions = drive.revisions(); Drive.Revisions.List driveRevisionsList = driveRevisions.list(extRepositoryFileEntry.getExtRepositoryModelKey()); RevisionList revisionList = driveRevisionsList.execute(); List<Revision> revisions = revisionList.getItems(); List<ExtRepositoryFileVersion> extRepositoryFileVersions = new ArrayList<>(revisions.size()); for (int i = 0; i < revisions.size(); i++) { Revision revision = revisions.get(i); extRepositoryFileVersions.add( new GoogleDriveFileVersion( revision, extRepositoryFileEntry.getExtRepositoryModelKey(), i + 1)); } Collections.reverse(extRepositoryFileVersions); return extRepositoryFileVersions; } catch (IOException ioe) { _log.error(ioe, ioe); throw new SystemException(ioe); } }
@Override public ExtRepositoryFileVersion getExtRepositoryFileVersion( ExtRepositoryFileEntry extRepositoryFileEntry, String version) throws PortalException { try { Drive drive = getDrive(); Drive.Revisions driveRevisions = drive.revisions(); Drive.Revisions.List driveRevisionsList = driveRevisions.list(extRepositoryFileEntry.getExtRepositoryModelKey()); RevisionList revisionList = driveRevisionsList.execute(); List<Revision> revisions = revisionList.getItems(); int[] versionParts = StringUtil.split(version, StringPool.PERIOD, 0); Revision revision = revisions.get(versionParts[0]); return new GoogleDriveFileVersion( revision, extRepositoryFileEntry.getExtRepositoryModelKey(), versionParts[0]); } catch (IOException ioe) { _log.error(ioe, ioe); throw new SystemException(ioe); } }