Take a survey

Developing Applications Using APIs > Working with LiveCycle ES Repository > Searching for Resources > Searching for resources using the Java API

Searching for resources using the Java API
To programmatically search for a resource using the Repository service Java API, perform the following tasks:
1.
Include client JAR files in your Java project’s class path. For information about the location of these files, see Including LiveCycle ES library files.
2.
Create the connection properties that will be used to establish your service client. Create a java.util.Properties object by using the following connection properties (see Setting connection properties):
Create a com.adobe.idp.dsc.clientsdk.ServiceClientFactory object by passing the Properties object as input to the ServiceClientFactory object’s static createInstance method.
Create a com.adobe.repository.bindings.dsc.client.ResourceRepositoryClient object by using its constructor and passing in the ServiceClientFactory object as a parameter.
3.
Specify the URI of the base path from which to execute the search. In this example, the URI of the resource is "/testFolder".
4.
Specify the values for the attributes on which to conduct the search. The attributes exist within a com.adobe.repository.infomodel.bean.Resource object. In this example, the search will be conducted on the name attribute; therefore, a java.lang.String containing the Resource object’s name is used, which is "testResource" in this case. For more information, see LiveCycle ES Java API Reference at http://www.adobe.com/go/learn_lc_JavaAPI.
5.
To create a query, create a com.adobe.repository.query.Query object by invoking the default constructor for the Query class and add statements to the query.
To create a statement, invoke the constructor for the com.adobe.repository.query.Query.Statement class and pass in the following parameters:
A left operand containing the resource attribute constant. In this example, because the resource’s name is used as the basis for the search, the static value Resource.ATTRIBUTE_NAME is used.
An operator containing the condition used in the search for the attribute. The operator must be one of the static constants in the Query.Statement class. In this example, the static value Query.Statement.OPERATOR_BEGINS_WITH is used.
A right operand containing the attribute value on which to conduct the search. In this example, the name attribute, a String containing the value "testResource", is used.
Specify the namespace of the left operand by invoking the Query.Statement object’s setNamespace method and passing in one of the static values contained in the com.adobe.repository.infomodel.bean.ResourceProperty class. In this example, ResourceProperty.RESERVED_NAMESPACE_REPOSITORY is used.
Add each statement to the query by invoking the Query object’s addStatement method and passing in the Query.Statement object.
For more information, see LiveCycle ES Java API Reference at http://www.adobe.com/go/learn_lc_JavaAPI.
6.
To specify the sort order used in the search results, create a com.adobe.repository.query.sort.SortOrder object by invoking the default constructor for the SortOrder class, and add elements to the sort order.
To create an element for the sort order, invoke one of the constructors for the com.adobe.repository.query.sort.SortOrder.Element class. In this example, because the resource’s name is used as the basis for the search, the static value Resource.ATTRIBUTE_NAME is used as the first parameter, and ascending order (a boolean value of true) is specified as the second parameter.
Add each element to the sort order by invoking the SortOrder object’s addSortElement method and passing in the SortOrder.Element object.
For more information, see LiveCycle ES Java API Reference at http://www.adobe.com/go/learn_lc_JavaAPI.
7.
To search for resources based on attribute properties, invoke the ResourceRepositoryClient object’s searchProperties method and pass in the following parameters:
A String containing the base path from which to execute the search. In this case, "/testFolder" is used.
The depth of the search. In this case, com.adobe.repository.infomodel.bean.ResourceCollection.DEPTH_INFINITE is used to indicate that the base path and all its folders are to be used.
An int value indicating the first row from which to select the unpaged result set. In this example, 0 is specified.
An int value indicating the maximum number of results to be returned. In this example, 10 is specified.
The method returns a java.util.List of Resource objects in the specified sort order.
For more information, see LiveCycle ES Java API Reference at http://www.adobe.com/go/learn_lc_JavaAPI.
8.
To retrieve the resources contained in the search result, iterate through the List and cast each object to a Resource in order to extract its information. In this example, the name of each resource is displayed.
View Quick Start
 

 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/livecycle/es/sdkHelp/programmer/sdkHelp/repositorySearchResources.125.3.html