import com.sap.gateway.ip.core.customdev.util.Message
//Imports for DataStoreService-class
import com.sap.it.api.asdk.datastore.*
import com.sap.it.api.asdk.runtime.*
Message processData(Message message) {
//Get service instance
def service = new Factory(DataStoreService.class).getService()
//Check if valid service instance was retrieved
if( service != null) {
//Read data store entry via id
def dsEntry = service.get("DatastoreName","EntryId")
def result = new String(dsEntry.getDataAsArray())
message.setBody(body)
}
return message
}
import com.sap.gateway.ip.core.customdev.util.Message
//Imports for DataStoreService-class
import com.sap.it.api.asdk.datastore.*
import com.sap.it.api.asdk.runtime.*
Message processData(Message message) {
//Data to be stored in datatore
def payload = "This is sample data"
//Get service instance
def service = new Factory(DataStoreService.class).getService()
//Check if valid service instance was retrieved
if( service != null) {
def dBean = new DataBean()
dBean.setDataAsArray(payload.getBytes("UTF-8"))
//Class model offers headers, but for me it didn't work out
//Map<String, Object> headers = ["headerName1":"me", "anotherHeader": false]
//dBean.setHeaders(headers)
//Define datatore name and entry id
def dConfig = new DataConfig()
dConfig.setStoreName("DatastoreFromGroovyASDK")
dConfig.setId("TestEntry")
dConfig.setOverwrite(true)
//Write to data store
result = service.put(dBean,dConfig)
}
return message
}
import com.sap.gateway.ip.core.customdev.util.Message
//Imports for the DataStore-class handling/access
import com.sap.esb.datastore.DataStore
import com.sap.esb.datastore.Data
import org.osgi.framework.*
Message processData(Message message) {
//Get CamelContext and from that the DataStore instance
def camelCtx = message.exchange.getContext()
DataStore dataStore = (DataStore)camelCtx.getRegistry().lookupByName(DataStore.class.getName())
//Read from Datastore params => (DatastoreName, EntryId)
def dsEntry = dataStore.get("DatastoreFromGroovyServiceImpl", "TestEntry")
//Get datastore entry payload as String
def payload = new String(dsEntry.getDataAsArray())
//NOTE: If you pass the name context-name ad third parameter, you can read from
// any datastore, regardless if it's global or local! The context name usually
// equals the id of the IFlow a Datastore belongs to.
//def dsEntry = dataStore.get("DatastoreName", "ContextName", "EntryId")
//If you want to select multiple entry, use select-method and pass the
//following params => (DatastoreName, ContextName, NumberOfEntriesToPull)
//def dsEntryArray = dataStore.select("DatastoreName", "ContextName", 10)
message.setBody(payload)
return message
}
import com.sap.gateway.ip.core.customdev.util.Message
//Imports for the DataStore-class handling/access
import com.sap.esb.datastore.DataStore
import com.sap.esb.datastore.Data
import org.osgi.framework.*
Message processData(Message message) {
//Get CamelContext and from that the DataStore instance
def camelCtx = message.exchange.getContext()
DataStore dataStore = (DataStore)camelCtx.getRegistry().lookupByName(DataStore.class.getName())
//Define headers and payload/body as byte[]
Map<String, Object> headers = ["headerName1":"me", "anotherHeader": false]
def payload = "This is sample data".getBytes("UTF-8")
//Create datastore payload/data with the following parameters
//params => (DatastoreName, ContextName, EntryId, Body, Headers, MessageId, Version)
//Note: Setting ContextName to null, will create a global Datastore
Data dsData = new Data("DatastoreFromGroovyServiceImpl", null,
"TestEntry", payload, headers, "life-is-hard", 0)
//Write dsData element to the data store
//params => (DataInstance, overwriteEntry, encrypt, alertPeriodInMs, expirePeriodInMs)
dataStore.put(dsData, true, false, 13824000000, 90552000000)
return message
}
//DataStoreService.class
public int delete(String storeName, String id) throws DataStoreException
public DataBean get(String storeName, String id) throws DataStoreException
public Class<DataStoreService> getServiceInterface()
public void put(DataBean data, DataConfig config) throws DataStoreException
//DataBean.class
public byte[] getDataAsArray()
public InputStream getDataAsStream()
public Map<String, Object> getHeaders()
public void setDataAsArray(byte[] dataAsArray)
public void setDataAsStream(InputStream dataAsStream)
public void setHeaders(Map<String, Object> headers)
//DataConfig.class
public Boolean doEncrypt()
public Boolean doOverwrite()
public long getExpires()
public String getId()
public String getStoreName()
public void setEncrypt(Boolean encrypt)
public void setExpires(long expires)
public void setId(String id)
public void setOverwrite(Boolean overwrite)
public void setStoreName(String storeName)
//DataStore.class
public int countEntries(String storeName) throws DataStoreException
public int countStores(boolean alertOnly, String excludeName) throws DataStoreException
public int delete(Long tid) throws DataStoreException
public int delete(String storeName, String id) throws DataStoreException
public int delete(String storeName, String qualifier, String id) throws DataStoreException
public int deleteExpired(int blocksize) throws DataStoreException
public int deleteStore(String storeName, String qualifier, int blocksize) throws DataStoreException
public ExtendedData get(Long tid) throws DataStoreException, MessageNotFoundException
public ExtendedData get(String storeName, String id) throws DataStoreException, MessageNotFoundException
public ExtendedData get(String storeName, String qualifier, String id) throws DataStoreException, MessageNotFoundException
public DataStoreTable getDataStoreTable()
public PlatformTransactionManager getLocalTransactionManager()
public ExtendedData getLock(Long tid) throws DataStoreException, MessageNotFoundException
public ExtendedData getLock(String storeName, String qualifier, String id) throws DataStoreException, MessageNotFoundException
public Long getTid(String storeName, String qualifier, String id) throws DataStoreException, MessageNotFoundException
public int move(String storeName, String qualifier, String oldStoreName, String oldQualifier, List<String> ids) throws DataStoreException
public void put(Data data, BaseData oldData, boolean encrypt, long alert, long expires) throws DataStoreException
public void put(Data data, boolean overwrite, boolean encrypt, long alert, long expires) throws DataStoreException
public void put(Data data, boolean encrypt, long alert, long expires) throws DataStoreException
public List<Data> select(String storeName, String qualifier, int numRows) throws DataStoreException
public List<Data> select(String storeName, int numRows) throws DataStoreException
public List<String> selectIds(String storeName, String qualifier) throws DataStoreException
public List<MetaData> selectMetaData(String storeName, String id, Date alertAt, int numRows, Long excludeRowBefore) throws DataStoreException
public List<MetaData> selectMetaData(String storeName, String qualifier, String id, Date alertAt, int numRows, Long excludeRowBefore) throws DataStoreException
public List<MetaData> selectMetaData(String storeName, String qualifier, String id, Date alertAt, int numRows, Long excludeRowBefore, boolean excludeNonRetry) throws DataStoreException
public List<DataStoreAggregate> selectStores(boolean alertOnly) throws DataStoreException
public List<DataStoreAggregate> selectStoresInternal(boolean alertOnly) throws DataStoreException
public List<Long> selectTids(String storeName, String qualifier) throws DataStoreException
public void setCipherStreamFactory(CipherStreamFactory cipherStreamFactory)
public void setDataSource(DataSource dataSource)
public void setDatabaseProperties(DatabaseProperties databaseProperties)
public void setPlatformTransactionManager(PlatformTransactionManager platformTransactionManager)
public boolean supportsSaneLocking()
public void updateRetry(Long tid, Date retryAt) throws MessageNotFoundException, DataStoreException
public void updateRetry(Long tid, Date retryAt, String mplId) throws MessageNotFoundException, DataStoreException
//Data.class
public Data(String storeName, String id, InputStream data)
public Data(String storeName, String id, InputStream data, Map<String, Object> headers)
public Data(String storeName, String id, InputStream data, Map<String, Object> headers, Integer version)
public Data(String storeName, String qualifier, String id, InputStream data)
public Data(String storeName, String qualifier, String id, InputStream data, Integer version)
public Data(String storeName, String qualifier, String id, InputStream data, Map<String, Object> headers)
public Data(String storeName, String qualifier, String id, InputStream data, Map<String, Object> headers, Integer version)
public Data(String storeName, String qualifier, String id, InputStream data, Map<String, Object> headers, String mplId, Integer version)
public Data(String storeName, String qualifier, String id, InputStream data, String mplId, Integer version)
public Data(String storeName, String qualifier, String id, byte[] data)
public Data(String storeName, String qualifier, String id, byte[] data, Integer version)
public Data(String storeName, String qualifier, String id, byte[] data, Map<String, Object> headers)
public Data(String storeName, String qualifier, String id, byte[] data, Map<String, Object> headers, Integer version)
public Data(String storeName, String qualifier, String id, byte[] data, Map<String, Object> headers, String mplId, Integer version)
public Data(String storeName, String qualifier, String id, byte[] data, String mplID, Integer version)
public Data(String storeName, String id, byte[] data)
public Data(String storeName, String id, byte[] data, Map<String, Object> headers)
public Object getData()
public byte[] getDataAsArray()
public InputStream getDataAsStream()
public Map<String, Object> getHeaders()
public void setHeaders(Map<String, Object> headers)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 | |
2 |