Utilisation de REST avec des composants

Vous pouvez utiliser le service REST de Web Content Manager pour créer, lire, mettre à jour et supprimer des types de composant.

Vous pouvez utiliser les types de composant ci-dessous avec le service REST de Web Content Manager.
Tableau 1. Types de composant
Composant Type d'API
Composant d'outils de création LibraryAuthoringToolsComponent
Composant de date et heure LibraryDateComponent
Composant de ressource de fichier LibraryFileComponent
Composant HTML LibraryHTMLComponent
Composant d'image LibraryImageComponent
Composant JSP LibraryJSPComponent
Composant de lien LibraryLinkComponent
Composant de présentation de liste LibraryListPresentationComponent
Composant de menu LibraryMenuComponent
Composant de navigateur LibraryNavigatorComponent
Composant de nombre LibraryNumericComponent
Composant de navigation de pages LibraryPageNavigationComponent
Composant de personnalisation LibraryPersonalizationComponent
Composant de référence LibraryReferenceComponent
Composant de texte enrichi LibraryRichTextComponent
Composant de recherche LibrarySearchComponent
Composant de texte court LibraryShortTextComponent
Composant de feuille de style LibraryStyleSheetComponent
Composant de texte LibraryTextComponent
Composant de sélection d'utilisateurs LibraryUserSelectionComponent
Composant de nom d'utilisateur LibraryUserNameComponent

Créer

Vous pouvez créer un composant en envoyant une demande POST à l'URI suivant avec une entrée Atom représentant le composant :
/<library-component-api-type>
Par exemple:
POST /wps/mycontenthandler/wcmrest/LibraryNumericComponent HTTP/1.0
Content-Type: application/atom+xml

<entry xmlns="http://www.w3.org/2005/Atom" xmlns:wcm="wcm/namespace">
    <title>SampleNumericComponentTitle</title>
    <link rel="library" href="/wps/mycontenthandler/!ut/p/wcmrest/item/c98d11e1-7f2a-480e-9aac-40eb1949cbda"/>
    <wcm:name>SampleNumericComponentName</wcm:name>
    <wcm:description>SampleNumericComponentDescription</wcm:description>
</entry>

HTTP/1.0 201 Created
Content-type: application/atom+xml; type=entry
Content-location: /wps/mycontenthandler/!ut/p/wcmrest/LibraryNumericComponent/0d678334-69ae-4d3a-a525-91bb551e5a18

<entry xmlns="http://www.w3.org/2005/Atom" xmlns:wcm="wcm/namespace">
    <id>0d678334-69ae-4d3a-a525-91bb551e5a18</id>
    <title>SampleNumericComponentTitle</title>
    <link rel="edit" href="/wps/mycontenthandler/!ut/p/wcmrest/LibraryNumericComponent/0d678334-69ae-4d3a-a525-91bb551e5a18"/>
    <link rel="edit-media" type="text/plain" href="/wps/mycontenthandler/!ut/p/wcmrest/LibraryNumericComponent/0d678334-69ae-4d3a-a525-91bb551e5a18"/>
    <link rel="library" href="/wps/mycontenthandler/!ut/p/wcmrest/item/c98d11e1-7f2a-480e-9aac-40eb1949cbda"/>
    <link rel="create-draft" href="/wps/mycontenthandler/!ut/p/wcmrest/item/0d678334-69ae-4d3a-a525-91bb551e5a18/create-draft"/>
    <link rel="change-to-draft" href="/wps/mycontenthandler/!ut/p/wcmrest/item/0d678334-69ae-4d3a-a525-91bb551e5a18/change-to-draft"/>
    <link rel="versions" href="/wps/mycontenthandler/!ut/p/wcmrest/item/0d678334-69ae-4d3a-a525-91bb551e5a18/versions"/>
    <updated>2011-05-30T04:33:40.540Z</updated>
    <author>
        <wcm:distinguishedName>uid=wpsadmin,o=defaultWIMFileBasedRealm</wcm:distinguishedName>
        <uri>/wps/mycontenthandler/!ut/p/digest!6GVkh5Ul75Ln7DdEgvHm_g/um/users/profiles/Z9eAeH1C2JG561RC6JM47H9E4MMG6PHO6JM4C5JD0JMOC6BEEJS464JDG3I56K1</uri>
        <name>wpsadmin</name>
    </author>
    <wcm:owner>
        <wcm:distinguishedName>uid=wpsadmin,o=defaultWIMFileBasedRealm</wcm:distinguishedName>
        <uri>/wps/mycontenthandler/!ut/p/digest!6GVkh5Ul75Ln7DdEgvHm_g/um/users/profiles/Z9eAeH1C2JG561RC6JM47H9E4MMG6PHO6JM4C5JD0JMOC6BEEJS464JDG3I56K1</uri>
        <name>wpsadmin</name>
    </wcm:owner>
    <wcm:name>SampleNumericComponentName</wcm:name>
    <wcm:description>SampleNumericComponentDescription</wcm:description>
    <wcm:type>NUMERIC</wcm:type>
    <wcm:state>PUBLISHED</wcm:state>
