<%@ include file="adminHeaders.jsp" %> <% /* $Id$ */ /** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ %> <% final String clientTimezoneString = variableContext.getParameter("client_timezone"); final TimeZone clientTimezone; if (clientTimezoneString == null || clientTimezoneString.length() == 0) { clientTimezone = TimeZone.getDefault(); } else { clientTimezone = TimeZone.getTimeZone(clientTimezoneString); } try { // Check if authorized if (!adminprofile.checkAllowed(threadContext,IAuthorizer.CAPABILITY_VIEW_REPORTS)) { variableContext.setParameter("target","index.jsp"); %> <% } if (org.apache.manifoldcf.crawler.system.ManifoldCF.checkMaintenanceUnderway()) { %> <% } int k; // Read the document selection parameters. // The status report is connection based, so the connection has to be selected before anything else makes sense. String statusConnection = variableContext.getParameter("statusconnection"); if (statusConnection == null) statusConnection = ""; // Which jobs we care about also figure in the selection part of the query. It is the user's responsibility to pick jobs // that are in desired states. String[] statusJobIdentifiers = variableContext.getParameterValues("statusjobs"); if (statusJobIdentifiers == null) statusJobIdentifiers = new String[0]; // We can select documents from the queue based on the earliest time they can be acted upon. This is specified in // a delta in minutes offset from "now". Empty means that we don't want to select on that criteria. String activeTimeOffsetMinutes = variableContext.getParameter("statusscheduleoffset"); if (activeTimeOffsetMinutes == null) activeTimeOffsetMinutes = ""; // There is a selection criteria also based on the document state; these are integers defined in IJobManager. String[] documentStateTypes; if (variableContext.getParameter("statusdocumentstates_posted") != null) { documentStateTypes = variableContext.getParameterValues("statusdocumentstates"); if (documentStateTypes == null) documentStateTypes = new String[0]; } else documentStateTypes = null; // There is a selection criteria based on the document status; these are also integers defined in IJobManager. String[] documentStatusTypes; if (variableContext.getParameter("statusdocumentstatuses_posted") != null) { documentStatusTypes = variableContext.getParameterValues("statusdocumentstatuses"); if (documentStatusTypes == null) documentStatusTypes = new String[0]; } else documentStatusTypes = null; // Match string for the document identifier String identifierMatch = variableContext.getParameter("statusidentifiermatch"); if (identifierMatch == null) identifierMatch = ""; // From the passed-in selection values, calculate the actual selection criteria that we'll use in the queries. IRepositoryConnectionManager connMgr = RepositoryConnectionManagerFactory.make(threadContext); IRepositoryConnection[] connList = connMgr.getAllConnections(); IJobManager jobManager = JobManagerFactory.make(threadContext); // Repository connection name: This simply needs to be mapped to an eligible list of identifiers. IJobDescription[] eligibleList = null; HashMap selectedJobs = null; if (statusConnection.length() > 0) { eligibleList = jobManager.findJobsForConnection(statusConnection); selectedJobs = new HashMap(); k = 0; while (k < statusJobIdentifiers.length) { Long identifier = new Long(statusJobIdentifiers[k++]); selectedJobs.put(identifier,identifier); } } // Time offset: Need to calculate the actual time in ms since epoch to use to query against the "checktime" field. // Note that the checktime field is actually nullable and will only have a value when the document is in certain states; // therefore, the query itself will only include checktime for those states where it makes sense. An empty value // means "from the beginning of time", or is equivalent to time 0. long nowTime = 0L; if (activeTimeOffsetMinutes.length() > 0) { nowTime = System.currentTimeMillis() + (new Long(activeTimeOffsetMinutes).longValue()) * 60000L; if (nowTime < 0L) nowTime = 0L; } else nowTime = System.currentTimeMillis(); // Translate the states from a string to a number that will be understood by IJobManager. int[] matchingStates; if (documentStateTypes == null) { matchingStates = new int[]{IJobManager.DOCSTATE_NEVERPROCESSED,IJobManager.DOCSTATE_PREVIOUSLYPROCESSED, IJobManager.DOCSTATE_OUTOFSCOPE}; } else { matchingStates = new int[documentStateTypes.length]; k = 0; while (k < matchingStates.length) { matchingStates[k] = new Integer(documentStateTypes[k]).intValue(); k++; } } HashMap matchingStatesHash = new HashMap(); k = 0; while (k < matchingStates.length) { Integer state = new Integer(matchingStates[k++]); matchingStatesHash.put(state,state); } // Convert the status from a string to a number that will be understood by IJobManager int[] matchingStatuses; if (documentStatusTypes == null) { matchingStatuses = new int[]{IJobManager.DOCSTATUS_INACTIVE,IJobManager.DOCSTATUS_PROCESSING,IJobManager.DOCSTATUS_EXPIRING, IJobManager.DOCSTATUS_DELETING,IJobManager.DOCSTATUS_READYFORPROCESSING,IJobManager.DOCSTATUS_READYFOREXPIRATION, IJobManager.DOCSTATUS_WAITINGFORPROCESSING,IJobManager.DOCSTATUS_WAITINGFOREXPIRATION,IJobManager.DOCSTATUS_WAITINGFOREVER, IJobManager.DOCSTATUS_HOPCOUNTEXCEEDED}; } else { matchingStatuses = new int[documentStatusTypes.length]; k = 0; while (k < matchingStatuses.length) { matchingStatuses[k] = new Integer(documentStatusTypes[k]).intValue(); k++; } } HashMap matchingStatusesHash = new HashMap(); k = 0; while (k < matchingStatuses.length) { Integer status = new Integer(matchingStatuses[k++]); matchingStatusesHash.put(status,status); } %>
<% if (eligibleList != null) { %> <% } else { %> <% } %>
<%=Messages.getBodyString(pageContext.getRequest().getLocale(),"documentstatus.Connection")%> <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"documentstatus.Jobs")%>
<%=Messages.getBodyString(pageContext.getRequest().getLocale(),"documentstatus.TimeOffsetFromNowMinutes")%>
<%=Messages.getBodyString(pageContext.getRequest().getLocale(),"documentstatus.DocumentState")%>
<%=Messages.getBodyString(pageContext.getRequest().getLocale(),"documentstatus.DocumentState")%>
<%=Messages.getBodyString(pageContext.getRequest().getLocale(),"documentstatus.DocumentIdentifierMatch")%>
<% if (statusConnection.length() > 0) { if (statusJobIdentifiers.length > 0) { // Run the report. // First, we need to gather the sort order object. String sortOrderString = variableContext.getParameter("sortorder"); SortOrder sortOrder; if (sortOrderString == null || sortOrderString.length() == 0) sortOrder = new SortOrder(); else sortOrder = new SortOrder(sortOrderString); // Now, gather the column header that was clicked on (if any) String clickedColumn = variableContext.getParameter("clickcolumn"); if (clickedColumn != null && clickedColumn.length() > 0) sortOrder.clickColumn(clickedColumn); // Gather the start String startRowString = variableContext.getParameter("startrow"); int startRow = 0; if (startRowString != null && startRowString.length() > 0) startRow = Integer.parseInt(startRowString); // Gather the max String maxRowCountString = variableContext.getParameter("rowcount"); int rowCount = 20; if (maxRowCountString != null && maxRowCountString.length() > 0) rowCount = Integer.parseInt(maxRowCountString); Long[] ourJobs = new Long[selectedJobs.size()]; Iterator iter = selectedJobs.keySet().iterator(); int zz = 0; while (iter.hasNext()) { ourJobs[zz++] = (Long)iter.next(); } RegExpCriteria identifierMatchObject = null; if (identifierMatch.length() > 0) identifierMatchObject = new RegExpCriteria(identifierMatch,true); StatusFilterCriteria criteria = new StatusFilterCriteria(ourJobs,nowTime,identifierMatchObject,matchingStates,matchingStatuses); IResultSet set = jobManager.genDocumentStatus(statusConnection,criteria,sortOrder,startRow,rowCount+1); %>
<% zz = 0; boolean hasMoreRows = (set.getRowCount() > rowCount); int iterCount = hasMoreRows?rowCount:set.getRowCount(); while (zz < iterCount) { IResultRow row = set.getRow(zz); // Translate column values into something that can be reasonably displayed. // Note that the actual hard work of translating things to human-readable strings largely is done by the query itself; this is because // we want to sort on the columns, so it has to be that way. String[] identifierBreakdown = org.apache.manifoldcf.ui.util.Formatter.formatString(row.getValue("identifier").toString(),64,true,true); Long scheduleTime = (Long)row.getValue("scheduled"); String scheduleTimeString = ""; if (scheduleTime != null) scheduleTimeString = org.apache.manifoldcf.ui.util.Formatter.formatTime(clientTimezone, pageContext.getRequest().getLocale(), scheduleTime.longValue()); String scheduledActionString = (String)row.getValue("action"); if (scheduledActionString == null) scheduledActionString = ""; Long retryCount = (Long)row.getValue("retrycount"); String retryCountString = ""; if (retryCount != null) retryCountString = retryCount.toString(); Long retryLimit = (Long)row.getValue("retrylimit"); String retryLimitString = ""; if (retryLimit != null) retryLimitString = org.apache.manifoldcf.ui.util.Formatter.formatTime(clientTimezone, pageContext.getRequest().getLocale(), retryLimit.longValue()); %> <% zz++; } %>
<%=Messages.getBodyString(pageContext.getRequest().getLocale(),"documentstatus.Identifier")%> <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"documentstatus.Job")%> <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"documentstatus.State")%> <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"documentstatus.Status")%> <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"documentstatus.Scheduled")%> <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"documentstatus.ScheduledAction")%> <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"documentstatus.RetryCount")%> <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"documentstatus.RetryLimit")%>
<% int q = 0; while (q < identifierBreakdown.length) { %> <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(identifierBreakdown[q++])%>
<% } %>
<%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(row.getValue("job").toString())%> <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(row.getValue("state").toString())%> <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(row.getValue("status").toString())%> <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(scheduleTimeString)%> <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(scheduledActionString)%> <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(retryCountString)%> <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(retryLimitString)%>
<% } else { %>

<%=Messages.getBodyString(pageContext.getRequest().getLocale(),"documentstatus.PleaseSelectAtLeastOneJob")%>

<% } } else { %>

<%=Messages.getBodyString(pageContext.getRequest().getLocale(),"documentstatus.PleaseSelectaConnection")%>

<% } %>
<% } catch (ManifoldCFException e) { e.printStackTrace(); variableContext.setParameter("text",e.getMessage()); variableContext.setParameter("target","index.jsp"); %> <% } %>