Professional Documents
Culture Documents
Table of Contents
I. Creating and Using Web Services in the ATG Platform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1. ATG Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2. Creating Custom Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Overview of ATG Web Services Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 JAX-RPC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Automatic Generation of Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Session and Security Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Web Service Creation Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Using the Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Naming Restrictions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Anatomy of a Web Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Service Endpoint Interface and Implementation Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 WSDL Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 web.xml File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 JAX-RPC Deployment Descriptor and Mapping Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Runtime Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 JSR 109 Compliant EAR File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Web Service Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Security Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 Creating and Editing Security Configurations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Deploying Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Managing Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Registering Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 3. Creating JMS Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Using the JMS Message Web Service Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Structure of a JMS Web Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Patch Bay Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 4. Creating Repository Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Using the Repository Web Service Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Repository Web Service Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Modifying Repository Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 RepositoryService Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 5. Repository to XML Data Binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Mapping Files and XML Schemas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Mapping Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 Managing Mapping Files for Repository Item Descriptors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 XML Schemas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Managing Schemas and Mapping Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 PropertyElementNameSeparator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Item References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Repository Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Getting Repository Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Adding Repository Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Updating Repository Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 Removing Repository Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 6. Accessing ATG Web Services from Java Clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 About ATG Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 Sharing Sessions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
iii
RepositoryItems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Before You Begin Using a Java Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Writing a CookieContainer Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Calling ATG Web Services from a Java Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating a Call Using a Client Stub (Static) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating a Call Using the Dynamic Invocation Interface (Dynamic) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating a Serializer and Deserializer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating a Mapping File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Generating an XML Schema . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7. Accessing ATG Web Services from .NET Clients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . About Web Services in the ATG Platform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Session Sharing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Client Stubs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Web Services that Access RepositoryItems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Before You Begin Using a .NET Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Installing ATGWS.dll . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Calling ATG Web Services from a .NET Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Accessing an ATG Web Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Accessing a Custom ATG Web Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sample Web Service Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using the Atg.DotNet.WebService API to Serialize and Deserialize RepositoryItems . . . . . . . . . . . . . . . . . RepositoryItem Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Property Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RepositoryItemRef Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Complex Type Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . NoSuchPropertyException Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RepositoryItemSerializer Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RepositoryItemSerializationException Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . II. Integration Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8. Using the Integration Repository . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Integration Approaches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Remote Only . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Remote then Local . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Local then Remote . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Local Only . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Setting Up an Integration Repository . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Defining an Integration Repository . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Integration Repository APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . IntegrationRepository . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . IntegrationRepositoryItemDescriptor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . IntegrationRepositoryItem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ChangedPropertyBean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . atg.repository.databinding.MappingRepositoryItem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . IntegrationRepositoryView . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Command Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . executeQuery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . getItem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . updateItem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . addItem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . removeItem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
44 45 45 47 48 50 51 51 52 55 55 55 56 56 56 56 57 57 58 58 58 59 60 62 63 63 64 64 65 65 67 69 69 70 70 70 71 71 72 72 73 74 76 77 77 77 78 79 79 80 80 81 81
iv
Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 Persistent Caching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 Cleaning up the Persistent Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 Configuration Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 Configuring the Remote-Only Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 Configuring the Remote-then-Local Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 Configuring the Local-then-Remote Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 Integration Repository Definition File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 integration-repository-template tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 header tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 item-descriptor tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 item-descriptor Child Tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 integration-repository Document Type Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 9. Remote Procedure Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 RPC API Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Command Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 CommandHandler Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 CommandResult Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 Implementing the RPC API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 Exception Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 Executing Commands in Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 III. ATG Platform REST Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 10. Using REST Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Starting the REST module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 HTTP Requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 REST Web Services URLs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 Client Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 HTTP Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 Handling POST Requests as Other Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 Logging In . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 Handling Session Identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 Logging In as an External User . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 Logging In as an Internal User . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 Logging Out . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 Control Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 Control Parameter Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 Functional Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 Positional Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 URL Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 Message Body Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 Setting the Content-Type Value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 XML Parameter Markup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 JSON Parameter Markup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 URL Query String Parameter Markup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 Input Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 Primitive Values in Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 Multiple Values in Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 Object Values in Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 Nested Multiple Value Objects in Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 Date Format in Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 Setting Properties to Null . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 HTTP Status Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 Returned Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
Choosing Output Markup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . JSON Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . XML Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Identifying a Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Multiple Values in Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Return Depth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Date Format in Returned Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Errors and Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Problems Performing Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Problems Processing a Request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11. Working with Component Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Getting Component Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Setting Component Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12. Invoking Component Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13. Invoking Form Handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Submitting Form Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Returning Form Handler Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Returning Form Handler Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Form Value Priority . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14. Invoking Java Server Pages (JSPs) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . REST Web Services JSP Configuration Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . URL Templates for REST Web Services JSPs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Configuring the REST ServiceProcessor Component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Example REST Web Services JSP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15. Working with Repositories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Listing Repository Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Retrieving a Repository Item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Retrieving a Specific Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Performing RQL Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Adding a Repository Item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Transient Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Setting Repository Item Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Deleting a Repository Item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16. Property Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Default Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Specifying the Filter Depth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Filtering Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Filtering for One Request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Property Aliasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Suppressing Property Expansion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Suppressing Property Expansion for Java Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Suppressing Property Expansion for Specific Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Filtering Priority . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17. Configuring the REST Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . /atg/rest/Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . defaultOutputCustomizer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . maxDepthAllowed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . /atg/rest/processor/BeanProcessor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . returnFormHandlerExceptionsByDefault . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . returnFormHandlerPropertiesByDefault . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . /atg/rest/output/JSONOutputCustomizer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . enableFormatDateOutput for JSON . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . enablePerRequestFilters for JSON . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
126 127 127 128 129 134 135 135 136 137 139 139 140 143 145 146 146 147 148 149 150 151 152 152 155 155 156 157 158 160 161 162 163 165 165 167 168 169 170 171 171 172 172 173 173 173 173 173 174 174 174 174 174
vi
enablePerRequestComponentFilters for JSON . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . enablePerRequestRepositoryFilters for JSON . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . enablePerRequestClassFilters for JSON . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . showRestPaths for JSON . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . /atg/rest/output/XMLOutputCustomizer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . enableFormatDateOutput for XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . enablePerRequestFilters for XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . enablePerRequestComponentFilters for XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . enablePerRequestRepositoryFilters for XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . enablePerRequestClassFilters for XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . showRestPaths for XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . /atg/rest/processor/RepositoryProcessor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . acceptJSONInput . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . appendMultiValuesByDefault . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . /atg/rest/processor/RestSecurityProcessor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . allowAccessForUnsecuredRepository . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18. Security for REST Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Security Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Logging In and Session IDs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Nucleus Component Granularity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Quick Setup for Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Global Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Component Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Property and Method Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Repository Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Securing Groups of Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19. ATG Client Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Java Client Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating Requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating a RestSession Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Starting a REST Session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Logging in and Logging Out with the Java Client Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Starting a Session Without Logging In . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Accessing Data from the Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating a Raw REST Request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Handling Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Accessing Components with the Java Client Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Calling Methods with the Java Client Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Accessing Repository Items with the Java Client Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using the Java Client in Android Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ActionScript Client Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . atg.rest.client.RestComponentHelper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . atg.rest.client.RestRepositoryHelper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Calling Methods with ActionScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Formatting Input with ActionScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
175 175 175 175 176 176 176 176 176 177 177 177 177 178 178 178 179 179 179 179 180 180 181 181 182 182 183 183 183 185 186 187 189 189 190 191 192 193 194 197 197 198 199 199 201 203
vii
viii
The chapters in this section discuss how to create Web Services in the Oracle ATG Web Commerce platform, and how to write Java and .NET clients that call these services: Creating Custom Web Services (page 5) Creating JMS Web Services (page 19) Creating Repository Web Services (page 23) Repository to XML Data Binding (page 27) Accessing ATG Web Services from Java Clients (page 43) Accessing ATG Web Services from .NET Clients (page 55)
In addition to any Web Services you create, the Oracle ATG Web Commerce platform includes a number of prepackaged Web Services that you can call from Java and .NET clients. These services are packaged in three separate application modules. You can include any of these services in an assembled EAR file by including the module that contains the desired services. For example, to include the prepackaged Commerce Web Services, specify the DCS.WebServices module when you assemble your application. The following table summarizes these Web Services:
Application Module
DAS.WebServices
Web Services
- getRepositoryItem - performRQLQuery - performRQLCountQuery
For more information about these Web Services, see the ATG Repository Guide.
DPS.WebServices
User Session
For more information about these Web Services, see the ATG Personalization Programming Guide
loginUser logoutUser getProfileId setLocale setContactInfo setPassword getProfile createUser updateUser getPasswordHashKey getPasswordHashAlgorithm canClientEncryptPasswords executeRepositoryTargeter
Messaging
- sendPageVisit - sendClickThrough
Application Module
DCS.WebServices
Web Services
createOrderFromXML submitOrderWithReprice cancelOrder getOrderStatus getOrderAsXML getOrdersAsXML getOrderStatus getCurrentOrderId addItemToOrder addItemToShippingGroup createOrder createOrderForUser removeItemFromOrder setItemQuantity addCreditCardToOrder addShippingAddressOrder removePaymentGroupFromOrder removeCreditCardFromOrder removeShippingGroupFromOrder moveItemBetweenShippingGroups removeItemQuantityFromShippingGroup setOrderAmountToPaymenGroup getDefaultPaymentGroupId getDefaultShippingGroupId
For more information about these Web Services, see ATG Commerce Programming Guide.
Pricing
- calculateOrderPrice - calculateOrderPriceSummary - calculateItemPriceSummary grantPromotion revokePromotion claimCoupon getPromotionsAsXML getInventory getInventoryStatus setStockLevel setStockLevels getProductXMLById getProductXMLByDescription getProductXMLByRQL getProductSkusXML catalogItemViewed setDefaultShippingAddress setDefaultBillingAddress setDefaultCreditCard getDefaultShippingAddress getDefaultBillingAddress getDefaultCreditCard
Promotions
Inventory
Catalog
Profile
The Oracle ATG Web Commerce platform provides infrastructure and tools that enable you to expose a wide range of Oracle ATG Web Commerce functionality as Web Services. There are three kinds of Web Services you can create that expose Oracle ATG Web Commerce functionality: Web Services that invoke methods on Nucleus components. Web Services that send JMS messages through Patch Bay. Web Services that perform operations on repository items. This chapter describes the infrastructure for creating these services. It focuses on Web Services that invoke Nucleus methods, but most of what is described here applies to all three types of services. For information specific to Web Services that send JMS messages, see the Creating JMS Web Services (page 19) chapter. For information specific to Web Services that perform repository operations, see the Creating Repository Web Services (page 23) chapter. This chapter includes the following sections: Overview of ATG Web Services Support (page 5) Web Service Creation Wizard (page 7) Anatomy of a Web Service (page 9) Web Service Security (page 13) Deploying Web Services (page 15) Managing Web Services (page 16)
JAX-RPC
The Web Services support in the Oracle ATG Web Commerce platform is based on JAX-RPC (Java API for XMLbased RPC). The JAX-RPC specification defines a standard way for incoming XML-based SOAP messages to be converted to Java-based RPC calls. The Oracle ATG Web Commerce platform uses Oracles reference implementation of JAX-RPC. Parts of this reference implementation are used to generate Web Services, and other parts of it handle the processing of SOAP messages when a Web Service is called.
Limitations
You can create Web Services from most Nucleus methods, both from components Oracle ATG Web Commerce provides and components that you write. There are, however, some methods that cannot be exposed as valid Web Services. The Web Service Creation Wizard will not create Web Services from these methods. In particular, it enforces the following restrictions by preventing you from selecting these methods: You cannot create a Web Service from any method that has a parameter or return type that is an abstract data type (such as a Map, Collection, Interface, abstract class, or an object with abstract data type properties). You cannot create a Web Service from any method that has a parameter or return type that is a wrapper class for a primitive data type. The prohibited classes are Byte, Boolean, Character, Integer, Short, Long, Float, and Double. Note, however, that methods that use actual primitives are valid. If there is a method that you want to expose that has one of these wrapper classes as a parameter or return type, you can either rewrite the method to use a primitive instead (if the methods class is your own custom code), or else subclass the methods class (if it is a class provided by Oracle ATG Web Commerce) and overload the method with a version that uses primitives. In addition, you cannot create a Web Service from a method that has the same name and signature as any of the methods of atg.webservice.ManagedComponentProperties or java.lang.Object. Attempting to
do so results in a naming conflict, because the service implementation class of each Web Service subclasses atg.webservice.ManagedComponentProperties, which subclasses java.lang.Object. Note that the wizard does not prevent you from selecting these methods, but when you try to generate a Web Service, an exception is thrown and the service generation fails.
To create a Web Service that invokes a method on a Nucleus component, starting from the Web Service Administration page: 1. Click the Web Service Creation Wizard link. This takes you to a page titled Select Type, where you can select the type of Web Service to create. 2. Click the Component Method Web Service link. This takes you to the Select Nucleus Component page. 3. On the Select Nucleus Component page, specify the pathname of the Nucleus component you want to create the Web Service from. You can either enter the pathname directly in the field at the top of the page and then click the Next button, or you can use the component browser below it to navigate to the component and select it. 4. On the Select A Method page, select the method you want to expose as a Web Service. 5. If the method requires any input parameters, the Set Parameter Names page provides you with fields for specifying the names of these parameters. The names you specify are used for the parameters of the Web Service call, and can be anything you like. When the Web Service is called, the service passes the values of these parameters to the parameters of the exposed Nucleus method. There is thus a one-to-one correspondence between the parameters of the Web Service call and the parameters of the underlying Nucleus methods. 6. The next two pages are titled EAR Name & Servlet Settings and Enterprise and Web Application Settings. When the wizard creates a Web Service, it packages it in a WAR file, which is in turn packaged in an EAR file. It is possible to have any number of services in a single Web application (WAR file), and any number of Web applications in a single Enterprise application (EAR file). This flexibility gives you a good deal of control over how you deploy your Web Services. For each new Web Service, the wizard can do any of the following: Create a new EAR file for the service, and put it in a WAR file within the EAR file. Use an existing EAR file, and put the service in a new WAR file within it. Put the service in an existing WAR file within an existing EAR file. To add a Web Service to an existing EAR file, you specify that file as the EAR file name on the EAR Name & Servlet Settings page. The Web Application Settings page then gives you the choice of creating a new Web application for the service, or adding the service to an existing Web application. The wizard also gives you the option of specifying the host name and port number for a Web Service, or of leaving these fields blank. If you leave the fields blank, the values are dynamically assigned at runtime from the URL used for the WSDL file request. 7. The Session & Security Options page allows you to specify whether the Web Service should be executed within the context of an HTTP session. The wizard gives you these options: Neither provide a session nor security constraints. Provide a session, but no security constraints. Provide both a session and security constraints. If you want to call the Web Service from a client that uses sessions or session sharing, you must choose one of the last two options. If you choose the last option, the wizard then prompts you to select a security configuration. See Web Service Security (page 13) for information about security configurations for Web Services. 8. On the Create EAR File page, click the Create EAR File button to create the Web Service.
If there is already an EAR file with the specified name, the wizard first appends .old to the name of the existing file so that new file does not overwrite it. Once you have created an EAR file, you must deploy it in order to run the Web Services in it. See the Deploying Web Services (page 15) section for more information.
Naming Restrictions
Most of the class names and filenames for Web Services are generated automatically by the wizard. As a result, certain circumstances can result in naming conflicts. For example, if you create a Web Service from a Nucleus method, you cannot then create a second Web Service from another method with the same name (such as an overloaded method) and put it in the same WAR file, even if the two methods have different signatures or capitalization. If you attempt to do this, the second Web Service will simply overwrite the first. To prevent the second service from overwriting the first, put the second service in a different WAR file. In addition, be sure to give the second WAR file a different context root from the first WAR file. (The default value for the context root in the wizard is based on the method name, so youll need to change the value when you run the wizard.) It will then be possible to differentiate calls to the two services based on their context roots.
The service implementation class (also referred to as the service bean) implements the service endpoint interface and handles the actual servicing of incoming SOAP requests. In addition, service implementation classes generated by the Oracle ATG Web Commerce platform implement the interface javax.xml.rpc.server.ServiceLifecyle, and extend the atg.webservice.ManagedComponentProperties class, which registers services with the Oracle ATG Web Commerce platform Web Service Registry. The Web Service Registry is discussed in the Managing Web Services (page 16) section. The service endpoint interface and implementation class are generated by the /atg/webservice/ WebServiceGenerator component. The names for these classes are based on the name of the Nucleus method being exposed. For instance, if the Nucleus method is getOrderStatus, the service endpoint interface is named GetOrderStatusSEI, and the implementation class is named GetOrderStatusSEIImpl.
WSDL Document
Web Services Description Language (WSDL) is an XML language for describing Web Services in a platformindependent way. A WSDL document describes a Web Services methods by specifying the locations of the resources they use and defining the methods inputs and outputs. (A WSDL document for a Web Service generated by the Oracle ATG Web Commerce platform always describes one method, because each Web Service can expose only one Nucleus method.) There must be a separate WSDL document for each Web Service. The WSDL document is generated by the / atg/webservice/WSDLGenerator component, which is of class atg.webservice.WSDLGeneratorImpl. This document is used for two key purposes: It is used by the JAX-RPC API to generate runtime classes. At runtime, it is used by Web Service clients to look up the semantics of the SOAP messages to send to invoke the service. When the Web Services input and output values are primitive types, they are defined in the primary WSDL document. For example:
<message name="getOrderStatusInput"> <part name="in0" type="xsd:string"> </message>
Each non-primitive input or output requires its own WSDL document that is imported by the primary WSDL document. Import statements similar to the following are included in the primary WSDL document when the Web Service is created using the Dynamo Administration UI:
<import location="atg.commerce.order.status.wsdl" namespace="http://www.atg.com/atg.commerce.order.status"/>
The location specified is relative to the primary WSDL document. Some Web Service clients are able to interpret relative locations, but others require fully qualified URLs. To work with these clients, when the Oracle ATG Web Commerce platform receives a request for a WSDL document, it uses the servlet class atg.webservice.WSDLFinderServlet and the filter class atg.webservice.WSDLImportFilter to translate the location value into a fully qualified URL: 1. At runtime, JAXRPCServlet updates the SOAP address in the WSDL document to include the domain host name and port number.
10
2. When WSDLFinderServlet detects a WSDL request, WSDLImportFilter appends the domain name and port number (from the SOAP address provided by JAXRPCServlet) and the context path (by calling request.getContextPath() on the Dynamo request) to the location value in the import statement. The resulting import statement looks similar to this:
<import location= "http://myhost:7881/catalog/atg.commerce.order.status.wsdl" namespace="http://www.atg.com/atg.commerce.order.status"/>
The WSDLFinderServlet and WSDLImportFilter classes are declared in the web.xml file for the Web application that the Web Service is a part of, as discussed in the next section. For more information about request handling, see the ATG Platform Programming Guide.
web.xml File
The web.xml file is the standard deployment descriptor for the Web application that the Web Service is a part of. It declares the filters and servlets used by the service. On the Oracle ATG Web Commerce platform, the servlet that listens for the SOAP request is com.sun.xml.rpc.server.http.JAXRPCServlet. This servlet is part of the JAX-RPC reference implementation, and is responsible for receiving the incoming SOAP request and determining how to dispatch the call. For example, if you create a Web Service called getOrderStatus, the entry for it in the web.xml file looks something like this:
<servlet> <servlet-name>getOrderStatus</servlet-name> <display-name>getOrderStatus</display-name> <servlet-class>com.sun.xml.rpc.server.http.JAXRPCServlet</servlet-class> <init-param> <param-name>configuration.file</param-name> <param-value>WEB-INF/wsconfig/getOrderStatus_Config.properties</param-value> </init-param> </servlet> ... <servlet-mapping> <servlet-name>getOrderStatus</servlet-name> <url-pattern>/getOrderStatus/*</url-pattern> </servlet-mapping>
When a call to the getOrderStatus Web Service is sent to the Oracle ATG Web Commerce platform, the JAXRPCServlet receives the request and dispatches it based on the information in the file that the configuration.file parameter points to. This configuration file is included in the WAR file, and looks similar to this:
11
Note that the port0.servant property is set to the name of the service implementation class. This property designates the class that JAXRPCServlet dispatches the SOAP request to.
12
<load-on-startup>1</load-on-startup> </servlet>
For more information about the Web Services Registry, see Managing Web Services (page 16).
Runtime Classes
The runtime classes are generated using the Oracle JAX-RPC reference implementation. These classes include: the tie class that JAXRPCServlet invokes the method on, and which in turn invokes the method on the service implementation class classes for handling serializing and deserializing SOAP requests and responses
13
the Web Service. You can create any number of different security configurations using the Web Services Administration UI, and you can apply a security configuration to any number of Web Services. A security configuration has a corresponding security policy component, plus an optional ACL. A security configuration is identified by its functional name, which is a property of the repository item that maps the security configuration to a security component and ACL. This section describes the main components involved in securing Web Service methods, as well as how to create security configurations through the Web Services Administration UI. For a broader discussion of the Oracle ATG Web Commerce security API, see the Managing Access Control chapter in the ATG Platform Programming Guide.
Security Components
There are two primary components involved in securing a Web Service method: /atg/webservice/security/NucleusSecurityManager (an instance of atg.webservice.NucleusSecurityManager) uses the security configuration associated with the Web Service to apply the corresponding security policy and ACL, to determine whether to grant or deny access. /atg/webservice/security/NucleusSecurityRepository (an instance of atg.adapter.gsa.GSARepository) stores the Web Service security configurations used by the NucleusSecurityManager.
NucleusSecurityManager
At startup time, the NucleusSecurityManager retrieves the repository items from the NucleusSecurityRepository (described below) and creates an internal mapping between each functional name and the SecurityPolicy component and ACL associated with it. When a client calls a Web Service, the service invokes the hasAccess() method on the /atg/webservice/ security/NucleusSecurityManager component, passing it the functional name of the services security configuration, the name of the Nucleus component and method exposed by the service, and a Map containing the methods parameters. The NucleusSecurityManager uses the functional name to find the associated SecurityPolicy component and ACL, applies them to the call, and returns the result (true or false) to the client. If true is returned, the Nucleus method exposed by the Web Service is invoked; if false is returned, access to the method is denied, and an exception of class atg.security.SecurityException is thrown. If the NucleusSecurityManager is unable to apply the security configuration to a Web Service call (for example, if the SecurityPolicy is not valid), it determines whether to grant access based on the value of its defaultGrantAccess property. The default value of this property is false (deny access). Setting defaultGrantAccess to true facilitates the development process, because it allows any Web Service that does not have an associated security configuration to be called by any client. For deployment purposes, though, this behavior is undesirable, because of the security risks involved. Therefore, when you enable liveconfig settings for the Oracle ATG Web Commerce platform, the defaultGrantAccess property is set to false. Note, however, that this means that each of your Web Services must have an associated security configuration, because any call to a service without a security configuration will fail. For information about enabling liveconfig settings, see the ATG Installation and Configuration Guide.
NucleusSecurityRepository
Web Service security configurations are stored in the NucleusSecurityRepository. This repository includes a single item descriptor called nucleusSecurity, which has properties called functionalName, policy, and ACL. The NucleusSecurityManager parses the items in this repository at startup time.
14
The Web Services Administration interface provides an easy way to add new security configurations to this repository. See the next section for details.
If you make any subsequent changes to the Web Service, you must reassemble and redeploy the application for the changes to take effect. Note that in addition to any Web Services you create, the Oracle ATG Web Commerce platform includes a number of prepackaged Web Services. These services are packaged in three separate application modules. You can include any of these services in an assembled EAR file by including the module that contains the desired services. For example, to include the prepackaged Commerce Web Services, specify the DCS.WebServices module when you assemble your application.
15
For more information about the runAssembler command, see the ATG Platform Programming Guide. For information about deploying EAR files, see the documentation from your application server vendor.
The Service Info indicates that there are six Web applications running that include Web Services. You can get more information about the services in a Web application by clicking the details link next to the applications name. For example, if you click on the link for the Pricing application, the Service Info looks like this:
16
The lower table summarizes the status of the Web Services in the Web application. The Name and URI Pattern are the values of the display-name and url-pattern tags in the web.xml file, and the WSDL file is the value of the wsdl.location property in the configuration file for the JAXRPCServlet. The Security functional name is the name that the service implementation class passes to the hasAccess() method of the NucleusSecurityManager to determine if the client has permission to call the Web Service. Some of the information shown in this table, such as the functional name, does not appear until the Web Service has been executed. If a service has been executed, the Instance Running and Registered value is true. You can stop a running service by clicking the Off link in the Enabled column.
Registering Services
Web Services generated by the Web Service Creation Wizard have the necessary code and configuration information to register the Web Service with the Web Service Registry. To register the service, the service implementation class extends the class atg.webservice.ManagedComponentProperties, which includes a register() method for registering the service. In addition, the web.xml file for the Web application the service is part of declares the WebServiceRegistrar servlet, as described in the Web Service Registrar (page 12) section.
17
18
In addition to Web Services that call Nucleus methods, the Oracle ATG Web Commerce platform enables you to create Web Services that send JMS messages through Patch Bay. Many events in the Oracle ATG Web Commerce platform are triggered by JMS messages, so by calling a Web Service that sends a JMS message, a client can start execution of various services and processes. In particular, scenario actions are triggered by JMS messages, so you can use Web Service calls to invoke scenario actions remotely. For example, suppose a new user registers in some application, which invokes a Web Service that sends the registration information to the Oracle ATG Web Commerce platform. The client application could then call a Web Service that sends a JMS message of type atg.dps.Register into Patch Bay, thereby triggering a scenario action that (for instance) sends an e-mail message to the new user. This chapter discusses how to create Web Services that send JMS messages, and how to configure components to listen for these messages. For more information about JMS and Patch Bay, see the Dynamo Message System chapter of the ATG Platform Programming Guide.
19
The service implementation class then calls the receiveObjectMessage() method like this:
messageImporter.receiveObjectMessage(a, "atg.dps.PageVisit", "IndividualEvents");
For information about calling Web Services that send JMS messages from Java clients, see the Accessing ATG Web Services from Java Clients (page 43) chapter. (Note that you cannot use the dynamic process described in that chapter for calling these Web Services.) For information about calling Web Services that send JMS messages from .NET clients, see the Accessing ATG Web Services from .NET Clients (page 55) chapter.
20
</nucleus-name> <output-port> <port-name> IndividualEvents </port-name> <output-destination> <destination-name> patchbay:/sqldms/MessageImporter/IndividualEvents </destination-name> <destination-type> Topic </destination-type> </output-destination> </output-port> <output-port> <port-name> GlobalEvents </port-name> <output-destination> <destination-name> patchbay:/sqldms/MessageImporter/CollectiveEvents </destination-name> <destination-type> Queue </destination-type> </output-destination> </output-port> </message-source>
The Scenario Manager is a message sink configured to receive messages from these destinations. This configuration occurs in two places: In the standard Patch Bay configuration file, the Scenario Manager is configured to receive individual scenario events from the destination patchbay:/sqldms/MessageImporter/IndividualEvents. In the /atg/dynamo/messaging/dynamoMessagingSystemDSSGlobal.xml file, the Scenario Manager is configured to receive global scenario events from the destination patchbay:/sqldms/MessageImporter/ CollectiveEvents. You can configure other message sinks to receive messages from the patchbay:/sqldms/MessageImporter/ IndividualEvents destination by declaring them in the dynamoMessagingSystem.xml file. Note, however, that you cannot configure other sinks to receive messages from patchbay:/sqldms/MessageImporter/ CollectiveEvents. This destination is a queue, used by global Scenario Managers only; adding sinks to this destination may interfere with the global Scenario Managers receiving messages. If you want another message sink to receive these messages, configure an additional destination for MessageImporter to send global scenario events to, and configure your sink to listen to that destination instead.
21
22
The ATG Dynamo Administration interface provides an easy, browser-based way to create Web Services based on repository items. This Repository Web Service wizard is part of the Web Service Administration user interface, which is introduced in the Web Service Creation Wizard (page 7) section of the Creating Custom Web Services (page 5) chapter. You can use the Repository Web Service wizard to create Web Services that add, remove, update, or get a complete repository item, or a single property of a repository item.
The Select Method page also allows you to create a Web Service for a specific property. The page displays a list of links for each of the properties of the item descriptor you selected. Click one of these property names to create a Web Service for an individual repository item property. The property name link leads to a list of the Web Service methods that are available for that repository item property, as well as notes about the Web Service limitations, if any, related to the repository item property. See Repository Web Service Limitations (page 24) for more information. Click the name of the method you want to expose in your Web Service.
23
5. In the EAR Name & Servlet Settings page, the Web Service Creation Wizard displays default names for the EAR file and servlet to be created. You can modify the default names. You can also, if you choose, enter a description for the servlet and a network hostname and port number for the Web Service. If you leave the fields blank, the values are dynamically assigned at runtime from the URL used for the WSDL file request. You should generally leave these fields blank, unless you want to require the Web Service to be accessed on a specific server and port. Enter any settings you want to change and click the Next button. 6. In the Enterprise & Web Application Settings page, the Web Service Creation Wizard displays default names for the enterprise application and Web application to be created. You can modify the default names. You can also, if you choose, enter a description for the enterprise application and Web application. Enter any settings you want to change and click the Next button. 7. The Session & Security Options page allows you to select one of the following three options for the Web Service: 8. Provide neither a session nor security constraints. 9. Provide a session, but no security constraints. 10.Provide both a session and security constraints. If you choose the last option, the wizard then prompts you to select a security configuration. See the Creating Custom Web Services (page 5) chapter for information about security configurations for Web Services. 11.The Create EAR File page displays the parameter values you have selected for your Web Service. Review them, then click the Create EAR File button to create the Web Service. The Web Service is created in an EAR file. You will find the EAR file in the <ATG10dir>/home directory, with the name you selected in step 4. To use the new Web Service, you need to deploy it. See Deploying Web Services (page 15) in the Creating Web Services chapter.
get/setPropertyValue
1. Collection properties may not be set or gotten as a whole. Only elements of the collection may be set. 2. RepositoryItem properties are set or gotten as Strings in XML form 3. There is no type of service that can get or set sub-properties. You must act upon the actual RepositoryItem you wish to read from or write to. 4. You cannot get or remove elements from a set or list. This is because in order to remove elements from either, you need to provide the object to remove (or index, see below), and a Web Service cannot guarantee that that object is of a type that can be transformed from XML into a Java object.
24
5. You cannot get or set a property of a type that corresponds to a Java primitive. For example, you cannot get or set a java.lang.Integer or a java.lang.Boolean. 6. You cannot get or set a property of a non-simple type, other than atg.repository.RepositoryItem. This includes types such as java.util.Timestamp and java.sql.Date. Note, however, that if you retrieve a Date property, a java.util.Calendar will be returned. 7. You cannot get a property that is not readable, or set a property that is not writable.
addItem
The item to be added must be supplied in XML form.
updateItem
1. The item to be updated must be supplied in XML form. 2. By default, when a repository item is passed into the Web Service, the existing RepositoryItem is found by matching repository IDs. We determine the value of the repository ID from the top-level XML element in the instance document, and then find a repository item with a matching ID.
removeItem
Users must pass in only the repository ID of the item to be removed.
RepositoryService Class
The atg.repository.RepositoryService class contains many methods that perform basic Repository operations, independent of any particular repository implementation or instance. Such operations include getting, adding, removing and updating a repository item, setting and getting properties of repository items, and performing queries for repository items using RQL. Using the Web Service generator, you can directly make some of these methods into Web Services by simply clicking a form submit button. Some others of these methods are too generic to be made available as a Web Service without limiting the types of the inputs or outputs. For example, the method setPropertyValue takes a java.lang.Object as a method argument for the property value. Since Web Services dont allow java.lang.Object as an input (or output), this method cannot be used as a Web Service in this form. However, we can restrict the type of this
25
argument using the code generator template functionality, so when the Web Service is generated, the outwardfacing method will be strongly typed based on the property being set, and can simply call through to the more generic setPropertyValue method in the body of the Web Service. The RepositoryService class has the following properties:
Type
javax.transaction. TransactionManager
Description The service that manages any transactions that are used to execute repository methods on this instance. The component that manages mapping files based on repository and item descriptor name combinations. For any methods that return a RepositoryItem, this service will be consulted to retrieve mapping files to use when transforming these items into XML. See Mapping Files and XML Schemas (page 27) in the Repository to XML Data Binding chapter for more information abut mapping files and the
ItemDescriptorMappingManager
mappingManager
atg.repository.xml. ItemDescriptorMappingManager
class. xmlGetService
atg.repository.xml. GetService atg.repository.xml. AddService
The service that knows how to turn RepositoryItems into XML. The service that knows how to add RepositoryItems in XML format to a repository. The service that knows how to take RepositoryItems in XML format and update them in their corresponding repositories.
xmlAddService
xmlUpdateService
atg.repository.xml. UpdateService
For information about the XML service properties, see Repository Operations (page 35) in the Repository to XML Data Binding chapter.
26
One of the key aspects of integrating the Oracle ATG Web Commerce platform with a remote system is sharing data between the two systems. Data sharing and synchronization are often complex, because the two systems may store their data in dissimilar formats. The Oracle ATG Web Commerce platform data is typically stored in a Dynamo repository, which handles the mapping of data in Java objects to the underlying data store (such as a SQL database). The Oracle ATG Web Commerce Integration Framework includes a data binding facility for reading and writing data between a repository and XML documents. Using this facility, you can write out repository data to XML documents that can then be read into a remote system, or read data into a repository from XML documents that store data from a remote system. A key aspect of this system is the use of mapping files to specify the data to include or exclude, and to map the names of repository properties to the names used by the remote system. The data binding facility also includes tools for generating XML Schemas that describe the structure of data in a repository, and to use these XML Schemas to validate the data written out from or read into the repository. The data binding facility provides services that perform these four operations with repository items: Getting items (retrieving items from a repository and writing them out to XML documents) Adding items (creating new items in a repository from data in XML documents) Updating items (modifying existing items using data in XML documents) Removing items (deleting items as indicated in XML documents) This chapter discusses: Mapping Files and XML Schemas (page 27) Repository Operations (page 35) Note that the classes described in this chapter work only with repositories included in the initialRepositories property of the /atg/registry/ContentRepositories component.
27
XML Schemas describe the structure of the data, and can be used to validate XML instance documents.
Mapping Files
When you exchange data between the Oracle ATG Web Commerce platform and a remote system, you will typically want to exclude certain data. For example, an the Oracle ATG Web Commerce platform profile usually includes Dynamo-specific information about scenarios. When you create an XML instance document from data in a repository, Dynamo includes and excludes certain properties by default: If a property is readable and does not point to another item descriptor, it is included. If a property is readable, points to another item descriptor, and its cascade attribute is set to "delete", it is included. All other properties are excluded. For more information about the default inclusion rules, see the isIncludeProperty() method of the atg.repository.xml.RepositoryXMLTools class in the ATG Platform API Reference. RepositoryXMLTools is a utilities class with various methods for encoding and decoding item descriptors, property names, and mapping files to and from XML-compatible namespaces and identifiers. If you want more explicit control over the properties that are written out, you can use a mapping file. A mapping file specifies what properties to include or exclude when moving data between a repository and an XML instance document, and provides a way to map the names of Dynamo properties to their equivalents in a remote system. For example, a Dynamo profile might have an email property that stores the same information as the Email_Address attribute on another system. The following is the Document Type Definition (DTD) for mapping files:
<!-This is the XML DTD for ItemDescriptorMapping --> <!-Specifies what properties in an item-descriptor should be included in another datamodel. A given mapping file gives the ability to - control what properties are included/excluded from the datamodel - control how names in one model relate to names in another model --> <!-Defines the mapping for a given item-descriptor. The name and repository property are required properties. The name property corresponds to the name of a given item-descriptor. The repository should be the Nucleus path to a particular repository. For example, if an item-descriptor mapping was going to point to the the ProfileAdapterRepository located at /atg/userprofiling/ProfileAdapterRepository Nucleus path, then the repository property should be the string "/atg/userprofiling/ProfileAdapterRepository". The default-include exists to indicate whether or not properties that are associated with this item-descriptor should be included by default or not. This property defaults to true. So, if a property is does not explicitly
28
appear as a child property element, it is assumed to be included in the data model to be exported. --> <!ELEMENT item-descriptor (property*)> <!ATTLIST item-descriptor repository-path CDATA #IMPLIED name CDATA #IMPLIED default-include (true | false) #IMPLIED> <!-A property element controls two aspects of including a property in a given mapping; whether the property should be included or not and what the targetName for the target datamodel should be. The name attribute corresponds to the name of a property defined for a given item-descriptor. The include attribute is optional. If it is not specified, the value is obtained from the default-include value of the enclosing item-descriptor. --> <!ELEMENT property (item-descriptor*)> <!ATTLIST property name CDATA #REQUIRED include (true | false) #IMPLIED targetName CDATA #IMPLIED>
The data binding services all work with a single item descriptor and its properties (including any other item descriptors that are properties of the main item descriptor). The mapping file uses the item-descriptor tag to specify the repository and item descriptor that the mapping file is associated with:
<item-descriptor repository-path="/atg/userprofiling/ProfileAdapterRepository" name="user"
29
default-include="true">
The default-include attribute specifies whether the items properties should be included or excluded by default. This value can be overridden for individual properties. In this mapping file, various scenario-related properties are excluded:
If a property is an item descriptor, there must be an item-descriptor tag inside the property tag. For example, the homeAddress property points to a contactInfo item descriptor:
Note that the item-descriptor tag for contactInfo can have property tags within it. The nesting of property tags and item-descriptor tags must reflect the hierarchy of the item descriptors in the repository. If you do not include a property tag for a property that points to an item descriptor (such as the homeAddress property shown above), the Oracle ATG Web Commerce platform uses the default inclusion rules for determining which properties of that item descriptor to include. Finally, the property tag has an optional targetName attribute for mapping the property name to its corresponding name in the remote system:
atg.repository.xml.ItemDescriptorMapping atg.repository.xml.ItemDescriptorMappingManager
ItemDescriptorMapping
An ItemDescriptorMapping is a simple bean that holds information about relationships between repository item descriptors and mapping files. The mapping files describe what properties are to be exposed when an item from that item descriptor is to be transformed into XML. Each ItemDescriptorMapping pertains to exactly one repository: for example, you would have a UserProfileItemDescriptorMapping, or a
30
PromotionItemDescriptorMapping component, each of which would provide a list of item descriptor names
from the corresponding repository and their corresponding mapping files. An ItemDescriptorMapping contains only three properties:
Property Name
repositoryPath
Type
java.lang.String
read-only property
repository atg.repository.Repository
A map where the keys are item descriptor names and the values are locations of mapping files, relative to the configuration path, which provide rules for how an item of the keyed item descriptor name appears in XML format
Here is an example properties file for an ItemDescriptorMapping that supports the profile repository:
$class=atg.repository.xml.ItemDescriptorMapping repository=/atg/userprofiling/ProfileAdapterRepository itemDescriptorMapping=\ user=/atg/userprofiling/userMapping.xml,\ contactInfo=/atg/userprofiling/contactInfoMapping.xml
Here we see the there are two entries in the itemDescriptorMapping property, one for the user item descriptor, and one for the contactInfo item descriptor. Whenever an entry is added to the itemDescriptorMapping property, whether through a properties file, or directly in code, the ItemDescriptorMapping checks to make sure that the key of the entry, the item descriptor name, resolves to an actual item descriptor of the repository this service is configured to support. If any item descriptor name does not resolve, a RepositoryException is thrown. By themselves, ItemDescriptorMappings dont do any work. They simply hold state. In order to put them to work, you must add them to the ItemDescriptorMappingManager, described below.
ItemDescriptorMappingManager
Class: atg.repository.xml.ItemDescriptorMappingManager Component: /atg/repository/xml/ItemDescriptorMappingManager
31
Module: DAS The ItemDescriptorMappingManager serves as a registry of ItemDescriptorMappings. It is through this service that you obtain mapping files for all repository and item descriptor combinations. The mapping files are registered in the itemDescriptorMappings property of the ItemDescriptorMappingManager component:
Property Name
itemDescriptorMappings
Type
atg.repository.xml. ItemDescriptorMapping[]
Description An array of
ItemDescriptorMapping
components. When a user calls methods to retrieve mapping files, this component sifts through the itemDescriptorMappings to determine the correct mapping.
Using the given repository path and item descriptor name, returns the mapping file for that given path:name combination, or null if none exists.
getMappingFileName(Repository pRepository, String pItemDescriptorName)
Using the given repository and item descriptor name, returns the mapping file for that given repository:name combination, or null if none exists. When you use the atg.repository.xml.GetService to get repository items in XML form, you can pass along a mapping file name using these ItemDescriptorMappingManager methods. Using the ItemDescriptorMappingManager, you can centralize all mapping files in one component for all item descriptors, and just call that to determine which mapping file to use for a given item descriptor.
XML Schemas
The Oracle ATG Web Commerce platform provides tools for creating and working with XML Schemas for the XML documents written and read by the various data binding services. XML Schema is a schema language for XML that describes and restricts what a particular XML instance document might look like. An XML document can be validated against an XML Schema to check that it conforms to that Schema. Additionally, many developer tools make use of XML Schemas. For example, some tools provide a visual representation of XML Schemas to allow mapping from one XML Schema to another.
32
the XML Schema describes an instance document that is capable of being processed by the Add, Update, or Remove service. The command-line tool is named generateXMLSchema.sh (on Unix) or generateXMLSchema.bat (on Windows) and is found in the <ATG10dir>/home/bin directory. The following table lists the arguments that can be supplied to this command:
-repository
Nucleus path to the repository containing the item descriptor that the XML Schema is being generated for. Required. Name of the item-descriptor that the XML Schema is being generated for. Required. Specifies a directory to save the XML Schema to. This directory is in addition to the directory specified by the XMLSchemaFileDirectory property of the XMLSchemaManager. Not required. If set to true, then the Schemas will be saved via the configured XMLSchemaManager. If omitted, defaults to true. Specifies the mapping file to use. Not required. Nucleus path to the Schema Generator component. If omitted, defaults to /atg/ repository/xml/SchemaGenerator. Specifies the set of modules to use in the repository definition. Required. Prints out a usage message. Not required.
-itemDescriptor
-outputDirectory
-saveSchemas
-mappingFile -schemaGenerator
-m -help
Example
The following command generates an XML Schema for the user item descriptor of the default Dynamo profile repository, using the properties defined in the repository definition file for the DSSJ2EEDemo application module (and the modules required by the DSSJ2EEDemo module):
generateXMLSchema -m DSSJ2EEDemo repository /atg/userprofiling/ProfileAdapterRepository -itemDescriptor user
The generated XML Schema is saved by the Schema Manager specified by the schemaManager property of the Schema Generator component. The default Schema Generator is the /atg/repository/xml/ SchemaGenerator component, and its schemaManager property points by default to the /atg/repository/ xml/SchemaManager component. Note that if the user item descriptor contains other item descriptors as properties, the generated Schema will reflect these other item descriptors as well. To save the Schema to the current working directory in addition to the directory determined by the XMLSchemaFileDirectory property of the Schema Manager:
generateXMLSchema -m DSSJ2EEDemo repository /atg/userprofiling/ProfileAdapterRepository -itemDescriptor user -outputDirectory .
33
Notice that only the name of the mapping file is specified, not the entire pathname. The Schema Managers mappingFileDirectories property points to the directories where the mapping file should be stored.
PropertyElementNameSeparator
The repository2xml feature specifies a separator character, which functions to separate a property name from the name of its item descriptor. By default, this separator character is . (dot). The default separator character may not work for you if, for example, you use composite repository IDs that also use the . (dot) character to separate elements of the repository ID. You can specify a different separator character in the propertyElementNameSeparator property of the /atg/repository/xml/RepositoryXMLTools component.
Item References
In a repository schema, a map, set, list, or array property can point to a single other item using the itemRef attribute. The value assigned to the itemRef attribute concatenates the item descriptor name, the property element separator, and the repository ID. In the following example, the item descriptor name is role, the property element separator is . (dot) and the repository ID is 2900004:
<user:itemRef itemRef="role.2900004"/>
The following is a more extended example, showing the context for the itemRef attribute:
<user:user xmlns:user=http://www.atg.com/ns/profileMapping/UserProfiles/user xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation="http://www.atg.com/ns/profileMapping/UserProfiles/user profileMapping+UserProfiles+user.xsd " ID="user747"> <user:homeAddress itemRef="contactInfo.1040001"/> <user:roles> <user:itemRef itemRef="role.2900004"/> <user:itemRef itemRef="role.3000008"/> </user:roles>
34
</user:user>
Repository Operations
The atg.repository.xml package includes a service class for each of the four repository operations supported by the data binding facility. The following table lists these classes and the Nucleus instances included in Dynamo:
Class
atg.repository.xml.GetService atg.repository.xml.AddService atg.repository.xml.UpdateService atg.repository.xml.RemoveService
Nucleus component
/atg/repository/xml/GetService /atg/repository/xml/AddService /atg/repository/xml/UpdateService /atg/repository/xml/RemoveService
The following sections discuss each of these classes and the operations they perform. See the entries for these classes in the ATG Platform API Reference for more information.
Example
Suppose you want to generate XML for a user profile, based on a mapping file named profileMapping.xml. The following code finds the user repository item whose ID is "user747" and generates an XML representation of it:
RepositoryItem userItem = getProfileRepository().getItem("user747", "user"); String userAsXML = GetService.getItemAsXML(userItem,"profileMapping.xml");
35
The following is sample output from this code. The data represents the profile of the user sandy in the Quincy Funds demo:
<user:user xmlns:user="http://www.atg.com/ns/profileMapping/UserProfiles/user" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.atg.com/ns/profileMapping/UserProfiles/user profileMapping+UserProfiles+user.xsd " ID="user747"> <user:securityStatus>0</user:securityStatus> <user:actualGoals>long-term</user:actualGoals> <user:gender>female</user:gender> <user:fundShares> <user:integer>500</user:integer> <user:integer>220</user:integer> <user:integer>180</user:integer> <user:integer>260</user:integer> </user:fundShares> <user:goals>short-term</user:goals> <user:dateOfBirth>1976-12-09</user:dateOfBirth> <user:pubPrivileges>none</user:pubPrivileges> <user:homeAddress> <user:homeAddresscontactInfo ID="contactInfo747"/> </user:homeAddress> <user:numberNewsItems>4</user:numberNewsItems> <user:strategy>conservative</user:strategy> <user:locale>en_US</user:locale> <user:lastActivity>2002-08-14T18:33:49.604</user:lastActivity> <user:aggressiveIndex>5</user:aggressiveIndex> <user:lastName>Pieta</user:lastName> <user:actualStrategy>conservative</user:actualStrategy> <user:interests> <user:string>tax</user:string> <user:string>international</user:string> </user:interests> <user:id>747</user:id> <user:fundList> <user:string>/repositories/Funds/en_US/overseas.xml</user:string> <user:string>/repositories/Funds/en_US/moneymarket.xml</user:string> <user:string>/repositories/Funds/en_US/growth.xml</user:string> <user:string>/repositories/Funds/en_US/growthincome.xml</user:string> </user:fundList> <user:email>sandy@example.com</user:email> <user:password>d686a53fb86a6c31fa6faa1d9333267e</user:password> <user:registrationDate>1999-04-15T00:00:00.0</user:registrationDate> <user:userType>investor</user:userType> <user:member>true</user:member> <user:brokerId>734</user:brokerId> <user:numberFeatureItems>3</user:numberFeatureItems> <user:login>sandy</user:login> <user:guests>false</user:guests> <user:brokers>false</user:brokers> <user:investors>true</user:investors> </user:user>
Namespaces
Notice that information about the XML Schema for this data is included in the user:user tag at the beginning of the document:
36
The xsi:schemaLocation attribute specifies the URL and name of the Schema file. The Schema filename (profileMapping+UserProfiles+user.xsd) is determined by the name of the mapping file (profileMapping.xml), the name of the repository (UserProfiles), and the item descriptor (user). If no mapping file is used to create the document, the Schema filename indicates the repository and item descriptor. If you want the Schema filename to include the entire pathname, set the appendRelativeSchemaLocation property of the GetService component to true. This is especially important if youre using an external Schema verification tool, which will generally need the complete pathname to find the Schema file. If you use a mapping file when you create an instance document, you should be sure to supply the name of this mapping file to the generateXMLSchema command (using the mappingFile argument) when you generate the Schema. Otherwise the actual Schema filename will not match the name in the xsi:schemaLocation tag, and the Schema may not accurately reflect the data in the instance document; as a result, you may not be able to validate the data when reading it into a remote system (or reading it back into Dynamo using AddService). Note also that if your call to getItemAsXML() includes an input argument that specifies the names of properties to write out, the Schema will not accurately reflect the data in the instance document, so validation will not be possible. To avoid any conflict between tag names, the XML tags in the generated instance document are named using the convention itemType:propertyName; for example the user:userType tag stores the value of the userType property of the user item type. If the addItemTypeToPropertyNames property of the RepositoryXMLTools component that GetService points to is set to true, the tags are named using the convention itemType:itemType.propertyName; in this case, the tag name would be user:user.userType. By default addItemTypeToPropertyNames is set to true, because the resulting XML is less likely to result in naming collisions.
37
AddService component. By default, this property is set to false, because validation slows down processing of the document. To enable validation, set the validate property to true.
The addItem() method can also take a Boolean argument to specify whether to validate the document. The value of this argument overrides the validate property. If you do not specify this argument, addItem() uses the validate property to determine whether to validate the document. If you are confident that your data is valid, you can disable validation, and the instance document will be processed more quickly. However, if the data turns out to be invalid, the invalid data may be written to the repository. If you enable validation and the data is invalid, addItem() does not write the contents of the instance document to the repository.
The updateItem() method can optionally validate the instance document against the specified Schema. The logic for this is similar to the AddService.addItem() method: the UpdateService component has a validate property whose default value is false, and the updateItem() method can take a Boolean argument that overrides the value of the validate property.
<user:user xmlns:user="http://www.atg.com/ns/UserProfiles/user" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.atg.com/ns/UserProfiles/user UserProfiles+user.xsd " ID="user747"> <user:user.emailAddress>sandy@example.com</user:user.emailAddress> <user:user.login>sandy</user:user.login> </user:user>
The application would then use the following code to update the user repository item whose login value is sandy (assuming the inputXML String contains the instance document shown above):
38
Note that UpdateService determines the repository and item type from the namespace of the instance document. For more information, see Namespaces (page 36) in the Getting Repository Items (page 35) section. The matchProperties array can contain any number of property names. If the value of each repository item property named in matchProperties matches its corresponding attribute in the XML instance document, the item is selected for update. All of the specified properties must match for the item to be selected; for example, if matchProperties lists login and lastName properties, the values of both properties must match. If multiple items are selected, an exception is thrown and no update occurs. Matching is limited to top-level properties of the repository item. Subproperties (such as properties of other repository items) cannot be matched. So, for example, if a user item has a lastName property that is a String, you can include lastName in matchProperties; but if a user item has a shippingAddress property that is another repository item, you cannot include, say, shippingAddress.city in matchProperties. If a property has been mapped to a different name in the instance document, the name to match on is the property name used in the repository, not the instance document. For example, suppose you use a mapping file to map a user items dateOfBirth property to the name birthday, like this:
To specify this property in matchProperties, you use the name of the property as it is defined in the repository (dateOfBirth), not the target name (birthday). For example:
You can configure the UpdateService to add a repository item if an attempt to update does not find a match. If you want the UpdateService to add items when no items are matched, set the addWhenNoMatchedItems property of the UpdateService to true. If the property being updated is a simple type (such as a String), then its value is updated by the UpdateService. When the property being updated is a list, map or array, then the old value is replaced by the new value. The new value is not appended to the old value. If the property being updated is an item descriptor, then the appropriate fields of the existing item descriptors are updated.
39
repositoryId
The repositoryId attribute of an item can be used as a special match property. If the repositoryId String is passed to UpdateService as a match property, the service will determine the value of this attribute from the top-level XML element in the instance document, and then find a repository item with a matching repository ID. The following XML example uses the repositoryId attribute as a match property:
<user:user xmlns:user="http://www.atg.com/ns/UserProfiles/user" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.atg.com/ns/UserProfiles/user UserProfiles+user.xsd " ID="user747" repositoryId="user707"> <user:user.emailAddress>sandy@example.com</user:user.emailAddress> </user:user>
In this case, the UpdateService selects the user item whose repositoryId is "user707" from /atg/ userprofiling/ProfileAdapterRepository. Note: Do not confuse with the repositoryId attribute, which identifies a repository item, with the ID attribute used in the XML schema to identify an XML element. The repositoryId attribute and not the ID attribute is used to identify which repository item to update.
The application then uses the following code to remove all the user repository items whose dateOfBirth value is 02-06-1975 (assuming the inputXML String contains the instance document shown above):
40
The maximum number of matching items is specified by the maxSelectedItems property of RemoveService. If the number of matching repository items exceeds this value, an exception is thrown. In the /atg/ repository/xml/RemoveService component, maxSelectedItems is set to 5 by default.
41
42
The Oracle ATG Web Commerce platform permits external Java clients to access Nucleus methods by exposing them as Oracle ATG Web Commerce Web Services. Many such Oracle ATG Web Commerce Web Services are included with the Oracle ATG Web Commerce platform, as are tools for creating custom Web Services. For a list of Oracle ATG Web Commerce Web Services, see ATG Web Services (page 3). Java clients can execute those Web Services through calls that are translated into XML wrapped in SOAP, transmitted to the Oracle ATG Web Commerce platform, and routed to the Nucleus method itself. Other Oracle ATG Web Commerce resources, such as JMS messages and RepositoryItems, can also be exposed as Oracle ATG Web Commerce Web Services. The Oracle ATG Web Commerce implementation of Web Services follows the standard Web Service guidelines outlined by JAX-RPC 1.0 and SOAP 1.1 specifications. You may use Apache Axis 1.4 to create your Web Service calls, and this chapter includes code examples that assume you are using Axis. This chapter aims to inform you how to call Oracle ATG Web Commerce Web Services from an Axis client. Rather than provide a broad discussion on how to use Axis, this chapter describes Oracle ATG Web Commerce-specific features and processes that you need to be familiar with. Please see the Axis documentation for comprehensive instructions. To access an Oracle ATG Web Commerce Web Service, you need to be familiar with the following topics: About ATG Web Services (page 43) Before You Begin Using a Java Client (page 45) Writing a CookieContainer Class (page 45) Calling ATG Web Services from a Java Client (page 47) Creating a Serializer and Deserializer (page 51)
43
Security
The content you see as a response to a Web Service call depends on your access privileges. When you login using the loginUser Web Service, you provide your user identity. If session sharing is enabled, all subsequent Web Service calls in that session are associated with that identity and related role. For more information on loginUser, see the ATG Personalization Programming Guide. You may also want to learn how other Web Services handle the security information provided by loginUser. Such information exists in the ATG Repository Guide and the ATG Commerce Programming Guide.
Transactions
When a client calls a Web Service, the transactional behavior of the service is managed entirely on the server side. The method that is exposed as a Web Service can use standard transaction demarcation techniques, but the calling client has no control over this. There are some practical considerations you should be aware of. If a single Web Service call attempts to perform some operation, and the operation fails, the operation can be rolled back (provided that the Nucleus method is demarcated properly). However, a transaction cannot span multiple Web Service calls so if an operation is performed by a sequence of Web Service calls, and the final call fails, there is no way to roll back the steps performed by the previous calls.
Sharing Sessions
When you create a Web Service, you specify whether it should be executed within the context of an HTTP session. Associating Web Services with a session enables an application to maintain state across Web Service calls and to use login information for security purposes. To allow multiple Web Services to share a session, two things need to happen: 1. The Web Service client must allow a session to be shared across certain Web Service calls. To do this, the client must pass a session cookie between calls. 2. The Web Services themselves must support sessions. When you create custom Web Services, the Web Service Creation Wizard gives you the option of supporting sessions. This chapter includes an example of a helper class that you can use to simplify cookie management. See Writing a CookieContainer Class (page 45).
RepositoryItems
If your Web Services access RepositoryItems, you need to provide a serializer and deserializer so the RepositoryItem content can be interpreted by non-Oracle ATG Web Commerce systems. The following Web Services transmit content thats natively stored as RepositoryItems: getProfile getRepositoryItem performRQLQuery getOrderAsXML (Commerce users only) getOrdersAsXML (Commerce users only) getProductXMLById (Commerce users only)
44
getProductXMLByDescription (Commerce users only) getProductXMLByRQL (Commerce users only) getProductSkusXML (Commerce users only) getPromotionsAsXML (Commerce users only) The Oracle ATG Web Commerce platform includes several tools for working with RepositoryItems. To make a client able to serialize and deserialize RepositoryItems, you need to translate the RepositoryItem class into a language thats native to your client. See Creating a Serializer and Deserializer (page 51) for more information.
3. Extract the contents of the Axis download file. 4. Add the axis libraries to your CLASSPATH. See the Apache site for more information about using Axis.
45
* A class that can be passed between web service clients that keeps track of * the cookies received from the server. These cookies are then used by * subsequent web service client calls in order to ensure that session * state is maintained. **/ public class CookieContainer { //------------------------------------// Member variables //------------------------------------/** Array of cookies from the Set-Cookie HTTP header **/ private String[] mCookies = null; /** Array of cookies from the Set-Cookie2 HTTP header **/ private String[] mCookies2 = null; //------------------------------------// Methods //------------------------------------/** * Gets the cookies set by the Set-Cookie HTTP header * @return the cookies from the Set-Cookie HTTP header, which * may be null **/ public String[] getCookies() { return mCookies; } /** * Gets the cookies set by the Set-Cookie2 HTTP header * @return the cookies from the Set-Cookie2 HTTP header, which * may be null **/ public String[] getCookies2() { return mCookies2; } /** * Extracts the cookies from the given Axis MessageContext, and * sets the cookies and cookies2 properties from them. * @param pContext the Axis message context to examine. This * cannot be null **/ public void extractCookies(MessageContext pContext) { mCookies = (String[])pContext.getProperty (HTTPConstants.HEADER_COOKIE); mCookies2 = (String[])pContext.getProperty (HTTPConstants.HEADER_COOKIE2); } /** * Extracts the cookies from the given Axis Call, and * sets the cookies and cookies2 properties from them. * @param pCall the Axis call to examine. This * cannot be null **/ public void extractCookies(Call pCall) { extractCookies(pCall.getMessageContext());
46
} /** * Extracts the cookies from the given Axis Stub, and * sets the cookies and cookies2 properties from them. * @param pStub the Axis stub to examine. This * cannot be null **/ public void extractCookies(Stub pStub) { extractCookies(pStub._getCall()); } /** * Pushes the cookie values that are set on the instance to * the given Call * @param pCall the call to set the cookies on. This cannot be null **/ public void pushCookies(Call pCall) { if(mCookies != null) pCall.setProperty(HTTPConstants.HEADER_COOKIE, mCookies); if(mCookies2 != null) pCall.setProperty(HTTPConstants.HEADER_COOKIE2, mCookies2); } /** * Pushes the cookie values that are set on the instance to * the given Stub * @param pStub the stub to set the cookies on. This cannot be null **/ public void pushCookies(Stub pStub) { if(mCookies != null) pStub._setProperty(HTTPConstants.HEADER_COOKIE, mCookies); if(mCookies2 != null) pStub._setProperty(HTTPConstants.HEADER_COOKIE2, mCookies2); } }
47
The static process can handle any data type regardless of whether its primitive, complex, object, or nonstandard. Non-standard types may require some extra effort as is the case when accessing Oracle ATG Web Commerce RepositoryItems or JMS messages. The dynamic process, conversely, is limited to only working with object versions of these data types (as permitted by SOAP 1.1): Boolean Byte Double Float Int Long Short Some complex types such as Array, List, Set, and Map may be supported using the dynamic process in a restricted way. See the JAX-RPC Specification for details on data type restrictions. The subsequent sections describe how you would make a call to the loginUser Oracle ATG Web Commerce Web Service following the static and dynamic processes.
The format of this call is clientStub.web_service(generated_web_Service_Call_instance) Axis creates the XML message, wraps it in SOAP, and sends it via HTTP to the Web Service location in the client stub.
48
{ LoginUserSEIService loginService = new LoginUserSEIServiceLocator(); LoginUserSEI loginStub = loginService.getLoginUserSEIPort(); org.apache.axis.client.Stub axisStub = (org.apache.axis.client.Stub) loginStub; CookieContainer cookieContainer = new CookieContainer(); axisStub.setMaintainSession(true); // Don't allow XML elements to reference other XML elements axisStub._setPropertyValue(AxisEngine.PROP_DOMULTIREFS, new Boolean(false)); // Push cookies onto the Stub cookieContainer.pushCookies(stub); String userId = loginStub.loginUser("bhavern", " xyo8bnif", false); // Get cookies out of the Stub, and pass them to subsequent calls as needed cookieContainer.extractCookies(stub); }
49
Service service = new Service(); Call call = (Call) service.createCall(); // Get a hold of a CookieContainer passed to this method/class CookieContainer cookieContainer = new CookieContainer(); // Push previous cookies (if any) to the new Call object cookieContainer.pushCookies(call); call.setMaintainSession(true); call.setTargetEndpointAddress(new java.net.URL("http://hostname:port/userprofiling/usersession/loginUser/ loginUser") ); // Don't allow XML elements to reference other XML elements call.setProperty(AxisEngine.PROP_DOMULTIREFS,Boolean.FALSE) call.addParameter("Login", org.apache.axis.Constants.XSD_STRING, javax.xml.rpc.ParameterMode.IN); call.addParameter("Password", org.apache.axis.Constants.XSD_STRING, javax.xml.rpc.ParameterMode.IN); call.addParameter("IsPasswordEncrypted", org.apache.axis.Constants.XSD_BOOLEAN, javax.xml.rpc.ParameterMode.IN); call.setReturnType(org.apache.axis.Constants.XSD_STRING); call.setOperationName(new QName("http://www.atg.com/webservices", "loginUser")); String userId = (String) call.invoke( new Object[] { "bhavern", "xyo8bnif", Boolean.FALSE } ); // Extract new cookies from the Call into the CookieContainer object, // which can then be passed to subsequent calls cookieContainer.extractCookies(call); }
50
51
2. Navigate to the Repository component that correlates to your Web Service as indicated in the documentation for your Oracle ATG Web Commerce Web Service. 3. Click the See Property Descriptions link beside the item descriptor name. For the item descriptor name, see the documentation for your Oracle ATG Web Commerce Web Service. This list that displays includes all properties that are available to the item descriptor based on the modules that are currently running. To make this XML schema compatible with the expectations of the resources that will use it, exclude the following items from your XML schema: 1. RepositoryItem properties that accept primitive data types and may be null. 2. RepositoryItem properties that accept Maps, Lists, or Sets.
52
The modules running when you call that Web Service The contents of your Oracle ATG Web Commerce module stack The custom Oracle ATG Web Commerce components you have created that may extend existing components accessed by the Web Service Note: The previous discussion addresses item descriptors and their subtypes, meaning item descriptors that inherit from the parent class. This relationship should not be confused with that which item descriptors share with extensions of themselves, which are added by other modules. For example, the order item descriptor has one set of properties provided by the Consumer Commerce module. A second order item descriptor is supplied by Business Commerce and, when both modules are running, the order item descriptors are concatenated so that Business Commerce properties take precedence. Because all versions of order for the running module are combined into one, you need only one XML schema for the order item descriptor. When you create that XML schema for order, remember to do so while the same modules are running as will run when your Web Service calls that item descriptor.
53
54
The Oracle ATG Web Commerce platform permits .NET clients to access Nucleus methods by exposing them as Oracle ATG Web Commerce Web Services. Many such Oracle ATG Web Commerce Web Services are included with the Oracle ATG Web Commerce platform as are tools for creating custom Web Services. For a list of Oracle ATG Web Commerce Web Services, see ATG Web Services (page 3). .NET clients are able to contact those Web Services through a carefully constructed call thats built in .NET, translated into XML wrapped in SOAP, transmitted to the Oracle ATG Web Commerce platform, and routed to the Nucleus method itself. Other Oracle ATG Web Commerce resources, such as JMS messages and RepositoryItems can also be exposed as Oracle ATG Web Commerce Web Services. This chapter aims to inform you how to call Oracle ATG Web Commerce Web Services from a .NET client. Rather than provide a broad discussion on how to use .NET, this chapter describes Oracle ATG Web Commercespecific features and processes that you need to be familiar with. Please see your .NET documentation for comprehensive instructions. To access an Oracle ATG Web Commerce Web Service, you need to be familiar with the following topics: About Web Services in the ATG Platform (page 55) Before You Begin Using a .NET Client (page 57) Calling ATG Web Services from a .NET Client (page 58) Using the Atg.DotNet.WebService API to Serialize and Deserialize RepositoryItems (page 60)
Security
The content you see as a response to a Web Service call depends on your access privileges. When you login using the loginUser Web Service, you provide your user identity. If session sharing is enabled, all subsequent Web Service calls in that session are associated with that identity and related role.
55
For more information on loginUser, see the ATG Personalization Programming Guide. You may also want to learn how other Web Services handle the security information provided by loginUser. Such information exists in the ATG Repository Guide and the ATG Commerce Programming Guide.
Transactions
When a client calls a Web Service, the transactional behavior of the service is managed entirely on the server side. The method that is exposed as a Web Service can use standard transaction demarcation techniques, but the calling client has no control over this. There are some practical considerations you should be aware of. If a single Web Service call attempts to perform some operation, and the operation fails, the operation can be rolled back (provided that the Nucleus method is demarcated properly). However, a transaction cannot span multiple Web Service calls so if an operation is performed by a sequence of Web Service calls, and the final call fails, there is no way to roll back the steps performed by the previous calls.
Session Sharing
When you create a Web Service, you specify whether it should be executed within the context of an HTTP session. Associating Web Services with a session enables an application to maintain state across Web Service calls and to use login information for security purposes. To allow multiple Web Services to share a session on .NET, two things need to happen: 1. The Web Service client must allow a session to be shared across Web Service calls. To do this, you need to define the Web Service calls in the same Web Control and assign a CookieContainer for each call. For instructions, see Calling ATG Web Services from a .NET Client (page 58). 2. The Web Services themselves must support sessions. When you create custom Web Services, the Web Service Creation Wizard gives you the option of supporting sessions.
Client Stubs
The Oracle ATG Web Commerce platform provides preconfigured client stubs for all Oracle ATG Web Commerce Web Services in ATGWS.dll. To use these stubs you need to install ATGWS.dll. See Installing ATGWS.dll (page 57) for instructions. The client stubs provided here should be sufficient for your Oracle ATG Web Commerce Web Services. Note that simultaneous calls to a Web Service made by different threads will require that a unique client stub instance exist for each thread.
56
getRepositoryItem performRQLQuery getOrderAsXML (Commerce users only) getOrdersAsXML (Commerce users only) getProductXMLById (Commerce users only) getProductXMLByDescription (Commerce users only) getProductXMLByRQL (Commerce users only) getProductSkusXML (Commerce users only) getPromotionsAsXML (Commerce users only) For these Web Services, you can use the Atg.DotNet.WebService API to serialize and deserialize related content. Descriptions for API classes are in Using the Atg.DotNet.WebService API to Serialize and Deserialize RepositoryItems (page 60). You can find this API in ATGWS.dll, which you need to install in order to access them. See Installing ATGWS.dll (page 57).
Installing ATGWS.dll
ATGWS.dll is a library that includes a stub class for each Oracle ATG Web Commerce Web Service. It also provides the Atg.DotNet.WebService API used for serializing and deserializing RepositoryItems. All users who want to access Oracle ATG Web Commerce Web Services from a .NET client should install ATGWS.dll.
You need two versions of ATGWS.dll on your system. One version lives in you Global Assembly Cache (GAC) so ASP.NET is able to access it when compiling the Web Service call. Another version should exist in a location that VS.NET recognizes. The instructions provided here direct you to use GACutil, a utility provided by .NET, although you can use any utility that can install ATGWS.dll to the Assembly folder in your windows directory. While the library does not need to live on the same machine as .NET, .NET needs to be able to access it. To install ATGWS.dll: 1. Copy <ATG10dir>/DAS/os_specific_files/i486-unknownwin32/ATGWS.dll to your Windows\Assembly folder.
57
In this example, <DotNetdir> represents the parent directory, such as c:\DotNet that holds your .NET software. Keep in mind that each time you install a new version of ATGWS.dll, it coexists with older versions. The latest version of ATGWS.dll will instruct the .NET client to use it. Theres no need to uninstall ATGWS.dll when you want to install a new version. Remember when you do install new versions, you need to update references in VS.NET to the old version of ATGWS.dll. If youd like to remove all versions of ATGWS.dll, use this command in a command prompt:
<DotNetdir> gacutil/u <ATG10dir>/DAS/os_specific_files/i486-unknownwin32/ATGWS
58
2. Deploy the application on your application server and start it up. 3. In your Visual Studio .NET project, add the Web Services as Web References. 4. When prompted for an Address, provide the WSDL URI, such as:
http://hostname:port/repository/generic/getItem?WSDL
You can find the URI for Oracle ATG Web Commerce Web Services in the documentation for the specific Web Service: For Repository Web Services, see the ATG Repository Guide. For Personalization Web Services, see the ATG Personalization Programming Guide. For Commerce Web Services, see the ATG Commerce Programming Guide.
A Simple Call
This Web Service call obtains a RepositoryItem by accessing the getRepositoryItem Oracle ATG Web Commerce Web Service.
using Atg.DotNet.WebService.Repository.GetRepositoryItem; // ... // create stub instance GetRepositoryItemSEIService getItemClientStub = new GetRepositoryItemSEIService(); // assign URL of web service getRepositoryItemClientStub.Url = "http://example.com/repository/generic/getItem/getRepositoryItem"; // call web service string itemXml = getRepositoryItemClientStub.getRepositoryItem("/nucleus/path/to/repository", "itemDescriptorName", "repositoryId");
A Complex Call
The following code demonstrates how you would construct a call that uses security controls to restrict the information users can access. Notice that the loginUser Web Service establishes the user identity role, which other Web Services refer to. Because an instance of a CookieContainer is created in this code and assigned to each Web Service stub, all Web Services called here exist in the same session. For brevity these examples omit some details such as a exception handling for the SoapException as well as class syntax.
using System.Net; // for CookieContainer using Atg.DotNet.WebService.Repository.GetItem;
59
using Atg.DotNet.WebService.Repository.PerformRQLQuery; using Atg.DotNet.WebService.UserSession.LoginUser; using Atg.DotNet.WebService.UserSession.LogoutUser; // create stub instances GetItemSEIService getItemClientStub = new GetItemSEIService(); PerformRQLQuerySEIService performRQLQueryClientStub = new PerformRQLQuerySEIService(); LoginUserSEIService loginUserClientStub = new LoginUserSEIService(); LogoutUserSEIService logoutUserClientStub = new LogoutUserSEIService(); // create a new cookie container for our session and share it between // the various stub instances CookieContainer cookieContainer = new CookieContainer(); getItemClientStub.CookieContainer = cookieContainer; performRQLQueryClientStub.CookieContainer = cookieContainer; loginUserClientStub.CookieContainer = cookieContainer; logoutUserClientStub.CookieContainer = cookieContainer; // authenticate the user for the session loginUserClientStub.loginUser("user", "password", false); // call services string itemXml = getItemClientStub.getItem("/nucleus/path/to/repository", "itemDescriptorName", "repositoryId"); string[] itemsXml = performRQLQueryClientStub.performRQLQuery("/nucleus/path/to/repository", "itemDescriptorName", "property = 'value'"); // log out the user logoutUserClientStub.logoutUser();
60
RepositoryItemRef Class (page 63) Complex Type Class (page 64) NoSuchPropertyException Class (page 64) RepositoryItemSerializer Class (page 65) RepositoryItemSerializationException Class (page 65) Note: Rather than use this API, you could generate an XML schema representation of the RepositoryItem and use that serialize/deserialize content. The advantage of using an XML schema is that you can control the properties you use, meaning you can easily exclude certain properties from your schema. You may find the disadvantages, namely the limitations in property types and values that this method supports, reason to use the provided API instead. For instructions on how to use an XML schema for serialization/deserialization, see the Creating a Serializer and Deserializer (page 51) in the Java client chapter.
61
A new property value is assigned to an empty RepositoryItem. Note: In order to use the classes in this interface, make sure that the Oracle ATG Web Commerce platform atg/ repository/xml/RepositoryXMLTools component has the encodeRepositoryIdAsAttr property set to true. This is the default setting.
RepositoryItem Class
The Atg.DotNet.WebService.RepositoryItem class is designed to manage XML serialization and deserialization for easy interoperability with the .NET Web Services framework. To serialize or deserialize a RepositoryItem, you need only to pass in the RepositoryName and RepositoryId. When you are working with content for the first time, you also need to call setPropertyType to instruct the deserializer/serializer to use a specific output data type.
Properties
Dirty Determines the overall dirtiness of an object by specifying whether all properties are clean (false) or one of more properties are dirty (true). ItemDescriptorName Name of the item descriptor associated with the objects RepositoryItem. Properties List of properties for this RepositoryItem. RepositoryId ID provided to the objects RepositoryItem representation. RepositoryName Name of the repository that the RepositoryItem is part of.
Constructors
RepositoryItem() Constructs a new, empty RepositoryItem object. When you serialize or deserialize a property with a value that is a pointer to a RepositoryItem, be sure to supply it a RepositoryName, RepositoryId, and ItemDescriptorName when you invoke the setRepositoryItem method. RepositoryItem(string) Constructs a new RepositoryItem in the Oracle ATG Web Commerce platform, populating it with values parsed from the XML instance of the Web Service call. The XML instance is a by-product from the Web Service call generation.
Methods
clearPropertyValues Clears all property values for a given RepositoryItem. Before using RepositoryItemSerializer.deserialize, its a good idea to use this method to clear all previous values. isPropertyDirty Determines whether a given property value is dirty (true) or clean (false). setPropertyDirty Designates a given property as dirty.
62
getPropertyValue Returns the value provided for a property in the Oracle ATG Web Commerce platform. If the property does not exist in the Oracle ATG Web Commerce platform, an error of type ATGWS.NoSuchPropertyException is thrown. setPropertyValue Sets a value for a property in the Oracle ATG Web Commerce platform. getPropertyType Returns the propertys XML data type. setPropertyType Specifies the XML data type for the property value. serialize Creates a string representation of an XML document for the RepositoryItem.
Property Class
This class represents a given propertys name and value.
Properties
Dirty Determines whether a given property is dirty (true) or clean (false). If you indicate that a property value should change by invoking the RepsoitoryItem setPropertyValue call, this property is set to true. Once a response is returned from the setPropertyValue call, this property is set to false. XmlType XML data type that will be used to represent the propertys value.
Constructor
Property() Constructs an empty object representing a property.
Methods
getName Returns the name of the property. getValue Returns the value of the property. setValue Sets a new value to the property.
RepositoryItemRef Class
This class represents a reference to another RepositoryItem.
Properties
RepositoryName
63
Name of the repository of which the referenced RepositoryItem is a part. ItemDescriptorName Name of the item descriptor used by the referenced RepositoryItem . RepositoryId ID for the referenced RepositoryItem .
Method
setRepositoryItem Initializes the ItemRef to refer to the provided RepositoryItem.
Properties
TypeName Data type for the RepositoryItem property. Properties Name of any properties that are either deserialized from or serialized into the complex type.
Constructor
ComplexType() Constructs an empty object to represent all properties of a complex data type.
Methods
getPropertyValue Retrieves values from the Oracle ATG Web Commerce platform for the specified properties. If the property does not exist in the Oracle ATG Web Commerce platform, an error of type ATGWS.NoSuchPropertyException is thrown. setPropertyValue Sets a property to a value supplied as an input. getPropertyType Returns the XML data type for the property value. setPropertyType Specifies the XML data type for the property value.
NoSuchPropertyException Class
This class generates an exception each time a getProperty or getPropertyValue method tries to interact with a property that has not been specified for the designated RepositoryItem.
Properties
PropertyName
64
Constructor
NoSuchPropertyException Constructs the exception.
RepositoryItemSerializer Class
This class conducts serialization/deserialization and permits you to decide if you want all or only dirty properties to be updated. Constructors RepositoryItemSerializer() Constructs a serializer instance. RepositoryItemSerializer(RepositoryItem) Constructs an object holding serialized content.
Methods
deserialize (string) Deserializes an XML-formatted string into a new RepositoryItem. deserialize (string, boolean) Deserializes an XML document string into a RepositoryItem. Additional arguments true or false indicate whether values for only dirty properties (true) or all properties (false) should be deserialized. serialize (string) Serializes a RepositoryItem into an XML-formatted string document. serialize (boolean) Serializes a RepositoryIteminto an XML document. Additional arguments true and false indicate whether values for only dirty properties (true) or all properties (false) should be deserialized.
RepositoryItemSerializationException Class
This class creates an exception object when errors occur during serialization or deserialization. Constructor RepositoryItemSerializationException() Constructs an empty exception object.
65
66
You can write adapters and integrators by implementing the various APIs described in this manual. Note that Oracle ATG Web Commerce adapters handle only the communication between the Oracle ATG Web Commerce platform and the middleware transport. Adapters for communication between a remote system and a middleware transport are typically available from the company that develops the remote system or the middleware.
The Oracle ATG Web Commerce Integration Framework includes the Integration Repository, which adds to the Oracle ATG Web Commerce Repository feature the ability to represent data on external systems as Oracle ATG Web Commerce repository items. The Integration Repository provides several key features for integrating Oracle ATG Web Commerce with external systems: You can execute queries from Oracle ATG Web Commerce against remote systems. The Integration Repository represents the results of the queries as repository items. You can create queries using RQL or other Oracle ATG Web Commerce query building techniques, and the Integration Repository translates the queries into the format required by the remote system. When data from the remote system is represented as repository items, the Integration Repository can automatically submit changes to these items to the remote system without requiring special update calls to a remote system.
Architecture
The Integration Repository is a wrapper around an Oracle ATG Web Commerce SQL repository, which is referred to as the local repository. In a system architecture that uses an Integration Repository, the integrated data resides in the remote system, rather than just in a local database, and queries are made using the RPC command structure described in the Remote Procedure Calls (page 95) chapter. Just like other repositories, an Integration Repository defines one or more item descriptors. Each item descriptor defines one or more commands to be used for the operations that need to interact with the remote system: executeQuery getItem createItem updateItem removeItem These operations are described in more detail in the Command Operations (page 79) section of this chapter. Each command involves an RPC call that may access the remote system, as described in the Remote Procedure Calls (page 95) chapter. The Integration Repository enables you to use the Oracle ATG Web Commerce Repository Query Language (RQL) and all the RQL droplets to access data that is stored on remote systems. The translation between RQL and the query format required by the remote system is handled by an implementation of the
69
IntegrationRepositoryView (page 78) class. An implementation of IntegrationRepositoryView typically needs to be written for each remote system you want to integrate with Oracle ATG Web Commerce. Wrapping the SQL repository provides the Integration Repository with superior performance and robustness by leveraging the SQL repositorys sophisticated item caching features. You can persist data from the remote system locally in a SQL repository. By maintaining locally-cached copies of the remote data, the Integration Repository can make the data available more quickly than if you needed to access the remote system every time you needed to access the data. In addition, the local SQL repository offers a degree of protection against the remote system being temporarily unavailable. More details of the Integration Repository architecture are described in the Integration Repository APIs (page 73) section of this chapter.
Integration Approaches
The Integration Repository is designed to help integrate Oracle ATG Web Commerce applications with remote systems. It assumes that your business maintains data on a remote system and you want to expose and possibly modify this data within your Oracle ATG Web Commerce application in the form of Oracle ATG Web Commerce repository items. There are several ways you can set up such an integration, depending on the demands of your Oracle ATG Web Commerce application and the characteristics of the remote system and the data maintained there. Here are four possible approaches for getting remote data. Which approach to choose depends on balancing your need for consistent data and best performance.
Remote Only
In this case, the data is maintained only on the remote system. Each time that the Oracle ATG Web Commerce application needs to access the data, a command is issued to the remote system. The local repository is configured to use transient repository items. Advantages: You are always sure that the data returned to Oracle ATG Web Commerce is up to date. Disadvantages: If the remote system is unavailable, then no form of the data is available to the Oracle ATG Web Commerce application. Frequent queries to the remote system can affect the performance of the remote system, which may also be serving functions other than the Oracle ATG Web Commerce application. The need to query the remote system will tend to slow the performance of the Oracle ATG Web Commerce application. See Configuring the Remote-Only Model (page 84) for more details about how this approach could be configured.
70
Advantages: You are sure that the data returned to Oracle ATG Web Commerce is up to date, except in cases where the remote system is unavailable. In addition, the existence of the local repository can provide a backup form of the data, in case the remote system is inaccessible. Disadvantages: Frequent queries to the remote system can affect the performance of the remote system, which may also be serving functions other than the Oracle ATG Web Commerce application. The need to query the remote system will tend to slow the performance of the Oracle ATG Web Commerce application. See Configuring the Remote-then-Local Model (page 85) for more details about how this approach could be configured.
Local Only
This approach doesnt need to use the Oracle ATG Web Commerce Integration Framework. In this case, we periodically dump data from the remote system into the relational database used by the Oracle ATG Web Commerce application. The data is accessed by the SQL repository. Since this approach doesnt need to issue commands against the remote system in real time, there doesnt need to be an Integration Repository. Advantages: Oracle ATG Web Commerces performance is as fast as possible. The only interaction with the remote system is a periodic batch data transfer, which probably can be scheduled to place a minimal burden on the remote system.
71
Disadvantages: The local repository is not updated in real time, so any changes in the remote system are reflected in the local repository and therefore in your Web application only after the scheduled data transfer.
72
<integration-repository-template> <header> <name>RemoteX Repository</name> </header> <item-descriptor name="account"> <query command="/atg/integrations/remotex/queries/AccountQuery" view="atg.integrations.remotex.RemoteXView"> </query> <get-item command="/atg/integrations/remotex/queries/AccountQuery"> </get-item> <add-item command="/atg/integrations/remotex/queries/AccountUpdateRPC"> </add-item> <update-item command="/atg/integrations/remotex/queries/AccountUpdateRPC"> </update-item> <remove-item command="/atg/integrations/remotex/queries/AccountDeleteRPC"> </remove-item> </item-descriptor> </integration-repository-template>
The Integration Repository definition file conforms to a DTD file at this URL:
http://www.atg.com/dtds/integrations/integration-repository_1.0.dtd
The Integration Repository is also configured using normal JavaBean properties. An IntegrationRepository component might be configured in a properties file like this:
$class=atg.adapter.integrations.IntegrationRepository repositoryName=MyStuff localRepository=/mystuff/MyLocalRepository definitionFile=/mystuff/irConfig.xml transactionManager=/atg/dynamo/transaction/TransactionManager integrationRepositoryTools=/atg/integrations/repository/IntegrationRepositoryTools persistentCacheManager=/atg/integrations/repository/PersistentCacheManager mappingManager=/atg/repository/xml/SchemaManager mappingTools=/atg/integrations/repository/MappingTools lockManager=/atg/dynamo/service/ClientLockManager
73
The Integration Repository includes extensions to, or implementations of, the following repository classes. Each of these classes is in the atg.adapter.integrations package.
IntegrationRepository (page 74) extends atg.repository.RepositoryImpl
In addition, each IntegrationRepositoryItemDescriptor refers to one or more commands, which implement the atg.integrations.Command interface. The RPC call in a Command returns an object of the atg.integrations.CommandResult class. Command and CommandResult are discussed in the Remote Procedure Calls (page 95) chapter.
IntegrationRepository
extends RepositoryImpl The IntegrationRepository references another repository, which is referred to as the local repository and which is a SQL repository. The IntegrationRepository is defined by a Nucleus properties file and an XML definition file. Each method call functions as described in the Methods (page 62) section, forwarding the request either to the local repository or to the IntegrationRepositoryItemDescriptor, which then executes a Command against the remote system.
Properties
localRepository The SQL repository that acts as a local repository. The local repository is a normal SQL repository. It might be configured in a properties file like this:
//mystuff/MyLocalRepository.properties $class=atg.adapter.gsa.GSARepository definitionFiles=/mystuff/localConfig.xml repositoryName=MyLocalStuff groupContainerPath=/atg/registry/RepositoryGroups
74
definitionFile The Integration Repository definition file. This is an XML file that uses the Integration Repository DTD, http:// www.atg.com/dtds/integrations/integration-repository_1.0.dtd . See Integration Repository Definition File (page 87) for information about creating an Integration Repository definition file integrationRepositoryTools This is a property of type atg.adapter.integrations.IntegrationRepositoryTools. This class provides a set of helper methods that are used to convert between the local repository items and the remote systems data format. An instance of this class exists at /atg/integrations/repository/ IntegrationRepositoryTools. persistentCacheManager This is a property of type atg.adapter.integrations.PersistentCacheManager. This class provides management of persistent caching. An instance of this class exists at /atg/integrations/repository/ PersistentCacheManager. See the Persistent Caching (page 82) section. mappingManager This is a property of type atg.repository.databinding.MappingManager. You can optionally define a mapping of the local repository item to the data on the remote system. This class manages that mapping. See Mapping (page 82) in this chapter and see also the Repository to XML Data Binding (page 27) chapter. mappingTools This is a property of type atg.repository.databinding.MappingTools, which is a helper class to manage the mappings. An instance of this class exists at /atg/integrations/repository/MappingTools. defaultTimeoutResponse The Integration Repository needs to deal with the case of a Command timing out before a result is returned from the remote system. If the Command times out, this property defines what the default behavior should be. There are four choices:
Rollback the current transaction. Mark the items state as invalid. See Persistent Caching (page 82). Mark the items state as unknown. See Persistent Caching (page 82). Do nothing.
sendScenarioEvents A boolean property that controls whether the repository sends scenario events. The Integration Framework includes one scenario event by default, atg.adapter.integrations.IntegrationExternalIdChange, which is sent when the externalId of an item is set. To trigger this event, use the IntegrationRepositoryTools.externalIDWasUpdated method.
Methods
Most methods in the IntegrationRepository class are pass-through to the local repository. The following methods provide special behavior:
75
getItem Depending on how you have configured the Integration Repository, this method either: calls localRepository.getItem and, if the result is null, then calls IntegrationRepositoryItemDescriptor.getRemoteItem, or calls IntegrationRepositoryItemDescriptor.getRemoteItem and, if the result is null, then calls localRepository.getItem, or calls IntegrationRepositoryItemDescriptor.getRemoteItem only. Both the local repositorys query cache and the IntegrationRepositorys query cache will be used depending on the item descriptor. If the IntegrationRepository definition file includes a query Command, then the IntegrationRepository executes the query (and uses its query cache). If there is no query Command, then the query is forwarded to the local repository. For a more detailed description, see getItem (page 80) in the Command Operations (page 79) section. getView This method can operate in two ways. If querying is implemented in the local repository (no query command) then this returns a LocalRepositoryViewWrapper. If a Command is used for querying then this returns the configured RepositoryView class. getItemDescriptor Return an IntegrationRepositoryItemDescriptor (page 76) that wraps an item descriptor from the local repository. The local repositorys item cache will be used. getItemForUpdate getItemsForUpdate Return one (or more) IntegrationRepositoryItem, using similar behavior to the getItem method above. createItem Call localRepository.createItem. This method is just a pass through. See addItem. addItem Call localRepository.addItem. Also call IntegrationRepositoryItemDescriptor.addRemoteItem. For a more detailed description, see addItem in the Command Operations (page 79) section. updateItem Call localRepository.updateItem. Also call
IntegrationRepositoryItemDescriptor.updateRemoteItem. For a more detailed description, see
updateItem in the Command Operations (page 79) section. removeItem Call localRepository.removeItem. Also call
IntegrationRepositoryItemDescriptor.removeRemoteItem. For a more detailed description, see
removeItem in the Command Operations (page 79) section. Each of the Command executions is relevant only if the given command is defined for the item descriptor.
IntegrationRepositoryItemDescriptor
extends ItemDescriptorImpl This class references an item descriptor from the local repository. Most operations will be pass-through to the local repository item descriptor. The following operations (described in the Command Operations (page 79) section) execute a Command if one is defined for the item descriptor; otherwise they do nothing.
76
In addition, this class is responsible for converting the results of queries obtained from the remote system into repository items.
IntegrationRepositoryItem
implements RepositoryItem, MutableRepositoryItem This class references a repository item in the local repository. Most operations will be passed through to it.
ChangedPropertyBean
implements RepositoryItem, MutableRepositoryItem This class includes only the external ID property plus the list of properties in a RepositoryItem that have been changed. When, for example, updateItem is invoked on an IntegrationRepositoryItem, this wrapper can be passed to the update Command instead of the RepositoryItem. This allows us to send only the changed properties to be saved to the remote system, instead of trying to update all the properties of a repository item. For example, if you change the middleName property of the user profile, and the user profile is configured with an external id property called remoteId, the ChangedPropertyBean will only expose two properties: middleName and remoteId. If you call ChangedPropertyBean.getPropertyDescriptors, the result will only contain these two properties. A ChangedPropertyBean is read-only.
atg.repository.databinding.MappingRepositoryItem
implements RepositoryItem, MutableRepositoryItem A MappingRepositoryItem wraps a repository item and exposes properties as they are configured in a mapping file. The Integration Repository creates MappingRepositoryItems automatically if it is configured with a mapping file. The property names that are exposed are the target names as defined in the mapping file. If a propertys include attribute is false in the mapping file, then that property is not a legal property of the MappingRepositoryItem. For example, if the following mapping exists:
<item-descriptor repository-path="/atg/userprofiling/ProfileAdapterRepository" name="user" default-include="false"> <property name="firstName" include="true"/> <property name="lastName" include="true"/> <property name="id" target-name="dynamoId" include="true"/> </item-descriptor>
then the corresponding MappingRepositoryItem would contain three properties: firstName, lastName, and dynamoId. See the Repository to XML Data Binding (page 27) chapter.
77
IntegrationRepositoryView
extends RepositoryViewImpl
IntegrationRepositoryView is an abstract class that provides some standard operations like applyOptions and getRange. For each type of remote system that you want to integrate with, you need to create an implementation of IntegrationRepositoryView specific for your remote system in order to provide the translation between the Oracle ATG Web Commerce Query format, and the format expected by the remote system. When a query is executed, the executeUncachedQuery method is called. That method looks like this:
public RepositoryItem[] executeUncachedQuery(Query pQuery, QueryOptions pOptions) { // Step 1 Object input = createQueryCommandInput(pQuery, pOptions); // Step 2 RepositoryItem[] items = executeQueryCommand(input); // Step 3 return applyOptions(items, pOptions); }
The inputs to this method are a standard Query object and a standard QueryOptions object. The executeUncachedQuery method goes through the following steps: Step 1 The first thing the view needs to do is translate the Query object into an object that is understandable by the remote system. This is the responsibility of your subclass of IntegrationRepositoryView and the only method that you must implement. Step 2 This step is a call to the method defined in IntegrationRepositoryView that gets the correct Command according to your configuration and calls Command.execute with the provided query input. Step 3 This step may not be necessary. If your remote system supports sorting and ranging (returning a subset of the items) then it will be more efficient for that information to be included in the command input. In that case this step can be skipped in the executeUncachedQuery and you should override the applyOptions method to do nothing. The only thing required for querying to work is to subclass IntegrationRepositoryView and implement createQueryCommandInput. The implementation of this method will introspect the Query class and create an input object. The type and contents of the input object depend on the requirements of your application and the remote system you are querying. You then need to create a Command that knows what to do with this input. In addition, you will typically need to implement a processResults method in your IntegrationRepositoryView subclass. This method is responsible for translating between the remote data format and the repository items in the local repository. The default implementation of IntegrationRepositoryView.processResults calls IntegrationRepositoryTools.createRepositoryItems. It passes in the results from pCommandResult.getResults() as the first argument. The createRepositoryItems method uses DynamicBeans to look at the given command results. For each object in the result it uses the IntegrationRepositoryItemDescriptor to find the external ID. It uses this external ID to look for an existing item in the local repository with the same external ID. If one is found, this method iterates across the
78
properties in the result object (using DynamicBeans) and updates the properties. If one is not found, a new item is first created, then the properties are updated.
Command Operations
The Integration Repository can define five types of operations that allow Oracle ATG Web Commerce repository items to access data in remote systems: executeQuery (page 79) getItem (page 80) addItem (page 25) updateItem (page 25) removeItem (page 25)
executeQuery
There are four possibilities here: Always query against the local repository. For example, you may decide that updates to profiles need to be sent to a remote system, but queries of that data will always be done locally. Always query against the remote system. For example, you may want the data to remain in the remote system with no persistent storage in Dynamo. Check the local repository first, then check the remote system. Check the remote system first, then Dynamo. If there is a Command associated with the query operation then the remote system is queried. If no Command is configured, then the local repository is queried. When you want to execute a query against the Integration Repository, your code will look something like this:
Repository rep = getRepository(getMyRepository()); RepositoryView view = rep.getView(getMyView()); QueryBuilder builder = view.getQueryBuilder(); Query query = builder.createSomeQuery(MyQueryExpression); RepositoryItem[] results = view.executeQuery(query);
There is no Integration Repository specific code in any of this. This is because you build queries with the Integration Repository in exactly the same way that you would build queries with the SQL repository. This also means that you can use RQL. You can use standard query builder calls, so the Query object that gets generated is a standard Query object from the atg.repository.query package. This real difference is in the RepositoryView. The Integration Framework uses a subclass named IntegrationRepositoryView. This class provides an implementation of executeUncachedQuery that is expected to call the query Command. There needs to be a subclass of IntegrationRepositoryView for each remote system you want to query. This subclass is responsible for translating between the Oracle ATG Web Commerce Query and the query format expected by the remote system.
79
A query Command will receive whatever input is created by the createQueryCommandInput method of your IntegrationRepositoryView. The IntegrationRepositoryView.processResults method is responsible for translating between the remote data format and our repository items.
getItem
The getItem operation returns the value from the local repository. If there is no result, or if the entry in the local repository is invalid, the getItem operation updates the local repository with the results returned by the execution on the remote system of the Command associated with the getItem operation. This operation uses the IntegrationRepositoryItemDescriptor.getRemoteItem() method. Commands executed for get-item will receive whatever input is created by IntegrationRepositoryTools.createGetCommandInput(). By default this is a map of the external ID property name to the value of the external ID. If you require a more complex command input, extend IntegrationRepositoryTools and override the createGetCommandInput() method. If the item descriptors use-external-id attribute is true, then the given local repository item ID is identical to the remote ID. If this attribute is false, then the remote ID must be retrieved from the local item (using the item descriptors external-id-property). If getRemoteItem throws an exception, then if the item descriptors use-local-on-failure attribute is true, the operation returns the value from the local repository. Otherwise, the exception is passed on.
updateItem
The updateItem operation updates the values of the repository items properties both in the local repository and the remote system. The update is handled transactionally, so that if the update of the remote system fails, the change to the local value will not occur. This operation uses the IntegrationRepositoryItemDescriptor.updateRemoteItem() method. If the Integration Repository item descriptor defines a mapping file for the updateItem operation, then the updateItem operation creates a MappingRepositoryItem. If the changed-properties-only attribute is true, then the updateItem operation creates a ChangedPropertyBean. Otherwise, the IntegrationRepositoryItem is used. The input for the updateItem Command is either the IntegrationRepositoryItem, the MappingRepositoryItem, or the ChangedPropertyBean as appropriate. It returns a CommandResult. The updateItem operation checks if there is an external ID in the CommandResult returned by the updateItem Command. If there is, the updateItem operation updates the external ID property of the local repository item with the value. If update-local-with-result is set to true, then the Integration Repository looks in the CommandResult for new property values. Any values that appear in the result will be set on the local value of the item. If the updateRemoteItem call times out, the response depends on the setting of the timeout-response attribute for the updateItem operation. The possible settings are ROLLBACK, INVALID, UNKNOWN, IGNORE.
80
value of a property that is one of the derivation expressions of a derived property is changed, the Integration Repository treats the derived property itself as changed as well. The derived-properties element can optionally be used as a child element of an update-item Tag (page 89). It is a container for one or more property elements, each of which has a name attribute and a referenced-property attribute. The name attribute is the name of a property that can be derived from the referenced-property. The name attribute and referenced-property attribute must both be valid property names defined within the given item descriptor. If changed-properties-only="true" in the update-item element, then whenever the referencedproperty is sent in the update command, the name property will be as well. For example, suppose you have a property named remoteAddress that can be derived from a property named businessAddress. By including this derived-properties element in the update-item element, then whenever the businessAddress property is included as a changed property, the remoteAddress property will also be included as a changed property:
<derived-properties> <property name="remoteAddress" referenced-property="businessAddress"/> </derived-properties>
If you do not configure the derived-properties element for any derived properties in your item, then a change to a derived propertys expression will not cause the derived property itself to appear as a changed property. See SQL Repository Data Models: Derived Properties in the ATG Repository Guide for more information about derived properties.
addItem
The addItem operation adds the item to the local repository and to the remote system. If the addItem operation fails on the remote system, then the item will not be added to the local system. Since the item is being newly added to the remote system, it is impossible to know in advance what value of the external ID is. The addItem operation attempts to set the external ID property with the result of the addItem Command. If the useexternal-id attribute is true, then a change to the ID results in a clone of the item passed into this operation. This operation uses the IntegrationRepositoryItemDescriptor.addRemoteItem() method. The input for add-item Commands is the RepositoryItem being added. If the Integration Repository item descriptor defines a mapping file, then the addItem operation creates a MappingRepositoryItem. Otherwise, the IntegrationRepositoryItem is used. When the addItem Command returns successfully from the remote system, the addItem operation checks if there is an external ID in the CommandResult. If there is, the addItem operation updates the external ID property in the local repository with the ID value. If update-local-with-result is set to true, then the Integration Repository looks in the CommandResult for new property values. Any values that appear in the result will be set on the local value of the item. If the item was cloned, the original item is removed and the new item is returned. If the addRemoteItem call times out, the response depends on the setting of the timeout-response attribute for the addItem operation. The possible settings are ROLLBACK, INVALID, UNKNOWN, IGNORE.
removeItem
The removeItem operation removes the item from the local repository and from the remote system. This operation uses the IntegrationRepositoryItemDescriptor.removeRemoteItem() method. If there
81
is a mapping file defined in the item descriptor, the target name of the external ID property is used. If the useExternalId is false, then the given ID is the local repository item ID. The input for commands executed for remove-item is whatever input is created by IntegrationRepositoryTools.createRemoveCommandInput(). By default this is a map of the external ID property name to the value of the external ID. If you require a more complex command input, extend IntegrationRepositoryTools and override the createRemoveCommandInput() method. If the remove operation in the remote system fails, the local item will not be removed. If the removeRemoteItem call times out, the response depends on the setting of the timeout-response attribute for the removeItem operation. The possible settings are ROLLBACK, INVALID, UNKNOWN, IGNORE.
Mapping
The Oracle ATG Web Commerce Integration Framework provides tools to help you map Oracle ATG Web Commerce repository items to data objects on the remote system. Rather than export all the properties of a repository item in an integration command, you can define a map of repository item properties to attributes of the remote systems data objects. The mapping file controls which properties are sent as input in a Command, and what the external names of those properties are. For details about repository item mapping, see the Repository to XML Data Binding (page 27) chapter.
Persistent Caching
The Integration Framework uses a separate SQL repository to track integration information. This SQL repository is referred to as the persistent cache or the Integration Data repository. This repository exists to track when particular repository item properties have been fetched from the remote system. This lets the Integration Framework limit the frequency with which it needs to access the remote system. The Integration Data repository has a Nucleus address of /atg/integrations/repository/ IntegrationData. You should not need to do anything to configure or use the Integration Data repository. The repository uses a database table named if_integ_data that is created when you install Oracle ATG Web Commerce. The Integration Data repository defines a single item descriptor, named integration-data. For each repository item in the local repository, there is a corresponding repository item in the Integration Data repository. The integration-data item descriptor defines five properties:
Property
itemID
Description The repository ID of the repository item in the local repository that this information applies to. The name of the item descriptor in the local repository that this information applies to.
itemDescriptor
82
Property
repositoryName state
Description The name of the local repository. This property tracks whether the item in the local repository is up to date with the data in the remote system. The state can be one of OK, INVALID, or UNKNOWN. Unless the state is OK, then the Integration Repository tries to get the data from the remote system, rather than relying on the local repository. This property tracks the last time a getItem operation retrieved the items data from the remote system. If the current time minus the lastRun time exceeds the localvalue-timeout value set in the Integration Repository, then this item is marked INVALID and the Integration Repository retrieves the items data from the remote system with a getItem operation.
lastRun
The item descriptor definition in the Integration Repository definition file specifies a local-value-timeout attribute:
<item-descriptor name="my-item" local-value-timeout="1000"/>
The state of a repository item can be set to one of OK, INVALID, or UNKNOWN. The state can be changed if an Integration Repository command returns an error or times out. The Integration Repository checks the state and lastRun values on a get-item operation. If the state is INVALID, or the lastRun time for the given command is more than local-value-timeout milliseconds from the current time, then the item is reloaded from the remote system (using the get-item Command). If an item is transient, then a transient instance of the Integration Data repository item would be created. An item descriptor in the Integration Repository can also define one or more read-only states. If the state of an item in the Integration Data repository is in a read-only state, then the values in the local repository can be used for read-only operations (query, get) but not for write operations (update, add, remove).
Property Name
expireTimePeriod
Description Time in seconds that items remain in the persistent cache after they are last updated.
83
Property Name
deleteInvalidStateItems schedule
Description Items are deleted if their state is not OK. See Scheduler Services in the Core Dynamo Services chapter of the ATG Platform Programming Guide for information about how to set schedules in schedulable services.
Configuration Examples
The following examples show some ways to configure three of the alternatives described in the Integration Approaches (page 70) section: Configuring the Remote-Only Model (page 84) Configuring the Remote-then-Local Model (page 85) Configuring the Local-then-Remote Model (page 86)
<gsa-template> <item-descriptor name="contact" display-property="lastName"> <property name="id" data-type="string"/> <property name="firstName" data-type="string" display-name="First Name"/> <property name="lastName" data-type="string" display-name="Last Name"/> <property name="email" data-type="string" display-name="Email Address"/> </item-descriptor> </gsa-template>
You can define a mapping file that specifies the names of these properties on the remote system: mapping.xml
<item-descriptor
84
repository-path="/atg/integrations/remotex/RemoteXIntegrationRepository" name="contact"> <property name="id" targetName="Id" include="true"/> <property name="firstName" targetName="First Name" include="true"/> <property name="lastName" targetName="Last Name" include="true"/> <property name="email" targetName="Email Address" include="true"/> </item-descriptor>
The Integration Repository definition file would then look like this: integrationRepository.xml
<integration-repository-template> <item-descriptor name="contact" external-id-property="id" use-external-id="true" mapping-file="/atg/integrations/remotex/mapping.xml" local-value-timeout="1000"> <query command="/atg/integrations/remotex/GetContacts" view-class="atg.integrations.remotex.RemoteXQueryView"/> <get-item command="/atg/integrations/remotex/GetContacts" use-local-on-failure="false"/> <update-item command="/atg/integrations/remotex/UpdateContacts"/> </item-descriptor> </integration-repository-template>
This configuration means that queries and getItem operations use the GetContacts command. Users cannot remove or create contacts in the remote system, since no Command has been defined for these operations, but can update existing ones. If the remote system is unavailable in a getItem operation, then no data is available, since the use-local-on-failure attribute is set to false. Note that you could change this to provide Oracle ATG Web Commerce with read-only access to the remote system by omitting the updateItem Command, leaving only the GetContacts Command to query and get items.
<gsa-template> <item-descriptor name="contact" display-property="lastName"> <table name="contact" ... > <property name="id" data-type="string"/> <property name="firstName" data-type="string" display-name="First Name"/> <property name="lastName" data-type="string" display-name="Last Name"/>
85
integrationRepository.xml The Integration Repository definition file uses the local-value-timeout attribute with a small value, so that subsequent attempts to access an item will continue to try the remote system before resorting to the local repository. In addition, the use-local-on-failure attribute for the getItem command is set to true.
<integration-repository-template> <item-descriptor name="contact" external-id-property="id" use-external-id="true" local-value-timeout="1000"> <query command="/atg/integrations/remotex/GetContacts" view-class="atg.integrations.remotex.RemoteXQueryView"/> <get-item command="/atg/integrations/remotex/GetContacts" use-local-on-failure="true"/> <update-item command="/atg/integrations/remotex/UpdateContacts"/> </item-descriptor> </integration-repository-template>
<integration-repository-template> <item-descriptor name="contact" external-id-property="id" use-external-id="true" local-value-timeout="3600000"> <query command="/atg/integrations/remotex/GetContacts" view-class="atg.integrations.remotex.RemoteXQueryView"/> <get-item command="/atg/integrations/remotex/GetContacts" use-local-on-failure="true"/> <update-item command="/atg/integrations/remotex/UpdateContacts" timeout-response="UNKNOWN"/> <add-item command="/atg/integrations/remotex/AddContacts" timeout-response="INVALID"/> <remove-item command="/atg/integrations/remotex/RemoveContacts"/> </item-descriptor> </integration-repository-template>
86
The definition file includes the following elements: integration-repository-template tag (page 87) header tag (page 87) item-descriptor tag (page 87) item-descriptor Child Tags (page 88)
integration-repository-template tag
The integration-repository-template tag acts as a container for the Integration Repository definition file. It contains a single header tag and one or more item-descriptor tags.
header tag
The header tag contains information about the Integration Repository definition file. It can contain the following child elements: name author version description
item-descriptor tag
Each item descriptor in the local repository that is integrated must be defined in the Integration Repository definition file and configured in the item-descriptor tag. This tag has the following attributes:
Attribute
name
Description The name of the item descriptor being configured. This must match the name of the item descriptor in the local repository. This is the default mapping file that is used when sending a repository item to any of the configured commands. The mapping file controls which properties are sent as input, and what the external names of those properties are. See Mapping (page 82).
mapping-file
87
Attribute
external-idproperty
Description Just as there is a local ID (repositoryId) for each item in the local repository, there must also be an ID for each corresponding item in the remote system. This attribute identifies which repository item property in the local repository will be used to store the external ID. The external ID property does not have to be the same property as the repository ID in the local repository. If it is not, set useexternal-id to false. If the local repository ID should match the external ID, then this property should be set to true. If the external ID is just stored as a non-ID property on the local item, then set this property to false. This property configures the number of milliseconds that a local item is valid before it should be retrieved from the external system. For example, if this is set to 600000, and you call getItem, then each subsequent call to getItem for the next 10 minutes will return that same item with no updates. After 10 minutes, a call to getItem will once again execute the getItem command. Each item retrieved from the remote system has a state associated with it in the persistent cache. The state can be one of OK, INVALID, or UNKNOWN. The default value is UNKNOWN. This property identifies which of those states will render the item read-only. This is useful if you timed out on a recent call to getItem and you still want people to be able to view the item but do not want to run the risk of them changing it. See Persistent Caching (page 82). This attribute controls the behavior if there is no configured command for a particular operation. If this attribute is true, then the local repository can act on the local repository item without reference to the remote system. For example, if there is no update-item command configured, and someone calls updateItem, is this an error? Should the update just go to the local repository with no Command execution?
use-external-id
local-valuetimeout
read-only-states
allow-localoperation
query Tag
This configures the behavior of the Integration Repository when the executeQuery method is called on the RepositoryView for items of this type.
88
get-item Tag
This configures the behavior of the Integration Repository when getItem is called for repository items of this type.
update-item Tag
This configures the behavior of the Integration Repository when updateItem is called for repository items of this type. It can optionally contain a derived-properties Tag (page 90) as a child element. See updateItem and Derived Properties (page 80) in the Command Operations section.
89
If this is set to true, then the Integration Repository will look in the CommandResult for new property values. Any values that appear in the result will be set on the local value of the item. ignore-external-id-change If this is set to true, then if the only changed property on the item is the external ID property, no call to the update item Command will be made.
add-item Tag
This configures the behavior of the Integration Repository when addItem is called for repository items of this type.
remove-item Tag
This configures the behavior of the Integration Repository when removeItem is called for repository items of this type.
derived-properties Tag
If your underlying local repository uses the derived properties feature of the SQL repository and you have set changed-properties-only="true" in the update-item element, then you should define a derivedproperties element to specify how the derived properties are handled. The derived-properties element is a container for a list of derived properties mapped to some property that is used in the derivation. The derived-properties element can optionally be used as a child element of an update-item Tag (page 89). See updateItem and Derived Properties (page 80) in the Command Operations section. See also SQL Repository Data Models: Derived Properties in the ATG Repository Guide for more information about derived properties. The derived-properties element contains one or more property tags.
90
property Tag
The property tag in the Integration Repository definition file is a child element of a derived-properties element.
name referenced-property
The name of a property that can be derived from the referenced-property. The name of a derivation expression of a derived property specified by the name attribute.
If changed-properties-only="true" in the update-item element, then whenever the referencedproperty is sent in the update command, the property specified by the name attribute will be as well. See updateItem and Derived Properties (page 80) in the Command Operations section.
91
<!-- Version string --> <!ELEMENT version (#PCDATA)> <!-- Description string --> <!ELEMENT description (#PCDATA)>
<!-<!-<!-<!-<!--
=============================================================== --> integration-view element: --> The definition of a view as it appears to code that calls the --> integration repository. --> =============================================================== -->
<!ATTLIST item-descriptor name CDATA #REQUIRED mapping-file CDATA #IMPLIED external-id-property CDATA #IMPLIED use-external-id CDATA #IMPLIED local-value-timeout CDATA #IMPLIED read-only-states CDATA #IMPLIED allow-local-operation CDATA #IMPLIED > <!ELEMENT query EMPTY> <!ATTLIST query command CDATA #IMPLIED view-class CDATA #IMPLIED query-cache-size CDATA #IMPLIED query-expire-timeout CDATA #IMPLIED > <!ELEMENT get-item EMPTY> <!ATTLIST get-item command CDATA #IMPLIED use-local-on-failure CDATA #IMPLIED > <!ELEMENT update-item (derived-properties?)> <!ATTLIST update-item command CDATA #IMPLIED mapping-file CDATA #IMPLIED timeout-response %timeoutresponses; "ROLLBACK" changed-properties-only CDATA #IMPLIED update-local-with-result CDATA #IMPLIED ignore-external-id-change CDATA #IMPLIED > <!ELEMENT derived-properties (property+)> <!ELEMENT property EMPTY> <!ATTLIST property
92
name CDATA #REQUIRED referenced-property CDATA #REQUIRED > <!ELEMENT add-item EMPTY> <!ATTLIST add-item command CDATA #IMPLIED mapping-file CDATA #IMPLIED timeout-response %timeoutresponses; "ROLLBACK" update-local-with-result CDATA #IMPLIED > <!ELEMENT remove-item EMPTY> <!ATTLIST remove-item command CDATA #IMPLIED timeout-response %timeoutresponses; "ROLLBACK" >
93
94
The integration framework includes a facility for making remote procedure calls (RPC). The Integration Repository makes extensive use of RPC to make calls to the remote system for querying and data synchronization. The RPC facility is designed to be as generic as possible in order to support a variety of remote systems and middleware transports. The classes and interfaces in the atg.integrations package provide an API that can be implemented in various ways to work with Web Services, the Java Connector Architecture (JCA), or different middleware transports. For example, the Oracle ATG Web Commerce Tibco Adapter includes an implementation of the RPC API that enables the Oracle ATG Web Commerce platform to execute Tibco commands. This chapter discusses the following topics: RPC API Architecture (page 95) Implementing the RPC API (page 97) Executing Commands in Pages (page 98)
Command Interface
The atg.integrations.Command interface is a generic representation of a command. You create specific commands by implementing this interface.
95
The Command interface has two methods for executing commands, execute() and invokeRPC(). Both of these methods take a java.lang.Object as input (to be as generic as possible), and return a CommandResult. The execute() method is the one actually called by an application. Invoking this method sets off a chain of actions that ultimately results in the invokeRPC() method being executed. The invokeRPC() method does the actual work of making a call to the remote system. Note, however, that applications should not call this method directly, as the processing of commands is based on the assumption that execute() is called first. The Command.execute() method must implement the following logic: If the Command points to a CommandHandler (that is, if the Command.commandHandler property is not null), pass the Command and its input to that CommandHandler by calling the CommandHandler.executeCommand() method. If the Command does not point to a CommandHandler, call the Command.invokeRPC() method.
CommandHandler Interface
The atg.integrations.CommandHandler interface is a generic representation of a handler class for preprocessing and postprocessing commands. Command handlers are not a required part of the RPC API, since a Command.execute() method can call the corresponding Command.invokeRPC() method directly. However, command handlers add a great deal of power and flexibility to the RPC system. To pass a Command and its input to a CommandHandler, the Command.execute() method calls the CommandHandler.executeCommand() method. The CommandHandler.executeCommand() method must implement the following logic: If the CommandHandler points to another CommandHandler (that is, if the CommandHandler.nextCommandHandler property is not null): Perform any preprocessing. Pass along the Command and its input to the next CommandHandler by calling CommandHandler.getNextCommandHandler().executeCommand(). Perform any postprocessing. If the CommandHandler does not point to another CommandHandler: Perform any preprocessing. Execute the Command.invokeRPC() method. Perform any postprocessing. This logic allows command handlers (and the services they implement) to be chained together. The final CommandHandler in the chain must be able to call the Command.invokeRPC() method, to ensure that the command can be executed. However, it is not required that the command is always executed. For example, one typical use for a command handler is caching of commands and their results. Such a command handler might work like this: Examine the command to determine if it is in the cache. If the command is in the cache, return the cached result. If the command is not in the cache, execute the command, return the result, and cache the command and result.
96
CommandResult Class
When a Command or CommandHandler object executes a Command, it must return a CommandResult. A CommandResult is just a container that has two other objects as properties: The result property is a java.lang.Object that is the actual object returned by the remote call. The context property is a java.util.Map that can be used to store additional parameters and their values. Application code should access the results in the result object by using the DynamicBeans API. For example, suppose the RPC call adds two integers and stores the result as an integer named sum. The application code could obtain the value of sum like this:
Integer sum = (Integer) DynamicBeans.getPropertyValue(getCommandResult.getResults(),"sum");
The DynamicBeans API is recommended because it eliminates the need to convert the object returned from the transport RPC into a generic data format, which requires additional memory and processing time. For example, if a query returns a DOM object, the DynamicBeans API can be used to access the data directly from it, avoiding the need to copy the properties from the DOM object to another object type (such as a Map). RPC implementations are not required to use the context Map. It is included in the CommandResult object to provide a way to store additional information that is not part of the result object.
Public class CachingCommandHandler extends BaseCommandHandler { Map sCache = new HashMap(); // Cache of method invocations. Public CommandResult executeCommand(Command pCommand, Object pInput) { if (sCache.containsKey(pInput)) { return sCache.get(pInput); } else {
97
For more information about BaseCommand and BaseCommandHandler, see the ATG Platform API Reference.
Exception Handling
The Command.execute(), Command.invokeRPC(), and CommandHandler.executeCommand() methods must throw exceptions of class atg.integration.CommandInvocationException. This exception is intended to wrap any underlying exceptions that might be thrown by a particular transport or remote system. This exception must wrap the underlying exception, rather than copying its message, so that stack trace printouts include the information from the underlying exception. The CommandInvocationException class has two useful subclasses: atg.integration.CommandTimeoutException can be thrown when an RPC call times out. This is a special case, since a timeout doesnt indicate whether the RPC call succeeded or not. atg.integration.InvalidInputException can be thrown if the input object passed to the Command is invalid.
as a list of page parameters, and then use those page parameters to specify the input values. For example:
<dsp:param name="inputParameterNames" value="first_name,age"/> <dsp:param name="first_name" value="Bill"/> <dsp:param name="age" value="43"/>
98
You cannot include both the inputParameters and the inputParameterNames parameter in the same page, or include inputParameterNames in the page if inputParameters is specified in the servlet beans properties file. However, there is a way you can specify default values for the command parameters in the servlet beans properties file, and then optionally override these values in pages. To do this: Use the inputParameters property to specify the command parameters and their default values. In your pages, define page parameters with the same names as the command parameters. The values specified for the page parameters override the values in the properties file, and are used when the command is invoked. If a command parameter has no corresponding page parameter, the default value from the properties file is used.
Input Parameters
command The command to execute. Must be an instance of a class that implements the atg.integrations.Command interface. This parameter can either be defined in a page or by setting the command property of the servlet bean, but it cannot be defined both ways. inputParameters The inputs to pass to the command, supplied as a java.util.Map of parameter name/value pairs. This parameter can either be defined in a page or by setting the inputParameters property of this servlet bean, but it cannot be defined both ways. inputParameterNames A comma-separated list of command input parameter names. Each name defines a page parameter whose name and value (specified in the page) are used to supply one of the inputs to the command. parameter names Page parameters that correspond to the names of command input parameters specified in inputParameterNames.
Output Parameters
result The result object from the command, if the execution is successful. exception The exception thrown by the command, if the execution is unsuccessful.
Open Parameters
output Rendered if the command is executed successfully. error Rendered if the command throws an exception.
Example
The following example uses inputParameterNames to create a UserId page parameter, and then sets its value to the value of a profile ID. This parameter name/value pair is passed as an input to the command. Depending
99
on whether the command is executed successfully, Dynamo renders either the output open parameter or the error open parameter.
<dsp:droplet bean="/atg/integrations/MapRPCDroplet"> <dsp:param name="command" value="bean:/atg/integrations/jdbc/QueryForUser"/> <dsp:param name="inputParameterNames" value="UserId"/> <dsp:param name="UserId" value="bean:Profile.Id"/> <dsp:oparam name="output"> <p>The user's email address is: <dsp:valueof param="result.emailAddress"/> </dsp:oparam> <dsp:oparam name="error"> <p>Unable to execute query. The following exceptions occurred: <dsp:valueof param="exception"/> </dsp:oparam> </dsp:droplet>
100
This section provides general information about and instructions for using the Oracle ATG Web Commerce platform REST Web Services interface. You must do the following before you can use the REST Web Services. 1. Start the REST module on the Oracle ATG Web Commerce platform server. See Starting the REST module (page 104). 2. Configure the security settings to give at least one user permission to use REST Web Services. See Security for REST Web Services (page 179). 3. Log in to the REST Web Services server and configure your HTTP client software to pass the session ID to the server with each HTTP request. See Logging In (page 108). The following diagram shows components of the REST Web Services interface and the sections of this document that explain them.
1. Starting the REST module (page 104) 2. Configuring the REST Server (page 173) 3. Security for REST Web Services (page 179) 4. HTTP Requests (page 104) 5. Input Values (page 118) 6. Returned Data (page 126)
103
7. Errors and Exceptions (page 135) 8. Client Software (page 106) 9. ATG Client Libraries (page 183)
Current Module List: DafEar.Admin, DPS, DSS, Service.SelfService, DAF.Search.Routing, ARF.base, DAF.Search.Base.QueryConsole, REST
HTTP Requests
This section provides information about the HTTP requests that you can send to the REST Web Services running on an Oracle ATG Web Commerce platform server.
104
The portion of the application path following /rest/ identifies the specific component you are addressing. This part of the URL is based on the component pathnames of Nucleus components and repository items. See information about component paths in the ATG Platform Programming Guide.
Nucleus Components
The URL for addressing a Nucleus component with the REST Web Services includes /bean/ in its application path. The following example shows the beginning of the URL for a Nucleus component.
http://servername:port/rest/bean/
You can invoke methods and get or set property values of Nucleus components. Include the names of methods and properties in the application path of the component. Separate the name of the method or property with a forward slash as if it were a separate container. For example, the following URL addresses the running property of the atg/dynamo/Configuration component.
http://servername:port/rest/bean/atg/dynamo/Configuration/running
See information about performing operations with Nucleus component properties and methods in Working with Component Properties (page 139) and Invoking Component Methods (page 143).
Repositories
The URL for addressing a repository item with the REST Web Services includes /repository/ in its application path. The following example shows the beginning of the URL for a repository item.
http://servername:port/rest/repository/
You can address specific repository items and get or set repository item property values. Include the names of repository items and values in the application path. Separate the names and values with a forward slash as if it were a separate container. For example, the following URL addresses the user repository item in the ProfileAdapterRepository repository.
http://servername:port/rest/repository/atg/userprofiling/ ProfileAdapterRepository/user
The following URL addresses a specific user record in the user repository item. The value of the id property at the end of the path indicates which user.
http://servername:port/rest/repository/atg/userprofiling/ ProfileAdapterRepository/user/210002
The following URL addresses a specific property of a user record in the user repository item.
http://servername:port/rest/repository/atg/userprofiling/ ProfileAdapterRepository/user/210002/login
See information about performing operations with repositories in Working with Repositories (page 155).
105
Client Software
You can use any means of transmitting HTTP requests to the ATG platform REST Web Services that you wish. Any client software that is capable of sending and receiving messages via HTTP will be adequate. Select the client software that you use according to the requirements of your environment.
Command Component
curl
Explanation Names the program being invoked. The manner in which you invoke the Curl command-line tool depends on the way it has been installed in your environment. Write verbose output while sending and receiving HTTP messages. This option exposes more details of the HTTP transaction.
-v
106
Command Component
-b
Explanation Use cookies stored in the specified file to authenticate the client. This example specifies that cookies are stored in a file named cookies.txt. A session identifier must be stored in the file. When Curl logs into the REST Web Services, the -c cookies.txt instructs it to write the cookies it receives in that file. See Logging In (page 108).
-X
Use the specified HTTP method when communicating with the REST Web Services. This example specifies that Curl should use the PUT method. Include the specified Content-Type declaration in the HTTP request header. This describes the nature of the data in the message body of the HTTP request. See Setting the Content-Type Value (page 117). Include the following content in the message body of the HTTP request. This example includes XML parameters in the message body. The URL of the Oracle ATG Web Commerce platform REST Web Service that is used in the example. See REST Web Services URLs (page 104).
-H
-d
URL
Note: The HTTP transactions shown in the examples in this document may include specific details of the testing environment used to produce them. Some details may differ in the HTTP transactions you conduct with the Oracle ATG Web Commerce platform REST Web Services. For example, the application server version identifiers shown in the HTTP transaction may not match the application that your Oracle ATG Web Commerce platform server uses.
HTTP Methods
The Oracle ATG Web Commerce platform REST Web Services support the standard HTTP methods. These methods are described in the following table.
Method GET
Explanation Use this method to return data. Examples of the values you may get are repository item and Nucleus component property values, RQL query results, repository items, and Nucleus components.
107
Method POST
Explanation Use this method to invoke functionality or make changes to your Oracle ATG Web Commerce platform server. For example, you may invoke methods, update Nucleus component properties, and create repository items. The REST Web Services server will treat POST requests as different methods if you include certain control parameters. See Handling POST Requests as Other Methods (page 108).
PUT
Use this method to make changes to your Oracle ATG Web Commerce platform server. For example, you may update repository item and Nucleus component property values.
DELETE
Logging In
Before you can use the Oracle ATG Web Commerce platform REST Web Services you must log in to open an authorized HTTP session. When the server receives a log in request for a valid user account, it will authenticate the user and return a session identifier if the authentication is successful. The procedure for logging in to the REST Web Services server is different for external and internal users. See specific procedures with examples in Logging In as an External User (page 109) and Logging In as an Internal User (page 110).
108
The specific procedure you use to handle the session identifier depends on the client software you are using. The examples in Logging In as an External User (page 109) and Logging In as an Internal User (page 110) show how one HTTP client stores the session identifier in a cookie file.
curl -v -c cookies.txt -X POST \ -H "Content-Type: application/xml" \ -d "<parameters><arg1>MyUsername</arg1><arg2>MyPassword</arg2></parameters>" \ http://myserver:8080/rest/bean/atg/userprofiling/ProfileServices/loginUser * * * > > > > > > > < < < * * < < About to connect() to myserver port 8080 (#0) Trying 12.34.567.890... connected Connected to myserver (12.34.567.890) port 8080 (#0) POST /rest/bean/atg/userprofiling/ProfileServices/loginUser HTTP/1.1 User-Agent: curl/7.21.1 (i386-pc-win32) libcurl/7.21.1 zlib/1.2.5 Host: myserver:8080 Accept: */* Content-Type: application/xml Content-Length: 71
HTTP/1.1 200 OK Server: Apache-Coyote/1.1 X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1 Added cookie JSESSIONID="7978B952714AB08BEB006A348A25ADB0" for domain myserver, path /, expire 0 Set-Cookie: JSESSIONID=7978B952714AB08BEB006A348A25ADB0; Path=/ X-ATG-Version: version=QVRHUGxhdGZvcm0vMTAuMCxDb21tZXJjZVJlZmVyZW5jZVN0b3JlLzEwLjAgWyBQbGF0Zm9y bUxpY2Vuc2UvMCBCMkNMaWNlbnNlLzAgIF0= * Added cookie DYN_USER_ID="120001" for domain myserver, path /, expire 1290872360 < Set-Cookie: DYN_USER_ID=120001; Expires=Sat, 27-Nov-2010 15:39:20 GMT; Path=/
109
* Added cookie DYN_USER_CONFIRM="bca3eb6c2cdeb0e4a625c7165a088e2e" for domain myserver, path /, expire 1290872360 < Set-Cookie: DYN_USER_CONFIRM=bca3eb6c2cdeb0e4a625c7165a088e2e; Expires=Sat, 27Nov-2010 15:39:20 GMT; Path=/ < Content-Type: application/xml;charset=UTF-8 < Transfer-Encoding: chunked < Date: Thu, 28 Oct 2010 15:39:20 GMT < <?xml version="1.0" encoding="UTF-8"?> <atgResponse>120001</atgResponse> * Connection #0 to host myserver left intact * Closing connection #0
If your attempt to log in fails, the server will return the exceptions encountered in an HTTP response with status code 200 OK. For example:
110
Note: the server returns status code 200 OK in both conditions. Make sure you examine the response value to determine whether an attempt to log in succeeded.
curl -v -c cookies.txt -X POST \ -H "Content-Type: application/json" \ -d "{ value.login=MyInternalUsername , value.password=MyInternalPassword }" \ http://myserver:8280/rest/bean/atg/userprofiling/InternalProfileFormHandler/login?atgrest-return-form-handler-exceptions=true * About to connect() to myserver port 8280 (#0) * Trying 12.34.567.890... connected * Connected to myserver (12.34.567.890) port 8280 (#0) > POST /rest/bean/atg/userprofiling/InternalProfileFormHandler/login?atg-rest-returnform-handler-exceptions=true HTTP/1.1 > User-Agent: curl/7.21.1 (i386-pc-win32) libcurl/7.21.1 zlib/1.2.5 > Host: myserver:8280 > Accept: */* > Content-Type: application/json > Content-Length: 70 > < HTTP/1.1 200 OK < Server: Apache-Coyote/1.1 < X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1 * Added cookie JSESSIONID="09FA8F5B4B8A4C1A1E97480A91BA7EB8" for domain myserver, path /, expire 0 < Set-Cookie: JSESSIONID=09FA8F5B4B8A4C1A1E97480A91BA7EB8; Path=/ < X-ATG-Version: version=QVRHUGxhdGZvcm0vMTAuMCxDb21tZXJjZVJlZmVyZW5jZVN0b3JlLzEwLjAsU2VhcmNoLzEwLjAg WyBQbGF0Zm9ybUxpY2Vuc2UvMCBT ZWFyY2hBZG1pbkxpY2Vuc 2UvMCBQdWJsaXNoaW5nTGljZW5zZS8wIEIyQ0xpY2Vuc2UvMCAgXQ== < Content-Type: application/xml;charset=UTF-8 < Transfer-Encoding: chunked < Date: Thu, 28 Oct 2010 20:57:22 GMT < <?xml version="1.0" encoding="UTF-8"?> <atgResponse> <class>class atg.rest.processor.BeanProcessor$FormHandlerExceptions</class> <exceptions/> <result>true</result> </atgResponse> * Connection #0 to host myserver left intact * Closing connection #0
111
Logging Out
You can log out to end your Oracle ATG Web Commerce platform REST Web Services session. After you log out, no client will be able to perform REST Web Services operations using the session ID that you present with the log out request. Invoke the /atg/userprofiling/ProfileServices.logoutUser method to log out of the REST Web Services server. Use the HTTP POST method. The following example shows an HTTP request to log out of a REST Web Services session.
curl -v -b cookies.txt -X POST \ http://myserver:8080/rest/bean/atg/userprofiling/ProfileServices/logoutUser * * * > > > > > > < < < < About to connect() to myserver port 8080 (#0) Trying 12.34.567.890... connected Connected to myserver (12.34.567.890) port 8080 (#0) POST /rest/bean/atg/userprofiling/ProfileServices/logoutUser HTTP/1.1 User-Agent: curl/7.21.1 (i386-pc-win32) libcurl/7.21.1 zlib/1.2.5 Host: myserver:8080 Accept: */* Cookie: DYN_USER_ID=120001; JSESSIONID=51B1124DFFC8293CF42ACA8AF2D88324; DYN_USER_CONFIRM=bca3eb6c2cdeb0e4a625c7165a088e2e
HTTP/1.1 200 OK Server: Apache-Coyote/1.1 X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1 X-ATG-Version: version=QVRHUGxhdGZvcm0vMTAuMCxDb21tZXJjZVJlZmVyZW5jZVN0b3JlLzEwLjAgWyBQbGF0Zm9ybUxpY 2Vuc2UvMCBCMkNMaWNlbnNlLzAgIF0= < Content-Type: application/xml;charset=UTF-8 < Transfer-Encoding: chunked < Date: Thu, 28 Oct 2010 20:41:00 GMT < <?xml version="1.0" encoding="UTF-8"?> <atgResponse>void</atgResponse> * Connection #0 to host myserver left intact * Closing connection #0
Control Parameters
Include control parameters with HTTP requests to alter the way that the Oracle ATG Web Commerce platform REST Web Services handle them. For example, if you would like the server to include an identifying string in the response you can use the atg-rest-user-input control parameter to specify that identifying string. You can include control parameters either in the URL for the REST Web Service or in the message body of a POST or PUT request. See URL Parameters (page 116) and Message Body Parameters (page 116). Note: Several control parameters have equivalent configuration properties. Set these configuration properties to control the way that REST Web Services are processed by default. See Configuring the REST Server (page 173).
112
Parameter
atg-rest-appendmulti-values
Explanation Use this parameter to control whether setting a value on a repository item property will add the value to an existing set of values or replace them. This only applies to repository item properties that hold multiple values. See Appending Values to Repository Item Properties (page 120). For requests which return an array or ordered list, adding this parameter with an integer value allows the caller to specify the number of elements to return. Used with atg-rest-index. Use this parameter to specify the container and element Java classes for nested object property values. See Nested Multiple Value Objects in Input (page 122). Use this parameter to specify a Java class when you are setting an object property value. See Object Values in Input (page 121). The number of references to traverse when rendering output. By default it is zero which causes only the top level object to be returned. Use this parameter to specify which form handler values should be processed first. See Form Value Priority (page 148). Use this parameter to send the REST Web Server a POST HTTP request but have it process the request as if it used a different HTTP method. For example you can use this control parameter to include message body data in a POST HTTP request but have the server process the request as if it used the GET method. Set the value of this parameter to GET, PUT, or DELETE.
atg-rest-count
atg-rest-classdescriptor
atg-rest-class-type
atg-rest-depth
atg-rest-form-tagpriorities atg-rest-http-method
atg-rest-index
Use this parameter to specify the entry in an array or ordered list that will be the starting point when that array or ordered list is returned by the server. Set the value of the parameter to the integer value of the starting position. Use this parameter with atg-rest-count.
atg-rest-input
Use this parameter to override the default input format configured for the server. Set the value of this parameter to json or xml.
atg-rest-json-input
Use this parameter to control whether the REST Web Services server will accept standard JSON markup for setting collection or map values on repository item properties. See JSON Markup Input for Multiple Value Repository Item Properties (page 121).
113
Parameter
atg-rest-method
Explanation Use this parameter to specify the Java method signature when calling an overloaded method. This parameter is only needed if two or more instances of the overloaded method have the same number of arguments.
atg-rest-null
Use this parameter to set the value of a component or repository item property to null. Set the property and include this parameter as the new value. See Setting Properties to Null (page 124). Use this parameter to override the default output format configured for the server. See Choosing Output Markup (page 126). Set the value of this parameter to json or xml. Use this parameter to specify the Java classes for multiple values in JSON functional parameters. The atg-rest-param-class-types parameter includes three components, container-class, element-class, and keyclass. For example, if a functional parameter is a java.util.ArrayList<String>, set the atg-rest-param-class-types as shown below.
{'container-class':'java.util.ArrayList','elementclass':'java.lang.String'}
atg-rest-output
atg-rest-param-classtypes
Use the key-class attribute when the container-class implements java.util.Map. For example
{'container-class':'java.util.HashMap','keyclass':'java.lang.String','elementclass':'java.lang.String'}
See Specifying Java Classes for Multiple Value Input (page 119).
atg-rest-propertyfilter-templates atg-rest-propertyfilters atg-rest-return-formhandler-exceptions
Use this parameter to apply property filter templates to individual REST Web Services Requests. See Filtering Templates (page 168). Use this parameter to apply property filtering to individual REST Web Services Requests. See Filtering for One Request (page 169). Use this parameter to specify that the REST Web Services server should return exceptions it encounters when invoking form handlers in the HTTP response. See Returning Form Handler Exceptions (page 146). Use this parameter to specify that the REST Web Services server should return the properties of the form handler objects it invokes in the HTTP response. See Returning Form Handler Properties (page 147). Include RQL query strings in this parameter. See Performing RQL Queries (page 158). Include this parameter to cause the server to return OK (200) for success rather than CREATED (201) or GONE (410).
atg-rest-return-formhandler-properties
atg-rest-rql
atg-rest-simpleresponse-codes
114
Parameter
atg-rest-transient
Explanation Use this parameter to create transient repository items. Include the parameter with the value true with a REST Web Services request to create a repository item. See Transient Items (page 161). Use this parameter to specify an identifying string that the REST Web Services server will include in the HTTP response. See Identifying a Response (page 128).
atg-rest-user-input
Functional Parameters
Functional parameters provide data that is required by the Oracle ATG Web Commerce platform REST Web Services operation you are performing. For example, if you are setting a property value, the new value is a functional parameter of the operation. You can include functional parameters either in the URL for the REST Web Service or in the message body of a POST or PUT request. See URL Parameters (page 116) and Message Body Parameters (page 116). The functional parameters you provide for a REST Web Services operation depend on the nature of that operation. When invoking a method, you may supply arguments to it. When invoking a form handler, you will supply the form field values. When setting a repository item property value, you will supply the new value. The functional parameters for each operation are explained in the procedures for those operations. See operational procedures in the following sections. Working with Component Properties (page 139) Invoking Component Methods (page 143) Working with Repositories (page 155)
Positional Parameters
Some Oracle ATG Web Commerce platform REST Web Services operations require parameters that are not named. For example, if you invoke the loginUser method of the /atg/userprofiling/ProfileServices component you must pass in two positional arguments. The first is the login value for a user and the second is the password value for that user. The REST Web Services server uses a convention to name positional parameters. It expects the first positional parameter to be named arg1, the second to be named arg2, and any further parameters to be named similarly. The URL parameters in the following REST Web Services URL contain positional parameters that are passed to the loginUser method.
http://servername:port/rest/bean/atg/userprofiling/ProfileServices/loginUser? arg1=MyUsername&arg2=MyPassword
The REST Web Services server will call the loginUser method with the arguments in the positional parameters arg1 and arg2 in that sequence. The method definition for loginUser is shown below. See information about invoking methods in Invoking Component Methods (page 143).
115
URL Parameters
You can include control and functional parameters in the URL for Oracle ATG Web Commerce platform REST Web Services. Use standard URL query string syntax and URL encoding if needed. The following example shows a URL with two functional parameters and a control parameter.
http://servername:port/rest/bean/atg/userprofiling/ProfileServices/loginUser? arg1=MyUsername&arg2=MyPassword&atg-rest-user-input=MyMessageId
The REST Web Services server can interpret message body parameters in one of the following three markup formats. Make sure you set the correct Content-Type value for the markup that you use. See Setting the Content-Type Value (page 117). XML, see XML Parameter Markup (page 117). JSON, see JSON Parameter Markup (page 118). URL query string, see URL Query String Parameter Markup (page 118). The REST Web Services server will only accept parameters in the message body of a POST or PUT HTTP request. If you need to use the GET or DELETE methods, you need to include data with your request, and you cannot include URL parameters, use the atg-rest-view and atg-rest-http-method control parameters. See Handling POST Requests as Other Methods (page 108).
116
curl -v -c cookies.txt -X POST \ -H "Content-Type: application/xml" \ -d "<parameters><arg1>MyUsername</arg1><arg2>MyPassword</arg2><atg-rest-userinput>MyMessageId</atg-rest-user-input></parameters>" http://servername:8080/rest/bean/ atg/userprofiling/ProfileServices/loginUser * * * > > > > > > About to connect() to servername port 8080 (#0) Trying 12.34.567.890... connected Connected to servername (12.34.567.890) port 8080 (#0) POST /rest/bean/atg/userprofiling/ProfileServices/loginUser HTTP/1.1 User-Agent: curl/7.21.1 (i386-pc-win32) libcurl/7.21.1 zlib/1.2.5 Host: servername:8080 Accept: */* Content-Type: application/xml Content-Length: 125
Make sure that you specify Content-Type: application/xml in the HTTP message. See Setting the ContentType Value (page 117).
117
Make sure that you specify Content-Type: application/json in the HTTP message. See Setting the Content-Type Value (page 117). The following example shows numeric parameter input using JSON markup.
arg1=MyUsername&arg2=MyPassword&atg-rest-user-input=MyMessageId
URL encode any special URL characters in the parameter values. Make sure that you specify Content-Type: application/x-www-form-urlencoded in the HTTP message. See Setting the Content-Type Value (page 117).
Input Values
This section provides information about the way the Oracle ATG Web Commerce platform REST Web Services server expects to receive parameter values.
118
Values Accepted A sequence of characters. For example, MyUsername. An integer or decimal number. For example, 123 or 123.456.
true and false
See more information about setting property values in Setting Component Properties (page 140) and Setting Repository Item Properties (page 162).
curl -v -b cookies.txt -X POST \ -H "Content-Type: application/json" \ -d "{'atg-rest-param-class-types':{'container-class':'java.util.ArrayList','elementclass':'java.lang.String'},'arg1':['Existing String in the Collection','New String for the Collection']}" \ http://myserver:7003/rest/bean/atg/MyDog/tricks?atg-rest-json-input=true
See more information about setting property values in Setting Component Properties (page 140) and Setting Repository Item Properties (page 162).
119
Collection
Map
If your input is in JSON format, you can use the atg-rest-param-class-types control parameter to specify Java classes. The atg-rest-param-class-types parameter includes two components, container-class and element-class. Include this attribute in your JSON input as shown below.
{'atg-rest-param-class-types':{'container-class':'java.util.ArrayList','elementclass':'java.lang.String'},'arg1':['sit','stay','speak']}
See information about the atg-rest-param-class-types parameter in the Control Parameter Reference (page 113).
Note: The REST Web Services server is configured to append values to repository item properties that accept multiple values by default. The appendMultiValuesByDefault configuration property controls this behavior for repository item properties. If you have reconfigured this setting, set the atg-rest-append-multivalues control parameter to true for each REST Web Services request that should append the new value. See appendMultiValuesByDefault (page 178).
120
121
The following example shows a POST request to set an object property value for a Nucleus component.
$ curl -v -b cookies.txt -X POST -H "Content-Type: application/json" -d "{"arg1": {"atg-rest-class-type":"atg.MyObjectValue","name":"Berthoud","height":"1"}}" http:// myserver:7003/rest/bean/atg/MyDog/objectvalue * About to connect() to myserver port 7003 (#0) * Trying 12.34.567.890... connected * Connected to myserver (12.34.567.890) port 7003 (#0) > POST /rest/bean/atg/MyDog/objectvalue HTTP/1.1 > User-Agent: curl/7.20.1 (i686-pc-cygwin) libcurl/7.20.1 OpenSSL/0.9.8r zlib/1.2.5 libidn/1.18 libssh2/1.2.5 > Host: myserver:7003 > Accept: */* > Cookie: JSESSIONID=llf3PN8N0CfQ6h41Y278NfLjvCJZn6CR8ydhQRbg7GTQ7Nn5mW8p!1359398113; DYN_USER_CONFIRM=838bac4608584930cf177410e3b46448; DYN_USER_ID=110001 > Content-Type: application/json > Content-Length: 69 > < HTTP/1.1 200 OK < Date: Wed, 29 Feb 2012 05:52:39 GMT < Transfer-Encoding: chunked < Content-Type: application/json; charset=UTF-8 < X-ATG-Version: version=QVRHUGxhdGZvcm0vMTAuMSxDb21tZXJjZVJlZmVyZW5jZVN0b3JlLzEwLjE= < X-Powered-By: Servlet/2.5 JSP/2.1 < * Connection #0 to host myserver left intact * Closing connection #0 {"atgResponse": true}
122
The name of the parameter inside the atg-rest-class-descriptor matches the name of one of the actual values that you supply later in the input parameter. The input structure for nested multiple value objects builds on the structure for input objects in general. See Object Values in Input (page 121). The following example uses the atg-rest-class-descriptor control parameter to specify that the value of the myListOfSets property is a java.util.ArrayList object. That ArrayList object holds java.util.HashSet objects. After the atg-rest-class-descriptor, the example provides the values that are nested inside the myListOfSets property.
{arg1 : { "atg-rest-class-type":"foo.class.WithNestedMultis", "atg-rest-class-descriptor": { "myListOfSets": { "container-class": "java.util.ArrayList", "element-class": "java.util.HashSet" } }, "myListOfSets": [["red","blue"],["green","yellow"]] } }
<arg1> <atg-rest-class-type>foo.class.WithNestedMultis</atg-rest-class-type> <atg-rest-class-descriptor> <myListOfSets> <container-class>java.util.ArrayList</container-class> <element-class>java.util.HashSet</element-class> </myListOfSets> </atg-rest-class-descriptor> <myListOfSets> <element> <element>red</element> <element>blue</element> </element> <element> <element>green</element> <element>yellow</element> </element> </myListOfSets> </arg1>
"atg-rest-class-descriptor": {
123
Array Types
To specify an array type in the atg-rest-class-descriptor control parameter, use the standard Java notation for arrays.
Java Notation
[Ljava.lang.String; [B [I [[Ljava.lang.String;
MM/dd/yyyy HH:mm:ss z
124
-H "Content-Type: application/json" \ -d "{"arg1":"atg-rest-null"}" \ http://myserver:7003/rest/bean/atg/MyDog/name * About to connect() to myserver port 7003 (#0) * Trying 12.34.567.890... connected * Connected to myserver (12.34.567.890) port 7003 (#0) > POST /rest/bean/atg/MyDog/name HTTP/1.1 > User-Agent: curl/7.20.1 (i686-pc-cygwin) libcurl/7.20.1 OpenSSL/0.9.8r zlib/1.2.5 libidn/1.18 libssh2/1.2.5 > Host: myserver:7003 > Accept: */* > Cookie: JSESSIONID=S31vPTNFpLQQ7Bj6l16wh5KgDqqv18yXxwy1khgBpvqRkW5NfQRm!1359398113; DYN_USER_CONFIRM=838bac4608584930c f177410e3b46448; DYN_USER_ID=110001 > Content-Type: application/json > Content-Length: 20 > < HTTP/1.1 200 OK < Date: Thu, 01 Mar 2012 01:18:50 GMT < Transfer-Encoding: chunked < Content-Type: application/json; charset=UTF-8 < X-ATG-Version: version=QVRHUGxhdGZvcm0vMTAuMSxDb21tZXJjZVJlZmVyZW5jZVN0b3JlLzEwLjE= < X-Powered-By: Servlet/2.5 JSP/2.1 < * Connection #0 to host myserver left intact * Closing connection #0 {"atgResponse": true}
125
Returned Data
The Oracle ATG Web Commerce platform REST Web Services server will return the results of the operations you perform in an HTTP response message body. The contents of the returned data depend on the operation you are performing. This section explains the formats that the server will return data in. It also explains how to configure the server to return data in the manner you choose.
126
JSON Output
The following example shows JSON output. Notice how string values are surrounded by quotes, numerical values have no quotes, multivalve elements are surrounded by brackets, and references to repository items are URLs to the item referenced. Note that multivalve elements will be URLs also, but in this example, the abcArray has been expanded.
{ "myClass": "class atg.rest.processor.MockObject", "size": 10, "abcArray": { "type": "int", "elements": [ 0, 1, 2, 3 ] }, "product": "http://localhost/rest/repository/atg/commerce/catalog/ProductCatalog/ product/prod12345" }
XML Output
The following example shows XML output.
<atgResponse> <organizationPathCache> <atgRestComponentPath>/atg/userprofiling/OrganizationPathCache</ atgRestComponentPath> </organizationPathCache> <rootOrganizationPrimaryKey>root</rootOrganizationPrimaryKey> [Additional property values omitted to save space] <roles> <element> -- RepositoryItemGroupRole: --> name: Young --> primary key: Young__grouprole </element> <element> -- RepositoryItemGroupRole: --> name: WomenOnly --> primary key: WomenOnly__grouprole </element> <element> -- RepositoryItemGroupRole: --> name: Fashionista --> primary key: Fashionista__grouprole </element> <element> -- RepositoryItemGroupRole: --> name: MenOnly
127
--> primary key: MenOnly__grouprole </element> <element> -- RepositoryItemGroupRole: --> name: ThirtySomethings --> primary key: ThirtySomethings__grouprole </element> </roles> [Additional property values omitted to save space] </atgResponse>
Identifying a Response
You can include an identifying string with an Oracle ATG Web Commerce platform REST Web Services request and the server will include that string in the response it returns. One use of this function is to identify the response to an asynchronous REST Web Service request. To specify the identifying string for a REST Web Services response, include the atg-rest-user-input control parameter in your HTTP request. Set the value of the control parameter to the identifying string. See Control Parameters (page 112). The following example shows a REST Web Services request that includes the atg-rest-user-input control parameter.
curl -v -b cookies.txt -X GET \ http://myserver:8080/rest/bean/atg/dynamo/Configuration/httpPort?atg-rest-userinput=MyMessageId001 * About to connect() to myserver port 8080 (#0) * Trying 12.34.567.890... connected * Connected to myserver (12.34.567.890) port 8080 (#0) > GET /rest/bean/atg/dynamo/Configuration/httpPort?atg-rest-user-input=MyMessageId001 HTTP/1.1 > User-Agent: curl/7.21.1 (i386-pc-win32) libcurl/7.21.1 zlib/1.2.5 > Host: myserver:8080 > Accept: */* > Cookie: JSESSIONID=AD84270CB05CC0960580D1B875595822 > < HTTP/1.1 200 OK < Server: Apache-Coyote/1.1 < X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1 < X-ATG-Version: version=QVRHUGxhdGZvcm0vMTAuMCxTZXJ2aWNlLzEwLjAsQ0FGLzEwLjAgWyBQbGF0Zm9ybUxpY2Vuc 2UvMCBTZWxmU2VydmljZUxpY2Vuc2UvMCAgXQ== < Content-Type: application/json;charset=UTF-8 < Transfer-Encoding: chunked < Date: Fri, 22 Oct 2010 16:36:07 GMT < { "atg-rest-response": {"httpPort": 8080}, "atg-rest-user-input": "MyMessageId001" }* Connection #0 to host myserver left intact * Closing connection #0
128
curl -v -b cookies.txt -X GET \ http://myserver:8080/rest/repository/atg/userprofiling/ProfileAdapterRepository/ user/130001/ * * * > > > > > > < < < * About to connect() to myserver port 8080 (#0) Trying 12.34.567.890... connected Connected to myserver (12.34.567.890) port 8080 (#0) GET /rest/repository/atg/userprofiling/ProfileAdapterRepository/user/130001/ HTTP/1.1 User-Agent: curl/7.21.1 (i386-pc-win32) libcurl/7.21.1 zlib/1.2.5 Host: myserver:8080 Accept: */* Cookie: DYN_USER_ID=140003; JSESSIONID=9B95CAFAA8B94A05C46488E482A91543; DYN_USER_CONFIRM=1231cf3e7573bf936dbd29dbbbfe150b
HTTP/1.1 200 OK Server: Apache-Coyote/1.1 X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1 Replaced cookie JSESSIONID="A2C79A00F7194A1F113604FD1C4BE7DD" for domain myserver, path /, expire 0 < Set-Cookie: JSESSIONID=A2C79A00F7194A1F113604FD1C4BE7DD; Path=/ < X-ATG-Version: version=QVRHUGxhdGZvcm0vMTAuMCxDb21tZXJjZVJlZmVyZW5jZVN0b3JlLzEwLjAgWyBQbGF0Zm9ybUxpY2 Vuc2UvMCBCMkNMaWNlbnNlLzAgIF0= < Content-Type: application/xml;charset=UTF-8 < Transfer-Encoding: chunked < Date: Fri, 05 Nov 2010 21:50:44 GMT < <?xml version="1.0" encoding="UTF-8"?> <atgResponse> [Additional property values omitted to save space] <creditCards>http://myserver:8080/rest/repository/atg/userprofiling/ ProfileAdapterRepository/user/130001/creditCards</creditCards> [Additional property values omitted to save space]
129
The example below shows a collection value that has been expanded. The REST Web Services request sets the atg-rest-show-rest-paths control parameter to false.
curl -v -b cookies.txt -X GET \ http://myserver:8080/rest/repository/atg/userprofiling/ProfileAdapterRepository/ user/130001/?atg-rest-show-rest-paths=false * About to connect() to myserver port 8080 (#0) * Trying 12.34.567.890... connected * Connected to myserver (12.34.567.890) port 8080 (#0) > GET /rest/repository/atg/userprofiling/ProfileAdapterRepository/user/130001/?atgrest-show-rest-paths=false HTTP/1.1 > User-Agent: curl/7.21.1 (i386-pc-win32) libcurl/7.21.1 zlib/1.2.5 > Host: myserver:8080 > Accept: */* > Cookie: DYN_USER_ID=140003; JSESSIONID=9B95CAFAA8B94A05C46488E482A91543; DYN_USER_CONFIRM=1231cf3e7573bf936dbd29dbbbfe150b > < HTTP/1.1 200 OK < Server: Apache-Coyote/1.1 < X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1 * Replaced cookie JSESSIONID="9D730DE9D4A7C250994F20363ACC3FA6" for domain myserver, path /, expire 0 < Set-Cookie: JSESSIONID=9D730DE9D4A7C250994F20363ACC3FA6; Path=/ < X-ATG-Version: version=QVRHUGxhdGZvcm0vMTAuMCxDb21tZXJjZVJlZmVyZW5jZVN0b3JlLzEwLjAgWyBQbGF0Zm9ybU xpY2Vuc2UvMCBCMkNMaWNlbnNlLzAgIF0= < Content-Type: application/xml;charset=UTF-8 < Transfer-Encoding: chunked < Date: Fri, 05 Nov 2010 22:04:32 GMT < <?xml version="1.0" encoding="UTF-8"?> <atgResponse> [Additional property values omitted to save space] <creditCards> <element> <key>MyOtherCard</key> <value> <atgRestComponentPath>/atg/userprofiling/ProfileAdapterRepository</ atgRestComponentPath> <atgRestItemDescriptor>credit-card</atgRestItemDescriptor> <atgRestRepositoryId>usercc10003</atgRestRepositoryId> </value> </element> <element> <key>MyCard</key> <value> <atgRestComponentPath>/atg/userprofiling/ProfileAdapterRepository</ atgRestComponentPath> <atgRestItemDescriptor>credit-card</atgRestItemDescriptor> <atgRestRepositoryId>usercc10001</atgRestRepositoryId>
130
</value> </element> </creditCards> [Additional property values omitted to save space] </atgResponse> * Connection #0 to host myserver left intact * Closing connection #0
curl -v -b cookies.txt -X GET \ http://myserver:8080/rest/bean/atg/userprofiling/ProfileUserDirectory/roles * * * > > > > > > < < < * * < < About to connect() to myserver port 8080 (#0) Trying 12.34.567.890... connected Connected to myserver (12.34.567.890) port 8080 (#0) GET /rest/bean/atg/userprofiling/ProfileUserDirectory/roles HTTP/1.1 User-Agent: curl/7.21.1 (i386-pc-win32) libcurl/7.21.1 zlib/1.2.5 Host: myserver:8080 Accept: */* Cookie: DYN_USER_ID=140003; JSESSIONID=9B95CAFAA8B94A05C46488E482A91543; DYN_USER_CONFIRM=1231cf3e7573bf936dbd29dbbbfe150b
HTTP/1.1 200 OK Server: Apache-Coyote/1.1 X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1 Replaced cookie JSESSIONID="6F710DD421CDBB1C0A092133210E7A0E" for domain myserver, path /, expire 0 Set-Cookie: JSESSIONID=6F710DD421CDBB1C0A092133210E7A0E; Path=/ X-ATG-Version: version=QVRHUGxhdGZvcm0vMTAuMCxDb21tZXJjZVJlZmVyZW5jZVN0b3JlLzEwLjAgWyBQbGF0Zm9yb UxpY2Vuc2UvMCBCMkNMaWNlbnNlLzAgIF0= < Content-Type: application/xml;charset=UTF-8 < Transfer-Encoding: chunked < Date: Wed, 03 Nov 2010 15:05:19 GMT < <?xml version="1.0" encoding="UTF-8"?> <atgResponse> <roles> <element> -- RepositoryItemGroupRole: --> name: Young --> primary key: Young__grouprole </element> <element> -- RepositoryItemGroupRole: --> name: WomenOnly --> primary key: WomenOnly__grouprole </element> <element> -- RepositoryItemGroupRole: --> name: Fashionista --> primary key: Fashionista__grouprole </element> <element>
131
-- RepositoryItemGroupRole: --> name: MenOnly --> primary key: MenOnly__grouprole </element> <element> -- RepositoryItemGroupRole: --> name: ThirtySomethings --> primary key: ThirtySomethings__grouprole </element> </roles></atgResponse>* Connection #0 to host myserver left intact * Closing connection #0
The following example shows the same property value in JSON format.
{"roles": [ "\n-- RepositoryItemGroupRole:\n--> \n", "\n-- RepositoryItemGroupRole:\n--> WomenOnly__grouprole\n", "\n-- RepositoryItemGroupRole:\n--> Fashionista__grouprole\n", "\n-- RepositoryItemGroupRole:\n--> MenOnly__grouprole\n", "\n-- RepositoryItemGroupRole:\n--> ThirtySomethings__grouprole\n" ]}
name: Young\n--> primary key: Young__grouprole name: WomenOnly\n--> primary key: name: Fashionista\n--> primary key: name: MenOnly\n--> primary key: name: ThirtySomethings\n--> primary key:
132
< <?xml version="1.0" encoding="UTF-8"?> <atgResponse> <creditCards> <element> <key>MyOtherCard</key> <value>http://myserver:8080/rest/repository/atg/userprofiling/ ProfileAdapterRepository/credit-card/usercc10003</value> </element> <element> <key>MyCard</key> <value>http://myserver:8080/rest/repository/atg/userprofiling/ ProfileAdapterRepository/credit-card/usercc10001</value> </element> </creditCards> </atgResponse> * Connection #0 to host myserver left intact * Closing connection #0
The following example shows the same property value in JSON format.
{"creditCards": { "MyCard": "http://myserver:8080/rest/repository/atg/userprofiling/ ProfileAdapterRepository/credit-card/usercc10001", "MyOtherCard": "http:// myserver:8080/rest/repository/atg/userprofiling/ProfileAdapterRepository/credit-card/ usercc10003" }}
133
< Set-Cookie: JSESSIONID=V9TCTXPTkCnXrgJJKb2bhbzHwpvn2yzlDJb4JTXhLlkyw22J7xm7!-249339435; path=/; HttpOnly < X-Powered-By: Servlet/2.5 JSP/2.1 < <?xml version="1.0" encoding="UTF-8"?> <atgResponse> <previousPasswords> <element>17d0b74864b89840e07f08f46dd72f90fed59b62d476639c25667a3b3f74bdf5</element> <element>914eb28cb2996739bdd33ed74deed1005ff1fd40489583d22bd35d5a8344fa6c</element> </previousPasswords> </atgResponse> * Connection #0 to host 12.34.567.890 left intact * Closing connection #0
The following example shows the same property value in JSON format.
{"previousPasswords": [ "17d0b74864b89840e07f08f46dd72f90fed59b62d476639c25667a3b3f74bdf5", "914eb28cb2996739bdd33ed74deed1005ff1fd40489583d22bd35d5a8344fa6c" ]}
Return Depth
You can control the number of nested levels of property information that the REST Web Services server will return when you request property values. Use the atg-rest-depth control parameter to specify the number of levels that will be included in returned data. The number of nested levels you can expand in returned data is limited by the maxDepthAllowed configuration for the REST Web Services server. See maxDepthAllowed (page 173). The default number of levels is zero which returns only the immediate properties of the Nucleus component you specify in your request. If one of those properties includes multiple values or is a complex object, the returned data will include only the REST path of the property value. For example:
<creditCards>http://myserver:8080/rest/repository/atg/userprofiling/ ProfileAdapterRepository/user/130001/creditCards</creditCards>
If you set the return depth to one, the returned data will expand properties that contain multiple values and complex objects. The individual values within them will be included in the returned data. For example:
<creditCards> <element> <key>MyOtherCard</key> <value> <atgRestComponentPath>/atg/userprofiling/ProfileAdapterRepository</ atgRestComponentPath> <atgRestItemDescriptor>credit-card</atgRestItemDescriptor> <atgRestRepositoryId>usercc10003</atgRestRepositoryId> </value> </element> <element>
134
135
curl -v -b cookies.txt -X GET \ http://myserver:8080/rest/bean/atg/dynamo/Configuration/fakeProperty * * * > > > > > > < < < < About to connect() to myserver port 8080 (#0) Trying 12.34.567.890... connected Connected to myserver (12.34.567.890) port 8080 (#0) GET /rest/bean/atg/dynamo/Configuration/fakeProperty HTTP/1.1 User-Agent: curl/7.21.1 (i386-pc-win32) libcurl/7.21.1 zlib/1.2.5 Host: myserver:8080 Accept: */* Cookie: JSESSIONID=67B1EAF58CC556CE7C628CDE6F395FB4
HTTP/1.1 400 Bad Request Server: Apache-Coyote/1.1 X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1 X-ATG-Version: version=QVRHUGxhdGZvcm0vMTAuMCxTZXJ2aWNlLzEwLjAsQ0FGLzEwLjAgWyBQbGF0Zm9ybUxp Y2Vuc2UvMCBTZWxmU2VydmljZUxpY2Vuc2UvMCAgXQ== < Content-Type: text/html;charset=utf-8 < Content-Length: 1585 < Date: Fri, 22 Oct 2010 19:48:53 GMT < Connection: close < <html><head><title>JBoss Web/2.1.3 - Error report</title><style><!--H1 {fontfamily:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;fontsize:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;backgroundcolor:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sansserif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sansserif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sansserif;background:white;color:black;font-size:12px;}A {color: black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 400 atg.beans.PropertyNotFoundException: Can't find property named: fakeProperty in class: atg.service.dynamo.DAFConfiguration Can't find property named: fakeProperty in class: atg.service.dynamo.DAFConfiguration</h1><HR size="1" noshade="noshade"><p><b>type</ b> Status report</p><p><b>message</b> <u>atg.beans.PropertyNotFoundException: Can't find property named: fakeProperty in class: atg.service.dynamo.DAFConfiguration Can't find property named: fakeProperty in class: atg.service.dynamo.DAFConfiguration</ u></p><p><b>description</b> <u>The request sent by the client was syntactically incorrect (atg.beans.PropertyNotFoundException: Can't find property named: fakeProperty in class: atg.service.dynamo.DAFConfiguration Can't find property named: fakeProperty in class: atg.service.dynamo.DAFConfiguration).</u></p><HR size="1" noshade="noshade"><h3>JBoss Web/2.1.3</h3> </body></html>* Closing connection #0
136
HTTP/1.1 500 Internal Server Error Server: Apache-Coyote/1.1 X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1 Added cookie JSESSIONID="24C3CC9056EA3A1B62DD2002DEDFAA7F" for domain myserver, path /, expire 0 < Set-Cookie: JSESSIONID=24C3CC9056EA3A1B62DD2002DEDFAA7F; Path=/ < X-ATG-Version: version=QVRHUGxhdGZvcm0vMTAuMCxDb21tZXJjZVJlZmVyZW5jZVN0b3JlLzEwLjAgWyBQbGF0Zm9ybUxpY2Vuc2U vMCBCMkNMaWNlbnNlLzAgIF0= < Content-Type: text/html;charset=utf-8 < Content-Length: 1776 < Date: Wed, 27 Oct 2010 18:15:29 GMT < Connection: close < <html><head><title>JBoss Web/2.1.3 - Error report</title><style><!--H1 {fontfamily:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;fontsize:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;backgroundcolor:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sansserif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sansserif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sansserif;background:white;color:black;font-size:12px;}A {color: black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 org.dom4j.DocumentException: Error on line 1 of document : Content is not allowed in prolog. Nested exception: Content is not allowed in prolog. Error on line 1 of document : Content is not allowed in prolog. Nested exception: Content is not allowed in prolog.</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</ p><p><b>message</b> <u>org.dom4j.DocumentException: Error on line 1 of document : Content is not allowed in prolog. Nested exception: Content is not allowed in prolog. Error on line 1 of document : Content is not allowed in prolog. Nested exception: Content is not allowed in prolog.</u></p><p><b>description</b> <u>The server encountered an internal error (org.dom4j.DocumentException: Error on line 1 of document : Content is not allowed in prolog. Nested exception: Content is not allowed in prolog. Error on line 1 of document : Content is not allowed in prolog. Nested exception: Content is not allowed in prolog.) that prevented it from fulfilling this
137
138
This section provides instructions for Oracle ATG Web Commerce platform REST Web Services operations involving Nucleus component properties.
Value GET None Include the component pathname in the application path after /rest/ bean/. Include the name of the property at the end of the path. See Nucleus Components (page 105). To get the values of all properties of a component, do not include a property name at the end of the path.
The following example shows a REST Web Services request that returns the value of the atg/dynamo/ Configuration.httpPort property.
curl -v -b cookies.txt -X GET \ http://myserver:8080/rest/bean/atg/dynamo/Configuration/httpPort * * * > > About to connect() to myserver port 8080 (#0) Trying 12.34.567.890... connected Connected to myserver (12.34.567.890) port 8080 (#0) GET /rest/bean/atg/dynamo/Configuration/httpPort HTTP/1.1 User-Agent: curl/7.21.1 (i386-pc-win32) libcurl/7.21.1 zlib/1.2.5
139
HTTP/1.1 200 OK Server: Apache-Coyote/1.1 X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1 X-ATG-Version: version=QVRHUGxhdGZvcm0vMTAuMCxTZXJ2aWNlLzEwLjAsQ0FGLzEwLjAgWyBQbGF0Zm9ybUxp Y2Vuc2UvMCBTZWxmU2VydmljZUxpY2Vuc2UvMCAgXQ== < Content-Type: application/xml;charset=UTF-8 < Transfer-Encoding: chunked < Date: Mon, 25 Oct 2010 21:29:05 GMT < <?xml version="1.0" encoding="UTF-8"?> <atgResponse> <httpPort>8080</httpPort> </atgResponse> * Connection #0 to host myserver left intact * Closing connection #0
The following example shows a REST Web Services request that returns all the properties of a Nucleus component.
curl -v -b cookies.txt -X GET \ http://myserver:8080/rest/bean/atg/dynamo/Configuration
Value POST or PUT Include the new value for the property. Use the positional parameter name arg1 for the value. See Positional Parameters (page 115).
URL
Include the component pathname in the application path after /rest/ bean/. Include the name of the property at the end of the path. See Nucleus Components (page 105).
The following example shows a REST Web Services request that sets the value of the atg/userprofiling/ passwordchecker/PasswordRuleChecker.enabled property.
140
curl -v -b cookies.txt -X POST \ -H "Content-Type: application/xml" \ -d "<parameters><arg1>false</arg1></parameters>" \ http://myserver:8080/rest/bean/atg/userprofiling/passwordchecker/PasswordRuleChecker/ enabled * About to connect() to myserver port 8080 (#0) * Trying 12.34.567.890... connected * Connected to myserver (12.34.567.890) port 8080 (#0) > POST /rest/bean/atg/userprofiling/passwordchecker/PasswordRuleChecker/enabled HTTP/1.1 > User-Agent: curl/7.21.1 (i386-pc-win32) libcurl/7.21.1 zlib/1.2.5 > Host: myserver:8080 > Accept: */* > Cookie: JSESSIONID=7205768051AC55AAFD5020D8931C71A7 > Content-Type: application/xml > Content-Length: 43 > < HTTP/1.1 200 OK < Server: Apache-Coyote/1.1 < X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1 < X-ATG-Version: version=QVRHUGxhdGZvcm0vMTAuMCxTZXJ2aWNlLzEwLjAsQ0FGLzEwLjAgWyBQbGF0Zm9ybUxp Y2Vuc2UvMCBTZWxmU2VydmljZUxpY2Vuc2UvMCAgXQ== < Content-Type: application/xml;charset=UTF-8 < Transfer-Encoding: chunked < Date: Tue, 26 Oct 2010 14:58:28 GMT < <?xml version="1.0" encoding="UTF-8"?> <atgResponse>true</atgResponse> * Connection #0 to host myserver left intact * Closing connection #0
141
142
To invoke a Nucleus component method, send a REST Web Services request as described in the following table.
Value POST Include any arguments to the method as positional parameters. The name of the parameter for the first argument is arg1. The name of the parameter for the second argument is arg2. Continue this naming pattern for any further arguments. See Positional Parameters (page 115). Include the component pathname in the application path after /rest/ bean/. Include the name of the method at the end of the path. See Nucleus Components (page 105).
URL
The following example shows a REST Web Services request that invokes the /atg/commerce/order/ OrderManager.getOrderCountForProfile method. The method takes a user identifier as its argument and it returns an integer value.
curl -v -b cookies.txt -X POST \ -H "Content-Type: application/xml" \ -d "<parameters><arg1>130001</arg1></parameters>" \ http://myserver:8080/rest/bean/atg/commerce/order/OrderManager/getOrderCountForProfile * * * > > > > > About to connect() to myserver port 8080 (#0) Trying 12.34.567.890... connected Connected to myserver (12.34.567.890) port 8080 (#0) POST /rest/bean/atg/commerce/order/OrderManager/getOrderCountForProfile HTTP/1.1 User-Agent: curl/7.21.1 (i386-pc-win32) libcurl/7.21.1 zlib/1.2.5 Host: myserver:8080 Accept: */* Cookie: DYN_USER_ID=120001; JSESSIONID=7C4C04BFDA404FA7D9443A820F32BE0D; DYN_USER_CONFIRM=bca3eb6c2cdeb0e4a625c7165a088e2e > Content-Type: application/xml > Content-Length: 44 > < HTTP/1.1 200 OK < Server: Apache-Coyote/1.1 < X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1
143
< X-ATG-Version: version=QVRHUGxhdGZvcm0vMTAuMCxDb21tZXJjZVJlZmVyZW5jZVN0b3JlLzEwLjAgWyBQbGF0Zm9ybUxpY2Vuc2Uv MCBCMkNMaWNlbnNlLzAgIF0= < Content-Type: application/xml;charset=UTF-8 < Transfer-Encoding: chunked < Date: Wed, 27 Oct 2010 17:17:33 GMT < <?xml version="1.0" encoding="UTF-8"?> <atgResponse>2</atgResponse> * Connection #0 to host myserver left intact * Closing connection #0
144
To invoke a Nucleus form handler, send a REST Web Services request as described in the following table.
Value POST Submit the required property values of the form as functional parameters. Name each parameter with the property name it corresponds to. See Submitting Form Values (page 146). Include the component pathname in the application path after /rest/bean/. Include the name of the form handler operation at the end of the path. See Nucleus Components (page 105).
URL
The following example shows a REST Web Services request that invokes the create operation of /atg/store/ profile/RegistrationFormHandler. The HTTP request includes functional parameters to supply the value property of the form handler. The data type of the value property is java.util.Dictionary; parameter names such as value.password correspond to the password key in the dictionary value.
curl -v -b cookies.txt -X POST \ -H "Content-Type: application/json" \ -d "{ "value.email":"sheroux@example.com", "value.password":"mypassword", "value.confirmPassword":"mypassword", "value.firstName":"Severe", "value.lastName":"Heroux" }" \ http://myserver:8080/rest/bean/atg/store/profile/RegistrationFormHandler/create * * * > > > > > About to connect() to myserver port 8080 (#0) Trying 12.34.567.890... connected Connected to myserver (12.34.567.890) port 8080 (#0) POST /rest/bean/atg/store/profile/RegistrationFormHandler/create HTTP/1.1 User-Agent: curl/7.21.1 (i386-pc-win32) libcurl/7.21.1 zlib/1.2.5 Host: myserver:8080 Accept: */* Cookie: DYN_USER_ID=140003; JSESSIONID=1DEDBDEE3BF322FA71AFE89438DCCF9E; DYN_USER_CONFIRM=1231cf3e7573bf936dbd29dbbbfe150b > Content-Type: application/json > Content-Length: 147 > < HTTP/1.1 200 OK < Server: Apache-Coyote/1.1
145
< X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1 < X-ATG-Version: version=QVRHUGxhdGZvcm0vMTAuMCxDb21tZXJjZVJlZmVyZW5jZVN0b3JlLzEwLjAgWyBQbGF0Zm9ybUxpY2 Vuc2UvMCBCMkNMaWNlbnNlLzAgIF0= * Replaced cookie DYN_USER_ID="140003" for domain myserver, path /, expire 1291317542 < Set-Cookie: DYN_USER_ID=140003; Expires=Thu, 02-Dec-2010 19:19:02 GMT; Path=/ * Replaced cookie DYN_USER_CONFIRM="1231cf3e7573bf936dbd29dbbbfe150b" for domain myserver, path /, expire 1291317542 < Set-Cookie: DYN_USER_CONFIRM=1231cf3e7573bf936dbd29dbbbfe150b; Expires=Thu, 02Dec-2010 19:19:02 GMT; Path=/ < Content-Type: application/xml;charset=UTF-8 < Transfer-Encoding: chunked < Date: Tue, 02 Nov 2010 19:19:02 GMT < <?xml version="1.0" encoding="UTF-8"?> <atgResponse>true</atgResponse> * Connection #0 to host myserver left intact * Closing connection #0
146
The following example shows the response to a REST Web Services request to invoke /atg/userprofiling/ InternalProfileFormHandler/login. The response includes an exceptions element that contains information about the exception that occurred.
<atgResponse> <class>class atg.rest.processor.BeanProcessor$FormHandlerExceptions</class> <exceptions> <formExceptions> <element>Missing value for the login property</element> </formExceptions> </exceptions> <result>true</result> </atgResponse>
The following example shows the response to a successful REST Web Services request to invoke /atg/ userprofiling/InternalProfileFormHandler/login. The response includes an empty exceptions element because no exceptions occurred.
<atgResponse> <class>class atg.rest.processor.BeanProcessor$FormHandlerExceptions</class> <exceptions/> <result>true</result> </atgResponse>
Note: if you choose to include both exceptions and form handler properties in a REST Web Services request, the class element in the atgResponse will contain the following value: class atg.rest.processor.BeanProcessor$FormHandlerPropertiesAndExceptions. See Returning Form Handler Properties (page 147).
147
Note: if you choose to include both exceptions and form handler properties in a REST Web Services request, the class element in the atgResponse will contain the following value: class atg.rest.processor.BeanProcessor$FormHandlerPropertiesAndExceptions. See Returning Form Handler Exceptions (page 146).
148
This section provides instructions for using the Oracle ATG Web Commerce platform REST Web Services to invoke Java Server Pages (JSPs) in your Web applications. You can create JSPs that access the functionality of a Web application that would otherwise be difficult to use via REST Web Services. JSPs may combine several functions and return a purpose-built set of information to REST Web Services clients. Note: The REST Web Services interface does not secure access to JSPs. If your JSP provides access to sensitive resources, make sure to include security measures such as an access control servlet in your Web application. The REST Web Services use the URL recoding feature of the Oracle ATG Web Commerce platform. This feature links URL application paths (for example, http://domain/an/application/path/) to specific JSPs in a Web application. It can identify input parameters in the URL and pass them to the JSP. See comprehensive information about URL recoding in the ATG Platform Programming Guide. See instructions for configuring JSPs to be accessed by REST Web Services clients in REST Web Services JSP Configuration Procedure (page 150). To invoke a JSP, send a REST Web Services request as described in the following table.
Value GET or POST Do not submit functional parameters when accessing JSPs via the REST Web Services. Pass parameters in the URL that corresponds to the JSP. The format of the parameters that you pass in the URL is configured by the URL recoding feature of the Oracle ATG Web Commerce platform. The developers who design the JSP and the URL recoding template control the parameter format. See URL Templates for REST Web Services JSPs (page 151).
URL
Include the component pathname that corresponds to the JSP in the application path after /rest/service/. Include the parameters at the end of the path in the format expected by the template. The URL that corresponds to a JSP is configured by the URL recoding feature of the Oracle ATG Web Commerce platform. The developers who design the JSP and the URL recoding template control the URL and the parameter format. See URL Templates for REST Web Services JSPs (page 151).
149
The following example shows a REST Web Services request that invokes a JSP. The application path and parameters in the URL are the controlled by the example configurations shown in URL Templates for REST Web Services JSPs (page 151). The code of the JSP itself is shown in Example REST Web Services JSP (page 152).
$ curl -v -b cookies.txt -X GET http://myserver:7003/rest/service/atg/AnyComponent/ xprod2083,foo * About to connect() to myserver port 7003 (#0) * Trying 12.34.567.890... connected * Connected to myserver (12.34.567.890) port 7003 (#0) > GET /rest/service/atg/AnyComponent/xprod2083,foo HTTP/1.1 > User-Agent: curl/7.20.1 (i686-pc-cygwin) libcurl/7.20.1 OpenSSL/0.9.8r zlib/1.2.5 libidn/1.18 libssh2/1.2.5 > Host: myserver:7003 > Accept: */* > Cookie: JSESSIONID=tGD0P6WBTGp62dd5QczJjM0JhpMSvzQvqMbC9jvMNhJ8fS3w33vD!-531422523; DYN_USER_CONFIRM=838bac4608584930c f177410e3b46448; DYN_USER_ID=110001 > < HTTP/1.1 200 OK < Date: Tue, 14 Feb 2012 18:17:34 GMT < Content-Length: 127 < Content-Type: application/json < X-ATG-Version: version=QVRHUGxhdGZvcm0vMTAuMSxDb21tZXJjZVJlZmVyZW5jZVN0b3JlLzEwLjE= < X-Powered-By: Servlet/2.5 JSP/2.1 < {"displayName":"Wine Glass Set","someString":"foo"} * Connection #0 to host myserver left intact * Closing connection #0
150
<ATG10dir>/home/servers/servername/localconfig/atg/rest/processor/templates/ MyTemplate.properties
An example URL template component properties file is shown below. The urlTemplateFormat property defines the application path of the URL that REST Web Services clients will access. It includes a comma separated list of parameters that the client must supply. The URL format must begin with /rest/service. After that, it must contain the Nucleus path of an existing component in your application. It does not matter which component you choose. The indirectRegex property matches parameters that are supplied in the URL application path. The URL recoding feature will pass these parameters to the JSP. The regexElementList property provides information about each parameter. The two parameters shown in this example are a repository item identifier and a simple string. The forwardUrlTemplateFormat property configures the JSP file that the REST Web Services interface will invoke. The application path includes the context root of the Web application (mymodule in the example). It also includes each parameter that was identified in the URL template as URL parameters that will be passed to the JSP.
$class=atg.repository.seo.IndirectUrlTemplate # Url template format urlTemplateFormat=/rest/service/atg/AnyComponent/{item.id},{mystring} # Regex that matches above format indirectRegex=.*/rest/service/atg/AnyComponent/([^/].*?),([^/].*?)$ # Regex elements regexElementList=item | id | /atg/AnyComponent\:product, mystring | string # Forward Url template forwardUrlTemplateFormat=/mymodule/WEB-INF/rest/myRestJsp.jsp?productId \={item.id}&myString\={mystring} # Web App registry webAppRegistry=/atg/registry/WebApplicationRegistry
Note: See comprehensive information about configuring the URL recoding feature of the Oracle ATG Web Commerce platform in the ATG Platform Programming Guide.
151
The example ServiceProcessor.properties file shown below adds a URL template component to the templates property.
templates+=/atg/rest/processor/templates/MyTemplate
152
<dsp:oparam name="output"> <json:object name="product"> <json:property name="displayName"> <dsp:valueof param="element.displayName"/> </json:property> <json:property name="someString"> <dsp:valueof param="aString"/> </json:property> </json:object> </dsp:oparam> </dsp:droplet> </dsp:page>
153
154
This section provides instructions for Oracle ATG Web Commerce platform REST Web Services operations involving repositories. A repository item is a JavaBean component that implements atg.repository.RepositoryItem or one of its sub-interfaces, and corresponds to the smallest uniquely identifiable entity in the underlying data store. Each repository item is composed of named properties that store the items datafor example, id, firstName, and lastName.
Value GET None Include the component pathname of the repository in the application path after /rest/repository/. Include the name of the item type at the end of the path.
The following example shows a REST Web Services request that lists the repository items of the user item type in the atg/userprofiling/ProfileAdapterRepository repository.
curl -v -b cookies.txt -X GET \ http://myserver:8080/rest/repository/atg/userprofiling/ProfileAdapterRepository/user * * * > > > > > About to connect() to myserver port 8080 (#0) Trying 12.34.567.890... connected Connected to myserver (12.34.567.890) port 8080 (#0) GET /rest/repository/atg/userprofiling/ProfileAdapterRepository/user HTTP/1.1 User-Agent: curl/7.21.1 (i386-pc-win32) libcurl/7.21.1 zlib/1.2.5 Host: myserver:8080 Accept: */* Cookie: DYN_USER_ID=140001; JSESSIONID=46E252A84E611BCD06710FD6A0FBA5A4; DYN_USER_CONFIRM=2a952017db56aab256c7e7077bf1feec
155
HTTP/1.1 200 OK Server: Apache-Coyote/1.1 X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1 X-ATG-Version: version=QVRHUGxhdGZvcm0vMTAuMCxDb21tZXJjZVJlZmVyZW5jZVN0b3JlLzEwLjAgWyBQbGF0Zm9ybUxpY2Vuc 2UvMCBCMkNMaWNlbnNlLzAgIF0= < Content-Type: application/xml;charset=UTF-8 < Transfer-Encoding: chunked < Date: Fri, 29 Oct 2010 16:27:49 GMT < <?xml version="1.0" encoding="UTF-8"?> <atgResponse> <user> <element>http://myserver:8080/rest/repository/atg/userprofiling/ ProfileAdapterRepository/user/se-570040</element> <element>http://myserver:8080/rest/repository/atg/userprofiling/ ProfileAdapterRepository/user/120001</element> <element>http://myserver:8080/rest/repository/atg/userprofiling/ ProfileAdapterRepository/user/140001</element> </user> </atgResponse> * Connection #0 to host myserver left intact * Closing connection #0
Value GET None Include the component pathname of the repository in the application path after /rest/repository/. Include the name of the item type and the identifier of the specific item at the end of the path.
The following example shows a REST Web Services request that lists the properties of a specific repository item of the user item type in the /atg/userprofiling/ProfileAdapterRepository repository.
curl -v -b cookies.txt -X GET \ http://myserver:8080/rest/repository/atg/userprofiling/ProfileAdapterRepository/ user/130001/ * About to connect() to myserver port 8080 (#0)
156
* * > > > > > > < < < <
Trying 12.34.567.890... connected Connected to myserver (12.34.567.890) port 8080 (#0) GET /rest/repository/atg/userprofiling/ProfileAdapterRepository/user/130001/ HTTP/1.1 User-Agent: curl/7.21.1 (i386-pc-win32) libcurl/7.21.1 zlib/1.2.5 Host: myserver:8080 Accept: */* Cookie: DYN_USER_ID=140001; JSESSIONID=46E252A84E611BCD06710FD6A0FBA5A4; DYN_USER_CONFIRM=2a952017db56aab256c7e7077bf1feec
HTTP/1.1 200 OK Server: Apache-Coyote/1.1 X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1 X-ATG-Version: version=QVRHUGxhdGZvcm0vMTAuMCxDb21tZXJjZVJlZmVyZW5jZVN0b3JlLzEwLjAgWyBQbGF0Zm9ybUxpY2Vuc 2UvMCBCMkNMaWNlbnNlLzAgIF0= < Content-Type: application/xml;charset=UTF-8 < Transfer-Encoding: chunked < Date: Fri, 29 Oct 2010 16:40:51 GMT < <?xml version="1.0" encoding="UTF-8"?> <atgResponse> <repositoryId>130001</repositoryId> <securityStatus>4</securityStatus> [Additional property values omitted to save space] <ThirtySomethings>false</ThirtySomethings> <MenOnly>false</MenOnly> <Fashionista>false</Fashionista> <Young>false</Young> <WomenOnly>false</WomenOnly> </atgResponse> * Connection #0 to host myserver left intact * Closing connection #0
Value GET None Include the component pathname of the repository in the application path after /rest/repository/. Include the name of the item type, the identifier of the specific item, and the name of the property at the end of the path.
157
The following example shows a REST Web Services request that returns the lastPurchaseDate property of a specific repository item of the user item type in the atg/userprofiling/ProfileAdapterRepository repository.
curl -v -b cookies.txt -X GET \ http://myserver:8080/rest/repository/atg/userprofiling/ProfileAdapterRepository/ user/130001/lastPurchaseDate * About to connect() to myserver port 8080 (#0) * Trying 12.34.567.890... connected * Connected to myserver (12.34.567.890) port 8080 (#0) > GET /rest/repository/atg/userprofiling/ProfileAdapterRepository/user/130001/ lastPurchaseDate HTTP/1.1 > User-Agent: curl/7.21.1 (i386-pc-win32) libcurl/7.21.1 zlib/1.2.5 > Host: myserver:8080 > Accept: */* > Cookie: DYN_USER_ID=140001; JSESSIONID=46E252A84E611BCD06710FD6A0FBA5A4; DYN_USER_CONFIRM=2a952017db56aab256c7e7077bf1feec > < HTTP/1.1 200 OK < Server: Apache-Coyote/1.1 < X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1 * Replaced cookie JSESSIONID="A8D99275B90B200E0913A8831E77A9F4" for domain myserver, path /, expire 0 < Set-Cookie: JSESSIONID=A8D99275B90B200E0913A8831E77A9F4; Path=/ < X-ATG-Version: version=QVRHUGxhdGZvcm0vMTAuMCxDb21tZXJjZVJlZmVyZW5jZVN0b3JlLzEwLjAgWyBQbGF0Zm9ybUxpY2Vuc 2UvMCBCMkNMaWNlbnNlLzAgIF0= < Content-Type: application/xml;charset=UTF-8 < Transfer-Encoding: chunked < Date: Fri, 29 Oct 2010 19:42:35 GMT < <?xml version="1.0" encoding="UTF-8"?> <atgResponse> <lastPurchaseDate>2010-10-27</lastPurchaseDate> </atgResponse> * Connection #0 to host myserver left intact * Closing connection #0
Value GET
158
Value Include the atg-rest-rql functional parameter. Set its value to the RQL query you want to execute. If you include this parameter as a URL query string, make sure that you URL encode the RQL query. For example, the query ALL RANGE +4 should be encoded as ALL+RANGE+%2B4.
URL
Include the component pathname of the repository item type that you want to query in the application path after /rest/repository/.
The following example shows a REST Web Services request that performs an RQL query. It returns the first four items of item type product in the /atg/commerce/catalog/ProductCatalog repository.
curl -v -b cookies.txt -X GET \ http://myserver:8080/rest/repository/atg/commerce/catalog/ProductCatalog/product?atgrest-rql=ALL+RANGE+%2B4 * About to connect() to myserver port 8080 (#0) * Trying 12.34.567.890... connected * Connected to myserver (12.34.567.890) port 8080 (#0) > GET /rest/repository/atg/commerce/catalog/ProductCatalog/product?atg-rest-rql=ALL +RANGE+%2B4 HTTP/1.1 > User-Agent: curl/7.21.1 (i386-pc-win32) libcurl/7.21.1 zlib/1.2.5 > Host: myserver:8080 > Accept: */* > Cookie: DYN_USER_ID=140003; JSESSIONID=0D62D5F5145D6A1E7A2EDBC669F3BA0F; DYN_USER_CONFIRM=1231cf3e7573bf936dbd29dbbbfe150b > < HTTP/1.1 200 OK < Server: Apache-Coyote/1.1 < X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1 < X-ATG-Version: version=QVRHUGxhdGZvcm0vMTAuMCxDb21tZXJjZVJlZmVyZW5jZVN0b3JlLzEwLjAgWyBQbGF0Zm9ybU xpY2Vuc2UvMCBCMkNMaWNlbnNlLzAgIF0= < Content-Type: application/xml;charset=UTF-8 < Transfer-Encoding: chunked < Date: Fri, 29 Oct 2010 21:33:00 GMT < <?xml version="1.0" encoding="UTF-8"?> <atgResponse> <product> <element>http://myserver:8080/rest/repository/atg/commerce/catalog/ProductCatalog/ product/xprod2022</element> <element>http://myserver:8080/rest/repository/atg/commerce/catalog/ProductCatalog/ product/xprod1064</element> <element>http://myserver:8080/rest/repository/atg/commerce/catalog/ProductCatalog/ product/xprod2024</element> <element>http://myserver:8080/rest/repository/atg/commerce/catalog/ProductCatalog/ product/xprod1066</element> </product> </atgResponse> * Connection #0 to host myserver left intact
159
* Closing connection #0
Note: You can include the atg-rest-rql functional parameter in the message body of a POST HTTP request if you prefer not to URL encode your RQL queries. Use the atg-rest-view control parameter to instruct the REST Web Services server to handle your POST request as a GET request. See Handling POST Requests as Other Methods (page 108). Note: Do not include parameters in the RQL queries that you perform via the REST Web Services. Make sure that all constants are explicitly included in the RQL statements. See information about parameters in RQL queries in the ATG Repository Guide.
Value POST Include all required property values for the new repository item as functional parameters with the REST Web Services request. Include the component pathname of the repository in the application path after /rest/repository/. Include the name of the item type at the end of the path.
URL
The following example shows a REST Web Services request that creates a new repository item in the /atg/ userprofiling/ProfileAdapterRepository repository. The returned data includes all the property values for the new item.
curl -v -b cookies.txt -X POST -H "Content-Type: application/xml" \ -d "<parameters><login>rbriere</login><lastName>Briere</lastName><firstName>Roland</ firstName><email>rbriere@example.com</email><password>mypassword</password></ parameters>" \ http://myserver:8080/rest/repository/atg/userprofiling/ProfileAdapterRepository/user * * * > > > > > About to connect() to myserver port 8080 (#0) Trying 12.34.567.890... connected Connected to myserver (12.34.567.890) port 8080 (#0) POST /rest/repository/atg/userprofiling/ProfileAdapterRepository/user HTTP/1.1 User-Agent: curl/7.21.1 (i386-pc-win32) libcurl/7.21.1 zlib/1.2.5 Host: myserver:8080 Accept: */* Cookie: DYN_USER_ID=140003; JSESSIONID=F9C672B8E52D2033A1B70C4EE225577F; DYN_USER_CONFIRM=1231cf3e7573bf936dbd29dbbbfe150b > Content-Type: application/xml > Content-Length: 168 >
160
HTTP/1.1 201 Created Server: Apache-Coyote/1.1 X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1 X-ATG-Version: version=QVRHUGxhdGZvcm0vMTAuMCxDb21tZXJjZVJlZmVyZW5jZVN0b3JlLzEwLjAgWyBQbGF0Zm9 ybUxpY2Vuc2UvMCBCMkNMaWNlbnNlLzAgIF0= < Content-Type: application/xml;charset=UTF-8 < Transfer-Encoding: chunked < Date: Mon, 01 Nov 2010 17:35:29 GMT < <?xml version="1.0" encoding="UTF-8"?> <atgResponse> <repositoryId>130030</repositoryId> <securityStatus>4</securityStatus> [Additional property values omitted to save space] <lastPurchaseDate/> <lastName>Briere</lastName> <gender>unknown</gender> <salePriceList/> <categoryLastBrowsed/> [Additional property values omitted to save space] <registrationDate>2010-11-01 13:35:28.742</registrationDate> <dateOfBirth/> <member>false</member> <firstName>Roland</firstName> <billingAddress/> [Additional property values omitted to save space] <Young>false</Young> <WomenOnly>false</WomenOnly> </atgResponse> * Connection #0 to host myserver left intact * Closing connection #0
Transient Items
Use the atg-rest-transient control parameter to create transient repository items. Set the value of the parameter to true. The following command creates a transient repository item.
curl -v -b cookies.txt -X POST -H "Content-Type: application/xml" \ -d "<parameters><login>agold</login><lastName>Gold</lastName> <firstName>Abbey</firstName><email>agold@example.com</email> <password>mypassword</password></parameters>" \ http://myserver:8080/rest/repository/atg/userprofiling/ProfileAdapterRepository/user? atg-rest-transient=true
161
Value PUT Include the new values for each property you are updating as functional parameters with the REST Web Services request. Include the component pathname of the repository in the application path after /rest/repository/. Include the name of the item type and the item identifier at the end of the path.
URL
The following example shows a REST Web Services request that updates two properties of an existing repository item in the /atg/userprofiling/ProfileAdapterRepository repository.
curl -v -b cookies.txt -X PUT \ -H "Content-Type: application/xml" \ -d "<parameters><middleName>Desire</middleName><email>agoldie@example.com</email></ parameters>" \ http://myserver:8080/rest/repository/atg/userprofiling/ProfileAdapterRepository/ user/130034 * * * > > > > > About to connect() to myserver port 8080 (#0) Trying 12.34.567.890... connected Connected to myserver (12.34.567.890) port 8080 (#0) PUT /rest/repository/atg/userprofiling/ProfileAdapterRepository/user/130034 HTTP/1.1 User-Agent: curl/7.21.1 (i386-pc-win32) libcurl/7.21.1 zlib/1.2.5 Host: myserver:8080 Accept: */* Cookie: DYN_USER_ID=140003; JSESSIONID=B6D3509A03881D9CE1A1370434AD18CB; DYN_USER_CONFIRM=1231cf3e7573bf936dbd29dbbbfe150b > Content-Type: application/xml > Content-Length: 90 > < HTTP/1.1 200 OK < Server: Apache-Coyote/1.1 < X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1 * Replaced cookie JSESSIONID="6A9888BA9F4035AF606AE7E40A435451" for domain myserver, path /, expire 0 < Set-Cookie: JSESSIONID=6A9888BA9F4035AF606AE7E40A435451; Path=/ < X-ATG-Version: version=QVRHUGxhdGZvcm0vMTAuMCxDb21tZXJjZVJlZmVyZW5jZVN0b3JlLzEwLjAgWyBQbGF0Zm 9ybUxpY2Vuc2UvMCBCMkNMaWNlbnNlLzAgIF0= < Content-Type: application/xml;charset=UTF-8 < Transfer-Encoding: chunked < Date: Mon, 01 Nov 2010 19:40:41 GMT < <?xml version="1.0" encoding="UTF-8"?> <atgResponse>true</atgResponse>
162
Value DELETE Include the new values for each property you are updating as functional parameters with the REST Web Services request. Include the component pathname of the repository in the application path after /rest/repository/. Include the name of the item type and the item identifier at the end of the path.
URL
The following example shows a REST Web Services request that deletes an existing repository item in the /atg/ userprofiling/ProfileAdapterRepository repository.
curl -v -b cookies.txt -X DELETE \ http://myserver:8080/rest/repository/atg/userprofiling/ProfileAdapterRepository/ user/130037 * About to connect() to myserver port 8080 (#0) * Trying 12.34.567.890... connected * Connected to myserver (12.34.567.890) port 8080 (#0) > DELETE /rest/repository/atg/userprofiling/ProfileAdapterRepository/user/130037 HTTP/1.1 > User-Agent: curl/7.21.1 (i386-pc-win32) libcurl/7.21.1 zlib/1.2.5 > Host: myserver:8080 > Accept: */* > Cookie: DYN_USER_ID=140003; JSESSIONID=E8FF855FEF5C59ECF6FA9D1A69F1C30D; DYN_USER_CONFIRM=1231cf3e7573bf936dbd29dbbbfe150b > < HTTP/1.1 410 Gone < Server: Apache-Coyote/1.1 < X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1 < X-ATG-Version: version=QVRHUGxhdGZvcm0vMTAuMCxDb21tZXJjZVJlZmVyZW5jZVN0b3JlLzEwLjAgWyBQbGF0Zm9 ybUxpY2Vuc2UvMCBCMkNMaWNlbnNlLzAgIF0= < Content-Type: application/xml;charset=UTF-8 < Transfer-Encoding: chunked < Date: Mon, 01 Nov 2010 20:21:19 GMT < <?xml version="1.0" encoding="UTF-8"?>
163
164
16 Property Filtering
The Oracle ATG Web Commerce platform REST Web Services include functionality that filters properties from output. Use this functionality to: Mark a property in a Nucleus component or repository item as hidden or not writable. Configure the system to override the default functionality of outputting all items and instead output only the items defined in the filtering configuration file. Add your own custom properties for components or repository items and specify the sources of their values. An extension of the property filtering feature, called property aliasing, allows you to create virtual components with properties that assemble values from a variety of sources.
Default Filtering
The filtering configuration file is located at /atg/rest/filtering/filteringConfiguration.xml in your Oracle ATG Web Commerce platform servers configuration path. To customize it, create that file in your own module and the servers XML combination functionality will combine all the filteringConfiguration.xml files. Include component elements in the file to configure the filtering applied to requests for Nucleus components and repositories. Set the name attribute of the component element to a Nucleus component path, a repository path, or a fully qualified Java class or interface name. If you enter a Java class or interface name, the filtering behavior will apply to objects that are subclasses or implementations of it. Filters for Nucleus component paths override filters for Java classes and implementations. Only one filter can apply to a request for an object. The following sample makes one property hidden and another writable in a Nucleus component and a repository item: property1 and repProperty1 are both hidden and will not be returned in the output whenever the Nucleus component or that specific property is requested. property2 and repProperty2 cannot be changed by a REST request. (Note that the writable flag affects only REST requests.)
<rest-filtering> <component name="/some/Component" default-include="true"> <property name="property1" hidden="true"/> <property name="property2" writable="false"/> </component>
16 Property Filtering
165
<component name="/some/Repository" default-include="true"> <item-descriptor name="anItemDescriptorName"> <property name="repProperty1" hidden="true"/> <property name="repProperty2" writable="false"/> </item-descriptor> </component> </rest-filtering>
The default-include attribute tells the server that it should return only the values specified inside this component tag and ignore all other properties of the Nucleus component or repository item. The following sample adds additional properties which do not exist in the Nucleus component or repository item. The sample also configures where the values for these virtual properties come from. The property called virtual1 does not exist in the /some/Component bean. Its value, specified by the target attribute, is the value of property2 in the same object. Similarly, the repVirtual1 property returns the value of repProperty2 as its value. The target attribute also allows for subproperties to be specified, as the sample demonstrates for the virtual2 and repVirtual2 properties. Note that the dot notation can be more than one level deep.
<rest-filtering> <component name="/some/Component" default-include="true"> <property name="property1" hidden="true"/> <property name="property2" writable="false"/> <property name="virtual1" target="property2"/> <property name="virtual2" target="property2.subproperty"/> </component> <component name="/some/Repository" default-include="true"> <item-descriptor name="anItemDescriptorName"> <property name="repProperty1" hidden="true"/> <property name="repProperty2" writable="false"/> <property name="repVirtual1" target="repProperty2"/> <property name="repVirtual2" target="repProperty2.subproperty"/> </item-descriptor> </component> </rest-filtering>
The next sample extends the previous one by adding a component attribute to the property tag and using that in combination with the target tag. This demonstrates how the value of a property can come from another Nucleus component. (Note that the component attribute can only reference a Nucleus component.) Dot notation can be used in the target attribute when the component attribute is used.
<rest-filtering> <component name="/some/Component" default-include="true"> <property name="property1" hidden="true"/> <property name="property2" writable="false"/> <property name="virtual1" target="property2"/> <property name="virtual2" target="property2.subproperty"/> <property name="virtual3" component="/some/other/Component" target="aProperty"/> </component> <component name="/some/Repository" default-include="true">
166
16 Property Filtering
<item-descriptor name="anItemDescriptorName"> <property name="repProperty1" hidden="true"/> <property name="repProperty2" writable="false"/> <property name="repVirtual1" target="repProperty2"/> <property name="repVirtual2" target="repProperty2.subproperty"/> <property name="repVirtual3" component="/some/other/Component" target="aProperty"/> </item-descriptor> </component> </rest-filtering>
Finally, if you need to write custom code to specify your value, then you must use the property-customizer attribute, as shown in the following sample.
<rest-filtering> <component name="/some/Component" default-include="true"> <property name="property1" hidden="true"/> <property name="property2" writable="false"/> <property name="virtual1" target="property2"/> <property name="virtual2" target="property2.subproperty"/> <property name="virtual3" component="/some/other/Component" target="aProperty"/> <property name="virtual4" property-customizer="some.class.Here"/> </component> <component name="/some/Repository" default-include="true"> <item-descriptor name="anItemDescriptorName"> <property name="repProperty1" hidden="true"/> <property name="repProperty2" writable="false"/> <property name="repVirtual1" target="repProperty2"/> <property name="repVirtual2" target="repProperty2.subproperty"/> <property name="repVirtual3" component="/some/other/Component" target="aProperty"/> <property name="repVirtual4" property-customizer="some.class.Here"/> </item-descriptor> </component> </rest-filtering>
When using the property-customizer attribute, the value should be the name of a class which implements the atg.rest.filtering.RestPropertyCustomizer interface, shown below.
public Object getPropertyValue(String pPropertyName, Object pResource); public void setPropertyValue(String pPropertyName, Object pValue, Object pResource);
You can also set the property-customizer attribute to a Nucleus component path. The component must be an instance of a class that implements the atg.rest.filtering.RestPropertyCustomizer interface.
16 Property Filtering
167
default-include="false"> <item-descriptor name="user" depth="1"> <property name="wishlist" hidden="false"/> <property name="creditCards" hidden="false"/> </item-descriptor> </component>
To set the filter depth for a non-repository component, add the depth attribute to the component element. For example:
Filtering Templates
You can configure property filtering templates that will be applied when REST requests invoke them. Configure filtering templates for specific Nucleus components, repositories, or Java classes in the /atg/rest/filtering/ filteringConfiguration.xml file, just as you would for default filtering. See Default Filtering (page 165). Include a template element in the rest-filtering element for each template you want to configure. Add an id attribute to the template element. REST clients will refer to this id value when invoking the template. Configure the filtering behavior of the template using the same elements and syntax that you would in a component element for default filtering. See Default Filtering (page 165). The following filteringConfiguration.xml file defines a filtering template.
<rest-filtering> <template id="myfiltertemplate" name="/atg/MyDog" default-include="true"> <property name="tricks" hidden="true" /> </template> </rest-filtering>
Invoke filtering templates with the atg-rest-property-filter-templates control parameter. Include the id of a template or a JSON array of ids as the value of this parameter. The following REST request invokes the filtering template configured in the example above.
168
16 Property Filtering
http://myserver:7003/rest/bean/atg/MyDog?atg-rest-property-filtertemplates=["userFilter","wishlistFilter"]
For example, the following atg-rest-property-filters control parameter value specifies that only the wishlist property will be returned for user repository items. It also specifies that only the eventType and published values will be returned for the wishlist property.
{ "/atg/userprofiling/ProfileAdapterRepository": [ { "item-descriptor": "user", "depth": 0, "properties": { "wishlist": {
16 Property Filtering
169
The REST Web Service server will check several configuration parameters before accepting filters supplied with the atg-rest-property-filters control parameter. These configuration properties control whether certain types of per-request filtering will be accepted. There are individual configuration properties for requests that will return JSON and XML output. See information about the following properties in /atg/rest/output/ JSONOutputCustomizer (page 174) and /atg/rest/output/XMLOutputCustomizer (page 176). enablePerRequestFilters enablePerRequestComponentFilters enablePerRequestRepositoryFilters enablePerRequestClassFilters
Property Aliasing
Property aliasing allows you to create virtual components with properties that assemble values from a variety of sources. Use virtual components to gather data from a variety of sources and return it in a single REST Web Services request. To create a virtual component with property aliasing: 1. Add a component element to the /atg/rest/filtering/filteringConfiguration.xml configuration file for your Oracle ATG Web Commerce platform server. Specify the Nucleus path for the virtual component in the name attribute of that element. 2. Include one or more property elements in the component element. Either draw the value of the component from another component property using the component and target attributes or from a custom class using the property-customizer attribute. The following example configuration creates a virtual component. It specifies the name of a component that does not exist in the name attribute of the component tag, thus creating a virtual component. When creating virtual components in this way, do not use the item-descriptor element.
170
16 Property Filtering
When a REST client requests this component, the list of properties that are specified inside the component element will be rendered.
<rest-filtering> <component name="/some/nonexisting/Component"> <property name="property1" component="/some/other/Component" target="aProperty"/> <property name="property2" property-customizer="some.class.Here"/> </component> <rest-filtering>
The following example output shows a timestamp value that has been expanded.
"creationDate": { "class": "class java.sql.Timestamp", "date": 21, "day": 2, "hours": 16, "minutes": 52, "month": 9, "nanos": 0, "seconds": 0, "time": 1224622320000, "timezoneOffset": 240, "year": 108 },
See instructions for suppressing property expansion in the following sections: Suppressing Property Expansion for Java Classes (page 171) Suppressing Property Expansion for Specific Properties (page 172)
16 Property Filtering
171
1. Add the fully qualified Java class name of each Java class that you want to suppress property expansion for. Separate class names with commas.
nonExpandableClassesList=java.util.Date,java.sql.TimeStamp
Filtering Priority
You can apply property filtering for REST requests at three levels: default filtering, filtering templates, and perrequest filtering. The REST Web Services server gives priority to filters according to these levels in the following order. 1. Per-request filtering 2. Filtering templates 3. Default filtering For example, if default filtering specifies that a property should be hidden and a per-request filter specifies that it is not hidden, the per-request filtering has priority. The property value will be returned in the results.
172
16 Property Filtering
Configure the Oracle ATG Web Commerce platform REST Web Services by setting the parameters described in the following sections.
/atg/rest/Configuration
This section explains configuration properties that are set on the /atg/rest/Configuration component.
defaultOutputCustomizer
This configuration property controls the markup that the REST Web Services server uses for returned data. See Choosing Output Markup (page 126). The following example specifies that the server should use XML format for the data it returns.
defaultOutputCustomizer=/atg/rest/output/XMLOutputCustomizer
maxDepthAllowed
This configuration property controls the maximum number of nested property levels that you can expand in returned data. See Expanding Multiple Values and Complex Objects (page 129). The following example specifies that only three nested levels may be expanded.
maxDepthAllowed=3
/atg/rest/processor/BeanProcessor
This section explains configuration properties that are set on the /atg/rest/processor/BeanProcessor component.
173
returnFormHandlerExceptionsByDefault
This configuration property controls whether the REST Web Services server will return information about the exceptions it encounters while invoking form handlers. See Returning Form Handler Exceptions (page 146). The following example specifies that exceptions should be included in the HTTP response to a Web Services request.
returnFormHandlerExceptionsByDefault=true
returnFormHandlerPropertiesByDefault
This configuration property controls whether the REST Web Services server will return the properties of the form handler components it invokes. See Returning Form Handler Properties (page 147). The following example specifies that the form handler properties should be included in the HTTP response to a Web Services request.
returnFormHandlerPropertiesByDefault=true
/atg/rest/output/JSONOutputCustomizer
This section explains configuration properties that are set on the /atg/rest/output/ JSONOutputCustomizer component.
If this property is set to true, dates will be returned in this format. If the property is set to false, dates will be returned as a string representation of the java.util.Date object. See Date Format in Returned Data (page 135).
174
showRestPaths=false
175
/atg/rest/output/XMLOutputCustomizer
This section provides information about configuration properties that may be set on the /atg/rest/output/ XMLOutputCustomizer component.
MM/dd/yyyy HH:mm:ss z
If this property is set to true, dates will be returned in this format. If the property is set to false, dates will be returned as a string representation of the java.util.Date object. See Date Format in Returned Data (page 135).
176
If this property is set to true, the server will accept the control parameters. If it is set to false the server will ignore them.
showRestPaths=false
/atg/rest/processor/RepositoryProcessor
This section explains configuration properties that are set on the /atg/rest/processor/ RepositoryProcessor component.
acceptJSONInput
This configuration property specifies whether the REST Web Services server will accept standard JSON markup for setting collection or map values on repository item properties. See JSON Markup Input for Multiple Value Repository Item Properties (page 121). The following example specifies that the REST Web Services server will accept JSON markup for setting multiple value repository item properties.
acceptJSONInput=true
177
appendMultiValuesByDefault
This configuration property specifies whether the values you set in repository item properties should be added to an existing set of values or should replace them. This only applies to repository item properties that accept multiple values. See Multiple Values in Input (page 119). The following example specifies that values set in a repository item property that holds multiple values should be added to the existing list. The existing values will remain set.
appendMultiValuesByDefault=true
/atg/rest/processor/RestSecurityProcessor
This section explains configuration properties that are set on the /atg/rest/processor/RestSecurityProcessor component.
allowAccessForUnsecuredRepository
This configuration property specifies whether the REST Web Services server will allow clients to get or set properties in unsecured repositories. Allowing this access is not recommended in a production environment. Configure repository security before allowing REST Web Services clients to interact with repositories. See Repository Security (page 182). The following example specifies that any REST Web Services client may get or set properties in unsecured repositories. Use this setting for testing only.
allowAccessForUnsecuredRepository=true
178
This section provides information about the way the Oracle ATG Web Commerce platform REST Web Services server secures its interface and how it interacts with the underlying security system for the Oracle ATG Web Commerce platform in general.
Security Overview
The Oracle ATG Web Commerce platform REST Web Services server uses the underlying security system of the Oracle ATG Web Commerce platform. HTTP clients that invoke REST Web Services functionality behave in a manner that is similar to human users logging into an Oracle ATG Web Commerce platform user interface and interacting with its functionality. To understand the security system used by the REST Web Services server you must understand the system used by the Oracle ATG Web Commerce platform. See Managing Access Control in the ATG Platform Programming Guide.
179
The REST security configuration file is located at /atg/rest/security/restSecurityConfiguration.xml. To add your own security configuration create a file at that location in the config directory of your module. Note: The Oracle ATG Web Commerce platform REST Web Services module does not provide functionality for securing repository items All Oracle ATG Web Commerce repository security is handled by the Oracle ATG Web Commerce secured repository system, which works in conjunction with the Oracle ATG Web Commerce Security System to provide fine-grained access control to repository item descriptors, individual repository items, and even individual properties. For more information, see the ATG Repository Guide.
Global Security
To configure global security, use the default-acl tag. This tag defines which personas have access to Nucleus components. In the following example, all users who are assigned the restUser role have read and write access to all Nucleus properties and execute access for all methods on Nucleus components. The defaultacl tag is optional. This example assumes that a role called restUser has already been created in the profile repository.
<rest-security> <default-acl value="Profile$role$restUser:read,write,execute"/> </rest-security>
180
Component Security
To configure security on a specific component, use the resource tag. This tag, along with the component attribute, allows you to define which users have access to the specified component. You could disable security entirely for the specified component by using the optional secure attribute. In the following example, the /some/Component component is configured so that only the user whose login is restAdmin has full access to it; users with the restUser role only have read access. In addition, the /some/ other/Component component is configured to disable security. This means that all users have full access to all properties and methods of that component.
<rest-security> <default-acl value="Profile$role$restUser:read,write,execute"/> <resource component="/some/Component"> <default-acl value="Profile$login$restAdmin:read,write,execute;Profile$role$restUser:read"/> </resource> <resource component="/some/other/Component" secure="false"/> </rest-security>
181
Methods which are overloaded and have different security requirements require a signature attribute, available on the method tag. This attribute allows for a Java method signature that uniquely identifies the method.
Repository Security
The Oracle ATG Web Commerce platform REST Web Services module does not provide functionality for securing repository items. If you need to provide access to repository data to REST Web Services clients, use one of the following options: Implement a Java Server Page (JSP) to access and return the repository data to REST clients. See Invoking Java Server Pages (JSPs) (page 149). If your JSP provides access to sensitive resources, make sure to include security measures such as an access control servlet in your Web application. Use the secured repository system, which works in conjunction with the Oracle ATG Web Commerce security system to provide fine-grained access control to repository item descriptors, individual repository items, and even individual properties. For more information, refer to the ATG Repository Guide
182
The Oracle ATG Web Commerce platform REST Web Services package includes two client libraries: Java Client Library (page 183) ActionScript Client Library (page 197) These libraries make Oracle ATG Web Commerce platform REST Web Services easier to use by hiding the complexity of creating connections, assembling payloads for requests, and processing responses.
Accesses the RestResult object that is returned when a request is made to the server. This class also includes convenience methods for retrieving the response data.
RestComponentHelper
Contains a series of static helper methods that simplify issuing Nucleus component calls to the server.
RestRepositoryHelper
Contains a series of static helper methods that simplify issuing repository calls to the server.
Creating Requests
You will find it easiest to make most Oracle ATG Web Commerce platform REST Web Services requests with the RestComponentHelper and RestRepositoryHelper classes. These two classes simplify calling into the server by providing methods which hide the complexity of assembling the data for the request. All the methods for both classes are static and each returns a RestResult object and throws RestClientException. See the Javadoc for more information about each method.
183
atg.rest.client.RestComponentHelper
The methods of the RestComponentHelper class allow access to components, properties, and methods. Each of the methods accepts a Map of parameters, which control the request. For more information and examples, see Accessing Components with the Java Client Library (page 192). public static RestResult getComponent(String pComponentPath, Map<String,Object>
pParams, RestSession pSession)
Returns all the properties of the specified Nucleus component. public static RestResult getPropertyValue(String pComponentPath, String pProperty,
Map<String,Object> pParams, RestSession pSession)
Returns the requested property from the specified Nucleus component. public static RestResult setPropertyValue(String pComponentPath, String pProperty,
Object pValue, Map<String,Object> pParams, RestSession pSession)
Sets a value on the specified Nucleus component property. public static RestResult executeMethod(String pComponentPath, String pMethodName,
Object[] pArguments, Map<String,Object> pParams, RestSession pSession)
Calls a public method on the specified Nucleus component. The Object[] pArguments parameter is an array of method arguments. This parameter should contain one Object for each of the method parameters. For example, if the method takes an int, then a java.lang.Integer object should be passed. The Java client library handles converting the object for transport to the server and the Oracle ATG Web Commerce REST module handles converting it to an int. If any parameter object is passed as a String, the parameter will be transported to the server without any changes. This means that a method that takes an int can have a java.lang.String object with a value of 2, for example, passed. For parameters that are complex objects, the object can be passed as a parameter and the library will attempt to convert it for transport. When the request is sent to the server, a new instance will be constructed and its properties populated with the values from the original object. Collections and Maps can also be transported. For more information, see Calling Methods with the Java Client Library (page 193).
atg.rest.client.RestRepositoryHelper Class
The methods of the RestRepositoryHelper class allow you to access repository items, execute RQL queries, retrieve individual property values, set property values, create items, and remove items. Each of the methods takes a Nucleus repository path and item descriptor name as its first two arguments, as well as a Map of parameters, which control various aspects of the request. For more information and examples, see Accessing Repository Items with the Java Client Library (page 194). public static RestResult createItem(String pRepositoryPath, String
pItemDescriptorName, Map<String,Object> pParams, RestSession pSession)
Returns the ID of the newly created repository item. public static RestResult createItem(String pRepositoryPath, String
pItemDescriptorName, String pItemId, Map<String,Object> pParams, RestSession pSession)
184
Returns true if the repository item was successfully removed; otherwise, returns false. public static RestResult getItem(String pRepositoryPath, String pItemDescriptorName,
String pItemId, Map<String,Object> pParams, RestSession pSession)
Returns the contents of the repository item. If any of the properties are references to other items, Collections, arrays, or Maps, returns a REST URL that you can use to access the contents of the specific property. You can create a raw REST request to access the data for the property. For more information, see Creating a Raw REST Request (page 190). public static RestResult getItems(String pRepositoryPath, String
pItemDescriptorName, Map<String,Object> pParams, RestSession pSession)
Returns a series of URLs, one for each item which is being returned. T to control the number of items returned, the atg-rest-index and atg-rest-count parameters can be passed into the pParams argument. public static RestResult executeRQLQuery(String pRepositoryPath, String
pItemDescriptorName, String pRQL, Map<String,Object> pParams, RestSession pSession)
Returns a series of URLs, one for each item which is being returned. To control the number of items returned, the atg-rest-index and atg-rest-count parameters can be passed into the pParams argument. Note: Do not include parameters in the RQL queries that you perform via the REST Web Services. Make sure that all constants are explicitly included in the RQL statements. See information about parameters in RQL queries in the ATG Repository Guide. public static RestResult getPropertyValue(String pRepositoryPath, String
pItemDescriptorName, String pItemId, String pProperty, Map<String,Object> pParams, RestSession pSession)
Returns the value of the requested property. If the property is a Collection, Map, array, or reference to another repository item, returns a URL. public static RestResult setPropertyValue(String pRepositoryPath, String
pItemDescriptorName, String pItemId, String pProperty, Object pValue, Map<String,Object> pParams, RestSession pSession)
Note: You can perform multiple REST Web Services requests during an HTTP session. See information about HTTP sessions and the REST Web Services server in Logging In (page 108).
185
Property
Hostname
Description The name of the host which the session will or is connected to. Default is localhost. The port number which the session will use. Default is 80. The username the session will use to connect. The password the session will use to connect. The scheme the session will use to connect. Default is HTTP expect for login calls. The web application context root for Oracle ATG Web Commerce platform REST Web Services. Default is /rest.
restContextRoot
useInternalProfileForLogin Tells the session object to login as an internal user instead of a profile user. You will probably need to change this property after the RestSession object is
created and before login is called. When connecting to a server that can be accessed only by internal users, this property must be set to true or the login will fail.
useHttpsForLogin httpsPort userId sessionId Encoding inputFormat
Tells the session object to use the HTTPS scheme for login calls. Default is true. The HTTPS port number which the session will use. Default is 443. The userId of the connected user. This value is set after logging in. The session ID of the current session. This value is set after logging in. The encoding to use when encoding parameter values. Default is UTF The default input format that is set on the server. Changing this value has no effect on the server. The default output format that is set on the server. Changing this value has no effect on the server
outputFormat
186
Invoke the RestSession.startSession() method. This will start the session but does not authenticate the client for access to secured Oracle ATG Web Commerce components. See Starting a Session Without Logging In (page 189).
import java.io.IOException; public class RestClientSample { private String mUsername = null; private String mPassword = null; private String mHost = "localhost"; private int mPort = 80; private RestSession mSession = null; public RestClientSample() {} protected void parseArguments(String[] pArgs) throws Exception { for (int i = 0; i < pArgs.length; i++) { String arg = pArgs[i]; if (arg.equals("-user")) mUsername = pArgs[i+1]; else if (arg.equals("-password")) mPassword = pArgs[i+1]; else if (arg.equals("-host")) mHost = pArgs[i+1]; else if (arg.equals("-port")) mPort = Integer.parseInt(pArgs[i+1]); } if (isBlank(mUsername)) throw new Exception("Must supply username"); if (isBlank(mPassword)) throw new Exception("Must supply password"); } protected boolean isBlank(String pStr) {
187
return (pStr == null || pStr.length() == 0 || pStr.trim().length() == 0); } protected void println(String s) { System.out.println(s); } protected void println(Throwable t) { t.printStackTrace(System.out); } protected void execute() throws RestClientException { mSession = RestSession.createSession(mHost, mPort, mUsername, mPassword); mSession.setUseHttpsForLogin(false); try { String loginStatus = mSession.login(); if(loginStatus == null || "null".equals(loginStatus)) { mSession = null; System.out.println("Login Failed"); } else { System.out.println("Login Successful"); } } catch (Throwable t) { println(t); } finally { try { if(mSession != null) { mSession.logout(); System.out.println("Logout Successful"); } } catch (RestClientException e) { println(e); } } } /** * @param args */ public static void main(String[] args) { RestClientSample sample = new RestClientSample(); try { sample.parseArguments(args); sample.execute(); } catch (Throwable t) { sample.println(t); } } }
188
189
The RestResult object can be used to access the data from the response. The following sample calls readInputStream() to return a String of the response data. In this case, you can assume that the server is using the default output format which is JSON. The string in response data will contain the JSON output. A JSON object is then constructed and output. Another alternative is to simply output responseData, but this sample illustrates how you might use the output. Similarly, if the output format was XML, you could create an XML document object using dom4j. The finally block includes a call to close the result. Doing this will release the underlying connection resources. If this call is omitted, the next call to the server using the same RestSession object will close the result.
protected void execute() throws RestClientException { RestResult result = null; mSession = RestSession.createSession(mHost, mPort, mUsername, mPassword); mSession.setUseHttpsForLogin(false); try { mSession.login(); println("Login Successful"); result = RestComponentHelper.getComponent("/atg/dynamo/Configuration", null, mSession); String responseData = result.readInputStream(); if (responseData != null) { JSONObject json = new JSONObject(responseData); println(json.toString()); } } catch (Throwable t) { println(t); } finally { if (result != null) result.close(); try { mSession.logout(); println("Logout Successful"); } catch (RestClientException e) { println(e); } } }
190
public RestResult createHttpRequest(String pURL, Map<String,Object> pParams, Object[] pArguments, String pMethodType)
The following table describes the arguments for each version of this method.
Argument
pURL
Description The URL to request, formatted as http://hostname:port/uri The pURL argument must be an absolute URL, including the hostname (and port, if it is not 80). The RestSession class includes a convenience method called getHostString() which returns a string containing the scheme, host, and port number. The caller can then append the remainder of the URL and pass the resulting string as the first argument to this method.
pParams
A Map of parameters to submit along with the request. This argument is the same as it would have been if you made the request using either of the helper classes. It contains parameters which can control certain aspects of the request.
pArguments
An array of Objects which contain the method parameter values. Use this argument only for method calls. The value is the same as it would be if calling the executeMethod() method on the RestComponentHelper class.
pMethodType
The HTTP method for the request: GET, POST, PUT, or DELETE. The atg.rest.client.RestConstants class contains constant values for these strings. In short, GET should be used when retrieving data, POST should be used when calling methods, PUT should be used when setting properties, and DELETE is used for deleting repository items. DELETE is not used when interacting with Nucleus components.
Handling Results
createHttpRequest() and all the helper class methods return a RestResult object that allows
access to various parts of the response. The most interesting and useful method on the RestResult is readInputStream(). This is a convenience method which will return the response data into a String
After calling this method the String object which is returned will contain the JSON or XML with the content which was requested. The REST module uses the org.json.jar library and the dom4j XML library internally. You can also use these libraries, or comparable libraries, in your applications.
191
If the response data is large, you can access the input stream directly by calling getInputStream() on the RestResult. Other useful methods on the RestResult object are getResponseCode() and getResponseMessage(). These return the responses response code and message, respectively. For more information, see HTTP Status Codes (page 125). The Java client library uses the java.net.HttpURLConnection class to communicate with servers. To access any functionality that the RestResult does not expose, call the getConnection() method to return the underlying HttpURLConnection object. When you are finished with the RestResult object, it is good practice to call the close() method. This releases any resources that the HttpURLConnection might hold. If the connection is not closed, the next request to the server will close the HttpURLConnection.
Use the RestComponentHelper.setPropertyValue() method to set property values on Nucleus components. The following code sample sets the value of the Configuration component property httpPort to 8580.
192
In order to pass repository items, use a preformatted string that takes the format of
repository Nucleus path:item descriptor name:item id
For example:
/atg/commerce/catalog/ProductCatalog:product:prod12345
When you reference a repository item this way, the server performs a lookup and uses the item as the method argument. For example:
If a method takes a GenericService as an argument, simply passing the Nucleus path as a string will cause the server to lookup the Nucleus component and use it as the method argument. For example:
193
If passing a complex Java object, attempt to add the object to the pArguments argument and call the method. In most cases, the argument will not need to be transformed before it is transported to the server. The client library will make an attempt at converting the object for you.
MyObject myObject = new MyObject(); RestResult result = RestComponentHelper.executeMethod("/some/Component", "aMethod", new Object[] {myObject}, null, session)
As long as a form handler does not submit a redirect, the execution would be similar to a regular method call. For those form handler methods which do redirect, the redirect will be intercepted and returned back to the client as an exception.
Map<String,String> params = new HashMap<String,String>(); params.put("firstName", "Andy"); params.put("lastName", "Jones"); RestResult result = RestComponentHelper.executeMethod("/some/FormHandler", "create", null, params, session);
194
The getItems() method retrieves multiple repository items of the same type in a single call. The following code sample returns an array of URLs:
RestResult result = RestRepositoryHelper.getItems("/atg/commerce/catalog/ ProductCatalog", "product", params, session)
When a getItems() call returns many items, you can control the number of items returned with the atgrest-index and atg-rest-count parameters. The atg-rest-index parameter tells the server which item to return first. The atg-rest-count parameter tells the server how many items past the index item to return. In the following code sample, the first query, with an index of 0 and a count of 10, retrieves 10 items at a time. The next query has an index of 10 and a count of 10, third, index of 20 and count of 10, and so on.
Map<String,String> params = new HashMap<String,String>(); params.put(RestConstants.COUNT, 10); params.put(RestConstants.INDEX, 0); RestResult result = RestRepositoryHelper.getItems("/atg/commerce/catalog/ ProductCatalog", "product", params, session); params.put(RestConstants.INDEX, 10); result = RestRepositoryHelper.getItems("/atg/commerce/catalog/ProductCatalog", "product", params, session); params.put(RestConstants.INDEX, 20); result = RestRepositoryHelper.getItems("/atg/commerce/catalog/ProductCatalog", "product", params, session);
Repository IDs
Each repository item has a unique identifier, called a repository ID. Depending on the repositorys configuration, the repository ID might not be exposed as a property of the repository item. However, when a repository item is returned with a Rest RepositoryHelper method, you can reliably retrieve its repositoryID by getting the value of the repositoryId property.
195
A createItem() call returns a data stream that contains all the properties of the created item. This is the same data stream that is returned when you call RestRepositoryHelper.getItem(). The following code sample adds a repository item and allows the server to generate the repository ID:
RestResult result = RestRepositoryHelper.createItem("/atg/commerce/catalog/ ProductCatalog", "product", params, session);
The following code sample adds a repository item and specifies the value of myProductId-12345 as the repository ID:
RestResult result = RestRepositoryHelper.createItem("/atg/commerce/catalog/ ProductCatalog", "product", "myProductId-12345", params, session);
196
params.put(RestConstants.INDEX, 20); result = RestRepositoryHelper.executeRQLQuery("/atg/commerce/catalog/ProductCatalog", "product", "age >= 30", params, session);
197
Note: The Oracle ATG Web Commerce platform REST Web Services were tested with ActionScript 3. The ActionScript client library is nearly identical in structure to the Java client library. The main difference between the two libraries is the way they handle results: The Java client library uses the RestResult class to handle results. The ActionScript library does not include a RestResult class; instead, it handles results using a callback mechanism. Therefore, helper class methods and the createHttpRequest() method for the ActionScript client library take a result handler and fault/error handler functions as arguments. The following code sample illustrates how the ActionScript client library handles results.
public function getPropertyValue():void { RestComponentHelper.getPropertyValue("/atg/dynamo/Configuration", "httpPort", null, session, handleResult, handleFault); // get the httpPort property from the Configuration component } public function handleResult(pEvent:Event):void { var xml:XML = new XML(pEvent.target.data); // create an XML object populateGridWithXML(xml); // populate the control with the XML output } public function handleFault(pEvent:Event):void { Alert.show("Fault"); // display an error dialog }
atg.rest.client.RestComponentHelper
The RestComponentHelper class simplifies Nucleus requests. The RestComponentHelper methods are written in ActionScript as follows. For details about individual class methods, refer to the Java Client Library (page 183) section.
public static function getComponent(pComponentPath:String, pParams:Array, pSession:RestSession, pResultHandler:Function, pFaultHandler:Function):void public static function getPropertyValue(pComponentPath:String, pProperty:String, pParams:Object, pSession:RestSession, pResultHandler:Function, pFaultHandler:Function):void public static function setPropertyValue(pComponentPath:String, pProperty:String, pValue:Object, pParams:Object, pSession:RestSession, pResultHandler:Function, pFaultHandler:Function):void public static function executeMethod(pComponentPath:String, pMethodName:String, pArguments:Array, pParams:Object, pSession:RestSession, pResultHandler:Function, pFaultHandler:Function):void
198
atg.rest.client.RestRepositoryHelper
The RestRepositoryHelper class simplifies repository requests. The RestRepositoryHelper class methods are written in ActionScript as follows. For details about individual class methods, refer to the Java Client Library (page 183) section.
public static function getItem(pRepositoryPath:String, pItemDescriptorName:String, pItemId:String, pParams:Object, pSession:RestSession, pResultHandler:Function, pFaultHandler:Function):void public static function getItems(pRepositoryPath:String, pItemDescriptorName:String, pParams:Object, pSession:RestSession, pResultHandler:Function, pFaultHandler:Function):void public static function executeRQLQuery(pRepositoryPath:String, pItemDescriptorName:String, pRQL:String, pParams:Object, pSession:RestSession, pResultHandler:Function, pFaultHandler:Function):void public static function getPropertyValue(pRepositoryPath:String, pItemDescriptorName:String, pItemId:String, pProperty:String, pParams:Object, pSession:RestSession, pResultHandler:Function, pFaultHandler:Function):void public static function setPropertyValue(pRepositoryPath:String, pItemDescriptorName:String, pItemId:String, pProperty:String, pValue:Object, pParams:Object, pSession:RestSession, pResultHandler:Function, pFaultHandler:Function):void public static function createItem(pRepositoryPath:String, pItemDescriptorName:String, pParams:Object, pSession:RestSession, pResultHandler:Function, pFaultHandler:Function):void public static function createItemWithId(pRepositoryPath:String, pItemDescriptorName:String, pItemId:String, pParams:Object, pSession:RestSession, pResultHandler:Function, pFaultHandler:Function):void public static function removeItem(pRepositoryPath:String, pItemDescriptorName:String, pItemId:String, pParams:Object, pSession:RestSession, pResultHandler:Function, pFaultHandler:Function):void
199
The following table describes the arguments for each of these methods.
Argument
pMultiValueType
Description The absolute path of a Java class, such as java.util.ArrayList. Be sure to specify a valid class name and not an interface name. The class type of the component to instantiate for each element in the multivalve type. For example, an array of integers in ActionScript could be converted to an ArrayList of java.lang.Integer objects. The servers input format type. This can be retrieved from the session objects inputFormat property. ActionScript objects act as associative arrays (similar to java Maps), the convertObjectToMultivalue() method takes a key type and value type. These arguments are similar to pComponentType and are absolute names of Java classes to use for the key and value objects in the Java Map.
pComponentType
pFormat
pKeyType pValueType
Similar to the Java client library, passing arguments to methods is generally straightforward. For primitive types, just add them to the pArguments array.
var result:RestResult = RestComponentHelper.executeMethod("/some/Component", "aMethod", [1,2,3,4.4,5.5,true,'a',0xa], null, session, handleResult, handleFault)
For example:
var result:RestResultRestComponentHelper.executeMethod("/some/Component", "aMethod", ["/atg/commerce/catalog/ProductCatalog:product:prod12345"], null, session, handleResult, handleFault)
To pass a reference to a Nucleus component, pass the Nucleus component path. For example:
var result:RestResultRestComponentHelper.executeMethod("/some/Component", "aMethod", ["/atg/dynamo/Configuration"], null, session, handleResult, handleFault)
The following example is a call to a method which takes a repository item array and a GenericService array.
<programlisting>
200
var result:RestResultRestComponentHelper.executeMethod("/some/Component", "aMethod", [["/atg/commerce/catalog/ProductCatalog:product:prod12345", "/atg/commerce/catalog/ProductCatalog:product:prod67890"], ["/atg/dynamo/Configuration","/atg/dynamo/Configuration"]], null, session, handleResult, handleFault)
As mentioned above, arrays, ILists, and Objects must be converted before being passed to the server. The following example demonstrate passing an array using the helper methods in the RestClientUtils class.
var arrayCollection:ArrayCollection = new ArrayCollection(["abc","def"]); var result:RestResultRestComponentHelper.executeMethod("/some/Component", "aMethod", [RestClientUtils.convertIListToMultivalue(arrayCollection, "java.util.ArrayList", "java.lang.String", RestConstants.JSON, session)], null, session, handleResult, handleFault);
The following example, which calls executeMethod(), produces the same result as the previous example:
var result:RestResultRestComponentHelper.executeMethod("/some/Component", "aMethod", ["java.util.ArrayList:java.lang.String:[\"abc\",\"def\"]"], null, session, handleResult, handleFault)
The following examples use the helper methods in the RestClientUtils class.
var result:RestResultRestComponentHelper.executeMethod("/some/Component", "aMethod", [RestClientUtils.convertArrayToMultivalue(["abc","def"], "java.util.HashSet", "java.lang.String", RestConstants.JSON, session)], null, session, handleResult, handleFault) var obj:Object = new Object(); obj["abc"] = 123; obj["def"] = 456; var result:RestResultRestComponentHelper.executeMethod("/some/Component", "aMethod", [RestClientUtils.convertObjectToMultivalue(obj, "java.util.HashMap", "java.lang.String", "java.lang.Integer", RestConstants.JSON, session)], null, session, handleResult, handleFault)
201
The following sample uses XML input. Note that you could also take advantage of the ECMAScript for XML functionality once the XML object is created. The following sample does not use that approach, though it is an option.
var xml:XML = new XML(pEvent.target.data); var xmlList:XMLList = pXML.elements(); if (xmlList.length() == 0) xmlList = new XMLList(pXML); var count:int = 0; for each(var item:XML in xmlList) { if (item.name() != "element") array.addItem({name: item.name(), value: item.text()}); else if (item.hasComplexContent()) { var elementList:XMLList = item.child("element"); if (elementList != null && elementList.length() > 0) { var count2:int = 0; for each (var el:XML in elementList) array.addItem({name: count2++, value: el.text()}); } else array.addItem({name: item.key.text(), value: item.value.text()}); } else array.addItem({name: count++, value: item.text()}); }
202
Index
Symbols
.NET clients ATGWS.dll, 60 before calling Web Services, 57 calling Web Services, 55 client stubs, 56 security, 55 session sharing, 44, 56 transactions, 56 Web Service call examples, 59, 59
A
about ATG Web Services, 43, 55 acceptJSONInput, 177 accessing ATG Web Services from .NET clients, 55 accessing ATG Web Services from Java clients, 43 ActionScript client library REST Web Services, 197 add-item tag, 90 addItem operations, 81 AddService, 37 data validation, 37 allowAccessForUnsecuredRepository, 178 appendMultiValuesByDefault, 178 arg1 functional parameter, 115 asynchronous requests, 128 ATG client libraries REST Web Services, 183 ATG Web Services, 3, 15 atg-rest-form-tag-priorities, 148 atg-rest-null, 124 atg-rest-output, 126 atg-rest-property-filters, 169 atg-rest-return-form-handler-exceptions, 146 atg-rest-return-form-handler-properties, 147 atg-rest-show-rest-paths, 129 atg-rest-transient, 161 atg-rest-user-input, 128 atg.adapter.integrations.ChangedPropertyBean, 77 atg.adapter.integrations.IntegrationRepository, 74
atg.adapter.integrations.IntegrationRepositoryItem, 77 atg.adapter.integrations.IntegrationRepositoryItemDescriptor, 76 atg.adapter.integrations.IntegrationRepositoryView , 78 Atg.DotNet.WebService API, 60 Atg.DotNet.WebService.ComplexType, 64 Atg.DotNet.WebService.NoSuchPropertyException, 64 Atg.DotNet.WebService.Property, 63 Atg.DotNet.WebService.RepositoryItem, 62 Atg.DotNet.WebService.RepositoryItemRef, 63 Atg.DotNet.WebService.RepositoryItemSerializationException, 65 atg.integrations.BaseCommand, 97 atg.integrations.BaseCommandHandler, 97 atg.integrations.Command interface, 95 atg.integrations.CommandHandler interface, 96 atg.integrations.CommandResults, 97 atg.integrations.MapRPCDroplet, 98 atg.repository.databinding.MappingRepositoryItem, 77 atg.repository.RepositoryService, 25 atg.repository.xml.AddService, 37 atg.repository.xml.GetService, 35 atg.repository.xml.RemoveService, 40 atg.repository.xml.UpdateService, 38 atg.repository.xml.XMLSchemaManager, 34 ATGWS.dll client stubs for .NET, 56, 60 deserializing RepositoryItems, 56 installing, 57 serializing RepositoryItems, 56 Axis calling Web Services using, 47
C
client stubs for .NET, 56 client stubs for Java clients (see static Web Service calls) command operations addItem, 81 executeQuery, 79 getItem, 80 Integration Repository, 79 removeItem, 81 updateItem, 80 CommandHandlers, 96 CommandResults, 97 commands, 96 executing, 96 executing in pages, 98 invoking, 96 component properties getting, 139 in REST Web Services, 139 setting, 140
Index
203
components REST path for, 105 configuration of the REST Web Services server, 173 Content-Type, 117 control parameters, 112 CookieContainer, 44, 44, 45, 56 .Net client example, 59 Java client example, 49, 50 curl command-line utility, 106 custom Web Services, 5
filtering templates, 168 filteringConfiguration.xml, 165 form handlers form value priority, 148 invoking with the REST Web Services, 145 returning exceptions, 146 returning properties, 147 submitting form values, 146 form values priority, 148 functional parameters, 115 positional, 115
D
data binding repository to XML (see repository to XML data binding) data validation, 37, 38 date format REST, 135 date format in REST input, 124 default-acl, 180 defaultOutputCustomizer, 126, 173 definition files Integration Repository, 72, 87 derived properties updating, 80 derived-properties tag, 90 deserializing content on the client side, 51, 60 dot Net clients (see .NET clients) DTDs Integration Repository, 91 repository to XML mapping files, 28 dynamic Web Service calls, 50 distinction from static calls, 47 limitations, 47 Dynamo Administration UI Web Service creation wizard, 7, 19 Web Service registry, 16 Web Service security manager, 15
G
generateXMLSchema utility, 33 get-item tag, 89 getItem operations, 80 GetService, 35
H
HTTP status codes, 125 HTTP methods for REST Web Services, 107 HTTP requests, 104
I
input values REST Web Services, 118 Installing ATGWS.dll, 57 Integration Data repository, 82 cleaning up, 83 Integration Repository, 69 APIs, 73 architecture, 69 command operations, 79 definition files, 72, 87 DTD, 91 examples, 84 operations, 69 persistent cache, 82 queries, 78 setting up, 72 IntegrationRepository component, 73, 74 IntegrationRepositoryView, 69 internal users logging into REST Web Services server, 110 item-descriptor tag, 87
E
enableFormatDateOutput, 174, 176 errors, 135 exceptions, 135 returning for form handlers, 146 executeQuery operations, 79 expand attribute, 172 external users logging into REST Web Services server, 109
F
filter depth specifying default, 167 specifying for one request, 169
J
Java classes controlling property expansion for, 171
204
Index
Java client library REST Web Services, 183 Java clients before calling Web Services, 45 calling Web Services, 43 CookieContainer, 44, 45, 49, 50 deserializing content, 51 dynamic Web Service calls, 50 security, 44 serializing content, 51 starting REST session, 189 static Web Service calls, 48, 50 transactions, 44 two ways to call Web Services, 47 JAX-RPC, 6 deployment descriptor, 13 mapping file, 13 JMS Web Services, 19 MessageImporter component, 20 Patch Bay configuration, 20 JSON markup for parameters, 118 JSON output, 127 JSPs invoking via REST Web Services, 149
XML Schema, 36 Nucleus component Web Services, 8 Nucleus components REST, 101 null values in REST input, 124
O
object values for properties, 121 nested multiple value objects, 122 operations repository items, 69 output markup REST Web Services, 126
P
parameters control, 112 functional, 115 JSON markup, 118 message body, 116 URL query string markup, 118 XML markup, 117 Patch Bay configuration for JMS Web Services, 20 persistent cache (see Integration Data repository) positional parameters, 115 POST method handling as other methods, 108 priority property filtering for REST requests, 172 properties returning for form handlers, 147 property aliasing, 170 property filtering, 165 propertyElementNameSeparator, 34
L
logging in as internal user, 110 external users, 109 to the REST Web Services server, 108 logging out of the REST Web Services server, 112
M
mapping files DTD, 28 example, 29 repository to XML data binding, 28 MappingRepositoryItem, 77 maxDepthAllowed, 173 message body parameters, 116 Content-Type, 117 MessageImporter component, 20 methods invoking with the REST Web Services, 143 multiple values in REST Web Services output, 129 JSON input for, 121 replacing in a repository item property, 121
Q
queries executeQuery operation, 79 Integration Repository, 78 query string parameters, 116 query tag, 88
R
Remote Procedure Calls, 95 APIs, 95 exception handling, 98 remove-item tag, 90 removeItem operations, 81 RemoveService, 40 removing repository items, 40 repositories
N
namespaces
Index
205
REST path for, 105 repository item properties appending values, 120 replacing multiple values, 121 retrieving, 157 repository items adding, 160 deleting, 163 generating from XML documents, 37 listing, 155 REST Web Services, 155 retrieving, 156 setting properties, 162 transforming into XML documents, 35 transient, 161 repository to XML data binding, 27 mapping files, 28 XML Schemas, 32 repository to XML mapping files DTD, 28 example, 29 repository Web Services, 23 limitations, 24 Repository XML schema generating, 52 mapping file, 51 RepositoryItems deserializing, 51, 60 serializing, 51, 60 Web Service calls from Java clients, 44, 56 XML schema for Web Service calls, 49 RepositoryService class, 25 REST Nucleus components, 101 REST module Starting, 104 REST property filtering filtering priority, 172 filtering templates, 168 REST sessions starting, 189 REST Web Services, 103 ATG client libraries, 106, 183 client software, 106 configuring the server, 173 control parameters, 112 functional parameters, 115 identifying a response, 128 input values, 118 invoking JSPs, 149 output markup, 126 property aliasing, 170 property filtering, 165
repository items, 155 returned data, 126 security, 179 return depth, 134 return values controlling property expansion, 171 returnFormHandlerExceptionsByDefault, 174 returnFormHandlerPropertiesByDefault, 174 RPCs (see Remote Procedure Calls) RQL queries, 158
S
Scenario Manager receiving messages from JMS Web Services, 21 SchemaManager component, 34 security REST Web Services, 179 Serializing content on the client side, 51, 60 service endpoint interface, 9 service interface class, 9 session identifiers for REST Web Services session, 108 session sharing example, 49, 50, 59 sessions sharing (.NET clients), 44, 56 showRestPaths, 175, 177 startSession(), 189 static Web Service calls, 48 creating and compiling stubs, 49 creating and compiling the client, 49 distinction from dynamic calls, 47 WSDL, 49, 49 status codes, HTTP, 125 stubs (see client stubs) (see client stubs for .NET)
T
templates filtering, 168 time zone in REST dates, 135
U
updateItem operations, 80 derived properties, 80 UpdateService, 38 data validation, 38 updating repository items from XML documents, 38 URL parameters, 116 URL query string markup for parameters, 118 URLs
206
Index
V
validating data AddService, 37 UpdateService, 38
W
Web Service security, 13 NucleusSecurityManager, 14 NucleusSecurityRepository, 14 Web Services Administration UI, 7, 19, 23 ATG Web Services, 3, 15 before calling from .NET, 57 before calling from Java clients, 45 calling from .NET clients, 55, 58 calling from Java clients, 43, 47, 50 client stubs for .NET, 56 custom Web Services, 5 deploying, 15 generating, 6 infrastructure, 1 JMS messages, 19 limitations, 6 managing, 16 naming restrictions, 9 Nucleus component methods, 8 overview, 5 repository items, 23 REST, 103 runtime classes, 13 security, 6, 44, 44, 44, 55, 56, 56, 56 transactions, 44, 56 wizard, 7, 19 web.xml files, 11 WSDL documents, 10
X
XML documents generating from repository items, 35 transforming into repository items, 37 updating repository items, 38 XML markup for parameters, 117 XML output, 127 XML SchemaManager component, 34 XML Schemas for Web Services, 51 generation utility, 33 itemRef attribute, 34 namespace, 36 references to other repository items, 34
Index
207
208
Index