Normal WCM Authoring Search does not work for pages in the Portal Site Library. The page title is in regular text as expected but the page name is in the form of an object id.
Answer by rickett (14292) | Aug 10, 2016 at 08:32 PM
The following JSP code will display the page name and path when the page title is entered.
DISCLAIMER OF WARRANTIES:
The following [enclosed] code is sample code created by IBM Corporation.
This sample code is provided to you solely for the purpose of assisting
you in the development of your applications.
The code is provided "AS IS", without warranty of any kind. IBM shall
not be liable for any damages arising out of your use of the sample code,
even if they have been advised of the possibility of such damages.
<%@page session="false" contentType="text/html" pageEncoding="ISO-8859-1" %>
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<%@ page import="com.ibm.workplace.wcm.api.*"%>
<H2>
LOOKUP PAGE NAME IN PORTAL SITE LIBRARY BY PAGE TITLE
</H2>
<form action="findPage.jsp" method="GET">
Enter page title to search:
<br>
<input type="text" name="pageName" />
<br>
<input type="submit" style="display:none">
</form>
</div>
<%
String pageName = (String) request.getParameter("pageName");
if(pageName != null) {
Workspace myworkspace = WCM_API.getRepository().getSystemWorkspace();
DocumentLibrary docLibrary = myworkspace.getDocumentLibrary("Portal Site");
myworkspace.setCurrentDocumentLibrary(docLibrary);
DocumentIdIterator docIt;
DocumentType[] types15 = {DocumentTypes.PortalPage};
String title = null;
docIt = myworkspace.findByType(types15[0]);
Document doc = null;
Document doc1 = null;
DocumentIdIterator doctmp = null;
DocumentId docId = null;
String path = "empty";
String initialPath = null;
String tmpPath[] = null;
String tmp = "Portal Site";
int length = 0;
while (docIt.hasNext()) {
docId = docIt.nextId();
doc = myworkspace.getById(docId);
title = doc.getTitle();
if (title.toLowerCase().contains(pageName.toLowerCase())) {
initialPath = myworkspace.getPathById(docId,true,true);
tmpPath = initialPath.split("/");
for( int i = 0; i < tmpPath.length - 1; i++) {
if(i>0) {
doctmp = myworkspace.findByName(DocumentTypes.PortalPage, tmpPath[i]);
docId = doctmp.nextId();
doc1 = myworkspace.getById(docId);
tmp = tmp.concat("/");
tmp = tmp.concat(doc1.getTitle());
}
}
out.println("<br><br>Page Title: " + title + "<br>Page Name: " + doc.getName() + "<br>" + "Path: " + tmp);
}
}
}
%>
<br>
<br>
<a href="http://rickett8.rtp.raleigh.ibm.com:10039/wps/wcm/jsp/html/findPage.jsp">Search Again</a>
WCM API sample code how to generateURL based on locale of the request 1 Answer
Considerations using getUserPrinciple with Portal API 1 Answer
WCM API sample code to rename the file in a file resource component 1 Answer
WCM API Quick Start Sample Code using findByName 2 Answers
Sample code to update or create an image in a content image element using the WCM API 1 Answer