Home

FindNoExpiry.jsp

<%@page session="false" contentType="text/html" pageEncoding="ISO-8859-1" %>
<%@ page import="java.util.*,javax.mail.*,javax.mail.internet.*,java.util.Properties,javax.activation.*"%>       
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.net.*" %>
<%@ page import="java.lang.*" %>
<%@ page import="com.ibm.workplace.wcm.api.*"%>
<%@ page import="com.ibm.workplace.wcm.api.exceptions.*"%>
<%@ page import="java.util.*,javax.servlet.jsp.JspWriter,java.io.*"%>
<%@ page import="javax.naming.InitialContext"%>
<%@ page import="javax.naming.Context"%>

<%
//Place the JSP  under <Profile Root>\installedApps\<nodename>\wcm.ear\ilwwcm.war\jsp\html             
//and then access it by using the following URL - 
//http://<hostname>:<port>/wps/wcm/jsp/html/FindUnexpired.jsp   


 Workspace myworkspace = WCM_API.getRepository().getSystemWorkspace();
   
 if ( myworkspace == null )    {
    out.println( "Unable to get a valid workspace.<br/>" );
 }
 else {
    // out.println("Found workspace<br/>");
 }
   
 myworkspace.login();
  
 myworkspace.setCurrentDocumentLibrary(myworkspace.getDocumentLibrary("My Content Library"));
 DocumentLibrary currentLib = myworkspace.getCurrentDocumentLibrary();

 Iterator libraries = myworkspace.getDocumentLibraries();

 out.println("</BR>" + "<h3> My content items with no expiry date</h3>");

 while (libraries.hasNext()) {

try
{
  //DocumentId libraryId = libraries.next();

  //DocumentLibrary library = myworkspace.getById(libraryId);

  DocumentLibrary currentlibrary = (DocumentLibrary) libraries.next();

  myworkspace.setCurrentDocumentLibrary(currentlibrary);

  out.println("</BR></BR>" + "*******************************");

  out.println("</BR>" + "Items for library: " + currentlibrary.getName() + "</BR>");
  
  DocumentIdIterator docIt;
  int total = 0;
  int k;
  WorkflowedDocument document;

  java.util.Date expiryDate;
  java.util.Date currentDate = new Date();
  int compareResult = 0;
  
  out.println("</BR>");
  DocumentType[] types1 = {DocumentTypes.Content};
  k=0;
  for(int i=0; i < types1.length; i++) {
     docIt = myworkspace.findByType(types1[i]);
     while (docIt.hasNext()) {
       k++;
       DocumentId docId = docIt.nextId();
       document = (WorkflowedDocument) myworkspace.getById(docId);
       if(document.isPublished()) {
         // out.println("Above document is in Published status</BR>");
         expiryDate = document.getExpiryDate();
         if(expiryDate == null) {
         out.println("Content item: " + docId.getName() + " |" + expiryDate + "|</BR>");
         }
         // else
         // {
         // out.println("Content item: " + docId.getName() + " |" + expiryDate + "|</BR>");
         // }
         //out.println("</BR>Content item  = " + docId.getName() + "</BR>");
        if(expiryDate != null) {
            //out.println("</BR>Content item  = " + docId.getName() + "</BR>");
            //out.println("Expiry date for document: " + expiryDate + "</BR>");
            //out.println("Current date: " + currentDate + "</BR>");
            compareResult = currentDate.compareTo(expiryDate);
            if(compareResult > 0) {
              out.println("Content item: " + docId.getName() + " is in published status past expiry date " + expiryDate + " </BR>");
//              //MOVE to next stage... document.nextWorkflowStage(boolean p_runExitActions, boolean p_runEntryActions, java.lang.String p_comment);
            }
         // else
         //      out.println("Content item: " + docId.getName() + "|" + expiryDate + "| has no expiry date!!! </BR>");
         }
       }
     }
   out.println("</BR>" + "Total Content Items  = " + k + "</BR>");
   total+=k;
  }
} 
catch(Exception exc)
{
out.println("<br/><br/>EXCEPTION : " + exc.getMessage());
}  

 }
 
 out.println("</BR></BR>" + "*******************************");

 myworkspace.logout();


%>