@Override public ValidationResult validate(RuntimeContainer container) { ValidationResult vr = new ValidationResultMutable(Result.OK); // check for Connection attributes if (StringUtils.isEmpty(serviceAccountFile)) { vr = new ValidationResultMutable(Result.ERROR).setMessage("Service Account JSON File cannot be empty."); return vr; } try { // make a dummy call to check drive's connection.. User u = getDriveService().about().get().setFields("user").execute().getUser(); LOG.debug("[validate] Testing User Properties: {}.", u); } catch (Exception ex) { LOG.error("[validate] {}.", ex.getMessage()); vr = new ValidationResultMutable(Result.ERROR).setMessage(ex.getMessage()); return vr; } return ValidationResult.OK; }
@Override public ValidationResult validate(RuntimeContainer container) { ValidationResult vr = new ValidationResultMutable(Result.OK); // check for Connection attributes if (StringUtils.isEmpty(serviceAccountFile)) { vr = new ValidationResultMutable(Result.ERROR).setMessage("Service Account JSON File cannot be empty."); return vr; } try { // make a dummy call to check drive's connection.. User u = getDriveService().about().get().setFields("user").execute().getUser(); LOG.debug("[validate] Testing User Properties: {}.", u); } catch (Exception ex) { LOG.error("[validate] {}.", ex.getMessage()); vr = new ValidationResultMutable(Result.ERROR).setMessage(ex.getMessage()); return vr; } return ValidationResult.OK; }
@Override @SuppressWarnings("all") public boolean isConnected() { boolean result = false; try { File file = new File(CLIENT_SECRET_JSON); if(file.exists()) { driveAuthService.getService(getContext().getCredsFile()).about(); sheetsAuthService.getService(getContext().getCredsFile()).spreadsheets(); result = true; } } catch(Exception e) { } return result; }
public String call() throws Exception { // make a dummy call to check drive's connection... User u = getDriveService().about().get().setFields("user").execute().getUser(); return u.toPrettyString(); } });
public String call() throws Exception { // make a dummy call to check drive's connection... User u = getDriveService().about().get().setFields("user").execute().getUser(); return u.toPrettyString(); } });
@Override public Space get() throws BackgroundException { try { final About about = session.getClient().about().get().setFields("user, storageQuota").execute(); final Long used = null == about.getStorageQuota().getUsage() ? 0L : about.getStorageQuota().getUsage(); final Long available = null == about.getStorageQuota().getLimit() ? Long.MAX_VALUE : about.getStorageQuota().getLimit() - used; return new Space(used, available); } catch(IOException e) { throw new DriveExceptionMappingService().map("Failure to read attributes of {0}", e, new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory))); } } }