
br.com.objectos.way.gdrive.DriveExecValid Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2014 Objectos, Fábrica de Software LTDA.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package br.com.objectos.way.gdrive;
import java.io.InputStream;
import java.util.Iterator;
import com.google.api.services.drive.Drive;
import com.google.api.services.drive.model.Change;
import com.google.api.services.drive.model.File;
/**
* @author [email protected] (Marcio Endo)
*/
class DriveExecValid implements DriveExec {
private final Drive drive;
public DriveExecValid(Drive drive) {
this.drive = drive;
}
@Override
public File directoryOf(String id) {
return execute(new DriveExecDirectoryOf(drive, id));
}
@Override
public Iterator iterateFilesOf(File file) {
String id = file.getId();
return iterateFilesOf(id);
}
@Override
public Iterator iterateFilesOf(String id) {
return execute(new DriveExecIterateFilesOf(drive, id));
}
@Override
public File getFile(String fileId) {
return execute(new DriveExecGetFile(drive, fileId));
}
@Override
public File mkdir(File file, String name) {
String id = file.getId();
return mkdir(id, name);
}
@Override
public File mkdir(String id, String name) {
return execute(new DriveExecMkdir(drive, id, name));
}
@Override
public File write(File file, From from, String title, MimeType mimeType) {
String id = file.getId();
return write(id, from, title, mimeType);
}
@Override
public File write(String id, From from, String title, MimeType mimeType) {
return execute(new DriveExecWrite(drive, id, from, title, mimeType));
}
@Override
public InputStream downloadUrl(String url) {
return execute(new DriveExecDownloadUrl(drive, url));
}
@Override
public Iterator iterateChangesOf(File file, ChangeId changeId) {
String id = file.getId();
return iterateChangesOf(id, changeId);
}
@Override
public Iterator iterateChangesOf(String id, ChangeId changeId) {
return execute(new DriveExecIterateChangesOf(drive, id, changeId));
}
@Override
public File trash(String id) {
return execute(new DriveExecTrashResource(drive, id));
}
@Override
public File untrash(String id) {
return execute(new DriveExecUntrashResource(drive, id));
}
private T execute(AbstractDriveExecCommand command) {
return command.get();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy