Class SPClient

java.lang.Object
com.avoka.component.sharepoint.SPClient

public class SPClient extends Object
Provides a Microsoft SharePoint Client class with web service factory methods.

SharePoint Client Example

The Groovy script example below illustrates using the SPClient object to create an List SharePoint web service object, which is then user to lookup a list collection. In this examples configuration Service Parameters are accessed via the params map object.

 import com.avoka.component.sharepoint.SPClient
 import com.avoka.component.sharepoint.service.List

 // Create a SharePoint client using the service params map with the configured connection details
 def spClient = new SPClient(params.username, params.password, params.url, params.domain)

 // Create a List web service
 def listService = spClient.getLists()

 // Get a List collection map
 def collectionMap = listService.getListCollection(params.siteContext) 

A SPClient can also be created by passing it a Map of connection parameters. This is typically used when the SharePoint server connection details are configured as Service Parameters. The service parameters must include:

  • username - the SharePoint server login username
  • password - the SharePoint server login password
  • url - the SharePoint server URL
  • domain - the SharePoint server Domain
An example SPClient being created with a Map of Service parameters is provided below:
 // Provides a Groovy script based submission delivery process.
 //
 // Script parameters include:
 //    submission : com.avoka.fc.core.entity.Submission
 //    submissionXml : String
 //    receiptPDF : byte[]
 //    attachmentsMap : Mapinvalid input: '<'String, com.avoka.fc.form.service.DataDocument>
 //    deliveryCheckpoint : com.avoka.fc.core.service.submission.DeliveryCheckpointService
 //    serviceDefinition : com.avoka.fc.core.entity.ServiceDefinition
 //    serviceParameters : Mapinvalid input: '<'String, String>
 import com.avoka.component.sharepoint.SPClient
 import com.avoka.component.sharepoint.service.Copy

 // Create a SharePoint client using the service params map with the configured connection details
 def spClient = new SPClient(serviceParameters)

 // Create a Copy web service
 def copyService = spClient.getCopy()

 // Copy the PDF receipt to location
 def path = "http://test-sharepoint/form/" + submission.receiptNumber + ".pdf"
 def displayName = submission.formName + " " + submission.receiptNumber
 def internalName = displayName
 def sourcePath = "http://null"

 copyService.copyIntoItems(path, displayName, internalName, sourcePath, receiptPDF) 
Since:
3.5.0
  • Constructor Details

    • SPClient

      public SPClient(String username, String password, String serverUrl, String serverDomain) throws SPException
      Instantiate a SharePoint client with the provided connection details.
      Parameters:
      username - SharePoint login username
      password - SharePoint login passsword
      serverUrl - SharePoint server URL
      serverDomain - SharePoint server domain
      Throws:
      SPException - in case of SharePoint error response during authentication
    • SPClient

      public SPClient(Map<String,String> serviceParameters) throws SPException
      Instantiate a SharePoint client with the provided connection details map.

      The serviceParameter constructor argument must contain the following key values:

      • username - the SharePoint server login username
      • password - the SharePoint server login password
      • url - the SharePoint server URL
      • domain - the SharePoint server Domain
      Parameters:
      serviceParameters - the containing the SharePoint server connection details with the names: [ "username", "password", "url", "domain" ].
      Throws:
      SPException - in case of SharePoint error response during authentication
  • Method Details

    • getCopy

      public Copy getCopy()
      Return a Copy SharePoint web service.

      Groovy Example

      The Groovy script example below illustrates using the SPClient object to create an Copy SharePoint web service object. In this examples configuration Service Parameters are accessed via the params map object.

       import com.avoka.component.sharepoint.SPClient
       import com.avoka.component.sharepoint.service.Copy
      
       // Create a SharePoint client using the service params map with the configured connection details
       def spClient = new SPClient(params.username, params.password, params.url, params.domain)
      
       // Create a Copy web service
       def copyService = spClient.getCopy()
      
       // Get an item byte array
       def itemData = copyService.getItem(params.path) 
      Returns:
      a Copy SharePoint web service.
    • getLists

      public Lists getLists()
      Return a Lists SharePoint web service.

      Groovy Example

      The Groovy script example below illustrates using the SPClient object to create an List SharePoint web service object. In this examples configuration Service Parameters are accessed via the params map object.

       import com.avoka.component.sharepoint.SPClient
       import com.avoka.component.sharepoint.service.Lists
      
       // Create a SharePoint client using the service params map with the configured connection details
       def spClient = new SPClient(params.username, params.password, params.url, params.domain)
      
       // Create a List web service
       def listService = spClient.getLists()
      
       // Get a List collection map
       def collectionMap = listService.getListCollection(params.siteContext) 
      Returns:
      a Lists SharePoint web service.
    • getUserGroup

      public UserGroup getUserGroup()
      Return a UserGroup SharePoint web service.

      Groovy Example

      The Groovy script example below illustrates using the SPClient object to create an UserGroup SharePoint web service object. In this examples configuration Service Parameters are accessed via the params map object.

       import com.avoka.component.sharepoint.SPClient
       import com.avoka.component.sharepoint.service.UserGroup
      
       // Create a SharePoint client using the service params map with the configured connection details
       def spClient = new SPClient(params.username, params.password, params.url, params.domain)
      
       // Create a UserGroup web service
       def userGroupService = spClient.getUserGroup()
      
       // Get a User object for the given username
       def user = userGroupService.getUserInfo(username) 
      Returns:
      a UserGroup SharePoint web service.
    • getUserProfileService

      public UserProfileService getUserProfileService()
      Return a UserProfileService SharePoint web service.

      Groovy Example

      The Groovy script example below illustrates using the SPClient object to create an UserProfileService SharePoint web service object. In this examples configuration Service Parameters are accessed via the params map object.

       import com.avoka.component.sharepoint.SPClient
       import com.avoka.component.sharepoint.service.UserProfileService
      
       // Create a SharePoint client using the service params map with the configured connection details
       def spClient = new SPClient(params.username, params.password, params.url, params.domain)
      
       // Create a UserProfileService web service
       def userProfileServiceService = spClient.getUserProfileService()
      
       // Get a user profile property data object for the given account name
       def propertyData = userProfileServiceService.getUserProfileByName(accountname) 
      Returns:
      UserProfileService SharePoint web service.
    • getWebs

      public Webs getWebs()
      Return a Webs SharePoint web service.

      Groovy Example

      The Groovy script example below illustrates using the SPClient object to create an Webs SharePoint web service object. In this examples configuration Service Parameters are accessed via the params map object.

       import com.avoka.component.sharepoint.SPClient
       import com.avoka.component.sharepoint.service.Webs
      
       // Create a SharePoint client using the service params map with the configured connection details
       def spClient = new SPClient(params.username, params.password, params.url, params.domain)
      
       // Create a Webs web service
       def websService = spClient.getWebs()
      
       // Get a web object for the given url
       def web = websService.getWeb(url) 
      Returns:
      Webs SharePoint web service.