Search in sources :

Example 1 with GoogleDriveGetParameters

use of org.talend.components.google.drive.runtime.utils.GoogleDriveGetParameters in project components by Talend.

the class GoogleDriveGetReader method start.

@Override
public boolean start() throws IOException {
    super.start();
    // 
    String resourceId = properties.fileAccessMethod.getValue().equals(AccessMethod.Id) ? properties.file.getValue() : utils.getFileId(properties.file.getValue());
    Map<String, MimeType> mimes = GoogleDriveMimeTypes.newDefaultMimeTypesSupported();
    mimes.put(MIME_TYPE_GOOGLE_DOCUMENT, properties.exportDocument.getValue());
    mimes.put(MIME_TYPE_GOOGLE_DRAWING, properties.exportDrawing.getValue());
    mimes.put(MIME_TYPE_GOOGLE_PRESENTATION, properties.exportPresentation.getValue());
    mimes.put(MIME_TYPE_GOOGLE_SPREADSHEET, properties.exportSpreadsheet.getValue());
    GoogleDriveGetParameters p = new GoogleDriveGetParameters(resourceId, mimes, properties.storeToLocal.getValue(), properties.outputFileName.getValue(), properties.setOutputExt.getValue());
    // 
    GoogleDriveGetResult r = utils.getResource(p);
    fileId = r.getId();
    byte[] content = r.getContent();
    record = new Record(properties.schemaMain.schema.getValue());
    record.put(0, content);
    result.totalCount++;
    result.successCount++;
    return true;
}
Also used : GoogleDriveGetResult(org.talend.components.google.drive.runtime.utils.GoogleDriveGetResult) GoogleDriveGetParameters(org.talend.components.google.drive.runtime.utils.GoogleDriveGetParameters) Record(org.apache.avro.generic.GenericData.Record) MimeType(org.talend.components.google.drive.GoogleDriveMimeTypes.MimeType)

Example 2 with GoogleDriveGetParameters

use of org.talend.components.google.drive.runtime.utils.GoogleDriveGetParameters in project components by Talend.

the class GoogleDriveGetRuntime method getFile.

public void getFile(RuntimeContainer container) {
    try {
        String resourceId = properties.fileAccessMethod.getValue().equals(AccessMethod.Id) ? properties.file.getValue() : getDriveUtils().getFileId(properties.file.getValue());
        Map<String, MimeType> mimes = GoogleDriveMimeTypes.newDefaultMimeTypesSupported();
        mimes.put(MIME_TYPE_GOOGLE_DOCUMENT, properties.exportDocument.getValue());
        mimes.put(MIME_TYPE_GOOGLE_DRAWING, properties.exportDrawing.getValue());
        mimes.put(MIME_TYPE_GOOGLE_PRESENTATION, properties.exportPresentation.getValue());
        mimes.put(MIME_TYPE_GOOGLE_SPREADSHEET, properties.exportSpreadsheet.getValue());
        GoogleDriveGetParameters p = new GoogleDriveGetParameters(resourceId, mimes, properties.storeToLocal.getValue(), properties.outputFileName.getValue(), properties.setOutputExt.getValue());
        // 
        GoogleDriveGetResult r = getDriveUtils().getResource(p);
        fileId = r.getId();
    } catch (IOException | GeneralSecurityException e) {
        LOG.error(e.getMessage());
        throw new ComponentException(e);
    }
}
Also used : GoogleDriveGetResult(org.talend.components.google.drive.runtime.utils.GoogleDriveGetResult) GoogleDriveGetParameters(org.talend.components.google.drive.runtime.utils.GoogleDriveGetParameters) GeneralSecurityException(java.security.GeneralSecurityException) ComponentException(org.talend.components.api.exception.ComponentException) IOException(java.io.IOException) MimeType(org.talend.components.google.drive.GoogleDriveMimeTypes.MimeType)

Aggregations

MimeType (org.talend.components.google.drive.GoogleDriveMimeTypes.MimeType)2 GoogleDriveGetParameters (org.talend.components.google.drive.runtime.utils.GoogleDriveGetParameters)2 GoogleDriveGetResult (org.talend.components.google.drive.runtime.utils.GoogleDriveGetResult)2 IOException (java.io.IOException)1 GeneralSecurityException (java.security.GeneralSecurityException)1 Record (org.apache.avro.generic.GenericData.Record)1 ComponentException (org.talend.components.api.exception.ComponentException)1