Package com.avoka.component.sharepoint
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 Summary
Constructors Constructor Description AbstractService(SPConnection sharePointConnection)
Create SharePoint service class with the given connection.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description 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.protected byte[]
getByteStream(Document doc, String streamTag)
Extracts a byte[] from a Document by looking up the given stream element tag.protected static Element
getDocumentElement(Element srcElement, String tagName)
Returns a Document Element by Tag Name (Assumes there is only a single element).protected static String
getDocumentTagValue(Element srcElement, String tagName)
Returns a Document Element Value by Tag Name (Assumes there is only a single element)protected String
getRequestMessage(String template, Map<String,String> requestModel)
Create the WS request body message using the given Velocity template and model.protected abstract String
getServiceName()
Return the Web Service name.protected SPConnection
getSPConnection()
protected String
getWsdlUrl()
protected String
loadProperty(String propName)
Load property from the service class specific property file.protected Document
postMessage(String wsPortName, String requestMessage)
Post a request to a SharePoint Web Service PortName.protected Document
postMessage(String siteContext, String wsPortName, String requestMessage)
Post a request to a SharePoint Web Service PortName.
-
-
-
Constructor Detail
-
AbstractService
public AbstractService(SPConnection sharePointConnection)
Create SharePoint service class with the given connection.- Parameters:
sharePointConnection
- the SharePoint connection
-
-
Method Detail
-
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 templaterequestModel
- 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 PortNamerequestMessage
- 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 PortNamerequestMessage
- 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 documentelementTag
- the element tag namekeyAttribName
- the key attribute namevalueAttribName
- 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 elementtagName
- 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 elementtagName
- 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 documentstreamTag
- the stream tag.- Returns:
- the Base64 decoded byte data
-
-