Package com.avoka.component.sharepoint
Class AbstractService
java.lang.Object
com.avoka.component.sharepoint.AbstractService
- Direct Known Subclasses:
Copy
,Lists
,UserGroup
,UserProfileService
,Webs
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
ConstructorDescriptionAbstractService
(SPConnection sharePointConnection) Create SharePoint service class with the given connection. -
Method Summary
Modifier and TypeMethodDescriptionbuildAttributeMap
(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
Return the Web Service name.protected SPConnection
protected String
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 Details
-
Method Details
-
getServiceName
Return the Web Service name.- Returns:
- the web service name.
-
getSPConnection
- Returns:
- the SharePoint connection
-
getRequestMessage
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
- Returns:
- the Sharepoint Server WSDL Endpoint using the Service Classname
-
postMessage
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
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
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
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
-
loadProperty
Load property from the service class specific property file.- Parameters:
propName
- the classpath property name to load- Returns:
- the property value
-