|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.yahoo.marketing.apt.client.ServiceFactory
public class ServiceFactory
Factory class to obtain service objects for accessing the APT from Yahoo! Web Service API. Include functions to:
- obtain the service objects
- get Quota information from headers
- log the APT error and its soap request, response message
- get the log helper object to log customized message.
Field Summary | |
---|---|
private java.lang.String |
CLASSNAME
The name of this class. |
private Credential |
credential
Credential instance which contains the credentials to access the APT Web Service API. |
private java.util.Properties |
defaultConfig
Properties instance for storing the default settings |
private java.util.Properties |
locationCache
Properties instance for caching locations for accounts |
private LogHelper |
logHelper
Loghelper to help logging with SOAP request and response. |
private java.util.Map |
mProperties
Map instance storing the settings of the servcie factory. |
Constructor Summary | |
---|---|
ServiceFactory()
Default constructor to instantiate ServiceFactory. |
|
ServiceFactory(Credential credential)
Constructor to instantiate ServiceFactory with credential. |
|
ServiceFactory(Credential credential,
java.util.Properties factoryConfig,
java.util.Properties logConfig)
Constructor to instantiate ServiceFactory with credential. |
|
ServiceFactory(Credential credential,
java.lang.String factoryConfigFileName,
java.lang.String logConfigFileName)
Constructor to instantiate ServiceFactory with credential. |
|
ServiceFactory(java.util.Properties aptConfig,
java.util.Properties logConfig)
Constructor to instantiate ServiceFactory. |
|
ServiceFactory(java.lang.String factoryConfigFileName,
java.lang.String logConfigFileName)
Constructor to instantiate ServiceFactory. |
Method Summary | |
---|---|
private org.apache.axis.message.SOAPHeaderElement |
createAxisWSSEHeader(java.lang.String username,
java.lang.String pwd)
Creates WS-Security compliant header |
private boolean |
createDir(java.lang.String filepath,
java.lang.String filename,
java.lang.String instructions)
Creates directory where a required file is to be created. |
Credential |
getCredential()
Return the Credential object. |
java.lang.String |
getDir(java.lang.String filepath)
Utility method to return directory structure from filepath String |
java.lang.String |
getEndPointLocation()
Retrieves the service endpoint address prefix for the specific accountID in the default credential using the APT LocationService. |
java.lang.String |
getEndPointLocation(Credential credential)
Retrieves the service endpoint address prefix for the specific accountID stored in credential |
private java.lang.String |
getLocationCacheFileName(java.lang.String serviceLocationAddress)
Simple algorithm to generate a unique cache filename suffix to store location information gotten from the specified LocationService |
LogHelper |
getLogHelper()
Return the LogHelper object. |
java.lang.String |
getProperty(java.lang.String propertyName)
Return value of propertyName passed in set from property file. |
java.util.Map<java.lang.String,java.lang.String> |
getQuotaFromLastServiceCall(org.apache.axis.client.Stub service)
Retrieve the quota information and time taken millis from SOAP headers of last call on the input service object |
org.apache.axis.client.Stub |
getService(java.lang.Class klass)
Return Axis generated client for the specified service class using default credential. |
org.apache.axis.client.Stub |
getService(java.lang.Class klass,
Credential credential)
Return Axis generated client for the specified service class with credential. |
org.apache.axis.client.Stub |
getService(java.lang.String serviceName)
Return Axis generated client for the specified service name using default credential. |
org.apache.axis.client.Stub |
getService(java.lang.String serviceName,
Credential credential)
Return Axis generated client for the specified service name with credential. |
private java.lang.String |
getValue(org.w3c.dom.Element element)
Extract child node value of element passed as input |
private void |
init()
Initiate the service factory through default property file |
private void |
init(java.util.Properties factoryConfig,
boolean readCredential)
Initiate the service factory through factoryConfig |
private void |
init(java.lang.String factoryConfigFileName,
boolean readCredential)
Initiate the service factory through property file factoryConfigFileName |
private void |
initLog(java.util.Properties logConfig)
Initiate the log helper with logConfig . |
private void |
initLog(java.lang.String logConfigFileName)
Initiate the log helper with property file logConfigFileName . |
private java.util.Properties |
loadDefaultConfig()
Load the default property file. |
private void |
loadLocationCache()
Called at initialization time to load previously cached location entries. |
java.util.Properties |
loadProperties(java.lang.String fileName)
Load properties from property file filename . |
void |
logAPTErrors(Error[] errors,
java.lang.String errorSource)
Log errors returned by APT in Response objects |
void |
logAPTErrors(org.apache.axis.client.Stub service,
Error[] errors,
java.lang.String errorSource)
Log errors returned by APT in Response objects as well as the SOAP request and response messages. |
private void |
persistAccountLocationCache(java.lang.String accountID,
java.lang.String serviceLocationAddress)
Persist location retrieved from LocationService into memory cache and on disk for future use |
void |
setCredential(Credential credential)
Set the Credential object. |
private void |
setHeaders(org.apache.axis.client.Stub _stub,
Credential credential,
java.lang.String apiNS)
Set headers on the org.apache.axis.client.Stub object passed in with credential and api namespace passed in and set the timeout on the Stub |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private LogHelper logHelper
private Credential credential
private final java.lang.String CLASSNAME
private java.util.Map mProperties
private java.util.Properties locationCache
private java.util.Properties defaultConfig
Constructor Detail |
---|
public ServiceFactory() throws java.lang.IllegalStateException, java.io.IOException
java.io.IOException
java.lang.IllegalStateException
public ServiceFactory(Credential credential) throws java.lang.IllegalStateException, java.io.IOException
credential
- contains the credentials to access the APT Web Service API.
java.io.IOException
java.lang.IllegalStateException
public ServiceFactory(Credential credential, java.util.Properties factoryConfig, java.util.Properties logConfig) throws java.lang.IllegalStateException, java.io.IOException
factoryConfig
and initiate
the log helper with logConfig
.
credential
- contains the credentials to access the APT! Web Service API.factoryConfig
- contains the service factory configures.logConfig
- contains the log configures.
java.io.IOException
java.lang.IllegalStateException
public ServiceFactory(Credential credential, java.lang.String factoryConfigFileName, java.lang.String logConfigFileName) throws java.lang.IllegalStateException, java.io.IOException
factoryConfigFileName
and initiate the log helper with property file logConfigFileName
.
credential
- contains the credentials to access the APT Web Service API.factoryConfigFileName
- property file contains the service factory configures.logConfigFileName
- property file contains the log configures.
java.io.IOException
java.lang.IllegalStateException
public ServiceFactory(java.util.Properties aptConfig, java.util.Properties logConfig) throws java.lang.IllegalStateException, java.io.IOException
factoryConfig
and will construct a Credential
object if credential configures are in factoryConfig
.
It will also initiate the log helper with logConfig
.
aptConfig
- contains the service factory configures. May also contain the credential configures.logConfig
- contains the log configures
java.io.IOException
java.lang.IllegalStateException
public ServiceFactory(java.lang.String factoryConfigFileName, java.lang.String logConfigFileName) throws java.lang.IllegalStateException, java.io.IOException
factoryConfigFileName
and will construct a Credential
object if credential configures are in property file factoryConfigFileName
.
It will also initiate the log helper with property file logConfigFileName
.
factoryConfigFileName
- property file contains the service factory configures. May also contain the credential configures.logConfigFileName
- property file contains the log configures.
java.io.IOException
java.lang.IllegalStateException
Method Detail |
---|
private void initLog(java.util.Properties logConfig)
logConfig
.
logConfig
- contains the log configures.private void initLog(java.lang.String logConfigFileName) throws java.io.IOException
logConfigFileName
.
logConfigFileName
- property file which contains the log configures.
java.io.IOException
private void init() throws java.lang.IllegalStateException, java.io.IOException
java.io.IOException
java.lang.IllegalStateException
private void init(java.util.Properties factoryConfig, boolean readCredential) throws java.io.IOException, java.lang.IllegalStateException
factoryConfig. Will construct a Credential
object
if credential configures are in factoryConfig
and readCredential
is true.
- Parameters:
factoryConfig
- contains the factory configures. May also contain the credential configures.readCredential
- true if construct Credential object from factoryConfig
.
- Throws:
java.io.IOException
java.lang.IllegalStateException
private void init(java.lang.String factoryConfigFileName, boolean readCredential) throws java.lang.IllegalStateException, java.io.IOException
factoryConfigFileName. Will construct a Credential
object
if credential configures are in property file factoryConfigFileName
and readCredential
is true.
- Parameters:
factoryConfigFileName
- property file which contains the factory configures. May also contain the credential configures.readCredential
- true if construct Credential object from property file factoryConfigFileName
.
- Throws:
java.io.IOException
java.lang.IllegalStateException
private java.util.Properties loadDefaultConfig() throws java.io.IOException, java.lang.IllegalStateException
java.io.IOException
java.lang.IllegalStateException
public java.util.Properties loadProperties(java.lang.String fileName) throws java.io.IOException
filename
.
fileName
- the property file
java.io.IOException
public org.apache.axis.client.Stub getService(java.lang.Class klass, Credential credential) throws java.rmi.RemoteException, javax.xml.rpc.ServiceException, java.io.IOException, java.lang.Exception
klass
- service class.credential
- contains the credentials to access the APT Web Service API.
java.io.IOException
javax.xml.rpc.ServiceException
java.rmi.RemoteException
java.lang.Exception
public org.apache.axis.client.Stub getService(java.lang.Class klass) throws java.rmi.RemoteException, javax.xml.rpc.ServiceException, java.io.IOException, java.lang.Exception
klass
- service class.
java.io.IOException
javax.xml.rpc.ServiceException
java.rmi.RemoteException
java.lang.Exception
public org.apache.axis.client.Stub getService(java.lang.String serviceName) throws java.rmi.RemoteException, javax.xml.rpc.ServiceException, java.io.IOException, java.lang.IllegalArgumentException, java.lang.Exception
serviceName
- service name.
java.io.IOException
javax.xml.rpc.ServiceException
java.rmi.RemoteException
java.lang.Exception
java.lang.IllegalArgumentException
public org.apache.axis.client.Stub getService(java.lang.String serviceName, Credential credential) throws java.rmi.RemoteException, javax.xml.rpc.ServiceException, java.io.IOException, java.lang.IllegalArgumentException, java.lang.Exception
serviceName
- service name.credential
- contains the credentials to access the APT Web Service API.
java.io.IOException
javax.xml.rpc.ServiceException
java.rmi.RemoteException
java.lang.Exception
java.lang.IllegalArgumentException
public java.lang.String getEndPointLocation() throws javax.xml.rpc.ServiceException, java.rmi.RemoteException, java.io.IOException, javax.xml.soap.SOAPException
javax.xml.rpc.ServiceException
java.rmi.RemoteException
java.io.IOException
javax.xml.soap.SOAPException
java.lang.IllegalArgumentException
public java.lang.String getEndPointLocation(Credential credential) throws javax.xml.rpc.ServiceException, java.rmi.RemoteException, java.io.IOException, java.lang.IllegalArgumentException, javax.xml.soap.SOAPException
credential using the APT LocationService.
Retrieved from Cache if present. Else procures a LocationService object with base URL specified in the
property file then uses the LocationService object and calls the location service to get the address of the
location where the given account resides and stores the location in the cache file and local locationCache
before returning it.
- Parameters:
credential
-
- Returns:
- endPointLocation
- Throws:
javax.xml.rpc.ServiceException
java.rmi.RemoteException
java.io.IOException
javax.xml.soap.SOAPException
java.lang.IllegalArgumentException
private void loadLocationCache() throws java.io.IOException
java.io.IOException
private void persistAccountLocationCache(java.lang.String accountID, java.lang.String serviceLocationAddress) throws java.io.IOException, java.lang.IllegalArgumentException
accountID
- serviceLocationAddress
-
java.io.IOException
java.lang.IllegalArgumentException
private boolean createDir(java.lang.String filepath, java.lang.String filename, java.lang.String instructions) throws java.io.IOException
filepath
- The directory which to be created.filename
- The instruction file in the directory.instructions
- The instruction message.
java.io.IOException
public java.lang.String getDir(java.lang.String filepath)
filepath
-
private java.lang.String getLocationCacheFileName(java.lang.String serviceLocationAddress)
serviceLocationAddress
-
private void setHeaders(org.apache.axis.client.Stub _stub, Credential credential, java.lang.String apiNS) throws javax.xml.soap.SOAPException
_stub
- credential
- apiNS
-
javax.xml.soap.SOAPException
private org.apache.axis.message.SOAPHeaderElement createAxisWSSEHeader(java.lang.String username, java.lang.String pwd) throws javax.xml.soap.SOAPException
username
- pwd
-
javax.xml.soap.SOAPException
public java.util.Map<java.lang.String,java.lang.String> getQuotaFromLastServiceCall(org.apache.axis.client.Stub service) throws java.lang.IllegalArgumentException
service
-
java.lang.IllegalArgumentException
private java.lang.String getValue(org.w3c.dom.Element element)
element
-
public void logAPTErrors(Error[] errors, java.lang.String errorSource)
errors
- errorSource
- public void logAPTErrors(org.apache.axis.client.Stub service, Error[] errors, java.lang.String errorSource)
service
- errors
- errorSource
- public LogHelper getLogHelper()
public Credential getCredential()
public void setCredential(Credential credential)
credential
- public java.lang.String getProperty(java.lang.String propertyName)
propertyName
passed in set from property file.
propertyName
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |