You can discover resources by listing resources. A query
is performed against the repository to find all the resources that
are related to a given resource collection.
Once you organize your resources, you can inspect the structure
you created by seeing a particular branch of the structure, much
like you would do in an operating system.
Listing resources operates by relationship: resources are members
of folders. Membership is represented by a relationship of type
"member of". When you list resources in a given folder, you are
querying for resources that are related to a given folder by the
relationship "member of". Relationships are directional: a member
of a relationship has a source that is a member of the target. The
source is the resource; the target is the parent folder.
Summary of steps
To list resources, follow these steps:
-
Include project files.
-
Create the service client.
-
Specify the folder path.
-
Retrieve the list of resources.
Include project files
Include the necessary files in your development
project. If you are creating a client application using Java, include
the necessary JAR files. If you are using web services, include
the proxy files.
Create the service client
Before you can programmatically create
a resource collection, you must establish a connection and provide
credentials. This is accomplished by creating a service client.
Specify the folder path
Create a string containing the path of
the folder containing the resources. The syntax includes forward
slashes, as in this example: "/
path
/
folder
".
Retrieve the list of resources
Invoke the Repository service method
to retrieve the list of resources, specifying the target folder’s
path.
List resources using the Java API
List
resources by using the Repository service API (Java):
-
Include project files
Include client JAR files
in your Java project’s class path.
-
Create the service client
Create a
ResourceRepositoryClient
object by
using its constructor and passing a
ServiceClientFactory
object
that contains connection properties.
-
Specify the folder path
Specify the URI of the resource
collection to be queried. In this case, its URI is
"/testFolder"
.
The URI is stored as a
java.lang.String
object.
-
Retrieve the list of resources
Invoke the
ResourceRepositoryClient
object’s
listMembers
method
and pass in the URI of the folder.
The method returns a
java.util.List
of
com.adobe.repository.infomodel.bean.Resource
objects
that are the source of a
com.adobe.repository.infomodel.bean.Relation
of
type
Relation.TYPE_MEMBER_OF
and have the resource
collection URI as the target. You can iterate through this
List
to
retrieve each of the resources. In this example, the name and description
of each resource is displayed.
List resources using the web service API
List
resources by using the Repository service API (web service):
-
Include project files
-
Create the service client
Using the Microsoft .NET
client assembly, create a
RepositoryServiceService
object
by invoking its default constructor. Set its
Credentials
property using
a
System.Net.NetworkCredential
object containing
the user name and password.
-
Specify the folder path
Specify a string containing
the URI of the folder to be queried. In this case, its URI is
"/testFolder"
.
When using a language that is compliant with the Microsoft .NET
Framework (for example, C#), store the URI in a
System.String
object.
-
Retrieve the list of resources
Invoke the
RepositoryServiceService
object’s
listMembers
method
and pass in the URI of the folder as the first parameter. Pass
null
for
the other two parameters.
The method returns an array of objects
that can be cast to
Resource
objects. You can iterate
through the object array to retrieve each of the related resources.
In this example, the name and description of each resource is displayed.
|
|
|