Developing Adapters
Content
Developing Adapters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1
1.2
Programming Guidelines. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
1.3
Deleting Adapters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
PUBLIC
2015 SAP SE or an SAP affiliate company. All rights reserved.
Developing Adapters
Content
Developing Adapters
You develop new SAP HCI adapters to extend the connectivity of SAP HANA Cloud Integration with remote
systems.
SAP HANA Cloud Integration (SAP HCI) provides a set of adapters to meet standard connectivity needs. For
example, the SOAP adapter allows you to exchange SOAP messages through SAP HCI, or the SFTP adapter
supports the exchange of files with SFTP servers. These adapters can be configured in integration flow to enable
connectivity between sender and reciever systems. For more details on integration flow and on existing
adapters(channels) refer to .
To extend the connectivity options of SAP HCI, you can develop new adapter tailored along specific requirements.
Once the adapter development process has been finished, you can open the configuration user interface for the
new adapter in the integration flow editor of Integration Designer. To develop new adapters, you use Apache
Camel. You can specify the detailed set of adapter attributes as component metadata. Component metadata
defines the adapter attributes, dependencies between them and the structure of configuration interface for a
specific adapter.
For more information on the public API for adapter development, please refer to JavaDoc at: https://
cp.hana.ondemand.com/dps/d/preview/java9f7e0f1e48ef9cb24533ae257970/1.0/en-US/index.html.
1.1
Prerequisites
You are aware of the technical details of component/domain that you have to connect with SAP HCI through
the newly developed adapter type.
You have Java 7 version.
You are familiar with using Apache Camel and Java.
You have the Camel component and its dependencies as OSGi bundles.
Procedure
1. Install the Adapter SDK for SAP HCI.
For more information, see Installation Instructions
2. Open Eclipse and choose the Integration Designer perspective.
3. Create a new adapter project using the following sub-steps:
1. Select
2. Choose
File
New
Project .
3. Choose Next.
Developing Adapters
Developing Adapters
PUBLIC
2015 SAP SE or an SAP affiliate company. All rights reserved.
Note
You should not add sender and receiver words in the adapter name.
4. Develop camel component.
5. Add one mandatory camel component .jar file in component folder and the other additional (optional)
dependent .jar files in libs folder.
Note
You must add only those jar files that are valid OSGi bundles. Component jar is a camel based component
bundle. Dependent jars are the osgi bundles that are required by camel component. To create an OSGi
bundle from a normal jar component with extra manifest headers, see Creating OSGi Bundle [page 5].
6. Right click on the new adapter project or the component folder and select Generate Component Metadata to
generate a sample component metadata.
Note
Generate component metadata works only if annotations are marked in the camel bundle.
Annotations:
@UriParam : used to generate the attributes and belongs to org.apache.camel.spi.UriParam
@Required : used to make the field mandatory and belongs to the package org.apache.camel.spi.Required
Example: @UriParam
@Required
private String testField;
7. Adapt the component metadata file according to the requirements of the new adapter type.
For more details refer to documentation of component metadata [page 6].
8. If you want to verify if the adapter project has valid contents such as component metadata in metadata folder
and jar files in the libs and component folder, right click on the project and choose Execute Checks.
9. If you want to build your project locally, right click on the project and choose Build Adapter Project.
Note
Once you build locally, the system creates target.build directory, where you can find a new adapter runtime
archive.
10. To configure the Operations Server to connect your local Eclipse tooling to the tenant, execute the following
sub-steps:
1. Select
Window
Preferences
Operations Server .
PUBLIC
2015 SAP SE or an SAP affiliate company. All rights reserved.
Developing Adapters
Developing Adapters
Prerequisites
You have the required jar file.
You have setup the eclipse with plug-in development enabled.
Procedure
1. In Eclipse, go to
File
New
Project .
2. In the New Project wizard, search for Plug-in Development and select Plug-in from Existing JAR Archives.
3. Choose Next.
4. If you have the JAR in the current workspace, then choose Add and select the JAR file from the JAR selection
dialog.
5. If you do not have the JAR in your current workspace, then choose Add External and select the required JAR
file from your local system.
6. Choose Next.
7. In the Plug-in Project Propertiesdialog, specify a name in the Project name field.
8. In the Execution Environment drop down list box, select any java version that is less than or equal to
JavaSE-1.7.
9. In the Target Platform, select an OSGi framework option.
10. Choose Finish.
11. Select the MANIFEST.MF file of your project, and go to Runtime tab.
12. Choose Add.
13. Select the required export packages.
Developing Adapters
Developing Adapters
PUBLIC
2015 SAP SE or an SAP affiliate company. All rights reserved.
Results
In the directory, you can see the plug-ins folder with the OSGi bundle of jar file.
Component Metadata
This set of metadata allows you to define components details.
Table 1: Component Metadata
Property
Datatype
Cardinality Description
ComponentId
xsd:string
Attribute
Specifies a unique Id for the component. The following are technical identifi
ers and should not contain any space or special character.
Example: ctype::Adapter/cname::sap:dropbox/version::
1.0.0
ctype is type of component, which is adapter in this particular example
cname is component name, which is sap:dropbox in this example. Here, sap
is namespace and dropbox is name
version is 1.0.0
ComponentName
xsd:string
Adapter Name
Example: dropbox
PUBLIC
2015 SAP SE or an SAP affiliate company. All rights reserved.
Developing Adapters
Developing Adapters
Property
Datatype
Cardinality Description
MetadataVersion
xsd:string
Attribute
This attribute is used to indicate all the version of the metadata. Default
value is 2.0.
Variant
Groups
Child Ele
Different variants for a specific component type - for example: Sender and
ment
Child Ele
ment
hci:RuntimeCompo xsd:string
nentBaseUri
Sample Code
<ComponentMetadata ComponentId="ctype::Adapter/
cname::sap:sampleadapter/version::1.0.0"
ComponentName="sap:sampleadapter"
UIElementType="Adapter"
IsDefaultGenerator="true"
hci:RuntimeComponentBaseUri="dropbox">
Example for generated bean.xml containing camel:from
Sample Code
<camel:from id="MessageFlow_1_1435812482630"
uri="dropbox:foo?path=/input/test.txt&
method=get&sendEmptyMessageWhenIdle=false
&
initialDelay=1000&greedy=false&startS
cheduler=false&timeUnit=MILLISECONDS&
useFixedDelay=false&delay=500&runLogg
ingLevel=TRACE"/>
IsRequestResponse
xsd:string
hci:FirstUriPart
xsd:string
This attribute is used for enabling the component to allow the service call for
Request Reply. Default value is false.
Attribute
Specifies the initial part of the URI. Customer can provide custom values for
the first part of the URI string. Default value is 'foo'.
Note
IsDefaultGenerator="true" is a mandatory attribute and should never be set to false, if you wish to use the
default generator for generating route information.
Note
Metadata Version attribute is generated with default value as 2.0.
Developing Adapters
Developing Adapters
PUBLIC
2015 SAP SE or an SAP affiliate company. All rights reserved.
Variants
This set of metadata allows you to define variants for a component.
Table 2: Variants
Property
Datatype Cardinal
ity
Description
Id
xsd:string
tp::dropbox/mp::dropbox/direction::Sender
tp stands for transport protocol
mp stands for message protocol
direction refers to Sender or Receiver system
Version in the format of major.minor.micro (where micro stands for changes that
have no impact on the component, minor stands for all compatible changes and
major for incompatible changes for older CMD's default value of 1.0.0 will be de
fined.)
Name
xsd:string
Child Ele
ment
Attributes/Child Ele
Description
ments
ContentType
Child Element
PUBLIC
2015 SAP SE or an SAP affiliate company. All rights reserved.
Developing Adapters
Developing Adapters
Property
Datatype Cardinal
ity
Description
Output Content
Child Ele
Output content specifies the type of data the adapter produces. Example: XML.
ment
Table 4:
Properties
Attributes/Child Ele
Description
ments
ContentType
Child Element
xsd:string Attribute
Specifies the initial part of the URI. Customer can provide custom values for the
first part of the URI string. Default value is 'foo'.
IsRequestRes
xsd:string Attribute
This attribute is used for enabling the variant to allow the service call for Request
Reply
xsd:boo
This attribute depicts if the component has the polling behavior. (supportsPol
ponse
supportsPolling
Attribute
lean
ling). It also helps in populating the timer icon at design time when IFlow is deco
rated. Default value is false. It is applicable for sender channel only.
AttachmentBe
havior
xsd:string Attribute
If attachment behavior is not specified; system considers that the component lost
the attachment.
Note
If you want to rename a variant id or delete a variant from adapter, first undeploy the adapter with old variants
and then deploy updated adapter.
You can still view the older variants if you do not undeploy the adapter with old variants.
Tabs
This set of metadata allows you to specify tab pages for the adapter configuration user interface.
Developing Adapters
Developing Adapters
PUBLIC
2015 SAP SE or an SAP affiliate company. All rights reserved.
Table 5: Tabs
Property
Datatype
Cardinality
Description
Id
xsd:string
GuiLabels
xsd:string
<GuiLabels>
<Label language="EN">Address</Label>
</GuiLabels>
Here, Label language = "EN" represents that the text of guilabel is in english. Ad
dress is the text for the attribute name.
Currently, guilabel supports only English language.
Attribute Group
This set of metadata allows you to group adapter attributes.
Table 6: Attribute Group
Property
Datatype
Name
xsd:string
Id
xsd:string
Cardinality Description
Dropbox Endpoint
Dropbox Security Settings
AttributeRe
ference
Child Ele
ment
GuiLabels
Value - Data
Child Ele
type
ment
10
PUBLIC
2015 SAP SE or an SAP affiliate company. All rights reserved.
Developing Adapters
Developing Adapters
<Restriction>Constraint.isValidRegex([A-Za-z]+[0-9_~\\-\\.]*)
&& Constraint.isAlphaNumeric && Constraint.isStartsWithLetter |
| Constraint.isValidXpath && Constraint.isValidNCName &&
Constraint.isValidURIString
&& Constraint.isValidXMLString+</Restriction>
<!-- This tag defines message to be displayed if field value is invalid -->
<ErrorMessage>Enter a valid address. E.g. /file</ErrorMessage>
<!-- Description tag defines tool tip for field value -->
<description>Relative endpoint address on which..</description>
</AttributeReference>
<AttributeReference>
<ReferenceName>wsdlURL</ReferenceName>
<Restriction>Constraint.isValidRegex(^(https://){1}(.)+)</Restriction>
<ErrorMessage>Enter a valid URL. E.g. /wsdl/abc.wsdl;</ErrorMessage>
<description>URL to the WSDL.</description>
</AttributeReference>
<AttributeReference>
<ReferenceName>cxfOnewayRobust</ReferenceName>
<description>Used for reliable one-way message exchanges.</description>
</AttributeReference>
</AttributeGroup>
Attribute Reference
Table 7: Attribute Reference
Property
Data Type
ReferenceName
xsd:string
Cardinality
Description
Specifies that in the CMD
there is a definition associ
ated with this reference
name.
description
xsd:string
Restriction
xsd:string
ErrorMessage
xsd:string
Developing Adapters
Developing Adapters
PUBLIC
2015 SAP SE or an SAP affiliate company. All rights reserved.
11
Description
isValidRegex
isAlphaNumeric
isStartsWithLetter
isValidURIString
isValidXMLString
isValidNCName
isValidXpath
Attribute Metadata
This set of metadata allows you to define the details of all adapter attributes. This includes, for example, also the
definition of fixed values for input help, and the kind of user interface element used for an adapter attribute (for
example if it is a checkbox or a dropdown list).
The sample attribute metadata should be as shown below:
<AttributeMetadata>
<Name>address</Name>
<Usage>true</Usage>
<Default>/BSN/paymentOrder</Default>
<DataType>xsd:string</DataType>
<isparameterized>true</isparameterized>
<Length>200</Length>
<FixedValues>
<FixedValue>
<Value>Atleast Once</Value>
<GuiLabels>
<Label language="EN">Atleast Once</Label>
</GuiLabels>
</FixedValue>
</FixedValues>
<GuiLabels>
<Label language="EN">Address</Label>
</GuiLabels>
</AttributeMetadata>
Table 9: Attribute Metadata
Property
Datatype
Name
xsd:string
Cardinality
Description
Specifies the parameter id.
Example: address
12
PUBLIC
2015 SAP SE or an SAP affiliate company. All rights reserved.
Developing Adapters
Developing Adapters
Property
Datatype
Cardinality
Description
Usage
xsd:boo
lean
Specifies if the field is mandatory or not. If the value is true then usage of field is
mandatory. If the value is false then usage of field is not mandatory.
Default
xsd:string
Datatype
xsd:string
xsd:integer
xsd:password (used to mark parameters as security relevant)
If you mark a particular field as password, then that field refers to security parame
ter artifact. For more details refer to documentation of deploying and editing a se
cure parameter artifact [page 16].
Length
xsd:inte
ger
Minlength
xsd:inte
ger
Child Ele
ment
GUILabel
Child Ele
ment
Fixed
Value(s)
Child Ele
ment
FixedValue
Child Ele
ment
Fixed list of allowed values. Multiple FixedValue tags together are called a combo. If
the value has data type as <xsd:choice> then it is treated as Radio Button.
Attribute
Child Ele
Name
ment
Attribute
Child Ele
Value
ment
Developing Adapters
Developing Adapters
PUBLIC
2015 SAP SE or an SAP affiliate company. All rights reserved.
13
Property
Datatype
Cardinality
Description
AndCondi
Child Ele
tion
ment
This is complex constraint that is used when there are two or more complex or basic
constraints that need to be satisfied to achieve certain criteria.
Example of Complex condition
Sample Code
<AndCondition>
<EditCondition>
AttributeName>
<AttributeName>reference1</
<AttributeValue>reference1value</
AttributeValue>
</EditCondition>
<EditCondition>
AttributeName>
<AttributeName>reference2</
<AttributeValue>reference2value</
AttributeValue>
</EditCondition>
</AndCOndition>
As you can see in the above example AndCondition is complex condition that con
tains two or more EditConditions(basic conditions) and for the condition to be satis
fied both of these basic conditions is satisfied.
OrCondition
Child Ele
ment
14
PUBLIC
2015 SAP SE or an SAP affiliate company. All rights reserved.
Developing Adapters
Developing Adapters
Property
Datatype
Cardinality
Description
NotCondi
Child Ele
tion
ment
This is complex constraint that is mostly used with other complex constraints, this
constraint reverses the result returned by the nested complex or basic condition
Not condition can contain only one edit condition but multiple complex conditions.
These complex conditions can be used with each other.
Sample Code
<AndCondition>
EditCondition>
EditCondition>
EditCondition>
<OrCondition>
<EditCondition></
<EditCondition></
</OrCondition>
<NotCondition>
<EditCondition></
</NotCondition>
</AndCondition>
EditCondi
Child Ele
tion
ment
AttributeBe
xsd:string
havior
Child Ele
ment
field refers to alias of ssecurity parameter artifact. For more details refer to docu
mentation of deploying and editing a secure parameter artifact [page 16].
Data Type
Name
xsd:string
Usage
xsd:boolean
Developing Adapters
Developing Adapters
Cardinality
Description
PUBLIC
2015 SAP SE or an SAP affiliate company. All rights reserved.
15
Property
Data Type
Cardinality
AttributeReference
Description
Specifies reference name that
is header of the column.
Note
Each reference name con
stitutes to one column in
the table.
Guilabels
xsd:string
Sample Code
<AttributeTableMetadata>
<Name>clientCertificates</Name>
<Usage>true</Usage>
<GuiLabels guid="01c2bd59-8dd1-4efb-b795-869851eb979b">
<Label language="EN">Client Certificate Authorization</Label>
<Label language="DE">Client Certificate Authorization</Label>
</GuiLabels>
<AttributeReference>
<ReferenceName>clientCertificate.subjectDN</ReferenceName>
</AttributeReference>
<AttributeReference>
<ReferenceName>clientCertificate.issuerDN</ReferenceName>
</AttributeReference>
</AttributeTableMetadata>
Prerequisites
In the Node Explorer you have selected a tenant, in the context menu you have selected Deploy Artifacts, and you
have specified Secure Parameter as the Artifact Type.
16
PUBLIC
2015 SAP SE or an SAP affiliate company. All rights reserved.
Developing Adapters
Developing Adapters
Context
You can store secure data like password in secure store and use alias name to access this data in integration flow.
Secure parameter artifact contains this alias name and confidential data.
You can deploy artifact on the tenant by following the procedure mentioned below.
Procedure
1. Specify the attributes on the wizard page.
Option
Description
Name
Description
Secure Parameter
Note
You should mark attribute(s) as xsd:password in component metadata.
2. Choose Finish.
Note
If correct alias is configured in the integration flow, then the runtime framework passes the secured artifact
value to the component at runtime from secure store.
1.2
Programming Guidelines
Following are the guidelines that your need to understand and follow while developing adapters:
Camel Component Scheme and Name - Make sure that you use a unique camel component scheme to avoid
runtime collisions with other registered schemes. For example, camel component scheme is dropbox and the
name is DropboxComponent.
Secure Programming Secure parameters set on field level contain security relevant information (for example: OAuth tokens,
user/password, secrets). Secure parameters are stored in secure store and accessed through the alias
configured in adapter.
Deploy the secure parameters by choosing Deploy option in the Node Explorer that allows to register an
unique alias (Name*) together with the secure content (Secure Parameter, Repeat Secure Parameter)
Developing Adapters
Developing Adapters
PUBLIC
2015 SAP SE or an SAP affiliate company. All rights reserved.
17
If you have configured the respective field types in CMD as "xsd:password", instead of string and int, then
the system treats these fields as "secure parameters" by hiding the field content and treating it as alias
that has to match one of the deployed secure parameters.
Sample Code
<AttributeMetadata>
<Name>accessToken</Name>
<Usage>false</Usage>
<DataType>xsd:password</DataType>
<Default></Default>
<Flag>nonTransportable</Flag>
<Length></Length>
<GuiLabels guid="bc58f2bd-7e5a-4bf2-be44-42096f4d5a3c">
<Label language="EN">Access Token</Label>
<Label language="DE">Access Token</Label>
</GuiLabels>
</AttributeMetadata>
Security Aspects Always scan for virus in the Adapter workspace / project before deployment.
The Adapter design time content bundle cannot contain any confidential information (For example: hardcoded secrets, passwords, users or documents). You can use existing tools and hooks for configuration
of secure material `Secure Parameter Wizard" to deploy secure parameters.
Perform fortify and jlin checks.
Logging - Use Slf4j logging
Version - Provide fixed versions according to the versioning concept. Version number must adhere to strict
compatibility guidelines for maintaining semantic version of adapter. This rule is valid for Adapter projects
and Apache Camel Components. Convention: <major.minor.micro> version on manifest file (For example:
1.0.0)
Rules:
Major version increment on incompatible changes. - 2.0.0 to 3.0.0. Example: Adding mandatory fields
Minor version increment on every release (compatible enhancements) - 2.3.0 to 2.4.0. Example: Adding
non mandatory fields
Micro version increment on patches (bug fixes) - 2.3.0 to 2.3.1. Example: Modifying labels and tool tips
API Consumption - Guides on consuming APIs offered by the platform in an adapter and how to test them
with and without SAP infrastructure. To consume the APIs, you need to use the code snippet
ITAiFactory.getApi(apiType, context); wherein, apiType is the class of the requested API interface
and context represents context for the determination of the API. The context can be null if it is not required for
a particular API.
For Example: For accessing KeystoreService, use ITApiFactory.getApi(KeystoreService.class, context)
Manifest.MF + Whitelisting - The HCI runtime library packages are not accessible by default (apart from
exceptions like the ADK services and the Logging). However, if required (For example: for OSGi), you can
import packages specified in the ADK design time artifacts Manifest.MF as import-packages, which are
checked during the processing for packages that are not allowed.
18
PUBLIC
2015 SAP SE or an SAP affiliate company. All rights reserved.
Developing Adapters
Developing Adapters
1.3
Deleting Adapters
Note
If you do not delete an adapter but some other user deletes the adapter and still the metadata is available
in integration flow, then you must restart the system.
You must undeploy the integration flows using the relevant adapter before undeploying adapter.
Developing Adapters
Developing Adapters
PUBLIC
2015 SAP SE or an SAP affiliate company. All rights reserved.
19
Coding Samples
Any software coding and/or code lines / strings ("Code") included in this documentation are only examples and are not intended to be used in a productive system
environment. The Code is only intended to better explain and visualize the syntax and phrasing rules of certain coding. SAP does not warrant the correctness and
completeness of the Code given herein, and SAP shall not be liable for errors or damages caused by the usage of the Code, unless damages were caused by SAP
intentionally or by SAP's gross negligence.
Accessibility
The information contained in the SAP documentation represents SAP's current view of accessibility criteria as of the date of publication; it is in no way intended to be a
binding guideline on how to ensure accessibility of software products. SAP in particular disclaims any liability in relation to this document. This disclaimer, however, does
not apply in cases of wilful misconduct or gross negligence of SAP. Furthermore, this document does not result in any direct or indirect contractual obligations of SAP.
Gender-Neutral Language
As far as possible, SAP documentation is gender neutral. Depending on the context, the reader is addressed directly with "you", or a gender-neutral noun (such as "sales
person" or "working days") is used. If when referring to members of both sexes, however, the third-person singular cannot be avoided or a gender-neutral noun does not
exist, SAP reserves the right to use the masculine form of the noun and pronoun. This is to ensure that the documentation remains comprehensible.
Internet Hyperlinks
The SAP documentation may contain hyperlinks to the Internet. These hyperlinks are intended to serve as a hint about where to find related information. SAP does not
warrant the availability and correctness of this related information or the ability of this information to serve a particular purpose. SAP shall not be liable for any damages
caused by the use of related information unless damages have been caused by SAP's gross negligence or willful misconduct. All links are categorized for transparency
(see: http://help.sap.com/disclaimer).
20
PUBLIC
2015 SAP SE or an SAP affiliate company. All rights reserved.
Developing Adapters
Important Disclaimers and Legal Information
Developing Adapters
Important Disclaimers and Legal Information
PUBLIC
2015 SAP SE or an SAP affiliate company. All rights reserved.
21
www.sap.com/contactsap