This blog explains about how to perform a custom query similar to Webcenter out of box search query
import com.incresearch.common.constant.PortalConstant;
import com.incresearch.common.contentmanagement.UCMFile;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import java.util.logging.Level;
import oracle.adf.share.logging.ADFLogger;
import oracle.jbo.JboException;
import oracle.stellent.ridc.IdcClient;
import oracle.stellent.ridc.IdcClientException;
import oracle.stellent.ridc.IdcClientManager;
import oracle.stellent.ridc.IdcContext;
import oracle.stellent.ridc.model.DataBinder;
import oracle.stellent.ridc.model.DataObject;
import oracle.stellent.ridc.model.DataResultSet;
import oracle.stellent.ridc.model.TransferFile;
import oracle.stellent.ridc.protocol.ServiceResponse;
public List getCustomQuerySearchResults(String pSearchCriteria) {
List fileList = new ArrayList();
try {
init("ohsadmin");
String contributedPagesQuery =
"(dDocTitle `" + pSearchCriteria + "`" +
" (" + pSearchCriteria + " ))";
System.out.println("Custom Search Query: " +contributedPagesQuery);
DataBinder dataBinder = myIdcClient.createBinder();
dataBinder.putLocal("IdcService", "GET_SEARCH_RESULTS");
dataBinder.putLocal("ResultCount", "50000");
dataBinder.putLocal("QueryText", contributedPagesQuery);
//setting date format
dataBinder.putLocal("dInDate", "MMMM dd, yyyy hh:mm tt");
ServiceResponse response;
DataBinder serverBinder = null;
response = myIdcClient.sendRequest(userContext, dataBinder);
serverBinder = response.getResponseAsBinder();
DataResultSet resultSet =
serverBinder.getResultSet("SearchResults");
int index = 0;
if (resultSet != null) {
UCMFile ucmFile = null;
for (DataObject dataObject1 : resultSet.getRows()) {
String docName = dataObject1.get("dDocName");
ucmFile = new UCMFile();
ucmFile.setDocumentId(dataObject1.get("dID"));
ucmFile.setContentID(docName);
ucmFile.setDatasource("UCM#dDocName:" +
dataObject1.get("dDocName"));
ucmFile.setDescription(dataObject1.get("xComments"));
ucmFile.setTitle(dataObject1.get("dDocTitle"));
ucmFile.setUrl(getDocWebUrl(dataObject1.get("dDocName")));
String date = formatDate(dataObject1.get("dInDate"));
ucmFile.setUploadDate(date);
ucmFile.setAuthor(dataObject1.get("dDocAuthor"));
ucmFile.setExt(dataObject1.get("dExtension"));
fileList.add(ucmFile);
index++;
}
}
} catch (Exception ice) {
System.out.println(ice.getMessage());
ice.printStackTrace();
} finally {
}
System.out.println("file size " + fileList.size());
return fileList;
}
No comments:
Post a Comment