To search for portal objects and documents from a remote application, use the IPortalSearchRequest interface in the Oracle WebCenter Interaction Development Kit (IDK).
The sample code below demonstrates how to query for a folder ID by folder name. The folder ID is required to execute other PRC functionality, including creating portlets, documents and groups. This example uses query constraints; for more information, see Using Query Constraints with the Oracle WebCenter Interaction Development Kit (IDK) Remote Search API.
Java
//set the endpoint to the value of web services server
String endpoint = "http://IP-GW-AS08:9080/ptapi/services/QueryInterfaceAPI";
URL url = new URL(endpoint);
//set username and password to log in
//hard-coding the values is only for demo purposes
String username = "Administrator";
String password = "";
IRemoteSession prcSession = RemoteSessionFactory.getExplicitLoginContext(url, username, password);
ISearchFactory searchFactory = prcSession.getSearchFactory();
IPortalSearchRequest searchRequest = searchFactory.createPortalSearchRequest();
public static int getFolderId(IPortalSearchRequest searchRequest, String folderName)
throws Exception
{
int folderId = -1;
//search for the given folder name
searchRequest.setQuery(folderName);
// only search for folders
ObjectClass[] objectTypes = {ObjectClass.DocumentFolder};
searchRequest.setObjectTypesToSearch(objectTypes);
ISearchResponse searchResponse = searchRequest.execute();
ISearchResultSet resultSet = searchResponse.getResultSet();
int numResults = searchResponse.getReturnedCount();
if(numResults > 0)
{
Enumeration results = resultSet.getResults(); //just get the first element
IPortalSearchResult result = (IPortalSearchResult) results.nextElement();
folderId = result.getObjectID();
}
returnfolderId;
}
.NET (C#)
//set the endpoint to the value of web services server
String endpoint = "http://IP-GW-AS08:9080/ptapi/services/QueryInterfaceAPI";
//set username and password to log in
//hard-coding the values is only for demo purposes
String username = "Administrator";
String password = "";
IRemoteSession session = RemoteSessionFactory.GetExplicitLoginContext(new System.Uri(endpoint), username, password);
ISearchFactory searchFactory = session.GetSearchFactory();
IPortalSearchRequest searchRequest = searchFactory.CreatePortalSearchRequest();
public static int GetFolderId(IPortalSearchRequest searchRequest, String folderName)
{
int folderId = -1;
//search for the given folder name
searchRequest.SetQuery(folderName);
// only search for folders
ObjectClass[] objectTypes = {ObjectClass.DocumentFolder};
searchRequest.SetObjectTypesToSearch(objectTypes);
ISearchResponse searchResponse = searchRequest.Execute();
ISearchResultSet resultSet = searchResponse.GetResultSet();
int numResults = searchResponse.GetReturnedCount();
if(numResults > 0)
{
Enumeration results = resultSet.GetResults(); //just get the first element
IPortalSearchResult result = (IPortalSearchResult) results.Current;
folderId = result.GetObjectID();
}
returnfolderId;
}
.NET (VB)
//set the endpoint to the value of web services server
String endpoint = "http://IP-GW-AS08:9080/ptapi/services/QueryInterfaceAPI"
//set username and password to log in
//hard-coding the values is only for demo purposes
String username = "Administrator"
String password = ""
Dim session As IRemoteSession = RemoteSessionFactory.GetExplicitLoginContext(New
System.Uri(endpoint), username, password)
Dim searchFactory As ISearchFactory = session.GetSearchFactory()
Dim searchRequest As IPortalSearchRequest = searchFactory.CreatePortalSearchRequest()
Public Shared Function GetFolderID(ByVal searchRequest As IPortalSearchRequest, ByVal
folderName As String)
Dim folderID As Int32 = -1
searchRequest.SetQuery(folderName)
Dim objectTypes() As ObjectClass = {ObjectClass.DocumentFolder}
searchRequest.SetObjectTypesToSearch(objectTypes)
Dim searchResponse As ISearchResponse = searchRequest.Execute()
Dim resultSet As ISearchResultSet = searchResponse.GetResultSet()
Dim numResults As Int32 = searchResponse.GetReturnedCount()
If (numResults > 0) Then
Dim results As IEnumerator = resultSet.GetResults()
results.MoveNext()
Dim result As IPortalSearchResult = DirectCast(results.Current, IPortalSearchResult)
folderId = result.GetObjectID()
End If
Return folderId
End Function