static ArrayList<BulkAdGroupProductPartition> applyBulkProductPartitionActions( ArrayList<BulkAdGroupProductPartition> partitionActions) throws IOException, ExecutionException, InterruptedException { FileUploadParameters fileUploadParameters = new FileUploadParameters(); fileUploadParameters.setResultFileDirectory(new File(FileDirectory)); fileUploadParameters.setResultFileName(ResultFileName); fileUploadParameters.setUploadFilePath(new File(FileDirectory + UploadFileName)); fileUploadParameters.setResponseMode(ResponseMode.ERRORS_AND_RESULTS); fileUploadParameters.setOverwriteResultFile(true); Writer = new BulkFileWriter(new File(FileDirectory + UploadFileName)); for (BulkAdGroupProductPartition partitionAction : partitionActions) { Writer.writeEntity(partitionAction); } Writer.close(); File bulkFilePath = BulkService.uploadFileAsync(fileUploadParameters, null, null).get(); Reader = new BulkFileReader(bulkFilePath, ResultFileType.UPLOAD, FileType); BulkEntityIterable entities = Reader.getEntities(); ArrayList<BulkAdGroupProductPartition> bulkAdGroupProductPartitionResults = new ArrayList<BulkAdGroupProductPartition>(); for (BulkEntity entity : entities) { if (entity instanceof BulkAdGroupProductPartition) { bulkAdGroupProductPartitionResults.add((BulkAdGroupProductPartition) entity); outputBulkAdGroupProductPartitions(bulkAdGroupProductPartitionResults); } } entities.close(); Reader.close(); return bulkAdGroupProductPartitionResults; }
static BulkFileReader uploadEntities(List<BulkEntity> uploadEntities) throws IOException, ExecutionException, InterruptedException { Writer = new BulkFileWriter(new File(FileDirectory + UploadFileName)); for (BulkEntity entity : uploadEntities) { Writer.writeEntity(entity); } Writer.close(); FileUploadParameters fileUploadParameters = new FileUploadParameters(); fileUploadParameters.setResultFileDirectory(new File(FileDirectory)); fileUploadParameters.setResultFileName(ResultFileName); fileUploadParameters.setUploadFilePath(new File(FileDirectory + UploadFileName)); fileUploadParameters.setResponseMode(ResponseMode.ERRORS_AND_RESULTS); fileUploadParameters.setOverwriteResultFile(true); File bulkFilePath = BulkService.uploadFileAsync(fileUploadParameters, null, null).get(); return new BulkFileReader(bulkFilePath, ResultFileType.UPLOAD, FileType); }