HomeListExpiry.jsp
This JSP lists Expiry dates for content items associated with an authoring template.
Drop this jsp into:
profile_home/installedApps/PPcell01/wcm.ear/ilwwcm.war/jsp/html
Usage:
wget https://myhost.mydomain.com:40035/wps/wcm/jsp/html/ListExpiry.jsp --no-check-certificate
Script:
<%@ page import="com.ibm.workplace.wcm.api.*"%> <%@ page import="java.util.*,javax.servlet.jsp.JspWriter,java.io.*,java.text.*"%> <%@ page import="com.ibm.workplace.wcm.api.query.*"%> <%@ page import="java.time.LocalDateTime"%> <%@ page import="java.util.Calendar"%> <% try { Workspace myworkspace = WCM_API.getRepository().getSystemWorkspace(); myworkspace.login(); Library mylib = myworkspace.getDocumentLibrary("My Content Library"); QueryService queryService = myworkspace.getQueryService(); Query query = queryService.createQuery(); query.addSelector(Selectors.libraryEquals(mylib)); query.addSelector(Selectors.typeEquals(AuthoringTemplate.class)); query.addSelector(Selectors.nameLike("My Authoring Template")); ResultIterator results = queryService.execute(query); Identity atid = ((AuthoringTemplate)results.next()).getIdentity(); //out.println("<h3>cmt AT \"" + atid + "\"</h3>"); out.println("<h3>List new Expiry date for content using the My Authoring Template</h3>"); out.println("Find content using the My Authoring Template with an Expiry date set to null. <p>"); Query query2 = queryService.createQuery(Content.class); query2.addSelector(Selectors.libraryEquals(mylib)); query2.addSelector(Selectors.authoringTemplateEquals(atid)); // SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); // Date fromDate = format.parse ( "2013-01-01" ); // Date toDate = format.parse ( "2021-07-13" ); // query2.addSelector(HistorySelectors.modifiedSince(fromDate)); // query2.addSelector(HistorySelectors.modifiedBefore(toDate)); ResultIterator results2 = queryService.execute(query2); java.util.Date expiryDate; java.util.Date publishedDate; // Test with one record first int x; x=0; //while (results2.hasNext() && x < 1) while (results2.hasNext()) { // Test with one record first x=x+1; Content content = (Content) results2.next(); //out.println("<p>Content without filter: " + content.getName()); if (content.getExpiryDate() == null ) { //out.println("<br>content: " + content.getName() + " publishedDate: " + content.getPublishedDate() + " Expiry: " + content.getExpiryDate()); publishedDate = content.getPublishedDate(); //out.println("<br>Published Date: " + publishedDate); if (publishedDate == null) { out.println("<p>Skipping content: " + content.getName() + ". <br>Published Date is null: "); } else { Calendar c = Calendar.getInstance(); c.setTime(publishedDate); c.add(Calendar.YEAR, 5); expiryDate = c.getTime(); out.println("<p>Content \"" + content.getName() + "\" <br> Published Date: " + publishedDate + "<br>Old Expiry Date: " + content.getExpiryDate() + "<br>New Expiry Date: " + expiryDate); } } } out.println("<p>Number of records processed:" + x); myworkspace.logout(); } catch (Exception e) { out.println("Exception " + e.getMessage()); e.printStackTrace(); } %>