• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Permission类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Permission类属于com.google.api.services.drive.model包,在下文中一共展示了Permission类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: shareFolder

import com.google.api.services.drive.model.Permission; //导入依赖的package包/类
public String shareFolder(String emailAddress) throws IOException {
    Permission readPermission = new Permission()
            .setRole("reader")
            .setType("user")
            .setValue(emailAddress);

    drive.permissions().insert(folder.getId(), readPermission)
            .setSendNotificationEmails(false)
            .execute();

    String domainName = EmailUtils.extractDomain(emailAddress);

    // Getting the web link seems to return nothing but null, so let's format the URL ourselves.
    if (domainName.equals("gmail.com")) {
        return String.format("https://drive.google.com/#folders/%s", folder.getId());
    } else {
        return String.format("https://drive.google.com/a/%s/#folders/%s", domainName, folder.getId());
    }
}
 
开发者ID:openmash,项目名称:mashmesh,代码行数:20,代码来源:DriveExporter.java


示例4: 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


示例5: 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


示例6: 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


示例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.
 * @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


示例8: 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类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IndexFieldData类代码示例发布时间:2022-05-22
下一篇:
Java FunctionTemplate类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap