%@ 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 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(clientTimezone, pageContext.getRequest().getLocale());
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(clientTimezone, pageContext.getRequest().getLocale());
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(clientTimezone, pageContext.getRequest().getLocale());
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(clientTimezone, pageContext.getRequest().getLocale());
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);
}
}
}
%>
<%
} catch (ManifoldCFException e)
{
e.printStackTrace();
variableContext.setParameter("text",e.getMessage());
variableContext.setParameter("target","index.jsp");
%>
<%
}
%>