<%@ 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. */ %> <% 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 parameters. String reportConnection = variableContext.getParameter("reportconnection"); if (reportConnection == null) reportConnection = ""; String[] reportActivities; if (variableContext.getParameter("reportactivities_posted") != null) { reportActivities = variableContext.getParameterValues("reportactivities"); if (reportActivities == null) reportActivities = new String[0]; } else reportActivities = null; // Get the current time, so we can fill in default values where possible. long currentTime = System.currentTimeMillis(); Long startTime = null; Long endTime = null; // Get start time, if selected String startYear = variableContext.getParameter("reportstartyear"); String startMonth = variableContext.getParameter("reportstartmonth"); String startDay = variableContext.getParameter("reportstartday"); String startHour = variableContext.getParameter("reportstarthour"); String startMinute = variableContext.getParameter("reportstartminute"); // Get end time, if selected. String endYear = variableContext.getParameter("reportendyear"); String endMonth = variableContext.getParameter("reportendmonth"); String endDay = variableContext.getParameter("reportendday"); String endHour = variableContext.getParameter("reportendhour"); String endMinute = variableContext.getParameter("reportendminute"); if (startYear == null && startMonth == null && startDay == null && startHour == null && startMinute == null && endYear == null && endMonth == null && endDay == null && endHour == null && endMinute == null) { // Nobody has selected a time range yet. Pick the last hour. endTime = null; startTime = new Long(currentTime - 1000L * 60L * 60L); } else { // Get start time, if selected if (startYear == null) startYear = ""; if (startMonth == null) startMonth = ""; if (startDay == null) startDay = ""; if (startHour == null) startHour = ""; if (startMinute == null) startMinute = ""; // Get end time, if selected. if (endYear == null) endYear = ""; if (endMonth == null) endMonth = ""; if (endDay == null) endDay = ""; if (endHour == null) endHour = ""; if (endMinute == null) endMinute = ""; if (startYear.length() == 0 || startMonth.length() == 0 || startDay.length() == 0 || startHour.length() == 0 || startMinute.length() == 0) { // Undetermined start startTime = null; } else { // Convert the specified times to a long. Calendar c = new GregorianCalendar(); c.set(Calendar.YEAR,Integer.parseInt(startYear)); c.set(Calendar.MONTH,Integer.parseInt(startMonth)); c.set(Calendar.DAY_OF_MONTH,Integer.parseInt(startDay) + 1); c.set(Calendar.HOUR_OF_DAY,Integer.parseInt(startHour)); c.set(Calendar.MINUTE,Integer.parseInt(startMinute)); startTime = new Long(c.getTimeInMillis()); } if (endYear.length() == 0 || endMonth.length() == 0 || endDay.length() == 0 || endHour.length() == 0 || endMinute.length() == 0) { // Undetermined end endTime = null; } else { // Convert the specified times to a long. Calendar c = new GregorianCalendar(); c.set(Calendar.YEAR,Integer.parseInt(endYear)); c.set(Calendar.MONTH,Integer.parseInt(endMonth)); c.set(Calendar.DAY_OF_MONTH,Integer.parseInt(endDay) + 1); c.set(Calendar.HOUR_OF_DAY,Integer.parseInt(endHour)); c.set(Calendar.MINUTE,Integer.parseInt(endMinute)); endTime = new Long(c.getTimeInMillis()); } } // Now, turn the startTime and endTime back into fielded values. The values will be blank where there is no limit. if (startTime == null) { startYear = ""; startMonth = ""; startDay = ""; startHour = ""; startMinute = ""; } else { // Do the conversion Calendar c = new GregorianCalendar(); c.setTimeInMillis(startTime.longValue()); startYear = Integer.toString(c.get(Calendar.YEAR)); startMonth = Integer.toString(c.get(Calendar.MONTH)); startDay = Integer.toString(c.get(Calendar.DAY_OF_MONTH)-1); startHour = Integer.toString(c.get(Calendar.HOUR_OF_DAY)); startMinute = Integer.toString(c.get(Calendar.MINUTE)); } if (endTime == null) { endYear = ""; endMonth = ""; endDay = ""; endHour = ""; endMinute = ""; } else { // Do the conversion Calendar c = new GregorianCalendar(); c.setTimeInMillis(endTime.longValue()); endYear = Integer.toString(c.get(Calendar.YEAR)); endMonth = Integer.toString(c.get(Calendar.MONTH)); endDay = Integer.toString(c.get(Calendar.DAY_OF_MONTH)-1); endHour = Integer.toString(c.get(Calendar.HOUR_OF_DAY)); endMinute = Integer.toString(c.get(Calendar.MINUTE)); } // Get the entity match string. String entityMatch = variableContext.getParameter("reportentitymatch"); if (entityMatch == null) entityMatch = ""; // Get the resultcode match string. String resultCodeMatch = variableContext.getParameter("reportresultcodematch"); if (resultCodeMatch == null) resultCodeMatch = ""; String reportBucketDesc = variableContext.getParameter("reportbucketdesc"); if (reportBucketDesc == null) reportBucketDesc = "(.*)"; String intervalString = variableContext.getParameter("reportinterval"); int interval = 5; if (intervalString != null && intervalString.length() > 0) interval = Integer.parseInt(intervalString); long intervalMilliseconds = ((long)interval) * 60L * 1000L; // Read the other data we need. IRepositoryConnectionManager connMgr = RepositoryConnectionManagerFactory.make(threadContext); IRepositoryConnection[] connList = connMgr.getAllConnections(); // Query the legal list of activities. This will depend on the connection has been chosen, if any. Map selectedActivities = null; String[] activityList = null; if (reportConnection.length() > 0) { activityList = org.apache.manifoldcf.crawler.system.ManifoldCF.getActivitiesList(threadContext,reportConnection); if (activityList == null) reportConnection = ""; else { selectedActivities = new HashMap(); String[] activitiesToNote; int j = 0; if (reportActivities == null) activitiesToNote = activityList; else activitiesToNote = reportActivities; while (j < activitiesToNote.length) { String activity = activitiesToNote[j++]; selectedActivities.put(activity,activity); } } } %> <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"maxactivityreport.ApacheManifoldCFMaximumActivityReport")%>

