Class AbstractService

java.lang.Object
com.avoka.component.sharepoint.AbstractService
Direct Known Subclasses:
Copy, Lists, UserGroup, UserProfileService, Webs

public abstract class AbstractService extends Object
Provides an abstract SharePoint service class to be extended by concrete SharePoint service implementations. This class provides utility methods for making web posts and parsing responses.
Since:
3.5.0
  • Constructor Details

    • AbstractService

      public AbstractService(SPConnection sharePointConnection)
      Create SharePoint service class with the given connection.
      Parameters:
      sharePointConnection - the SharePoint connection
  • Method Details

    • getServiceName

      protected abstract String getServiceName()
      Return the Web Service name.
      Returns:
      the web service name.
    • getSPConnection

      protected SPConnection getSPConnection()
      Returns:
      the SharePoint connection
    • getRequestMessage

      protected String getRequestMessage(String template, Map<String,String> requestModel)
      Create the WS request body message using the given Velocity template and model.
      Parameters:
      template - the request message Velocity template
      requestModel - the data model to merge with the Velocity template
      Returns:
      the WS request body message using the given Velocity template and model.
    • getWsdlUrl

      protected String getWsdlUrl()
      Returns:
      the Sharepoint Server WSDL Endpoint using the Service Classname
    • postMessage

      protected Document postMessage(String wsPortName, String requestMessage) throws SPException
      Post a request to a SharePoint Web Service PortName.
      Parameters:
      wsPortName - the Web Service PortName
      requestMessage - the request message
      Returns:
      the WS result Document
      Throws:
      SPException - if an error occurs
    • postMessage

      protected Document postMessage(String siteContext, String wsPortName, String requestMessage) throws SPException
      Post a request to a SharePoint Web Service PortName.
      Parameters:
      wsPortName - the Web Service PortName
      requestMessage - the request message
      Returns:
      the WS result Document
      Throws:
      SPException - if an error occurs
    • buildAttributeMap

      protected Map<String,String> buildAttributeMap(Document doc, String elementTag, String keyAttribName, String valueAttribName)
      Return a key/value pair map by extracting particular attribute values from a document's element tag.
      Parameters:
      doc - the document
      elementTag - the element tag name
      keyAttribName - the key attribute name
      valueAttribName - the value attribute name
      Returns:
      a Map of key/value pairs
    • getDocumentElement

      protected static Element getDocumentElement(Element srcElement, String tagName)
      Returns a Document Element by Tag Name (Assumes there is only a single element).
      Parameters:
      srcElement - the source element
      tagName - the tag name
      Returns:
      the Element for the given tag name
    • getDocumentTagValue

      protected static String getDocumentTagValue(Element srcElement, String tagName)
      Returns a Document Element Value by Tag Name (Assumes there is only a single element)
      Parameters:
      srcElement - the source element
      tagName - the tag name
      Returns:
      the tag value
    • getByteStream

      protected byte[] getByteStream(Document doc, String streamTag)
      Extracts a byte[] from a Document by looking up the given stream element tag. It is assumed there will only be a single valid stream within the document.
      Parameters:
      doc - the source document
      streamTag - the stream tag.
      Returns:
      the Base64 decoded byte data
    • loadProperty

      protected String loadProperty(String propName)
      Load property from the service class specific property file.
      Parameters:
      propName - the classpath property name to load
      Returns:
      the property value