SAP JAM
ESPM中,使用master branch。啟用SAP JAM服務(wù)

進(jìn)入管理員界面,點(diǎn)擊外部應(yīng)用程序

點(diǎn)擊添加應(yīng)用程序,創(chuàng)建ESPM應(yīng)用
創(chuàng)建完后,點(diǎn)擊管理記錄類型,添加記錄類型

添加Product 記錄類型
外部類型:
https://espmxxxxxxxtrial.hanatrial.ondemand.com/espm-cloud-web/espm.svc/$metadata#Products注釋URL:
https://espmxxxxxxxtrial.hanatrial.ondemand.com/espm-cloud-web/webshop/reviews_annotations.xml
同樣添加CustomerReviews記錄類型
外部類型:
https://espmxxxxxxxtrial.hanatrial.ondemand.com/espm-cloud-web/espm.svc/$metadata#CustomerReviews注釋URL:
https://espmxxxxxxxtrial.hanatrial.ondemand.com/espm-cloud-web/webshop/reviews_annotations.xml
在CustomerReviews記錄類型中,添加2個(gè)過濾器,分別過濾Rating eq 5和Rating eq 1

在產(chǎn)品設(shè)置-群組模板中,我們可以上傳模板,模板下載地址https://sapjamsamplecode.github.io/GroupTemplates/ESPM_Reviews-Products.zip

在主頁的業(yè)務(wù)記錄,可以看到ESPM應(yīng)用

點(diǎn)擊進(jìn)去可以查看詳細(xì)

針對(duì)單條記錄,我們可以創(chuàng)建群組,模板選擇上傳的 ESPM Review-Product 模塊

查看創(chuàng)建的群組,點(diǎn)擊面板上的編輯,可以編輯組件內(nèi)容

刪除原來的小部件,點(diǎn)擊添加小部件按鈕,可以添加相關(guān)業(yè)務(wù)記錄的內(nèi)容,編輯完成后,點(diǎn)擊發(fā)布,更新應(yīng)用

點(diǎn)擊相關(guān)的條目,可以再次添加評(píng)論

文檔管理
HCP通過CMIS服務(wù)來管理文檔

文檔管理步驟
1 Create a new repository:創(chuàng)建一個(gè)RepositoryOptions,設(shè)置唯一的Name與Key,創(chuàng)建InitialContext并調(diào)用
lookup("java:comp/env/EcmService")方法創(chuàng)建EcmService
RepositoryOptions options = new RepositoryOptions();
options.setUniqueName("com.foo.MyRepository");
options.setRepositoryKey("my_super_secret_key_123"); // (min. 10 chars)
options.setVisibility(Visibility.PROTECTED);
//optionally enable virus scanning on upload: options.setVirusScannerEnabled(true);
InitialContext ctx = new InitialContext();
EcmService ecmService = (EcmService) ctx.lookup("java:comp/env/EcmService");
ecmService.createRepository(options);
2 Connect and fetch the root folder:通過Name與Key連到EcmService,可以獲取RootFolder
openCmisSession = ecmService.connect(”com.foo.MyRepository”, ”my_super_secret_key_123”);
Folder root = openCmisSession.getRootFolder();
3 Get all children of root folder:通過root folder可以獲取子文件夾
ItemIterable<CmisObject> children = root.getChildren();
for (CmisObject o : children) { ... }
4 Create a new document:創(chuàng)建新的文檔,定義文檔的類型與名稱,再定義內(nèi)容,文檔內(nèi)容轉(zhuǎn)成InputStream
// define manadatory properties
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
properties.put(PropertyIds.NAME, "HelloWorld.txt");
// define the content
byte[] helloContent = "Hello World!".getBytes("UTF-8");
InputStream stream = new ByteArrayInputStream(helloContent);
ContentStream contentStream = openCmisSession.getObjectFactory().createContentStream("HelloWorld.txt",
helloContent.length, "text/plain; charset=UTF-8", stream);
// create the document below the root node
root.createDocument(properties, contentStream, VersioningState.NONE);
在SalesOrderProcessor.java文件的getSalesOrderById方法調(diào)用InvoiceBuilder生成PDF文檔
// if the sales order are fetched successfully, generate the pdf report data.
try {
if (CMISSessionHelper.getInstance().getSession() != null) {
InvoiceBuilder builder = new InvoiceBuilder();
String reportPath = builder.generateInvoice(soiList);
updateSalesOrderHeader(reportPath, soiList, em);
}
ESPM中的文檔管理
InvoiceBuilder中,通過Folder root = CMISSessionHelper.getInstance().getSession().getRootFolder();調(diào)用公共類CMISSessionHelper中的方法獲取API,CMISSessionHelper公共方法中,定義了獲取文檔的Session等內(nèi)容。
網(wǎng)頁訪問時(shí),點(diǎn)擊下載按鈕調(diào)用CmisRead這個(gè)Servlet,首先在init方法中獲取CmisSession
public void init(ServletConfig config) throws ServletException {
super.init(config);
try {
openCmisSession = CMISSessionHelper.getInstance().getSession();
} catch (Exception | NoClassDefFoundError e1) {
LOGGER.error(e1.getMessage());
}
}
在doGet方法中,獲取文檔流,并輸出
final String objectId = request.getParameter("objectId");
try {
if (openCmisSession != null) {
Document doc = (Document) openCmisSession.getObject(objectId);
ContentStream content = doc.getContentStream();
String type = content.getMimeType();
String name = content.getFileName();
int length = (int) content.getLength();
InputStream stream = content.getStream();
response.setContentType(type);
response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + name);
response.setContentLength(length);
ioCopy(stream, response.getOutputStream());
} else {
response.setStatus(501);
}
} catch (Exception exception) {
exception.printStackTrace();
}
Twitter APP
CheckOut Twitter Branch
TwitterUpdateWs.java文件中,修改final String statusMessage = "@openSAP test connection";,TwitterUpdate.java文件中,記錄Key與Secret。
static String consumerKeyStr = twitterDetails.get("consumerApplicationKey");
static String consumerSecretStr = twitterDetails.get("consumerApplicationSecret");
config.properities文件中,確定DestinationName
#Twitter Application Keys
OAuthDestinationName=twitterOauth
apps.twitter
登陸https://apps.twitter.com,創(chuàng)建APP,其中Callback URL 填寫webshop的URL,Permission改為Read, write, and direct messages,獲取Consumer Key (API Key)與Consumer Secret (API Secret)

HCP Destination
HCP中創(chuàng)建鏈接,名稱為OAuthDestinationName的內(nèi)容,添加屬性,key為代碼中consumerApplicationKey與consumerApplicationSecret,value為Twitter API中的值

測(cè)試APP
登陸https://espmc5228335trial.hanatrial.ondemand.com/espm-cloud-web,首次登陸會(huì)有Twitter授權(quán)頁面

創(chuàng)建Order并CheckOut
查看Twitter發(fā)布的消息,即為statusMessage中的內(nèi)容