<%=Messages.getBodyString(pageContext.getRequest().getLocale(),"maxactivityreport.MaximumActivityReport")%>

<% if (reportConnection.length() > 0) { %> <% } else { %> <% } %>

<%=Messages.getBodyString(pageContext.getRequest().getLocale(),"maxactivityreport.Connection")%> <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"maxactivityreport.Activities")%>

<%=Messages.getBodyString(pageContext.getRequest().getLocale(),"maxactivityreport.StartTime")%> : <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"maxactivityreport.on")%> ,
<%=Messages.getBodyString(pageContext.getRequest().getLocale(),"maxactivityreport.EndTime")%> : <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"maxactivityreport.on")%> ,

<%=Messages.getBodyString(pageContext.getRequest().getLocale(),"maxactivityreport.EntityMatch")%> <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"maxactivityreport.ResultCodeMatch")%>

<%=Messages.getBodyString(pageContext.getRequest().getLocale(),"maxactivityreport.IdentifierClassDescription")%> <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"maxactivityreport.SlidingWindowSize")%>

<% if (reportConnection.length() > 0) { %> " onClick="javascript:Go()" alt="<%=Messages.getAttributeString(pageContext.getRequest().getLocale(),"maxactivityreport.ExecuteThisQuery")%>"/> <% } else { %> " onClick="javascript:Continue()" alt="<%=Messages.getAttributeString(pageContext.getRequest().getLocale(),"maxactivityreport.Continue")%>"/> <% } %>

<% if (reportConnection.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); String[] ourActivities = new String[selectedActivities.size()]; Iterator iter = selectedActivities.keySet().iterator(); int zz = 0; while (iter.hasNext()) { ourActivities[zz++] = (String)iter.next(); } RegExpCriteria entityMatchObject = null; if (entityMatch.length() > 0) entityMatchObject = new RegExpCriteria(entityMatch,true); RegExpCriteria resultCodeMatchObject = null; if (resultCodeMatch.length() > 0) resultCodeMatchObject = new RegExpCriteria(resultCodeMatch,true); FilterCriteria criteria = new FilterCriteria(ourActivities,startTime,endTime,entityMatchObject,resultCodeMatchObject); %> <% long count = connMgr.countHistoryRows(reportConnection,criteria); long maxCount = connMgr.getMaxRows(); boolean hasMoreRows; if (count > maxCount) { hasMoreRows = false; %>
You have selected <%=new Long(count).toString()%> rows. Maximum allowed is <%=new Long(maxCount).toString()%>.
<% } else { BucketDescription idBucket = new BucketDescription(reportBucketDesc,false); IResultSet set = connMgr.genHistoryActivityCount(reportConnection,criteria,sortOrder,idBucket, intervalMilliseconds,startRow,rowCount+1); %> <% zz = 0; hasMoreRows = (set.getRowCount() > rowCount); int iterCount = hasMoreRows?rowCount:set.getRowCount(); while (zz < iterCount) { IResultRow row = set.getRow(zz); Object idBucketObject = row.getValue("idbucket"); String idBucketString; if (idBucketObject == null) idBucketString = ""; else idBucketString = idBucketObject.toString(); String startTimeString = org.apache.manifoldcf.ui.util.Formatter.formatTime(Converter.asLong(row.getValue("starttime"))); String endTimeString = org.apache.manifoldcf.ui.util.Formatter.formatTime(Converter.asLong(row.getValue("endtime"))); double activityCount = Converter.asDouble(row.getValue("activitycount")); double activityRate = activityCount * 60000.0 / intervalMilliseconds; %> > <% zz++; } %>
<%=Messages.getBodyString(pageContext.getRequest().getLocale(),"maxactivityreport.IdentifierClass")%> <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"maxactivityreport.HighestActivityRate")%> <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"maxactivityreport.StartTime")%> <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"maxactivityreport.EndTime")%>
<%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(idBucketString)%> <%=new Double(activityRate).toString()%> <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(startTimeString)%> <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(endTimeString)%>
<% } %>
<% if (startRow == 0) { %> <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"maxactivityreport.Previous")%> <% } else { %> "><%=Messages.getBodyString(pageContext.getRequest().getLocale(),"maxactivityreport.Previous")%> <% } %> <% if (hasMoreRows == false) { %> <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"maxactivityreport.Next")%> <% } else { %> "><%=Messages.getBodyString(pageContext.getRequest().getLocale(),"maxactivityreport.Next")%> <% } %> <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"maxactivityreport.Rows")%> <%=Integer.toString(startRow)%>-<%=(hasMoreRows?Integer.toString(startRow+rowCount-1):"END")%> <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"maxactivityreport.RowsPerPage")%>
<% } else { %>
<%=Messages.getBodyString(pageContext.getRequest().getLocale(),"maxactivityreport.PleaseSelectAConnection")%>
<% } %>
<% } catch (ManifoldCFException e) { e.printStackTrace(); variableContext.setParameter("text",e.getMessage()); variableContext.setParameter("target","index.jsp"); %> <% } %>