</entry>

Mettre à jour

Vous pouvez mettre à jour un composant en envoyant une demande PUT à l'URI suivant avec une entrée Atom incluant les zones de l'objet qui doivent être modifiées.
/<library-component-api-type>/<itemuuid>
Par exemple:
PUT /wps/mycontenthandler/wcmrest/LibraryNumericComponent/c98d11e1-7f2a-480e-9aac-40eb1949cbda HTTP/1.0
Content-type : application/atom+xml

<entry xmlns="http://www.w3.org/2005/Atom" xmlns:wcm="wcm/namespace">
    <title>SampleNumericComponentTitleUpdated</title>
    <link rel="library" href="/wps/mycontenthandler/!ut/p/wcmrest/item/c98d11e1-7f2a-480e-9aac-40eb1949cbda"/>
    <wcm:name>SampleNumericComponentNameUpdated</wcm:name>
    <wcm:description>SampleNumericComponentDescriptionUpdated</wcm:description>
</entry>


HTTP/1.0 200 OK
Content-type: application/atom+xml; type=entry

<entry xmlns="http://www.w3.org/2005/Atom" xmlns:wcm="wcm/namespace">
    <id>0d678334-69ae-4d3a-a525-91bb551e5a18</id>
    <title>SampleNumericComponentTitleUpdated</title>
    <link rel="edit" href="/wps/mycontenthandler/!ut/p/wcmrest/LibraryNumericComponent/0d678334-69ae-4d3a-a525-91bb551e5a18"/>
    <link rel="edit-media" type="text/plain" href="/wps/mycontenthandler/!ut/p/wcmrest/LibraryNumericComponent/0d678334-69ae-4d3a-a525-91bb551e5a18"/>
    <link rel="library" href="/wps/mycontenthandler/!ut/p/wcmrest/item/c98d11e1-7f2a-480e-9aac-40eb1949cbda"/>
    <link rel="create-draft" href="/wps/mycontenthandler/!ut/p/wcmrest/item/0d678334-69ae-4d3a-a525-91bb551e5a18/create-draft"/>
    <link rel="change-to-draft" href="/wps/mycontenthandler/!ut/p/wcmrest/item/0d678334-69ae-4d3a-a525-91bb551e5a18/change-to-draft"/>
    <link rel="versions" href="/wps/mycontenthandler/!ut/p/wcmrest/item/0d678334-69ae-4d3a-a525-91bb551e5a18/versions"/>
    <updated>2011-05-30T04:38:49.522Z</updated>
    <author>
        <wcm:distinguishedName>uid=wpsadmin,o=defaultWIMFileBasedRealm</wcm:distinguishedName>
        <uri>/wps/mycontenthandler/!ut/p/digest!6GVkh5Ul75Ln7DdEgvHm_g/um/users/profiles/Z9eAeH1C2JG561RC6JM47H9E4MMG6PHO6JM4C5JD0JMOC6BEEJS464JDG3I56K1</uri>
        <name>wpsadmin</name>
    </author>
    <wcm:owner>
        <wcm:distinguishedName>uid=wpsadmin,o=defaultWIMFileBasedRealm</wcm:distinguishedName>
        <uri>/wps/mycontenthandler/!ut/p/digest!6GVkh5Ul75Ln7DdEgvHm_g/um/users/profiles/Z9eAeH1C2JG561RC6JM47H9E4MMG6PHO6JM4C5JD0JMOC6BEEJS464JDG3I56K1</uri>
        <name>wpsadmin</name>
    </wcm:owner>
    <wcm:name>SampleNumericComponentNameUpdated</wcm:name>
    <wcm:description>SampleNumericComponentDescriptionUpdated</wcm:description>
    <wcm:type>NUMERIC</wcm:type>
    <wcm:state>PUBLISHED</wcm:state>
</entry>

Lire

Vous pouvez lire un composant en envoyant une demande GET à l'URI suivant :
/<library-component-api-type>/<itemuuid>
Par exemple:
GET /wps/mycontenthandler/wcmrest/LibraryNumericComonent/0d678334-69ae-4d3a-a525-91bb551e5a18 HTTP/1.0


HTTP/1.0 200 OK
Content-type: application/atom+xml; type=entry

