You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2010/06/30 20:11:02 UTC
svn commit: r959393 - in /incubator/lcf/trunk/modules/framework/crawler-ui:
editauthority.jsp editconnection.jsp editjob.jsp editoutput.jsp execute.jsp
Author: kwright
Date: Wed Jun 30 18:11:02 2010
New Revision: 959393
URL: http://svn.apache.org/viewvc?rev=959393&view=rev
Log:
Fix for CONNECTORS-47. Refactor the contract between execute.jsp and all edit pages. This refactor prevents post methods from being called more than once in a page.
Modified:
incubator/lcf/trunk/modules/framework/crawler-ui/editauthority.jsp
incubator/lcf/trunk/modules/framework/crawler-ui/editconnection.jsp
incubator/lcf/trunk/modules/framework/crawler-ui/editjob.jsp
incubator/lcf/trunk/modules/framework/crawler-ui/editoutput.jsp
incubator/lcf/trunk/modules/framework/crawler-ui/execute.jsp
Modified: incubator/lcf/trunk/modules/framework/crawler-ui/editauthority.jsp
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/crawler-ui/editauthority.jsp?rev=959393&r1=959392&r2=959393&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/framework/crawler-ui/editauthority.jsp (original)
+++ incubator/lcf/trunk/modules/framework/crawler-ui/editauthority.jsp Wed Jun 30 18:11:02 2010
@@ -23,6 +23,9 @@
%>
<%
+ // The contract of this edit page is as follows. It is either called directly, in which case it is expected to be creating
+ // a connection or beginning the process of editing an existing connection, or it is called via redirection from execute.jsp, in which case
+ // the connection object being edited will be placed in the thread context under the name "ConnectionObject".
try
{
// Get the connection manager handle
@@ -30,46 +33,47 @@
// Also get the list of available connectors
IAuthorityConnectorManager connectorManager = AuthorityConnectorManagerFactory.make(threadContext);
+ // Figure out what the current tab name is.
String tabName = variableContext.getParameter("tabname");
if (tabName == null || tabName.length() == 0)
tabName = "Name";
- // In case this form posts to itself, we need to pick up everything we can.
- String connectionName = variableContext.getParameter("connname");
+ String connectionName = null;
+ IAuthorityConnection connection = (IAuthorityConnection)threadContext.get("ConnectionObject");
+ if (connection == null)
+ {
+ // We did not go through execute.jsp
+ // We might have received an argument specifying the connection name.
+ connectionName = variableContext.getParameter("connname");
+ // If the connectionname is not null, load the connection description and prepopulate everything with what comes from it.
+ if (connectionName != null && connectionName.length() > 0)
+ {
+ connection = connMgr.load(connectionName);
+ }
+ }
+
+ // Setup default fields
String description = "";
String className = "";
int maxConnections = 10;
ConfigParams parameters = new ConfigParams();
- IAuthorityConnection connection = null;
- // If the connectionname is not null, load the connection description and prepopulate everything with what comes from it.
- if (connectionName != null && connectionName.length() > 0)
+ if (connection != null)
{
- connection = connMgr.load(connectionName);
- if (connection != null)
- {
- // Set up values
- description = connection.getDescription();
- className = connection.getClassName();
- parameters = connection.getConfigParams();
- maxConnections = connection.getMaxConnections();
- }
+ // Set up values
+ connectionName = connection.getName();
+ description = connection.getDescription();
+ className = connection.getClassName();
+ parameters = connection.getConfigParams();
+ maxConnections = connection.getMaxConnections();
}
else
- connectionName = "";
+ connectionName = null;
- // Passed-in parameters override the current values
- String x;
- x = variableContext.getParameter("description");
- if (x != null && x.length() > 0)
- description = x;
- x = variableContext.getParameter("classname");
- if (x != null && x.length() > 0)
- className = x;
- x = variableContext.getParameter("maxconnections");
- if (x != null && x.length() > 0)
- maxConnections = Integer.parseInt(x);
+ if (connectionName == null)
+ connectionName = "";
+ // Initialize tabs array
ArrayList tabsArray = new ArrayList();
// Set up the predefined tabs
@@ -80,22 +84,6 @@
%>
-<%
- if (className.length() > 0)
- {
- String error = AuthorityConnectorFactory.processConfigurationPost(threadContext,className,variableContext,parameters);
- if (error != null)
- {
- variableContext.setParameter("text",error);
- variableContext.setParameter("target","listauthorities.jsp");
-%>
-<jsp:forward page="error.jsp"/>
-<%
- }
- }
-
-%>
-
<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
Modified: incubator/lcf/trunk/modules/framework/crawler-ui/editconnection.jsp
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/crawler-ui/editconnection.jsp?rev=959393&r1=959392&r2=959393&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/framework/crawler-ui/editconnection.jsp (original)
+++ incubator/lcf/trunk/modules/framework/crawler-ui/editconnection.jsp Wed Jun 30 18:11:02 2010
@@ -23,6 +23,9 @@
%>
<%
+ // The contract of this edit page is as follows. It is either called directly, in which case it is expected to be creating
+ // a connection or beginning the process of editing an existing connection, or it is called via redirection from execute.jsp, in which case
+ // the connection object being edited will be placed in the thread context under the name "ConnectionObject".
try
{
// Get the connection manager handle
@@ -31,14 +34,26 @@
IConnectorManager connectorManager = ConnectorManagerFactory.make(threadContext);
IAuthorityConnectionManager authConnectionManager = AuthorityConnectionManagerFactory.make(threadContext);
+ // Figure out what the current tab name is.
String tabName = variableContext.getParameter("tabname");
if (tabName == null || tabName.length() == 0)
tabName = "Name";
- // In case this form posts to itself, we need to pick up everything we can.
- String connectionName = variableContext.getParameter("connname");
- if (connectionName == null)
- connectionName = "";
+ String connectionName = null;
+ IRepositoryConnection connection = (IRepositoryConnection)threadContext.get("ConnectionObject");
+ if (connection == null)
+ {
+ // We did not go through execute.jsp
+ // We might have received an argument specifying the connection name.
+ connectionName = variableContext.getParameter("connname");
+ // If the connectionname is not null, load the connection description and prepopulate everything with what comes from it.
+ if (connectionName != null && connectionName.length() > 0)
+ {
+ connection = connMgr.load(connectionName);
+ }
+ }
+
+ // Set up default fields.
String description = "";
String className = "";
String authorityName = null;
@@ -47,118 +62,35 @@
ArrayList throttles = new ArrayList();
ConfigParams parameters = new ConfigParams();
- IRepositoryConnection connection = null;
-
- // If the connectionname is not null, load the connection description and prepopulate everything with what comes from it.
- if (connectionName != null && connectionName.length() > 0)
- {
- connection = connMgr.load(connectionName);
- if (connection != null)
- {
- // Set up values
- description = connection.getDescription();
- className = connection.getClassName();
- parameters = connection.getConfigParams();
- authorityName = connection.getACLAuthority();
- maxConnections = connection.getMaxConnections();
- String[] throttlesX = connection.getThrottles();
- int j = 0;
- while (j < throttlesX.length)
- {
- String throttleRegexp = throttlesX[j++];
- Map map = new HashMap();
- map.put("regexp",throttleRegexp);
- map.put("description",connection.getThrottleDescription(throttleRegexp));
- map.put("value",new Long((long)(((double)connection.getThrottleValue(throttleRegexp) * (double)60000.0) + 0.5)));
- throttles.add(map);
- }
- }
- }
- else
- connectionName = "";
-
- // Passed-in parameters override the current values
- String x;
- x = variableContext.getParameter("description");
- if (x != null)
- description = x;
- x = variableContext.getParameter("classname");
- if (x != null)
- className = x;
- x = variableContext.getParameter("authorityname");
- if (x != null && x.length() > 0)
- {
- if (x.equals("_none_"))
- authorityName = null;
- else
- authorityName = x;
- }
- x = variableContext.getParameter("maxconnections");
- if (x != null && x.length() > 0)
- {
- maxConnections = Integer.parseInt(x);
- }
-
- // Gather and edit the throttle stuff
- x = variableContext.getParameter("throttlecount");
- if (x != null)
+ // If there's a connection object, set up all our parameters from it.
+ if (connection != null)
{
- int throttleCount = Integer.parseInt(x);
- throttles.clear();
+ // Set up values
+ connectionName = connection.getName();
+ description = connection.getDescription();
+ className = connection.getClassName();
+ parameters = connection.getConfigParams();
+ authorityName = connection.getACLAuthority();
+ maxConnections = connection.getMaxConnections();
+ String[] throttlesX = connection.getThrottles();
int j = 0;
- while (j < throttleCount)
+ while (j < throttlesX.length)
{
+ String throttleRegexp = throttlesX[j++];
Map map = new HashMap();
- String regexp = variableContext.getParameter("throttle_"+Integer.toString(j));
- map.put("regexp",regexp);
- String desc = variableContext.getParameter("throttledesc_"+Integer.toString(j));
- map.put("description",desc);
- String value = variableContext.getParameter("throttlevalue_"+Integer.toString(j));
- map.put("value",new Long(value));
+ map.put("regexp",throttleRegexp);
+ map.put("description",connection.getThrottleDescription(throttleRegexp));
+ map.put("value",new Long((long)(((double)connection.getThrottleValue(throttleRegexp) * (double)60000.0) + 0.5)));
throttles.add(map);
- j++;
- }
- x = variableContext.getParameter("throttleop");
- if (x != null && x.equals("Delete"))
- {
- // Delete an item from the throttles list
- x = variableContext.getParameter("throttlenumber");
- throttles.remove(Integer.parseInt(x));
- }
- else if (x != null && x.equals("Add"))
- {
- // Add an item to the throttles list
- String regexp = variableContext.getParameter("throttle");
- String desc = variableContext.getParameter("throttledesc");
- Long value = new Long(variableContext.getParameter("throttlevalue"));
- Map newMap = new HashMap();
- newMap.put("regexp",regexp);
- newMap.put("description",desc);
- newMap.put("value",value);
- j = 0;
- while (j < throttles.size())
- {
- Map currentPos = (Map)throttles.get(j);
- String currentRegexp = (String)currentPos.get("regexp");
- int pos = regexp.compareTo(currentRegexp);
- if (pos == 0)
- {
- throttles.remove(j);
- throttles.add(j,newMap);
- break;
- }
- if (pos < 0)
- {
- throttles.add(j,newMap);
- break;
- }
- j++;
- }
- if (j == throttles.size())
- throttles.add(newMap);
}
}
+ else
+ connectionName = null;
+
+ if (connectionName == null)
+ connectionName = "";
+ // Initialize tabs array.
ArrayList tabsArray = new ArrayList();
// Set up the predefined tabs
@@ -169,21 +101,6 @@
%>
-<%
- if (className.length() > 0)
- {
- String error = RepositoryConnectorFactory.processConfigurationPost(threadContext,className,variableContext,parameters);
- if (error != null)
- {
- variableContext.setParameter("text",error);
- variableContext.setParameter("target","listconnections.jsp");
-%>
-<jsp:forward page="error.jsp"/>
-<%
- }
- }
-%>
-
<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
Modified: incubator/lcf/trunk/modules/framework/crawler-ui/editjob.jsp
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/crawler-ui/editjob.jsp?rev=959393&r1=959392&r2=959393&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/framework/crawler-ui/editjob.jsp (original)
+++ incubator/lcf/trunk/modules/framework/crawler-ui/editjob.jsp Wed Jun 30 18:11:02 2010
@@ -23,6 +23,10 @@
%>
<%
+ // The contract of this edit page is as follows. It is either called directly, in which case it is expected to be creating
+ // a job or beginning the process of editing an existing job, or it is called via redirection from execute.jsp, in which case
+ // the job object being edited will be placed in the thread context under the name "JobObject".
+ // It may also be called directly with a parameter of "origjobid", which implies that a copy operation should be started.
try
{
// Get the job manager handle
@@ -32,16 +36,29 @@
IOutputConnectionManager outputMgr = OutputConnectionManagerFactory.make(threadContext);
IOutputConnection[] outputList = outputMgr.getAllConnections();
- // Since this form posts to itself, we need to pick up everything we can.
- String jobID = variableContext.getParameter("jobid");
- String origJobID = variableContext.getParameter("origjobid");
- if (origJobID == null || origJobID.length() == 0)
- origJobID = jobID;
-
+ // Figure out tab name
String tabName = variableContext.getParameter("tabname");
if (tabName == null || tabName.length() == 0)
tabName = "Name";
+ // Get a loaded job object, somehow.
+ String jobID = null;
+ IJobDescription job = (IJobDescription)threadContext.get("JobObject");
+ if (job == null)
+ {
+ // We did not go through execute.jsp
+ // We might have received an argument specifying the connection name.
+ jobID = variableContext.getParameter("jobid");
+ String origJobID = variableContext.getParameter("origjobid");
+ if (origJobID == null || origJobID.length() == 0)
+ origJobID = jobID;
+ if (origJobID != null)
+ job = manager.load(new Long(origJobID));
+ }
+ else
+ jobID = job.getID().toString();
+
+ // Setup default fields
String connectionName = "";
String outputName = "";
String description = "";
@@ -74,10 +91,9 @@
// Hop filters
Map hopFilterMap = new HashMap();
- // If the jobID is not null, load the job description and prepopulate everything with what comes from it.
- if (origJobID != null)
+ // If the job is not null, prepopulate everything with what comes from it.
+ if (job != null)
{
- IJobDescription job = manager.load(new Long(origJobID));
// Set up values
description = job.getDescription();
outputName = job.getOutputConnectionName();
@@ -104,218 +120,6 @@
hopFilterMap = job.getHopCountFilters();
}
- // Passed-in parameters override the current values
- String x;
- x = variableContext.getParameter("outputname");
- if (x != null)
- outputName = x;
- x = variableContext.getParameter("connectionname");
- if (x != null)
- connectionName = x;
- x = variableContext.getParameter("description");
- if (x != null)
- description = x;
- x = variableContext.getParameter("scheduletype");
- if (x != null)
- type = Integer.parseInt(x);
- x = variableContext.getParameter("priority");
- if (x != null)
- priority = Integer.parseInt(x);
- x = variableContext.getParameter("recrawlinterval");
- if (x != null)
- {
- if (x.length() == 0)
- recrawlInterval = null;
- else
- recrawlInterval = new Long(x);
- }
- x = variableContext.getParameter("reseedinterval");
- if (x != null)
- {
- if (x.length() == 0)
- reseedInterval = null;
- else
- reseedInterval = new Long(x);
- }
- x = variableContext.getParameter("expirationinterval");
- if (x != null)
- {
- if (x.length() == 0)
- expirationInterval = null;
- else
- expirationInterval = new Long(x);
- }
- x = variableContext.getParameter("startmethod");
- if (x != null)
- startMethod = Integer.parseInt(x);
- x = variableContext.getParameter("hopcountmode");
- if (x != null)
- hopcountMode = Integer.parseInt(x);
-
- String[] y;
-
- // First, get the number of entries
- x = variableContext.getParameter("schedulerecords");
- if (x != null)
- {
- // Scan the schedule records that came in, and fill in the appropriate structure.
- scheduleRecords.clear();
- int recordCount = Integer.parseInt(x);
- int j = 0;
- while (j < recordCount)
- {
- String indexValue = Integer.toString(j);
- EnumeratedValues srDayOfWeek = null;
- EnumeratedValues srDayOfMonth = null;
- EnumeratedValues srMonthOfYear = null;
- EnumeratedValues srYear = null;
- EnumeratedValues srHourOfDay = null;
- EnumeratedValues srMinutesOfHour = null;
- Long srDuration = null;
-
- y = variableContext.getParameterValues("dayofweek"+indexValue);
- if (y != null)
- {
- if (y.length >= 1 && y[0].equals("none"))
- srDayOfWeek = null;
- else
- srDayOfWeek = new EnumeratedValues(y);
- }
- y = variableContext.getParameterValues("dayofmonth"+indexValue);
- if (y != null)
- {
- if (y.length >= 1 && y[0].equals("none"))
- srDayOfMonth = null;
- else
- srDayOfMonth = new EnumeratedValues(y);
- }
- y = variableContext.getParameterValues("monthofyear"+indexValue);
- if (y != null)
- {
- if (y.length >= 1 && y[0].equals("none"))
- srMonthOfYear = null;
- else
- srMonthOfYear = new EnumeratedValues(y);
- }
- y = variableContext.getParameterValues("year"+indexValue);
- if (y != null)
- {
- if (y.length >= 1 && y[0].equals("none"))
- srYear = null;
- else
- srYear = new EnumeratedValues(y);
- }
- y = variableContext.getParameterValues("hourofday"+indexValue);
- if (y != null)
- {
- if (y.length >= 1 && y[0].equals("none"))
- srHourOfDay = null;
- else
- srHourOfDay = new EnumeratedValues(y);
- }
- y = variableContext.getParameterValues("minutesofhour"+indexValue);
- if (y != null)
- {
- if (y.length >= 1 && y[0].equals("none"))
- srMinutesOfHour = null;
- else
- srMinutesOfHour = new EnumeratedValues(y);
- }
- x = variableContext.getParameter("duration"+indexValue);
- if (x != null)
- {
- if (x.length() == 0)
- srDuration = null;
- else
- srDuration = new Long(new Long(x).longValue()*60000L);
- }
-
- x = variableContext.getParameter("recordop"+indexValue);
- if (x == null || !x.equals("Remove Schedule"))
- {
- ScheduleRecord sr = new ScheduleRecord(srDayOfWeek,srMonthOfYear,srDayOfMonth,srYear,srHourOfDay,srMinutesOfHour,
- null,srDuration);
- scheduleRecords.add(sr);
- }
- j++;
- }
- }
-
- x = variableContext.getParameter("recordop");
- if (x != null && x.equals("Add Scheduled Time"))
- {
- EnumeratedValues srDayOfWeek = null;
- EnumeratedValues srDayOfMonth = null;
- EnumeratedValues srMonthOfYear = null;
- EnumeratedValues srYear = null;
- EnumeratedValues srHourOfDay = null;
- EnumeratedValues srMinutesOfHour = null;
- Long srDuration = null;
-
- y = variableContext.getParameterValues("dayofweek");
- if (y != null)
- {
- if (y.length >= 1 && y[0].equals("none"))
- srDayOfWeek = null;
- else
- srDayOfWeek = new EnumeratedValues(y);
- }
- y = variableContext.getParameterValues("dayofmonth");
- if (y != null)
- {
- if (y.length >= 1 && y[0].equals("none"))
- srDayOfMonth = null;
- else
- srDayOfMonth = new EnumeratedValues(y);
- }
- y = variableContext.getParameterValues("monthofyear");
- if (y != null)
- {
- if (y.length >= 1 && y[0].equals("none"))
- srMonthOfYear = null;
- else
- srMonthOfYear = new EnumeratedValues(y);
- }
- y = variableContext.getParameterValues("year");
- if (y != null)
- {
- if (y.length >= 1 && y[0].equals("none"))
- srYear = null;
- else
- srYear = new EnumeratedValues(y);
- }
- y = variableContext.getParameterValues("hourofday");
- if (y != null)
- {
- if (y.length >= 1 && y[0].equals("none"))
- srHourOfDay = null;
- else
- srHourOfDay = new EnumeratedValues(y);
- }
- y = variableContext.getParameterValues("minutesofhour");
- if (y != null)
- {
- if (y.length >= 1 && y[0].equals("none"))
- srMinutesOfHour = null;
- else
- srMinutesOfHour = new EnumeratedValues(y);
- }
- x = variableContext.getParameter("duration");
- if (x != null)
- {
- if (x.length() == 0)
- srDuration = null;
- else
- srDuration = new Long(new Long(x).longValue() * 60000L);
- }
- ScheduleRecord sr = new ScheduleRecord(srDayOfWeek,srMonthOfYear,srDayOfMonth,srYear,srHourOfDay,srMinutesOfHour,
- null,srDuration);
- scheduleRecords.add(sr);
- }
-
- x = variableContext.getParameter("priority");
- if (x != null)
- priority = Integer.parseInt(x);
// This form reposts to itself. It basically only allows the connection to be picked once; once done, the repost occurs
// and cannot be undone.
@@ -336,21 +140,12 @@
connection = connMgr.load(connectionName);
model = RepositoryConnectorFactory.getConnectorModel(threadContext,connection.getClassName());
relationshipTypes = RepositoryConnectorFactory.getRelationshipTypes(threadContext,connection.getClassName());
- //threadContext.save("DocumentSpecification",documentSpecification);
- //threadContext.save("RepositoryConnection",connection);
}
if (outputName.length() > 0)
{
outputConnection = outputMgr.load(outputName);
- //threadContext.save("OutputSpecification",outputSpecification);
- //threadContext.save("OutputConnection",connection);
}
- // Assert the following variables regardless of connection choice/non-choice
- //threadContext.save("ScheduleCount",Integer.toString(scheduleRecords.size()));
- //threadContext.save("Tabs",tabsArray);
- //threadContext.save("TabName",tabName);
-
// Set up the predefined tabs
tabsArray.add("Name");
tabsArray.add("Connection");
@@ -361,78 +156,7 @@
tabsArray.add("Hop Filters");
}
- // Gather hopcount filters
- if (relationshipTypes != null)
- {
- x = variableContext.getParameter("hopfilters");
- if (x != null)
- {
- hopFilterMap.clear();
- int j = 0;
- while (j < relationshipTypes.length)
- {
- String relationshipType = relationshipTypes[j++];
- String hopMax = variableContext.getParameter("hopmax_"+relationshipType);
- if (hopMax != null && hopMax.length() > 0)
- hopFilterMap.put(relationshipType,new Long(hopMax));
- }
- }
- }
-
-%>
-
-<%
- if (outputConnection != null)
- {
- IOutputConnector outputConnector = OutputConnectorFactory.grab(threadContext,outputConnection.getClassName(),outputConnection.getConfigParams(),
- outputConnection.getMaxConnections());
- if (outputConnector != null)
- {
- try
- {
- String error = outputConnector.processSpecificationPost(variableContext,outputSpecification);
- if (error != null)
- {
- variableContext.setParameter("text",error);
- variableContext.setParameter("target","listjobs.jsp");
-%>
- <jsp:forward page="error.jsp"/>
-<%
- }
- }
- finally
- {
- OutputConnectorFactory.release(outputConnector);
- }
- }
- }
-%>
-<%
- if (connection != null)
- {
- IRepositoryConnector repositoryConnector = RepositoryConnectorFactory.grab(threadContext,connection.getClassName(),connection.getConfigParams(),
- connection.getMaxConnections());
- if (repositoryConnector != null)
- {
- try
- {
- String error = repositoryConnector.processSpecificationPost(variableContext,documentSpecification);
- if (error != null)
- {
- variableContext.setParameter("text",error);
- variableContext.setParameter("target","listjobs.jsp");
-%>
- <jsp:forward page="error.jsp"/>
-<%
- }
- }
- finally
- {
- RepositoryConnectorFactory.release(repositoryConnector);
- }
- }
- }
%>
<?xml version="1.0" encoding="utf-8"?>
Modified: incubator/lcf/trunk/modules/framework/crawler-ui/editoutput.jsp
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/crawler-ui/editoutput.jsp?rev=959393&r1=959392&r2=959393&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/framework/crawler-ui/editoutput.jsp (original)
+++ incubator/lcf/trunk/modules/framework/crawler-ui/editoutput.jsp Wed Jun 30 18:11:02 2010
@@ -23,6 +23,9 @@
%>
<%
+ // The contract of this edit page is as follows. It is either called directly, in which case it is expected to be creating
+ // a connection or beginning the process of editing an existing connection, or it is called via redirection from execute.jsp, in which case
+ // the connection object being edited will be placed in the thread context under the name "ConnectionObject".
try
{
// Get the connection manager handle
@@ -30,51 +33,45 @@
// Also get the list of available connectors
IOutputConnectorManager connectorManager = OutputConnectorManagerFactory.make(threadContext);
+ // Figure out what the current tab name is.
String tabName = variableContext.getParameter("tabname");
if (tabName == null || tabName.length() == 0)
tabName = "Name";
- // In case this form posts to itself, we need to pick up everything we can.
- String connectionName = variableContext.getParameter("connname");
- if (connectionName == null)
- connectionName = "";
+ String connectionName = null;
+ IOutputConnection connection = (IOutputConnection)threadContext.get("ConnectionObject");
+ if (connection == null)
+ {
+ // We did not go through execute.jsp
+ // We might have received an argument specifying the connection name.
+ connectionName = variableContext.getParameter("connname");
+ // If the connectionname is not null, load the connection description and prepopulate everything with what comes from it.
+ if (connectionName != null && connectionName.length() > 0)
+ {
+ connection = connMgr.load(connectionName);
+ }
+ }
+
+ // Set up default fields.
String description = "";
String className = "";
int maxConnections = 10;
ConfigParams parameters = new ConfigParams();
- IOutputConnection connection = null;
-
- // If the connectionname is not null, load the connection description and prepopulate everything with what comes from it.
- if (connectionName != null && connectionName.length() > 0)
+ // If there's a connection object, set up all our parameters from it.
+ if (connection != null)
{
- connection = connMgr.load(connectionName);
- if (connection != null)
- {
- // Set up values
- description = connection.getDescription();
- className = connection.getClassName();
- parameters = connection.getConfigParams();
- maxConnections = connection.getMaxConnections();
- }
+ // Set up values
+ connectionName = connection.getName();
+ description = connection.getDescription();
+ className = connection.getClassName();
+ parameters = connection.getConfigParams();
+ maxConnections = connection.getMaxConnections();
}
else
- connectionName = "";
-
- // Passed-in parameters override the current values
- String x;
- x = variableContext.getParameter("description");
- if (x != null)
- description = x;
- x = variableContext.getParameter("classname");
- if (x != null)
- className = x;
- x = variableContext.getParameter("maxconnections");
- if (x != null && x.length() > 0)
- {
- maxConnections = Integer.parseInt(x);
- }
+ connectionName = null;
+ // Initialize tabs array.
ArrayList tabsArray = new ArrayList();
// Set up the predefined tabs
@@ -85,21 +82,6 @@
%>
-<%
- if (className.length() > 0)
- {
- String error = OutputConnectorFactory.processConfigurationPost(threadContext,className,variableContext,parameters);
- if (error != null)
- {
- variableContext.setParameter("text",error);
- variableContext.setParameter("target","listoutputs.jsp");
-%>
-<jsp:forward page="error.jsp"/>
-<%
- }
- }
-%>
-
<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
Modified: incubator/lcf/trunk/modules/framework/crawler-ui/execute.jsp
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/modules/framework/crawler-ui/execute.jsp?rev=959393&r1=959392&r2=959393&view=diff
==============================================================================
--- incubator/lcf/trunk/modules/framework/crawler-ui/execute.jsp (original)
+++ incubator/lcf/trunk/modules/framework/crawler-ui/execute.jsp Wed Jun 30 18:11:02 2010
@@ -49,40 +49,417 @@
IAuthorityConnectionManager authConnManager = AuthorityConnectionManagerFactory.make(threadContext);
IOutputConnectionManager outputManager = OutputConnectionManagerFactory.make(threadContext);
+ String type = variableContext.getParameter("type");
String op = variableContext.getParameter("op");
+ if (type != null && op != null && type.equals("connection"))
+ {
+ // -- Connection editing operations --
+ if (op.equals("Save") || op.equals("Continue"))
+ {
+ try
+ {
+ // Set up a connection object that is a merge of an existing connection object plus what was posted.
+ IRepositoryConnection connection = null;
+ String connectionName = variableContext.getParameter("connname");
+ // If the connectionname is not null, load the connection description and prepopulate everything with what comes from it.
+ if (connectionName != null && connectionName.length() > 0)
+ {
+ connection = connManager.load(connectionName);
+ }
+
+ if (connection == null)
+ {
+ connection = connManager.create();
+ if (connectionName != null && connectionName.length() > 0)
+ connection.setName(connectionName);
+ }
+
+ // Fill in connection object from posted data
+ String x = variableContext.getParameter("description");
+ if (x != null)
+ connection.setDescription(x);
+ x = variableContext.getParameter("classname");
+ if (x != null)
+ connection.setClassName(x);
+ x = variableContext.getParameter("authorityname");
+ if (x != null && x.length() > 0)
+ {
+ if (x.equals("_none_"))
+ connection.setACLAuthority(null);
+ else
+ connection.setACLAuthority(x);
+ }
+ x = variableContext.getParameter("maxconnections");
+ if (x != null && x.length() > 0)
+ connection.setMaxConnections(Integer.parseInt(x));
+
+ // Gather and save throttles
+ x = variableContext.getParameter("throttlecount");
+ if (x != null)
+ {
+ int throttleCount = Integer.parseInt(x);
+ connection.clearThrottleValues();
+ int j = 0;
+ while (j < throttleCount)
+ {
+ String regexp = variableContext.getParameter("throttle_"+Integer.toString(j));
+ String desc = variableContext.getParameter("throttledesc_"+Integer.toString(j));
+ if (desc == null)
+ desc = "";
+ String value = variableContext.getParameter("throttlevalue_"+Integer.toString(j));
+ connection.addThrottleValue(regexp,desc,(float)(((double)new Long(value).longValue())/(double)(60000.0)));
+ j++;
+ }
+ x = variableContext.getParameter("throttleop");
+ if (x != null && x.equals("Delete"))
+ {
+ // Delete an item from the throttles list
+ x = variableContext.getParameter("throttlenumber");
+ String regexp = variableContext.getParameter("throttle_"+x);
+ connection.deleteThrottleValue(regexp);
+ }
+ else if (x != null && x.equals("Add"))
+ {
+ // Add an item to the throttles list
+ String regexp = variableContext.getParameter("throttle");
+ String desc = variableContext.getParameter("throttledesc");
+ if (desc == null)
+ desc = "";
+ Long value = new Long(variableContext.getParameter("throttlevalue"));
+ connection.addThrottleValue(regexp,desc,(float)(((double)value.longValue())/(double)(60000.0)));
+ }
+ }
+
+ String error = RepositoryConnectorFactory.processConfigurationPost(threadContext,connection.getClassName(),variableContext,connection.getConfigParams());
+
+ if (error != null)
+ {
+ variableContext.setParameter("text",error);
+ variableContext.setParameter("target","listconnections.jsp");
+%>
+ <jsp:forward page="error.jsp"/>
+<%
+ }
+
+ if (op.equals("Continue"))
+ {
+ threadContext.save("ConnectionObject",connection);
+%>
+ <jsp:forward page="editconnection.jsp"/>
+<%
+ }
+ else if (op.equals("Save"))
+ {
+ connManager.save(connection);
+ variableContext.setParameter("connname",connectionName);
+%>
+ <jsp:forward page="viewconnection.jsp"/>
+<%
+ }
+ }
+ catch (LCFException e)
+ {
+ e.printStackTrace();
+ variableContext.setParameter("text",e.getMessage());
+ variableContext.setParameter("target","listconnections.jsp");
+%>
+ <jsp:forward page="error.jsp"/>
+<%
+ }
+ }
+ else if (op.equals("Delete"))
+ {
+ try
+ {
+ String connectionName = variableContext.getParameter("connname");
+ if (connectionName == null)
+ throw new LCFException("Missing connection parameter");
+ connManager.delete(connectionName);
+%>
+ <jsp:forward page="listconnections.jsp"/>
+<%
+ }
+ catch (LCFException e)
+ {
+ e.printStackTrace();
+ variableContext.setParameter("text",e.getMessage());
+ variableContext.setParameter("target","listconnections.jsp");
+%>
+ <jsp:forward page="error.jsp"/>
+<%
+ }
+ }
+ else if (op.equals("Cancel"))
+ {
+%>
+ <jsp:forward page="listconnections.jsp"/>
+<%
+ }
+ else
+ {
+ // Error
+ variableContext.setParameter("text","Illegal parameter to connection execution page");
+ variableContext.setParameter("target","listconnections.jsp");
+%>
+ <jsp:forward page="error.jsp"/>
+<%
+ }
+ }
+ else if (type != null && op != null && type.equals("authority"))
+ {
+ // -- Authority editing operations --
+ if (op.equals("Save") || op.equals("Continue"))
+ {
+ try
+ {
+ // Set up a connection object that is a merge of an existing connection object plus what was posted.
+ IAuthorityConnection connection = null;
+ String connectionName = variableContext.getParameter("connname");
+ // If the connectionname is not null, load the connection description and prepopulate everything with what comes from it.
+ if (connectionName != null && connectionName.length() > 0)
+ {
+ connection = authConnManager.load(connectionName);
+ }
+
+ if (connection == null)
+ {
+ connection = authConnManager.create();
+ if (connectionName != null && connectionName.length() > 0)
+ connection.setName(connectionName);
+ }
+
+ // Gather all the data from the form.
+ String x = variableContext.getParameter("description");
+ if (x != null)
+ connection.setDescription(x);
+ x = variableContext.getParameter("classname");
+ if (x != null)
+ connection.setClassName(x);
+ x = variableContext.getParameter("maxconnections");
+ if (x != null && x.length() > 0)
+ connection.setMaxConnections(Integer.parseInt(x));
- if (op != null)
+ String error = AuthorityConnectorFactory.processConfigurationPost(threadContext,connection.getClassName(),variableContext,connection.getConfigParams());
+
+ if (error != null)
+ {
+ variableContext.setParameter("text",error);
+ variableContext.setParameter("target","listauthorities.jsp");
+%>
+ <jsp:forward page="error.jsp"/>
+<%
+ }
+
+ if (op.equals("Continue"))
+ {
+ threadContext.save("ConnectionObject",connection);
+%>
+ <jsp:forward page="editauthority.jsp"/>
+<%
+ }
+ else if (op.equals("Save"))
+ {
+ authConnManager.save(connection);
+ variableContext.setParameter("connname",connectionName);
+%>
+ <jsp:forward page="viewauthority.jsp"/>
+<%
+ }
+ }
+ catch (LCFException e)
+ {
+ e.printStackTrace();
+ variableContext.setParameter("text",e.getMessage());
+ variableContext.setParameter("target","listauthorities.jsp");
+%>
+ <jsp:forward page="error.jsp"/>
+<%
+ }
+ }
+ else if (op.equals("Delete"))
+ {
+ try
+ {
+ String connectionName = variableContext.getParameter("connname");
+ if (connectionName == null)
+ throw new LCFException("Missing connection parameter");
+ authConnManager.delete(connectionName);
+%>
+ <jsp:forward page="listauthorities.jsp"/>
+<%
+ }
+ catch (LCFException e)
+ {
+ e.printStackTrace();
+ variableContext.setParameter("text",e.getMessage());
+ variableContext.setParameter("target","listauthorities.jsp");
+%>
+ <jsp:forward page="error.jsp"/>
+<%
+ }
+ }
+ else if (op.equals("Cancel"))
+ {
+%>
+ <jsp:forward page="listauthorities.jsp"/>
+<%
+ }
+ else
+ {
+ // Error
+ variableContext.setParameter("text","Illegal parameter to authority execution page");
+ variableContext.setParameter("target","listauthorities.jsp");
+%>
+ <jsp:forward page="error.jsp"/>
+<%
+ }
+ }
+ else if (type != null && op != null && type.equals("output"))
{
- if (op.equals("Report") || op.equals("Status"))
- {
- String type = variableContext.getParameter("type");
- if (type != null)
+ // -- Output connection editing operations --
+ if (op.equals("Save") || op.equals("Continue"))
+ {
+ try
+ {
+ // Set up a connection object that is a merge of an existing connection object plus what was posted.
+ IOutputConnection connection = null;
+ String connectionName = variableContext.getParameter("connname");
+ // If the connectionname is not null, load the connection description and prepopulate everything with what comes from it.
+ if (connectionName != null && connectionName.length() > 0)
+ {
+ connection = outputManager.load(connectionName);
+ }
+
+ if (connection == null)
+ {
+ connection = outputManager.create();
+ if (connectionName != null && connectionName.length() > 0)
+ connection.setName(connectionName);
+ }
+
+ // Gather all the data from the form.
+ String x = variableContext.getParameter("description");
+ if (x != null)
+ connection.setDescription(x);
+ x = variableContext.getParameter("classname");
+ if (x != null)
+ connection.setClassName(x);
+ x = variableContext.getParameter("maxconnections");
+ if (x != null && x.length() > 0)
+ connection.setMaxConnections(Integer.parseInt(x));
+
+ String error = OutputConnectorFactory.processConfigurationPost(threadContext,connection.getClassName(),variableContext,connection.getConfigParams());
+
+ if (error != null)
+ {
+ variableContext.setParameter("text",error);
+ variableContext.setParameter("target","listoutputs.jsp");
+%>
+ <jsp:forward page="error.jsp"/>
+<%
+ }
+
+ if (op.equals("Continue"))
+ {
+ threadContext.save("ConnectionObject",connection);
+%>
+ <jsp:forward page="editoutput.jsp"/>
+<%
+ }
+ else if (op.equals("Save"))
+ {
+ outputManager.save(connection);
+ variableContext.setParameter("connname",connectionName);
+%>
+ <jsp:forward page="viewoutput.jsp"/>
+<%
+ }
+ }
+ catch (LCFException e)
+ {
+ e.printStackTrace();
+ variableContext.setParameter("text",e.getMessage());
+ variableContext.setParameter("target","listoutputs.jsp");
+%>
+ <jsp:forward page="error.jsp"/>
+<%
+ }
+ }
+ else if (op.equals("Delete"))
{
+ try
+ {
+ String connectionName = variableContext.getParameter("connname");
+ if (connectionName == null)
+ throw new LCFException("Missing connection parameter");
+ outputManager.delete(connectionName);
%>
- <jsp:forward page='<%=type+".jsp"%>'/>
+ <jsp:forward page="listoutputs.jsp"/>
+<%
+ }
+ catch (LCFException e)
+ {
+ e.printStackTrace();
+ variableContext.setParameter("text",e.getMessage());
+ variableContext.setParameter("target","listoutputs.jsp");
+%>
+ <jsp:forward page="error.jsp"/>
+<%
+ }
+ }
+ else if (op.equals("Cancel"))
+ {
+%>
+ <jsp:forward page="listoutputs.jsp"/>
+<%
+ }
+ else if (op.equals("ReingestAll"))
+ {
+ try
+ {
+ String connectionName = variableContext.getParameter("connname");
+ if (connectionName == null)
+ throw new LCFException("Missing connection parameter");
+ org.apache.lcf.agents.system.LCF.signalOutputConnectionRedo(threadContext,connectionName);
+%>
+ <jsp:forward page="listoutputs.jsp"/>
+<%
+ }
+ catch (LCFException e)
+ {
+ e.printStackTrace();
+ variableContext.setParameter("text",e.getMessage());
+ variableContext.setParameter("target","listoutputs.jsp");
+%>
+ <jsp:forward page="error.jsp"/>
+<%
+ }
+ }
+ else
+ {
+ // Error
+ variableContext.setParameter("text","Illegal parameter to output connection execution page");
+ variableContext.setParameter("target","listoutputs.jsp");
+%>
+ <jsp:forward page="error.jsp"/>
<%
}
- }
- else if (op.equals("Save"))
- {
- // Save operation.
- // There are two different kinds of save: for jobs, and for repository connections.
- String type = variableContext.getParameter("type");
- if (type != null && type.equals("job"))
+ }
+ else if (type != null && op != null && type.equals("job"))
+ {
+ // -- Job editing operations --
+ if (op.equals("Save") || op.equals("Continue"))
{
- // Saving a job.
try
{
String jobID = variableContext.getParameter("jobid");
- IJobDescription job;
- if (jobID == null)
- job = manager.createJob();
- else
+ IJobDescription job = null;
+ if (jobID != null)
{
job = manager.load(new Long(jobID));
- if (job == null)
- throw new LCFException("No such job: "+jobID);
}
+ if (job == null)
+ job = manager.createJob();
// Gather all the data from the form.
String x = variableContext.getParameter("description");
@@ -180,428 +557,229 @@
else
srDuration = new Long(new Long(x).longValue()*60000L);
}
- ScheduleRecord sr = new ScheduleRecord(srDayOfWeek,srMonthOfYear,srDayOfMonth,srYear,srHourOfDay,srMinutesOfHour,
- null,srDuration);
- job.addScheduleRecord(sr);
+
+ x = variableContext.getParameter("recordop"+j);
+ if (x == null || !x.equals("Remove Schedule"))
+ {
+ ScheduleRecord sr = new ScheduleRecord(srDayOfWeek,srMonthOfYear,srDayOfMonth,srYear,srHourOfDay,srMinutesOfHour,
+ null,srDuration);
+ job.addScheduleRecord(sr);
+ }
j++;
}
}
- x = variableContext.getParameter("priority");
- if (x != null)
- job.setPriority(Integer.parseInt(x));
- x = variableContext.getParameter("recrawlinterval");
- if (x != null)
- {
- if (x.length() == 0)
- job.setInterval(null);
- else
- job.setInterval(new Long(new Long(x).longValue() * 60000L));
- }
- x = variableContext.getParameter("reseedinterval");
- if (x != null)
- {
- if (x.length() == 0)
- job.setReseedInterval(null);
- else
- job.setReseedInterval(new Long(new Long(x).longValue() * 60000L));
- }
- x = variableContext.getParameter("expirationinterval");
- if (x != null)
- {
- if (x.length() == 0)
- job.setExpiration(null);
- else
- job.setExpiration(new Long(new Long(x).longValue() * 60000L));
- }
+ // Check for operation that adds to schedule
+ x = variableContext.getParameter("recordop");
+ if (x != null && x.equals("Add Scheduled Time"))
+ {
+ EnumeratedValues srDayOfWeek = null;
+ EnumeratedValues srDayOfMonth = null;
+ EnumeratedValues srMonthOfYear = null;
+ EnumeratedValues srYear = null;
+ EnumeratedValues srHourOfDay = null;
+ EnumeratedValues srMinutesOfHour = null;
+ Long srDuration = null;
- IRepositoryConnection connection = connManager.load(job.getConnectionName());
- IOutputConnection outputConnection = outputManager.load(job.getOutputConnectionName());
- String[] relationshipTypes = RepositoryConnectorFactory.getRelationshipTypes(threadContext,connection.getClassName());
-
- // Gather hopcount filters
- x = variableContext.getParameter("hopfilters");
- if (x != null && relationshipTypes != null)
- {
- job.clearHopCountFilters();
- int j = 0;
- job.clearHopCountFilters();
- while (j < relationshipTypes.length)
+ y = variableContext.getParameterValues("dayofweek");
+ if (y != null)
{
- String relationshipType = relationshipTypes[j++];
- x = variableContext.getParameter("hopmax_"+relationshipType);
- if (x != null && x.length() > 0)
- {
- job.addHopCountFilter(relationshipType,new Long(x));
- }
- }
- }
-
- IOutputConnector outputConnector = OutputConnectorFactory.grab(threadContext,
- outputConnection.getClassName(),outputConnection.getConfigParams(),outputConnection.getMaxConnections());
- if (outputConnector != null)
- {
- try
- {
- String error = outputConnector.processSpecificationPost(variableContext,job.getOutputSpecification());
- if (error != null)
- {
- variableContext.setParameter("text",error);
- variableContext.setParameter("target","listjobs.jsp");
-%>
- <jsp:forward page="error.jsp"/>
-<%
- }
+ if (y.length >= 1 && y[0].equals("none"))
+ srDayOfWeek = null;
+ else
+ srDayOfWeek = new EnumeratedValues(y);
}
- finally
+ y = variableContext.getParameterValues("dayofmonth");
+ if (y != null)
{
- OutputConnectorFactory.release(outputConnector);
+ if (y.length >= 1 && y[0].equals("none"))
+ srDayOfMonth = null;
+ else
+ srDayOfMonth = new EnumeratedValues(y);
}
- }
-
- IRepositoryConnector repositoryConnector = RepositoryConnectorFactory.grab(threadContext,
- connection.getClassName(),connection.getConfigParams(),connection.getMaxConnections());
- if (repositoryConnector != null)
- {
- try
+ y = variableContext.getParameterValues("monthofyear");
+ if (y != null)
{
- String error = repositoryConnector.processSpecificationPost(variableContext,job.getSpecification());
- if (error != null)
- {
- variableContext.setParameter("text",error);
- variableContext.setParameter("target","listjobs.jsp");
-%>
- <jsp:forward page="error.jsp"/>
-<%
- }
+ if (y.length >= 1 && y[0].equals("none"))
+ srMonthOfYear = null;
+ else
+ srMonthOfYear = new EnumeratedValues(y);
}
- finally
+ y = variableContext.getParameterValues("year");
+ if (y != null)
{
- RepositoryConnectorFactory.release(repositoryConnector);
+ if (y.length >= 1 && y[0].equals("none"))
+ srYear = null;
+ else
+ srYear = new EnumeratedValues(y);
}
- }
-
- manager.save(job);
- // Reset the job schedule. We may want to make this explicit at some point; having
- // this happen all the time seems wrong.
- manager.resetJobSchedule(job.getID());
- variableContext.setParameter("jobid",job.getID().toString());
-%>
- <jsp:forward page="viewjob.jsp"/>
-<%
-
- }
- catch (LCFException e)
- {
- e.printStackTrace();
- variableContext.setParameter("text",e.getMessage());
- variableContext.setParameter("target","listjobs.jsp");
-%>
- <jsp:forward page="error.jsp"/>
-<%
- }
- }
- else if (type != null && type.equals("output"))
- {
- // Saving a connection.
- try
- {
- String connectionName = variableContext.getParameter("connname");
- IOutputConnection connection = outputManager.load(connectionName);
- if (connection == null)
- {
- connection = outputManager.create();
- connection.setName(connectionName);
- }
-
- // Gather all the data from the form.
- String x = variableContext.getParameter("description");
- if (x != null)
- connection.setDescription(x);
- x = variableContext.getParameter("classname");
- if (x != null)
- connection.setClassName(x);
- x = variableContext.getParameter("maxconnections");
- if (x != null && x.length() > 0)
- connection.setMaxConnections(Integer.parseInt(x));
-
- String error = OutputConnectorFactory.processConfigurationPost(threadContext,connection.getClassName(),variableContext,connection.getConfigParams());
-
- if (error != null)
- {
- variableContext.setParameter("text",error);
- variableContext.setParameter("target","listoutputs.jsp");
-%>
- <jsp:forward page="error.jsp"/>
-<%
- }
- outputManager.save(connection);
- variableContext.setParameter("connname",connectionName);
-%>
- <jsp:forward page="viewoutput.jsp"/>
-<%
- }
- catch (LCFException e)
- {
- e.printStackTrace();
- variableContext.setParameter("text",e.getMessage());
- variableContext.setParameter("target","listoutputs.jsp");
-%>
- <jsp:forward page="error.jsp"/>
-<%
- }
- }
- else if (type != null && type.equals("connection"))
- {
- // Saving a connection.
- try
- {
- String connectionName = variableContext.getParameter("connname");
- IRepositoryConnection connection = connManager.load(connectionName);
- if (connection == null)
- {
- connection = connManager.create();
- connection.setName(connectionName);
- }
-
- // Gather all the data from the form.
- String x = variableContext.getParameter("description");
- if (x != null)
- connection.setDescription(x);
- x = variableContext.getParameter("classname");
- if (x != null)
- connection.setClassName(x);
- x = variableContext.getParameter("authorityname");
- if (x != null && x.length() > 0)
- {
- if (x.equals("_none_"))
- connection.setACLAuthority(null);
- else
- connection.setACLAuthority(x);
- }
- x = variableContext.getParameter("maxconnections");
- if (x != null && x.length() > 0)
- connection.setMaxConnections(Integer.parseInt(x));
-
- // Gather and save throttles
- x = variableContext.getParameter("throttlecount");
- if (x != null)
- {
- int throttleCount = Integer.parseInt(x);
- connection.clearThrottleValues();
- int j = 0;
- while (j < throttleCount)
+ y = variableContext.getParameterValues("hourofday");
+ if (y != null)
{
- String regexp = variableContext.getParameter("throttle_"+Integer.toString(j));
- String desc = variableContext.getParameter("throttledesc_"+Integer.toString(j));
- if (desc == null)
- desc = "";
- String value = variableContext.getParameter("throttlevalue_"+Integer.toString(j));
- connection.addThrottleValue(regexp,desc,(float)(((double)new Long(value).longValue())/(double)(60000.0)));
- j++;
+ if (y.length >= 1 && y[0].equals("none"))
+ srHourOfDay = null;
+ else
+ srHourOfDay = new EnumeratedValues(y);
}
- x = variableContext.getParameter("throttleop");
- if (x != null && x.equals("Delete"))
+ y = variableContext.getParameterValues("minutesofhour");
+ if (y != null)
{
- // Delete an item from the throttles list
- x = variableContext.getParameter("throttlenumber");
- String regexp = variableContext.getParameter("throttle_"+x);
- connection.deleteThrottleValue(regexp);
+ if (y.length >= 1 && y[0].equals("none"))
+ srMinutesOfHour = null;
+ else
+ srMinutesOfHour = new EnumeratedValues(y);
}
- else if (x != null && x.equals("Add"))
+ x = variableContext.getParameter("duration");
+ if (x != null)
{
- // Add an item to the throttles list
- String regexp = variableContext.getParameter("throttle");
- String desc = variableContext.getParameter("throttledesc");
- if (desc == null)
- desc = "";
- Long value = new Long(variableContext.getParameter("throttlevalue"));
- connection.addThrottleValue(regexp,desc,(float)(((double)value.longValue())/(double)(60000.0)));
+ if (x.length() == 0)
+ srDuration = null;
+ else
+ srDuration = new Long(new Long(x).longValue() * 60000L);
}
+ ScheduleRecord sr = new ScheduleRecord(srDayOfWeek,srMonthOfYear,srDayOfMonth,srYear,srHourOfDay,srMinutesOfHour,
+ null,srDuration);
+ job.addScheduleRecord(sr);
}
- String error = RepositoryConnectorFactory.processConfigurationPost(threadContext,connection.getClassName(),variableContext,connection.getConfigParams());
-
- if (error != null)
- {
- variableContext.setParameter("text",error);
- variableContext.setParameter("target","listconnections.jsp");
-%>
- <jsp:forward page="error.jsp"/>
-<%
- }
-
- connManager.save(connection);
- variableContext.setParameter("connname",connectionName);
-%>
- <jsp:forward page="viewconnection.jsp"/>
-<%
- }
- catch (LCFException e)
- {
- e.printStackTrace();
- variableContext.setParameter("text",e.getMessage());
- variableContext.setParameter("target","listconnections.jsp");
-%>
- <jsp:forward page="error.jsp"/>
-<%
- }
- }
- else if (type != null && type.equals("authority"))
- {
- // Saving a connection.
- try
- {
- String connectionName = variableContext.getParameter("connname");
- IAuthorityConnection connection = authConnManager.load(connectionName);
- if (connection == null)
+ x = variableContext.getParameter("priority");
+ if (x != null)
+ job.setPriority(Integer.parseInt(x));
+ x = variableContext.getParameter("recrawlinterval");
+ if (x != null)
{
- connection = authConnManager.create();
- connection.setName(connectionName);
+ if (x.length() == 0)
+ job.setInterval(null);
+ else
+ job.setInterval(new Long(new Long(x).longValue() * 60000L));
}
-
- // Gather all the data from the form.
- String x = variableContext.getParameter("description");
+ x = variableContext.getParameter("reseedinterval");
if (x != null)
- connection.setDescription(x);
- x = variableContext.getParameter("classname");
+ {
+ if (x.length() == 0)
+ job.setReseedInterval(null);
+ else
+ job.setReseedInterval(new Long(new Long(x).longValue() * 60000L));
+ }
+ x = variableContext.getParameter("expirationinterval");
if (x != null)
- connection.setClassName(x);
- x = variableContext.getParameter("maxconnections");
- if (x != null && x.length() > 0)
- connection.setMaxConnections(Integer.parseInt(x));
-
- String error = AuthorityConnectorFactory.processConfigurationPost(threadContext,connection.getClassName(),variableContext,connection.getConfigParams());
-
- if (error != null)
{
- variableContext.setParameter("text",error);
- variableContext.setParameter("target","listauthorities.jsp");
-%>
- <jsp:forward page="error.jsp"/>
-<%
+ if (x.length() == 0)
+ job.setExpiration(null);
+ else
+ job.setExpiration(new Long(new Long(x).longValue() * 60000L));
}
- authConnManager.save(connection);
- variableContext.setParameter("connname",connectionName);
-%>
- <jsp:forward page="viewauthority.jsp"/>
-<%
- }
- catch (LCFException e)
- {
- e.printStackTrace();
- variableContext.setParameter("text",e.getMessage());
- variableContext.setParameter("target","listauthorities.jsp");
-%>
- <jsp:forward page="error.jsp"/>
-<%
- }
- }
- else
- {
- // Error
- variableContext.setParameter("text","Illegal parameter to page");
- variableContext.setParameter("target","index.jsp");
-%>
- <jsp:forward page="error.jsp"/>
-<%
- }
- }
-
+ IRepositoryConnection connection = null;
+ if (job.getConnectionName() != null && job.getConnectionName().length() > 0)
+ connection = connManager.load(job.getConnectionName());
+ IOutputConnection outputConnection = null;
+ if (job.getOutputConnectionName() != null && job.getOutputConnectionName().length() > 0)
+ outputConnection = outputManager.load(job.getOutputConnectionName());
+
+ if (connection != null)
+ {
+ String[] relationshipTypes = RepositoryConnectorFactory.getRelationshipTypes(threadContext,connection.getClassName());
- else if (op.equals("Continue"))
- {
- // Continue (while editing a job)
- String type = variableContext.getParameter("type");
- if (type != null && (type.equals("simplereport") || type.equals("maxactivityreport") ||
- type.equals("maxbandwidthreport") || type.equals("resultreport") ||
- type.equals("documentstatus") || type.equals("queuestatus")))
- {
-%>
- <jsp:forward page='<%=type+".jsp"%>'/>
-<%
- }
- else if (type != null && type.equals("job"))
- {
-%>
- <jsp:forward page="editjob.jsp"/>
-<%
- }
- else if (type != null && type.equals("output"))
- {
-%>
- <jsp:forward page="editoutput.jsp"/>
-<%
- }
- else if (type != null && type.equals("connection"))
- {
+ // Gather hopcount filters
+ x = variableContext.getParameter("hopfilters");
+ if (x != null && relationshipTypes != null)
+ {
+ job.clearHopCountFilters();
+ int j = 0;
+ job.clearHopCountFilters();
+ while (j < relationshipTypes.length)
+ {
+ String relationshipType = relationshipTypes[j++];
+ x = variableContext.getParameter("hopmax_"+relationshipType);
+ if (x != null && x.length() > 0)
+ {
+ job.addHopCountFilter(relationshipType,new Long(x));
+ }
+ }
+ }
+ }
+
+ if (outputConnection != null)
+ {
+ IOutputConnector outputConnector = OutputConnectorFactory.grab(threadContext,
+ outputConnection.getClassName(),outputConnection.getConfigParams(),outputConnection.getMaxConnections());
+ if (outputConnector != null)
+ {
+ try
+ {
+ String error = outputConnector.processSpecificationPost(variableContext,job.getOutputSpecification());
+ if (error != null)
+ {
+ variableContext.setParameter("text",error);
+ variableContext.setParameter("target","listjobs.jsp");
%>
- <jsp:forward page="editconnection.jsp"/>
+ <jsp:forward page="error.jsp"/>
<%
- }
- else if (type != null && type.equals("authority"))
- {
+ }
+ }
+ finally
+ {
+ OutputConnectorFactory.release(outputConnector);
+ }
+ }
+ }
+
+ if (connection != null)
+ {
+ IRepositoryConnector repositoryConnector = RepositoryConnectorFactory.grab(threadContext,
+ connection.getClassName(),connection.getConfigParams(),connection.getMaxConnections());
+ if (repositoryConnector != null)
+ {
+ try
+ {
+ String error = repositoryConnector.processSpecificationPost(variableContext,job.getSpecification());
+ if (error != null)
+ {
+ variableContext.setParameter("text",error);
+ variableContext.setParameter("target","listjobs.jsp");
%>
- <jsp:forward page="editauthority.jsp"/>
+ <jsp:forward page="error.jsp"/>
<%
- }
- else
- {
- // Error
- variableContext.setParameter("text","Illegal parameter to page");
- variableContext.setParameter("target","index.jsp");
+ }
+ }
+ finally
+ {
+ RepositoryConnectorFactory.release(repositoryConnector);
+ }
+ }
+ }
+
+ if (op.equals("Continue"))
+ {
+ threadContext.save("JobObject",job);
%>
- <jsp:forward page="error.jsp"/>
+ <jsp:forward page="editjob.jsp"/>
<%
- }
- }
-
-
- else if (op.equals("ReingestAll"))
- {
- // Reingest signal operation
- String type = variableContext.getParameter("type");
- if (type != null && type.equals("output"))
- {
- try
- {
- String connectionName = variableContext.getParameter("connname");
- if (connectionName == null)
- throw new LCFException("Missing connection parameter");
- org.apache.lcf.agents.system.LCF.signalOutputConnectionRedo(threadContext,connectionName);
+ }
+ else if (op.equals("Save"))
+ {
+ manager.save(job);
+ // Reset the job schedule. We may want to make this explicit at some point; having
+ // this happen all the time seems wrong.
+ manager.resetJobSchedule(job.getID());
+ variableContext.setParameter("jobid",job.getID().toString());
%>
- <jsp:forward page="listoutputs.jsp"/>
+ <jsp:forward page="viewjob.jsp"/>
<%
+ }
}
catch (LCFException e)
{
e.printStackTrace();
variableContext.setParameter("text",e.getMessage());
- variableContext.setParameter("target","listoutputs.jsp");
+ variableContext.setParameter("target","listjobs.jsp");
%>
<jsp:forward page="error.jsp"/>
<%
}
}
- else
- {
- // Error
- variableContext.setParameter("text","Illegal parameter to page");
- variableContext.setParameter("target","index.jsp");
-%>
- <jsp:forward page="error.jsp"/>
-<%
- }
-
- }
-
-
- else if (op.equals("Delete"))
- {
- // Delete operation
- String type = variableContext.getParameter("type");
- if (type != null && type.equals("job"))
+ else if (op.equals("Delete"))
{
try
{
@@ -623,220 +801,114 @@
<%
}
}
- else if (type != null && type.equals("output"))
- {
- try
- {
- String connectionName = variableContext.getParameter("connname");
- if (connectionName == null)
- throw new LCFException("Missing connection parameter");
- outputManager.delete(connectionName);
-%>
- <jsp:forward page="listoutputs.jsp"/>
-<%
- }
- catch (LCFException e)
- {
- e.printStackTrace();
- variableContext.setParameter("text",e.getMessage());
- variableContext.setParameter("target","listoutputs.jsp");
-%>
- <jsp:forward page="error.jsp"/>
-<%
- }
- }
- else if (type != null && type.equals("connection"))
- {
- try
- {
- String connectionName = variableContext.getParameter("connname");
- if (connectionName == null)
- throw new LCFException("Missing connection parameter");
- connManager.delete(connectionName);
-%>
- <jsp:forward page="listconnections.jsp"/>
-<%
- }
- catch (LCFException e)
- {
- e.printStackTrace();
- variableContext.setParameter("text",e.getMessage());
- variableContext.setParameter("target","listconnections.jsp");
-%>
- <jsp:forward page="error.jsp"/>
-<%
- }
- }
- else if (type != null && type.equals("authority"))
+ else if (op.equals("Cancel"))
{
- try
- {
- String connectionName = variableContext.getParameter("connname");
- if (connectionName == null)
- throw new LCFException("Missing connection parameter");
- authConnManager.delete(connectionName);
-%>
- <jsp:forward page="listauthorities.jsp"/>
-<%
- }
- catch (LCFException e)
- {
- e.printStackTrace();
- variableContext.setParameter("text",e.getMessage());
- variableContext.setParameter("target","listauthorities.jsp");
+ // Cancel operation
%>
- <jsp:forward page="error.jsp"/>
+ <jsp:forward page="listjobs.jsp"/>
<%
- }
}
else
{
// Error
- variableContext.setParameter("text","Illegal parameter to page");
- variableContext.setParameter("target","index.jsp");
+ variableContext.setParameter("text","Illegal parameter to job definition execution page");
+ variableContext.setParameter("target","listjobs.jsp");
%>
<jsp:forward page="error.jsp"/>
<%
}
- }
- else if (op.equals("Cancel"))
- {
- // Cancel operation
- // Once again, lots of different cancels
- String type = variableContext.getParameter("type");
- if (type != null && type.equals("job"))
- {
- String jobID = variableContext.getParameter("jobid");
- if (jobID != null)
- {
- variableContext.setParameter("jobid",jobID);
-%>
- <jsp:forward page="viewjob.jsp"/>
-<%
- }
- else
- {
-%>
- <jsp:forward page="listjobs.jsp"/>
-<%
- }
- }
- else if (type != null && type.equals("output"))
- {
-%>
- <jsp:forward page="listoutputs.jsp"/>
-<%
- }
- else if (type != null && type.equals("connection"))
- {
-%>
- <jsp:forward page="listconnections.jsp"/>
-<%
- }
- else if (type != null && type.equals("authority"))
+ }
+ else if (type != null && op != null && (type.equals("simplereport") || type.equals("maxactivityreport") ||
+ type.equals("maxbandwidthreport") || type.equals("resultreport") ||
+ type.equals("documentstatus") || type.equals("queuestatus")))
+ {
+ // -- Report handling operations --
+ if (op.equals("Continue") || op.equals("Report") || op.equals("Status"))
{
%>
- <jsp:forward page="listauthorities.jsp"/>
+ <jsp:forward page='<%=type+".jsp"%>'/>
<%
}
else
{
// Error
- variableContext.setParameter("text","Illegal parameter to page");
+ variableContext.setParameter("text","Illegal parameter to report/status execution page");
variableContext.setParameter("target","index.jsp");
%>
<jsp:forward page="error.jsp"/>
<%
}
- }
-
-
-
- else if (op.equals("Start"))
- {
- // Start a job.
+ }
+ else if (op != null && op.equals("Start"))
+ {
+ // -- Start a job --
String jobID = variableContext.getParameter("jobid");
manager.manualStart(new Long(jobID));
// Forward to showjobstatus
%>
<jsp:forward page="showjobstatus.jsp"/>
<%
- }
-
-
-
- else if (op.equals("Pause"))
- {
- // Pause a job
+ }
+ else if (op != null && op.equals("Pause"))
+ {
+ // -- Pause a job --
String jobID = variableContext.getParameter("jobid");
manager.pauseJob(new Long(jobID));
// Forward to showjobstatus
%>
<jsp:forward page="showjobstatus.jsp"/>
<%
- }
-
-
-
- else if (op.equals("Abort"))
- {
- // Abort a job
+ }
+ else if (op != null && op.equals("Abort"))
+ {
+ // -- Abort a job --
String jobID = variableContext.getParameter("jobid");
manager.manualAbort(new Long(jobID));
// Forward to showjobstatus
%>
<jsp:forward page="showjobstatus.jsp"/>
<%
- }
-
-
- else if (op.equals("Restart"))
- {
- // Abort a job
+ }
+ else if (op != null && op.equals("Restart"))
+ {
+ // -- Restart a job --
String jobID = variableContext.getParameter("jobid");
manager.manualAbortRestart(new Long(jobID));
// Forward to showjobstatus
%>
<jsp:forward page="showjobstatus.jsp"/>
<%
- }
-
-
- else if (op.equals("Resume"))
- {
- // Pause a job
+ }
+ else if (op != null && op.equals("Resume"))
+ {
+ // -- Resume a job --
String jobID = variableContext.getParameter("jobid");
manager.restartJob(new Long(jobID));
// Forward to showjobstatus
%>
<jsp:forward page="showjobstatus.jsp"/>
<%
- }
+ }
+ else
+ {
+ /*
+ // If we didn't have an op, then we transfer control back to where the page said to.
+ String target = variableContext.getParameter("target");
+ if (target != null)
+ {
+ <jsp:forward page='<%=target%'/>
+ }
+ <jsp:forward page="index.jsp"/>
+ */
- else
- {
- variableContext.setParameter("text","Illegal operation to page");
+ // Error
+ variableContext.setParameter("text","Illegal parameter to page");
variableContext.setParameter("target","index.jsp");
-
%>
<jsp:forward page="error.jsp"/>
<%
- }
}
-
- // If we didn't have an op, then we transfer control back to where the page said to.
- String target = variableContext.getParameter("target");
- if (target != null)
- {
-%>
- <jsp:forward page='<%=target%>'/>
-<%
-
- }
-%>
- <jsp:forward page="index.jsp"/>
-<%
}
catch (LCFException e)
{