Java Based Apps on SAP Cloud_4_JAM與文檔管理

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)容

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,588評(píng)論 19 139
  • Android 自定義View的各種姿勢(shì)1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 179,111評(píng)論 25 709
  • 一 今天南京下了鵝毛大雪,今年南京的雪以往來得更早一些。坐在窗前碼字,偶爾抬頭,就能看見窗外的雪花洋洋灑灑從天上降...
    玖月成長(zhǎng)記閱讀 322評(píng)論 4 2
  • 隨著社會(huì)節(jié)奏的加快,我們變得越來越浮躁,進(jìn)而產(chǎn)生一種心態(tài):求快。 在這種心態(tài)的支配下,我們常?;孟耄ㄟ^短期的努力...
    胡豆豆joyce閱讀 771評(píng)論 0 0
  • 看所有好的育兒書和心理學(xué)書,每天練習(xí)百詞斬,流利說和嘰里呱啦提升自己英語能力,提升口語能力,18年初報(bào)雙語家庭,學(xué)...
    可樂mama閱讀 240評(píng)論 0 0

友情鏈接更多精彩內(nèi)容