使用API在網頁上列出表單 listing-forms-on-a-web-page-using-apis

AEM Forms提供REST型搜尋API,網頁開發人員可透過此API查詢及擷取符合搜尋條件的一組表單。 您可以使用API來根據各種篩選器搜尋表單。 回應物件包含表單屬性、屬性和轉譯器表單端點。

若要使用REST API搜尋表單,請傳送GET要求至伺服器: https://'[server]:[port]'/libs/fd/fm/content/manage.json 並使用如下所述的查詢引數。

查詢引數 query-parameters

屬性名稱
說明
函式

指定要呼叫的函式。 若要搜尋表單,請設定 func 歸因至 searchForms.

例如, URLParameterBuilder entityBuilder=new URLParameterBuilder (); entityBuilder.add("func", "searchForms");

注意: 此引數為必要項。

apppath

指定要搜尋表單的應用程式路徑。 依預設,appPath屬性會搜尋根節點層級的所有可用應用程式。

您可以在單一搜尋查詢中指定多個應用程式路徑。 請使用垂直號(|)分隔多個路徑。

剪下點

指定要與資產一起擷取的屬性。 您可以使用星號(*)一次擷取所有屬性。 使用垂直號(|)運運算元指定多個屬性。

例如, cutPoints=propertyName1|propertyName2|propertyName3

注意

  • 系統一律會擷取ID、路徑和名稱等屬性。
  • 每個資產都有不同的屬性集。 formUrl、pdfUrl和guideUrl等屬性不依賴於cutpoints屬性。 這些屬性視資產型別而定,系統會據以擷取。
關係

指定要與搜尋結果一起擷取的相關資產。 您可以選擇下列其中一個選項來擷取相關資產:

  • NO_RELATION:請勿擷取相關資產。
  • 立即:擷取與搜尋結果直接相關的資產。
  • 全部:擷取直接和間接相關的資產。
maxSize
指定要擷取的表單數上限。
offset
指定從開始起要略過的表單數目。
returnCount
指定是否傳回符合指定條件的搜尋結果。
陳述式

指定陳述式清單。 查詢會在以JSON格式指定的陳述式清單上執行。

例如,

JSONArray statementArray=new JSONArray(); JSONObject statement=new JSONObject(); statement.put("name", "title"); statement.put("value", "SimpleSurveyAF"); statement.put("operator", "EQ"); statementArray.put(statement);

在上述範例中,

  • 名稱:指定要搜尋的屬性名稱。

  • :指定要搜尋的屬性值。

  • 運運算元:指定搜尋時要套用的運運算元。 支援下列運運算元:

    • EQ — 等於
    • NEQ — 不等於
    • GT — 大於
    • LT — 小於
    • GTEQ — 大於或等於
    • LTEQ — 小於或等於
    • CONTAINS - A包含B,如果B是A的一部分
    • 全文 — 全文搜尋
    • STARTSTWITH — 如果B是A的開頭部分,則A以B開頭
    • ENDSWITH — 如果B是A的結尾部分,則A結尾為B
    • LIKE — 實作LIKE運運算元
    • AND — 合併多個陳述式

    注意: GT、LT、GTEQ和LTEQ運運算元適用於線性型別的屬性,例如LONG、DOUBLE和DATE。

排序

指定搜尋結果的順序條件。 條件會以JSON格式定義。 您可以在多個欄位上排序搜尋結果。 結果會依查詢中欄位的出現順序排序。

例如,

若要擷取依標題屬性遞增順序排序的查詢結果,請新增下列引數:

JSONArray orderingsArray=new JSONArray(); JSONObject orderings=new JSONObject(); orderings.put("name", "title"); orderings.put("criteria", "ASC"); orderingsArray.put(orderings); entityBuilder.add("orderings", orderingsArray.toString());

  • 名稱:指定用來排序搜尋結果的屬性名稱。

  • 條件:指定結果的順序。 order屬性接受下列值:

    • ASC — 使用ASC以遞增順序排列結果。
    • DES — 使用DES以遞減順序排列結果。
includeXdp
指定是否要擷取二進位內容。 此 includeXdp 屬性適用於以下型別的資產: FORMPDFFORM、和 PRINTFORM.
assetType
指定要從所有發佈的資產中擷取的資產型別。 使用垂直號(|)運運算元可指定多種資產型別。 有效的資產型別為FORM、PDF表單、PRINTFORM、RESOURCE和GUIDE。

範例要求 sample-request

func : searchForms
appPath : /content/dam/formsanddocuments/MyApplication23
cutPoints : title|description|author|status|creationDate|lastModifiedDate|activationDate|expiryDate|tags|allowedRenderFormat|formmodel
relation : NO_RELATION
includeXdp : false
maxSize : 10
offset : 0
returnCount : true
statements: [{"name":"name","value":"*Claim.xdp","operator":"CONTAINS"},
                {"name":"","value":"Expense","operator":"FULLTEXT"},
                {"name":"description","value":"ABCD*","operator":"CONTAINS"},
                {"name":"status","value":"false","operator":"EQ"},
                {"name":"lastModifiedDate","value":"01/09/2013","operator":"GTEQ"},
                {"name":"lastModifiedDate","value":"01/18/2013","operator":"LTEQ"}]
orderings:[{"name" :"lastModifiedDate":"order":"ASC"}]

範例回應 sample-response

[
{"resultCount":2},
    {"assetType":"FORM","name":"ExpenseClaim.xdp","id":"509fa2d5-e3c9-407b-b8dc-fa0ba08eb0ce",
       "path":"/content/dam/formsanddocuments/MyApplication23/1.0/ExpenseClaim.xdp",
       "title":"Expense Report","description":"ABCDEFGIJK","author":"Frank Bowman",
       "tags":[],"formUrl":"/content/dam/formsanddocuments/MyApplication23/1.0/ExpenseClaim.xdp/jcr:content",
       "pdfUrl":"/content/dam/formsanddocuments/MyApplication23/1.0/ExpenseClaim.xdp/jcr:content?type=pdf",
       "references":[],"images":[{"assetType":"resource","name":"Image.gif","id":"5477a127-8bbf-4cec-8f81-2689e5cb4a15",
       "path":"/content/dam/formsanddocuments/MyApplication23/1.0/Image.gif","resourceSize":0}],
       "status":false,"creationDate":1358429845623,"lastModifiedDate":1358429846771},
{"assetType":"FORM","name":"ExpenseClaim.xdp","id":"4312239b-b666-4d36-95bc-641b3a39ddd4",
       "path":"/content/dam/formsanddocuments/MyApplication23/ExpenseClaim.xdp",
       "title":"Expense Report","description":"ABCDefghijklm","author":"Frank Bowman",
       "tags":[],"formUrl":"/content/dam/formsanddocuments/MyApplication23/ExpenseClaim.xdp/jcr:content",
       "pdfUrl":"/content/dam/formsanddocuments/MyApplication23/ExpenseClaim.xdp/jcr:content?type=pdf",
       "references":[],"images":[{"assetType":"resource","name":"Image.gif","id":"118a2e3f-7097-4d8c-85d1-651306de284a",
       "path":"/content/dam/formsanddocuments/MyApplication23/Image.gif","resourceSize":0}],"status":false,
       "creationDate":1358429856690,"lastModifiedDate":1358430109023}
]

相關文章

recommendation-more-help
19ffd973-7af2-44d0-84b5-d547b0dffee2