<entry xmlns="http://www.w3.org/2005/Atom" xmlns:wcm="wcm/namespace">
    <id>0d678334-69ae-4d3a-a525-91bb551e5a18</id>
    <title>SampleNumericComponentTitleUpdated</title>
    <link rel="edit" href="/wps/mycontenthandler/!ut/p/wcmrest/LibraryNumericComponent/0d678334-69ae-4d3a-a525-91bb551e5a18"/>
    <link rel="edit-media" type="text/plain" href="/wps/mycontenthandler/!ut/p/wcmrest/LibraryNumericComponent/0d678334-69ae-4d3a-a525-91bb551e5a18"/>
    <link rel="library" href="/wps/mycontenthandler/!ut/p/wcmrest/item/c98d11e1-7f2a-480e-9aac-40eb1949cbda"/>
    <link rel="create-draft" href="/wps/mycontenthandler/!ut/p/wcmrest/item/0d678334-69ae-4d3a-a525-91bb551e5a18/create-draft"/>
    <link rel="change-to-draft" href="/wps/mycontenthandler/!ut/p/wcmrest/item/0d678334-69ae-4d3a-a525-91bb551e5a18/change-to-draft"/>
    <link rel="versions" href="/wps/mycontenthandler/!ut/p/wcmrest/item/0d678334-69ae-4d3a-a525-91bb551e5a18/versions"/>
    <updated>2011-05-30T04:38:49.522Z</updated>
    <author>
        <wcm:distinguishedName>uid=wpsadmin,o=defaultWIMFileBasedRealm</wcm:distinguishedName>
        <uri>/wps/mycontenthandler/!ut/p/digest!6GVkh5Ul75Ln7DdEgvHm_g/um/users/profiles/Z9eAeH1C2JG561RC6JM47H9E4MMG6PHO6JM4C5JD0JMOC6BEEJS464JDG3I56K1</uri>
        <name>wpsadmin</name>
    </author>
    <wcm:owner>
        <wcm:distinguishedName>uid=wpsadmin,o=defaultWIMFileBasedRealm</wcm:distinguishedName>
        <uri>/wps/mycontenthandler/!ut/p/digest!6GVkh5Ul75Ln7DdEgvHm_g/um/users/profiles/Z9eAeH1C2JG561RC6JM47H9E4MMG6PHO6JM4C5JD0JMOC6BEEJS464JDG3I56K1</uri>
        <name>wpsadmin</name>
    </wcm:owner>
    <wcm:name>SampleNumericComponentNameUpdated</wcm:name>
    <wcm:description>SampleNumericComponentDescriptionUpdated</wcm:description>
    <wcm:type>NUMERIC</wcm:type>
    <wcm:state>PUBLISHED</wcm:state>
</entry>

Supprimer

Vous pouvez supprimer un composant en envoyant une demande DELETE à l'URI suivant :
/<library-component-api-type>/<itemuuid>
Par exemple:
DELETE
HTTP/1.1 DELETE
http://host:port/wps/mycontenthandler/wcmrest/LibraryNumericComponent/<itemuuid>
Réponse
Status Code :200
Status Message : OK

Spécification de données brutes

Le contenu d'un composant est accessible à partir de l'emplacement spécifié dans l'attribut HREF du lien edit-media. Le lien contient également un attribut TYPE qui spécifie le type de support admis pour le contenu. Par exemple:
<link rel="edit-media" type="text/plain" 
href="/wps/mycontenthandler/!ut/p/wcmrest/LibraryTextComponent/0d678334-69ae-4d3a-a525-91bb551e5a18"/>

La liste complète de types de support est documentée ici : Types de support pris en charge.

Pour mettre à jour le contenu d'un composant de bibliothèque, envoyez une demande PUT pour placer un contenu sur un type de support admis à l'adresse URL edit-media. Par exemple:
PUT /wps/mycontenthandler/!ut/p/wcmrest/LibraryTextComponent/0d678334-69ae-4d3a-a525-91bb551e5a18 HTTP/1.0
Content-type: text/plain

This is some text to add to the component.


HTTP/1.0 200 OK
Pour extraire du contenu à partir d'un composant de bibliothèque, envoyez une demande GET pour obtenir du contenu à partir de l'adresse URL edit-media. Par exemple:
GET  /wps/mycontenthandler/!ut/p/wcmrest/LibraryTextComponent/0d678334-69ae-4d3a-a525-91bb551e5a18 HTTP/1.0
Accept: text/plain


HTTP/1.0 200 OK
Content-type: text/plain

This is some text to add to the component.

Au lieu de spécifier le type de support dans l'en-tête HTTP accept, vous pouvez aussi utiliser le paramètre de demande mime-type. Vous devez coder la valeur dans l'URL. Par exemple:
GET  /wps/mycontenthandler/!ut/p/wcmrest/LibraryTextComponent/0d678334-69ae-4d3a-a525-91bb551e5a18?mime-type=text%2Fplain HTTP/1.0


HTTP/1.0 200 OK
Content-type: text/plain

This is some text to add to the component.