Show: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
CollabMSGraphClient
Signature
global with sharing class CollabMSGraphClient
CollabMSGraphClient Methods
createFolder(userId, driveId, parentId, name)
Create folder "name" in drive identified by "driveId" with parent identified by "parentId"
Signature
global static SaveFileResponse createFolder(String userId, String driveId, String parentId, String name)
Parameters
userId
Type:
String
user ID
driveId
Type:
String
drive ID
parentId
Type:
String
parent ID
name
Type:
String
folder name
Returns
created folder
createSharingLink(userId, driveId, itemId)
creates a shareable link.
Signature
global static CreateLinkResponse createSharingLink(String userId, String driveId, String itemId)
Parameters
userId
Type:
String
user ID
driveId
Type:
String
drive ID
itemId
Type:
String
item Id
Returns
create a shareable link, the <var>link.webUrl</var> field contains the <u>shareable link</u>
Example
ensurePath(userId, driveId, path)
checks if the path exists on SharePoint
Signature
global static Boolean ensurePath(String userId, String driveId, String path)
Parameters
userId
Type:
String
user ID
driveId
Type:
String
drive ID
path
Type:
String
path to folder, <strong>Without file part</strong>
Returns
true on success
getDrive(userId, siteUrl)
Get drive from URL. You probably do not want to use this. #getSiteDrive()
Signature
global static GetDriveResponse getDrive(String userId, String siteUrl)
Parameters
userId
Type:
String
user Id
siteUrl
Type:
String
site URL
Returns
corresponding drive
See
CollabMSGraphClient.getSiteDrive()
getDriveItemByPath(userId, driveId, path)
Retrieve drive item in drive "driveId" at path <var>path</var>
Signature
global static GetDriveResponse getDriveItemByPath(String userId, String driveId, String path)
Parameters
userId
Type:
String
User Id
driveId
Type:
String
drive ID
path
Type:
String
path
Returns
drive item at path <var>path</var>. See: GetDriveResponse
See
CollabMSGraphClient.getDriveItemsByPath to get the children
Example
getDriveItemsById(userId, driveId, childId)
Retrieve drive items(children) in drive "driveId" identified by <var>childId<var>
Signature
global static GetDriveContentResponse getDriveItemsById(String userId, String driveId, String childId)
Parameters
userId
Type:
String
User Id
driveId
Type:
String
drive ID
childId
Type:
String
child id
Returns
drive item with id <var>childId</var>. See: GetDriveContentResponse
See
CollabMSGraphClient.getDriveItemByPath to get the children
Example
getDriveItemsByPath(userId, driveId, path)
Retrieve drive items (children) in drive "driveId" at path <var>path</var>
Signature
global static GetDriveContentResponse getDriveItemsByPath(String userId, String driveId, String path)
Parameters
userId
Type:
String
User Id
driveId
Type:
String
drive ID
path
Type:
String
path
Returns
drive items (children) at path <var>path</var>. See: GetDriveContentResponse
See
CollabMSGraphClient.getDriveItemByPath to get the item itself
getFile(userId, url, isLibrary, path)
Gets a SharePoint file
Signature
global static GetFileResponse getFile(String userId, String url, Boolean isLibrary, String path)
Parameters
userId
Type:
String
the user of which the SharePoint credentials should be used. Current user: UserInfo.getUserId()
url
Type:
String
Site Library Url
isLibrary
Type:
Boolean
unless you are using an old version, use "true"
path
Type:
String
sharepoint library folder patch
Returns
GetFileResponse object
Example
getFileAsPDF(userId, url, isLibrary, path)
Converts a SharePoint file into PDF - Remote Site Setting: https://westeurope1-mediap.svc.ms
Signature
global static GetFileResponse getFileAsPDF(String userId, String url, Boolean isLibrary, String path)
Parameters
userId
Type:
String
the user of which the SharePoint credentials should be used. Current user: UserInfo.getUserId()
url
Type:
String
Site Library Url
isLibrary
Type:
Boolean
unless you are using an old version, use "true"
path
Type:
String
sharepoint library folder patch
Returns
GetFileResponse object
Example
getRefreshedToken(userId)
Get a refreshed OAuth token. This method will save this token to the user, so afterwards, it will not be possible to callout to SharePoint in the same request
Signature
global static String getRefreshedToken(String userId)
Parameters
userId
Type:
String
the user id
Returns
refreshed token
getSiteDrive(userId, libraryUrl)
Get drive from URL, tacking into account sites and libraries.
Signature
global static GetDriveResponse getSiteDrive(String userId, String libraryUrl)
Parameters
userId
Type:
String
user Id
libraryUrl
Type:
String
site/library URL
Returns
corresponding drive: GetDriveResponse
isSubsite(domain, siteName, possibleSubSiteName, token)
Signature
global static Boolean isSubsite(String domain,String siteName,String possibleSubSiteName,String token)
Parameters
domain
Type:
String
Sharepoint domain
siteName
Sharepoint site
possibleSubSiteName
Sharepoint subsite
token
Sharepoint auth token
Returns
Whether <var>possibleSubSiteName</var> is a sub site of <var>siteName</var> for domain <var>domain</var>
See
CollabOAuthController.getSavedToken
refreshToken(userId)
Get a refreshed OAuth token. This method will save this token to the user, so afterwards, it will not be possible to callout to SharePoint in the same request
Signature
global static String refreshToken(String userId)
Parameters
userId
Type:
String
the user id
Returns
refreshed token
renameFolder(userId, url, isLibrary, basePath, sourceName, targetName)
Change the name of folder in a SharePoint Library
Signature
global static SaveFileResponse renameFolder(String userId,String url, Boolean isLibrary, String basePath, String sourceName,String targetName)
Parameters
userId
Type:
String
User ID
url
URR
isLibrary
Type:
Boolean
Is <var>url</var> pointing to a Library ?
basePath
Type:
String
Path to folder containing the driveItem to rename
sourceName
Type:
String
driveItem source name
targetName
driveItem desired name
Returns
changed driveItem, the id field contains the <u>list item id</u>
Example
sanitizeFileName(dirtyFilename)
General cleanup of characters SharePoint cannot deal with
Signature
global static String sanitizeFileName(String dirtyFilename)
Parameters
dirtyFilename
Type:
String
Filename <em>without</em> the path
Returns
clean URL
Example
sanitizeFolderName(dirtyFolderName)
General cleanup of characters SharePoint cannot deal with
Signature
global static String sanitizeFolderName(String dirtyFolderName)
Parameters
dirtyFolderName
Type:
String
Folder name <em>not</em> the entire path
Returns
clean URL
sanitizeFolderOrFileName(dirtyFolderOrFilename)
Only use if required. This attempt to detect if it's a file or folder by looking up for a dot (".") and apply the "appropriate" sanitization.
Signature
global static String sanitizeFolderOrFileName(String dirtyFolderOrFilename)
Parameters
dirtyFolderOrFilename
Type:
String
file or folder name
Returns
sanitized folder or file name
sanitizeFolderPath(dirtyFolderPath)
General cleanup of characters SharePoint cannot deal with
Signature
global static String sanitizeFolderPath(String dirtyFolderPath)
Parameters
dirtyFolderPath
Type:
String
Url path of the folder <em>without</em> filename (use{@link CollabMSGraphClient.sanitizeFileName})
Returns
clean URL
See
Example
saveFile(userId, url, isLibrary, path, fileContent)
Save file
Signature
global static SaveFileResponse saveFile(String userId, String url, Boolean isLibrary, String path, Blob fileContent)
Parameters
userId
Type:
String
user ID
url
Type:
String
drive URL
isLibrary
Type:
Boolean
indicate if it is a library
path
Type:
String
target path
fileContent
Type:
Blob
file content
Returns
saved file
saveFile(userId, driveUrl, path, fileContent)
Save file in a site drive
Signature
global static SaveFileResponse saveFile(String userId, String driveUrl, String path, Blob fileContent)
Parameters
userId
Type:
String
user ID
driveUrl
Type:
String
drive URL
path
Type:
String
target path
fileContent
Type:
Blob
file content
Returns
saved file
saveFileById(userId, driveId, parentId, fileName, fileContent)
Save file in a site drive using IDs
Signature
global static SaveFileResponse saveFileById(String userId, String driveId, String parentId, String fileName, Blob fileContent)
Parameters
userId
Type:
String
user ID
driveId
Type:
String
drive ID
parentId
Type:
String
parent ID
fileName
Type:
String
file name
fileContent
Type:
Blob
file content
Returns
saved file
updateColumns(userId, driveId, itemId, fields)
Update columns values (fields) for file in a site drive using IDs. Warning: the files has to be part of a LIST.
Signature
global static SaveFileResponse updateColumns(String userId,String driveId, String itemId,Map<String,String> fields)
Deprecated
use CollabMSGraphClient.updateMetadataColumns instead.
Parameters
userId
Type:
String
user ID
driveId
drive ID
itemId
Type:
String
parent ID
fields
custom columns values (fields) for file
Returns
saved file, the id field contains the <u>list item id</u>
See
CollabMSGraphClient.getDriveItemByPath - to retrieve itemId from drive and path, CollabMSGraphClient.getDrive - to retrieve driveId for sites, CollabMSGraphClient.getSiteDrive - to retrieve driveId for lists
Example
updateContentType(userId, driveId, itemId, contentTypeId)
Update ContentType for file in a site drive using IDs. Warning: the files has to be part of a LIST.
Signature
global static SaveFileResponse updateContentType(String userId,String driveId, String itemId,String contentTypeId)
Parameters
userId
Type:
String
user ID
driveId
drive ID
itemId
Type:
String
parent ID
contentTypeId
custom ContentType for file
Returns
saved file, the id field contains the <u>list item id</u>
updateMetadataColumns(userId, driveId, itemId, fields)
Update columns values (fields) for file in a site drive using IDs. Warning: the files has to be part of a LIST.
Signature
global static SaveFileResponse updateMetadataColumns(String userId,String driveId, String itemId,Map<String,Object> fields)
Parameters
userId
Type:
String
user ID
driveId
drive ID
itemId
Type:
String
parent ID
fields
custom columns values (fields) for file
Returns
saved file, the id field contains the <u>list item id</u>
See
CollabMSGraphClient.getDriveItemByPath - to retrieve itemId from drive and path, CollabMSGraphClient.getDrive - to retrieve driveId for sites, CollabMSGraphClient.getSiteDrive - to retrieve driveId for lists
Example
urlEncodeFilePath(url)
Convenience method for encoding url's.
Signature
global static String urlEncodeFilePath(String url)
Parameters
url
Type:
global static String
Url to encode
Returns
url-encoded URL
CollabMSGraphClient.Application
Signature
global class Application
CollabMSGraphClient.Application Properties
CollabMSGraphClient.Application ConstructorsApplication(parser)
Signature
global Application(JSONParser parser)
CollabMSGraphClient.CreateLinkResponse
Signature
global class CreateLinkResponse
CollabMSGraphClient.CreateLinkResponse Properties
CollabMSGraphClient.CreateLinkResponse Methods
isError()
Signature
global Boolean isError()
isError(errorCode)
checks if there is an error with a certain error-code present
Signature
global Boolean isError(String errorCode)
CollabMSGraphClient.CreateLinkResponseData
Signature
global class CreateLinkResponseData
CollabMSGraphClient.CreateLinkResponseData Properties
CollabMSGraphClient.CreateLinkResponseData ConstructorsCreateLinkResponseData(parser)
Signature
global CreateLinkResponseData(JSONParser parser)
CollabMSGraphClient.DriveItemResponse
Class to wrap an item, eg File, in a folder
Signature
global class DriveItemResponse
CollabMSGraphClient.DriveItemResponse Properties
CollabMSGraphClient.DriveItemResponse ConstructorsDriveItemResponse(parser)
Signature
global DriveItemResponse(JSONParser parser)
CollabMSGraphClient.GetDriveContentResponse
Class to wrap the Drive content returned from SharePoint
Signature
global class GetDriveContentResponse
CollabMSGraphClient.GetDriveContentResponse Properties
CollabMSGraphClient.GetDriveContentResponse Methods
isError()
checks if there is an error present
Signature
global Boolean isError()
isError(errorCode)
checks if there is an error with a certain error-code present
Signature
global Boolean isError(String errorCode)
CollabMSGraphClient.GetDriveResponse
Class to wrap the Drive information returned from SharePoint
Signature
global class GetDriveResponse
CollabMSGraphClient.GetDriveResponse Properties
CollabMSGraphClient.GetDriveResponse Methods
isError()
checks if there is an error present
Signature
global Boolean isError()
isError(errorCode)
checks if there is an error with a certain error-code present
Signature
global Boolean isError(String errorCode)
CollabMSGraphClient.GetDriveResponseData
Class to wrap the Drive response from SharePoint
Signature
global class GetDriveResponseData
CollabMSGraphClient.GetDriveResponseData Properties
CollabMSGraphClient.GetDriveResponseData ConstructorsGetDriveResponseData(parser)
Signature
global GetDriveResponseData(JSONParser parser)
GetDriveResponseData(id)
Signature
global GetDriveResponseData(String id)
CollabMSGraphClient.GetFileResponse
Class to wrap the File returned from SharePoint
Signature
global class GetFileResponse
CollabMSGraphClient.GetFileResponse Properties
CollabMSGraphClient.GetFileResponse Methods
isError()
checks if there is an error present
Signature
global Boolean isError()
isError(errorCode)
checks if there is an error with a certain error-code present
Signature
global Boolean isError(String errorCode)
CollabMSGraphClient.GraphErrorResponse
Class to wrap the errors
Signature
global class GraphErrorResponse
CollabMSGraphClient.GraphErrorResponse Properties
CollabMSGraphClient.GraphErrorResponse ConstructorsGraphErrorResponse(parser)
Signature
global GraphErrorResponse(JSONParser parser)
GraphErrorResponse()
Signature
GraphErrorResponse()
CollabMSGraphClient.Link
Signature
global class Link
CollabMSGraphClient.Link Properties
CollabMSGraphClient.Link ConstructorsLink(parser)
Signature
global Link(JSONParser parser)
CollabMSGraphClient.ParentReference
reference to the parent
Signature
global class ParentReference
CollabMSGraphClient.ParentReference Properties
CollabMSGraphClient.ParentReference ConstructorsParentReference(parser)
Signature
global ParentReference(JSONParser parser)
CollabMSGraphClient.SaveFileResponse
Response info after saving a File to SharePoint
Signature
global class SaveFileResponse
CollabMSGraphClient.SaveFileResponse Properties
CollabMSGraphClient.SaveFileResponse Methods
isError()
checks if there is an error present
Signature
global Boolean isError()
isError(errorCode)
checks if there is an error with a certain error-code present
Signature
global Boolean isError(String errorCode)
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||