public class HTTPStreamSource extends StreamSource implements ICachedSource
IURLFetcherService
and the transformation source.
// Getting source according to the XML iView properties related to current request.
HTTPStreamSource source = new HTTPStreamSource(request);
// Setting result stream
StreamResult strm = new StreamResult(response.getWriter());
// Transforming using the transformation service.
tService.transform(source, trns, paramsArray, context, null, strm);
// Getting source file - the SDN weblogs
HTTPStreamSource source = new HTTPStreamSource(request,
"http://weblogs.sdn.sap.com/pub/q/weblogs_rss?x-ver=1.0",
IConstants.Method.GET,
IConstants.CachingLevel.SHARED);
// Setting result stream
StreamResult strm = new StreamResult(response.getWriter());
// Transforming using the transformation service.
tService.transform(source, trns, paramsArray, context, null, strm);
getInputStream() is called. When using this class with the
transformation service, getInputStream() is called immediately
before the transformation is activated.
SHARED.
IURLFetcherService,
IURLFetcherProperties| Modifier and Type | Field and Description |
|---|---|
static com.sap.tc.logging.Category |
HTTP_STRM_SRC_CATEGORY
The category of the log file.
|
static com.sap.tc.logging.Location |
HTTP_STRM_SRC_LOCATION
The location in the log file.
|
FEATURE| Constructor and Description |
|---|
HTTPStreamSource(IPortalComponentRequest request)
A constructor that creates a new
HTTPStreamSource
object from the XML iView properties stored in the portal. |
HTTPStreamSource(IPortalComponentRequest request,
IURLFetcherProperties sourceProperties)
A constructor that creates a new
HTTPStreamSource object using
fetcher properties that were already initialized. |
HTTPStreamSource(IPortalComponentRequest request,
String URL)
A constructor that creates a new
HTTPStreamSource
object for a specified URL with no other HTTP properties definitions. |
HTTPStreamSource(IPortalComponentRequest request,
String URL,
IConstants.Method method,
IConstants.CachingLevel cacheLevel)
A constructor that creates a new
HTTPStreamSource object for a
specified URL and using a specified HTTP method and caching level. |
| Modifier and Type | Method and Description |
|---|---|
void |
addParameter(String paramName,
String paramValue)
Adds a parameter to the HTTP call.
|
void |
closeConnection()
Closes the open HTTP connection to the remote server.
|
IConstants.CachingLevel |
getCachingLevel()
Gets the caching level of the source XML.
|
InputStream |
getInputStream()
Gets the input stream from the fecher service.
|
Exception |
getLastError()
Gets the last error thrown.
|
IURLParameters |
getParameters()
Gets the parameters of the HTTP call.
|
String |
getPublicId() |
IPortalComponentRequest |
getRequest()
Gets the portal request object associated with the HTTP call.
|
protected Object |
getSourceFromCache()
Gets the source of the XML input stream from the cache.
|
String |
getSystemId() |
protected void |
putSourceToCache()
Places the data loaded from the input stream into the cache.
|
void |
setCacheStatus(boolean enabled)
Enables (
true) or disables (false) the cache
of the source XML. |
void |
setCachingLevel(IConstants.CachingLevel cacheLevel)
Sets the caching level of the source XML.
|
void |
setParameters(IURLParameters parameters)
Sets the URL parameters of the HTTP call.
|
void |
setPublicId(String url) |
void |
setSystemId(String url) |
getReader, setInputStream, setReader, setSystemIdpublic static final com.sap.tc.logging.Location HTTP_STRM_SRC_LOCATION
public static final com.sap.tc.logging.Category HTTP_STRM_SRC_CATEGORY
public HTTPStreamSource(IPortalComponentRequest request, IURLFetcherProperties sourceProperties)
HTTPStreamSource object using
fetcher properties that were already initialized.request - the current portal request objectsourceProperties - URL fetcher properties that initialize the
HTTP connection
* @since EP 6.0 SP7public HTTPStreamSource(IPortalComponentRequest request, String URL, IConstants.Method method, IConstants.CachingLevel cacheLevel)
HTTPStreamSource object for a
specified URL and using a specified HTTP method and caching level.request - the current portal request objectURL - the URL for the HTTP sourcemethod - HTTP methodcacheLevel - caching levelpublic HTTPStreamSource(IPortalComponentRequest request, String URL)
HTTPStreamSource
object for a specified URL with no other HTTP properties definitions.request - the current portal request objectURL - the URL for the HTTP sourcepublic HTTPStreamSource(IPortalComponentRequest request)
HTTPStreamSource
object from the XML iView properties stored in the portal. The default
cache value is SHARED.request - the current portal request objectpublic IPortalComponentRequest getRequest()
public InputStream getInputStream()
IHTTPRequest to manage the InputStream and the connection.
ITransformerService
before the transformation.
#closeConnection() method when you are finished using
the input stream.
#getLastError() method to retrieve the last error thrown.getInputStream in class StreamSourcecloseConnection()public IURLParameters getParameters()
IURLParameters object, make sure to use
the #setParameters() method to set the modified parameters.public void setParameters(IURLParameters parameters)
parameters - the URL parameterspublic void addParameter(String paramName, String paramValue) throws TransformationServiceException
paramName - the parameter nameparamValue - the value of the parameterTransformationServiceException - if the source data is corrupt,
if it cannot write to the result,
if one of the transformers doesn't
exist or if an error occurs
during the transformationpublic String getPublicId()
getPublicId in class StreamSourcepublic void setPublicId(String url)
setPublicId in class StreamSourcepublic String getSystemId()
getSystemId in interface SourcegetSystemId in class StreamSourcepublic void setSystemId(String url)
setSystemId in interface SourcesetSystemId in class StreamSourcepublic void closeConnection()
throws IOException
IOException - if it cannot close the HTTP connectionpublic Exception getLastError()
protected Object getSourceFromCache()
public void setCacheStatus(boolean enabled)
ICachedSourcetrue) or disables (false) the cache
of the source XML.setCacheStatus in interface ICachedSourceenabled - enables/disables the cacheprotected void putSourceToCache()
throws IOException
closeConnection() method is called.IOException - if the operation failspublic IConstants.CachingLevel getCachingLevel()
ICachedSourcegetCachingLevel in interface ICachedSourcepublic void setCachingLevel(IConstants.CachingLevel cacheLevel)
ICachedSourcesetCachingLevel in interface ICachedSourcecacheLevel - the caching level of the source| Access Rights |
|---|
| SC | DC | Public Part | ACH |
|---|---|---|---|
[sap.com] EP-ADMIN
|
[sap.com] tc/ep/admin/api/extd
|
api
|
EP-PIN
|
Copyright 2021 SAP SE Complete Copyright Notice