本文整理汇总了Java中com.google.api.services.drive.model.Change类的典型用法代码示例。如果您正苦于以下问题:Java Change类的具体用法?Java Change怎么用?Java Change使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Change类属于com.google.api.services.drive.model包,在下文中一共展示了Change类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFileAddedChange
import com.google.api.services.drive.model.Change; //导入依赖的package包/类
@Test
public void testFileAddedChange() throws IOException {
// Given
File file1 = createTextFile("file1.txt", "the contents");
File file2 = createTextFile("file2.txt", "the contents");
// When
// sometimes, we have deleted files (from previous tests ?)
List<Change> changes = getChangesOperation.getChanges(startChangeId).stream()
.filter(change -> change.getDeleted() == false).collect(Collectors.toList());
// Then
assertEquals("There is not 2 changes as expected :" + changes, 2, changes.size());
assertThat(changes).filteredOn(change->change.getFileId().equals(file1.getId())).hasSize(1);
assertThat(changes).filteredOn(change->change.getFileId().equals(file2.getId())).hasSize(1);
}
示例2: isChangeInValidSubfolder
import com.google.api.services.drive.model.Change; //导入依赖的package包/类
/** */
private boolean isChangeInValidSubfolder(Change change){
// If no folder specified, change is valid.
if (folderName == null){
return true;
}
// Else, check if parent of file changed is in valid subfolders.
if (change.getFile() != null){
List<ParentReference> references = change.getFile().getParents();
if (references != null && !references.isEmpty()){
for (ParentReference reference : references){
if (subfoldersId.contains(reference.getId())){
return true;
}
}
}
}
return false;
}
示例3: scan
import com.google.api.services.drive.model.Change; //导入依赖的package包/类
/** Scan the Google Drive folder for last changes. */
private Long scan(String folder, Long lastChangesId) throws Exception{
if (logger.isDebugEnabled()){
logger.debug("Starting scanning of folder {} since {}", folder, lastChangesId);
}
DriveChanges changes = drive.getChanges(lastChangesId);
// Browse change and checks if its indexable before starting.
for (Change change : changes.getChanges()){
if (change.getFile() != null && DriveRiverUtil.isIndexable(change.getFile().getTitle(),
feedDefinition.getIncludes(), feedDefinition.getExcludes())){
if (change.getDeleted()){
esDelete(indexName, typeName, change.getFileId());
} else {
indexFile(change.getFile());
}
}
}
return changes.getLastChangeId();
}
示例4: getDriveChangesInfo
import com.google.api.services.drive.model.Change; //导入依赖的package包/类
/**
* Gets the drive changes info in the My Tracks folder, including deleted
* files.
*
* @param changeId the largest change id
* @param changes a map of drive id to file for the changes
* @return an updated largest change id
*/
private long getDriveChangesInfo(long changeId, Map<String, File> changes) throws IOException {
Changes.List request = drive.changes().list().setStartChangeId(changeId + 1);
do {
ChangeList changeList = request.execute();
long newId = changeList.getLargestChangeId().longValue();
for (Change change : changeList.getItems()) {
if (change.getDeleted()) {
changes.put(change.getFileId(), null);
} else {
File file = change.getFile();
if (file.getLabels().getTrashed()) {
changes.put(change.getFileId(), null);
} else {
changes.put(change.getFileId(), file);
}
}
}
if (newId > changeId) {
changeId = newId;
}
request.setPageToken(changeList.getNextPageToken());
} while (request.getPageToken() != null && request.getPageToken().length() > 0);
Log.d(TAG, "Got drive changes: " + changes.size() + " " + changeId);
return changeId;
}
示例5: getChanges
import com.google.api.services.drive.model.Change; //导入依赖的package包/类
public List<Change> getChanges(Long startChangeId) throws IOException {
List<Change> changes = new ArrayList<Change>();
Changes.List request = drive.changes().list();
if (startChangeId != null) {
request.setStartChangeId(startChangeId);
}
do {
ChangeList changeList = request.execute();
changes.addAll(changeList.getItems());
request.setPageToken(changeList.getNextPageToken());
} while (request.getPageToken() != null && request.getPageToken().length() > 0);
return changes;
}
示例6: fireBookmarksFileChanged
import com.google.api.services.drive.model.Change; //导入依赖的package包/类
private void fireBookmarksFileChanged(BookmarkId bookmarkFolderId, Change change) {
for (IBookmarksFileChangeListener listener : listenerList) {
SafeRunner.run(new ISafeRunnable() {
public void run() throws Exception {
listener.bookmarksFileChanged(bookmarkFolderId, change);
}
public void handleException(Throwable exception) {
StatusHelper.logError("Error in bookmarks file change listener", exception);
}
});
}
}
示例7: testNoChanges
import com.google.api.services.drive.model.Change; //导入依赖的package包/类
@Test
public void testNoChanges() throws IOException {
// Given
// When
List<Change> changes = getChangesOperation.getChanges(startChangeId);
// Then
assertEquals(0, changes.size());
}
示例8: testGetNextStartChangeId
import com.google.api.services.drive.model.Change; //导入依赖的package包/类
@Test
public void testGetNextStartChangeId() throws Exception {
// Given
File file1 = createTextFile("file1.txt", "the contents");
waitUntilFileChange(startChangeId, file1.getId());
List<Change> changes = getChangesOperation.getChanges(startChangeId);
// When
startChangeId = changes.get(changes.size() - 1).getId() + 1;
File file2 = createTextFile("file2.txt", "the contents");
// Then
waitUntilFileChange(startChangeId, file2.getId());
}
示例9: testGet
import com.google.api.services.drive.model.Change; //导入依赖的package包/类
@Test
public void testGet() throws Exception {
final com.google.api.services.drive.model.ChangeList list = requestBody("direct://LIST", null);
List<Change> items = list.getItems();
if (!items.isEmpty()) {
Change change = items.get(0);
Long id = change.getId();
// using String message body for single parameter "changeId"
final com.google.api.services.drive.model.Change result = requestBody("direct://GET", id);
assertNotNull("get result", result);
LOG.debug("get: " + result);
}
}
示例10: getNewDiffs
import com.google.api.services.drive.model.Change; //导入依赖的package包/类
public List<String> getNewDiffs() throws Exception {
getDeviceFolderId(true); // required
Log.d(TAG, "Looking for updates in the device folder...");
List<String> result = new ArrayList<String>();
long lcid = session.driveLastChangeID();
ChangeList changes;
File file;
Changes.List request = service.changes().list().setIncludeDeleted(false).setIncludeSubscribed(
false).setFields("items/file,largestChangeId,nextPageToken").setStartChangeId(lcid + 1);
do {
try {
changes = request.execute();
for (Change change: changes.getItems()) {
file = change.getFile();
if (!file.getTitle().endsWith(".diff"))
continue;
// check for deleted (looks like List.setIncludeDeleted(false) has no effects)
Boolean deleted = change.getDeleted();
if (deleted != null && deleted)
continue;
deleted = file.getExplicitlyTrashed();
if (deleted != null && deleted)
continue;
for (ParentReference parent: file.getParents())
if (parent.getId().equals(deviceId)) {
result.add(file.getId());
break;
}
}
lcid = changes.getLargestChangeId();
request.setPageToken(changes.getNextPageToken());
} catch (Exception err) {
Log.e(TAG, "getNewDiffs", err);
request.setPageToken(null);
}
} while (request.getPageToken() != null && request.getPageToken().length() > 0);
session.setDriveLastChangeID(lcid);
Log.i(TAG, "Found " + Integer.toString(result.size()) + " diffs since last check.");
return result;
}
示例11: webhook_receiveFolderChanges
import com.google.api.services.drive.model.Change; //导入依赖的package包/类
@ApiMethod(
name = "webhook.receiveFolderChanges",
path = "webhook/receiveFolderChanges",
httpMethod = HttpMethod.POST
)
public void webhook_receiveFolderChanges(HttpServletRequest httpServletRequest, Change change) {
String projectKey = httpServletRequest.getHeader("X-Goog-Channel-Token");
Project project = ProjectService.getInstance().get(projectKey);
logger.info("Receiving folder changes for project "+projectKey);
//TODO: to be implemented
}
示例12: waitUntilFileChange
import com.google.api.services.drive.model.Change; //导入依赖的package包/类
private Change waitUntilFileChange(Long startChangeId, String fileId) throws TimeoutException {
return Waiter.waitUntil("No change for file " + fileId, () -> getChangesOperation.getChanges(startChangeId)
.stream().filter(change -> change.getFileId().equals(fileId)).findFirst()).get();
}
示例13: bookmarksFileChanged
import com.google.api.services.drive.model.Change; //导入依赖的package包/类
@Override
public void bookmarksFileChanged(BookmarkId bookmarkFolderId, Change change) {
events.add(new BookmarksFileChange(bookmarkFolderId, change));
}
示例14: BookmarksFileChange
import com.google.api.services.drive.model.Change; //导入依赖的package包/类
public BookmarksFileChange(BookmarkId bookmarkFolderId, Change change) {
this.bookmarkFolderId = bookmarkFolderId;
this.change = change;
}
示例15: getAllChanges
import com.google.api.services.drive.model.Change; //导入依赖的package包/类
public List<Change> getAllChanges(Long startChangeId) {
return retrieveAllChangesImpl(startChangeId, 3);
}