You can use the Legacy REST Web Services to call public methods on Nucleus components. If a method is overloaded, then the server will attempt to determine which method to call by looking at the number of arguments supplied. It is also possible to supply a method signature as a parameter to the RestComponentHelper.executeMethod() method. Supplying the atg-rest-method parameter allows you to specify the exact method to be called. The value of the parameter should be the Java method signature of the method to call. You can find the method signature for a method by using the javap command, which disassembles a class file. (The javap command is part of the JDK.)

Depending on the return type of the method, the output will vary. If the output is an object, then it will return a JSON or XML stream which contains the values of all the properties in the object. If it is a simple type like an int or a String, it will return the value. The identifier for the return type is atgResponse.

Passing Parameters to Methods

If you use the Java or ActionScript client libraries that ship with the Legacy REST Web Services, passing parameters to methods is as simple as supplying the Objects in the pArguments argument for the RestComponentHelper.executeMethod() method.

If one of the parameters is a simple type, then it should be wrapped in an object. For example, an int will become a java.lang.Integer, a boolean becomes a java.lang.Boolean, and so on.

When you pass collections, Maps, and arrays as parameters, the client library attempts to convert those types. Date, Time, and Timestamp objects can also be passed, as shown in the following sample.

RestResult result = RestComponentHelper.executeMethod("/some/Component",
"aMethod", new Object[] {1,2,3,4.4,5.5,true,'a',0xa}, null, session)

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:


When you reference a repository item this way, the server performs a lookup and uses the item as the method argument. For example:

RestResult result = RestComponentHelper.executeMethod("/some/Component",
"aMethod", new Object[] {"/atg/commerce/catalog/ProductCatalog:product:prod12345"}
, null, session)

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:

RestResult result = RestComponentHelper.executeMethod("/some/Component",
"aMethod", new Object[] {"/atg/dynamo/Configuration"}, null, session)

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)
Calling Handler Methods

Form handlers use special handler methods for linking form elements with Nucleus components. One of the more powerful features in the Legacy REST Web Services module is the ability to call handler methods. If you have existing JSP-based applications, all the functionality which has previously been exposed in those applications can be reused with REST based applications. Use RestComponentHelper.executeMethod() to call handler methods.

Keep the following in mind when calling a handler method

The following code sample calls the handleCreate method on a specified form handler:

RestResult result = RestComponentHelper.executeMethod("/some/FormHandler",
"create", null, 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.

Passing Parameters to Form Handlers

Form handler parameters which need to be supplied should be added to the params argument. In a JSP page these parameters would be the input tags in a JSP form. The following example calls the handleCreate() method on a form handler. The inputs to the form handler are a first and last name.

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

Copyright © 1997, 2013 Oracle and/or its affiliates. All rights reserved. Legal Notices