当前位置: 首页>>代码示例>>Java>>正文


Java Permission.setRole方法代码示例

本文整理汇总了Java中com.google.api.services.drive.model.Permission.setRole方法的典型用法代码示例。如果您正苦于以下问题:Java Permission.setRole方法的具体用法?Java Permission.setRole怎么用?Java Permission.setRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.api.services.drive.model.Permission的用法示例。


在下文中一共展示了Permission.setRole方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setPermission

import com.google.api.services.drive.model.Permission; //导入方法依赖的package包/类
private boolean setPermission(Track track, String tableId) throws IOException, GoogleAuthException {
  boolean defaultTablePublic = PreferencesUtils.getBoolean(context,
      R.string.export_google_fusion_tables_public_key,
      PreferencesUtils.EXPORT_GOOGLE_FUSION_TABLES_PUBLIC_DEFAULT);
  if (!defaultTablePublic) {
    return true;
  }
  GoogleAccountCredential driveCredential = SendToGoogleUtils.getGoogleAccountCredential(
      context, account.name, SendToGoogleUtils.DRIVE_SCOPE);
  if (driveCredential == null) {
    return false;
  }
  Drive drive = SyncUtils.getDriveService(driveCredential);
  Permission permission = new Permission();
  permission.setRole("reader");
  permission.setType("anyone");
  permission.setValue("");   
  drive.permissions().insert(tableId, permission).execute();
  
  shareUrl = SendFusionTablesUtils.getMapUrl(track, tableId);
  return true;
}
 
开发者ID:Plonk42,项目名称:mytracks,代码行数:23,代码来源:SendFusionTablesAsyncTask.java

示例2: insertPermission

import com.google.api.services.drive.model.Permission; //导入方法依赖的package包/类
/**
 * Insert a new permission.
 * 
 * @param service
 *            Drive API service instance.
 * @param fileId
 *            ID of the file to insert permission for.
 * @return The inserted permission if successful, {@code null} otherwise.
 */
private static Permission insertPermission(Drive service, String fileId,
		String value, String type, String role) {
	Permission newPermission = new Permission();

	newPermission.setValue(value);
	newPermission.setType(type);
	newPermission.setRole(role);
	try {
		return service.permissions().insert(fileId, newPermission)
				.execute();
	} catch (IOException e) {
		System.out.println("An error occurred: " + e);
	}
	return null;
}
 
开发者ID:plutext,项目名称:docx4j-cloud-GoogleDrive,代码行数:25,代码来源:Docx4jUploadToGoogleDrive.java

示例3: shareWithUser

import com.google.api.services.drive.model.Permission; //导入方法依赖的package包/类
public void shareWithUser(String fileId, String userEmail, boolean canWrite) throws IOException {
	Permission permission = new Permission();

	permission.setValue(userEmail);
	permission.setType("user");
	permission.setRole(canWrite ? "writer" : "reader");

	drive.permissions().insert(fileId, permission).execute();
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:10,代码来源:ShareFileOperation.java

示例4: shareWithAnyone

import com.google.api.services.drive.model.Permission; //导入方法依赖的package包/类
public void shareWithAnyone(String fileId, boolean canWrite, boolean withLink) throws IOException {
	Permission permission = new Permission();

	permission.setValue("");
	permission.setType("anyone");
	permission.setRole(canWrite ? "writer" : "reader");
	permission.setWithLink(withLink);
	
	drive.permissions().insert(fileId, permission).execute();
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:11,代码来源:ShareFileOperation.java

示例5: executeDrivePermission

import com.google.api.services.drive.model.Permission; //导入方法依赖的package包/类
protected void executeDrivePermission(Drive drive, String fileId, String email)
    throws ODKExternalServiceException {

  oauth2logger.info("Switching file permissions");

  if (email == null) {
    throw new ODKExternalServiceException(NO_EMAIL_SPECIFIED_ERROR);
  }

  try {
    String userName = email.substring(SecurityUtils.MAILTO_COLON.length());

    Permission newPermission = new Permission();
    newPermission.setKind("drive#permission");
    newPermission.setRole("owner");
    newPermission.setType("user");
    newPermission.setEmailAddress(userName);

    // NOTE: Dropped the check because name was not a good value to compare

    Drive.Permissions.Create createPerm = drive.permissions().create(fileId, newPermission);
    // ownership transfer now requires notification e-mail
    // createPerm.setSendNotificationEmail(false);
    createPerm.setTransferOwnership(true);
    Permission response = createPerm.execute();

    if (response == null) {
      oauth2logger.error(NO_PERM_RETURNED);
      throw new ODKExternalServiceException(NO_PERM_RETURNED);
    }

  } catch (IOException e) {
    throw new ODKExternalServiceException(e);
  }
}
 
开发者ID:opendatakit,项目名称:aggregate,代码行数:36,代码来源:GoogleOauth2ExternalService.java

示例6: insertPermission

import com.google.api.services.drive.model.Permission; //导入方法依赖的package包/类
/**
 * Insert a new permission.
 * 
 * @param service Drive API service instance.
 * @param fileId ID of the file to insert permission for.
 * @param value User or group e-mail address, domain name or
 *            {@code null} "default" type.
 * @param type The value "user", "group", "domain" or "default".
 * @param role The value "owner", "writer" or "reader".
 * @return The inserted permission if successful, {@code null}
 *         otherwise.
 * @throws UploadException 
 */
public static Permission insertPermission(Drive service, String fileId,
        String value, String type, String role) throws UploadException {
    Permission newPermission = new Permission();

    newPermission.setValue(value);
    newPermission.setType(type);
    newPermission.setRole(role);
    try {
        return service.permissions().insert(fileId, newPermission)
                .execute();
    } catch (IOException e) {
        throw new UploadException(e);
    }
}
 
开发者ID:mba811,项目名称:loli.io,代码行数:28,代码来源:GDriveAPI.java

示例7: insertPermission

import com.google.api.services.drive.model.Permission; //导入方法依赖的package包/类
/**
 * Insert a new permission.
 *
 * @param service
 *            Drive API service instance.
 * @param fileId
 *            ID of the file to insert permission for.
 * @param value
 *            User or group e-mail address, domain name or {@code null}
 *            "default" type.
 * @param type
 *            The value "user", "group", "domain" or "default".
 * @param role
 *            The value "owner", "writer" or "reader".
 * @return The inserted permission if successful, {@code null} otherwise.
 */
private static Permission insertPermission(Drive service, String fileId) {
	Permission newPermission = new Permission();

	newPermission.setValue("[email protected]");
	newPermission.setType("user");
	newPermission.setRole("writer");
	try {
		return service.permissions()
				.insert(fileId, newPermission)
				.execute();
	} catch (IOException e) {
        Log.e("myStress","Error on setting Permission for GDrive-File: " + e.getMessage());
	}
	return null;
}
 
开发者ID:BlackHawk90,项目名称:myStress,代码行数:32,代码来源:myStress_upload_service.java


注:本文中的com.google.api.services.drive.model.Permission.setRole方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。