<%@ 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. */ %> <% // 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 IJobManager manager = JobManagerFactory.make(threadContext); IRepositoryConnectionManager connMgr = RepositoryConnectionManagerFactory.make(threadContext); IRepositoryConnection[] connList = connMgr.getAllConnections(); IOutputConnectionManager outputMgr = OutputConnectionManagerFactory.make(threadContext); IOutputConnection[] outputList = outputMgr.getAllConnections(); // Figure out tab name String tabName = variableContext.getParameter("tabname"); if (tabName == null || tabName.length() == 0) tabName = Messages.getString(pageContext.getRequest().getLocale(),"editjob.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 = ""; int type = IJobDescription.TYPE_SPECIFIED; OutputSpecification outputSpecification = new OutputSpecification(); DocumentSpecification documentSpecification = new DocumentSpecification(); ArrayList scheduleRecords = new ArrayList(); EnumeratedValues dayOfWeek = null; EnumeratedValues dayOfMonth = null; EnumeratedValues monthOfYear = null; EnumeratedValues year = null; EnumeratedValues hourOfDay = null; EnumeratedValues minutesOfHour = null; // Duration in minutes Long duration = null; // Priority int priority = 5; // Minimum recrawl interval (Default: 1 day) Long recrawlInterval = new Long(60L * 24L); // Reseed interval (Default: 60 minutes) Long reseedInterval = new Long(60L); // Expiration interval (Default: never) Long expirationInterval = null; // Start method int startMethod = IJobDescription.START_DISABLE; // Hopcount mode int hopcountMode = IJobDescription.HOPCOUNT_ACCURATE; // Hop filters Map hopFilterMap = new HashMap(); // If the job is not null, prepopulate everything with what comes from it. if (job != null) { // Set up values description = job.getDescription(); outputName = job.getOutputConnectionName(); connectionName = job.getConnectionName(); type = job.getType(); startMethod = job.getStartMethod(); hopcountMode = job.getHopcountMode(); outputSpecification = job.getOutputSpecification(); documentSpecification = job.getSpecification(); // Fill in schedule records from job int j = 0; while (j < job.getScheduleRecordCount()) { scheduleRecords.add(job.getScheduleRecord(j++)); } priority = job.getPriority(); Long value = job.getInterval(); recrawlInterval = (value==null)?null:new Long(value.longValue()/60000L); value = job.getReseedInterval(); reseedInterval = (value==null)?null:new Long(value.longValue()/60000L); value = job.getExpiration(); expirationInterval = (value==null)?null:new Long(value.longValue()/60000L); hopFilterMap = job.getHopCountFilters(); } // This form reposts to itself. It basically only allows the connection to be picked once; once done, the repost occurs // and cannot be undone. // Therefore, there are three possible entry conditions: // 1) no jobid w/no connection name, which indicates a brand-new job without a chosen connection // 2) no jobid w/a connection name, which indicates that the connection at least has been chosen // 3) a jobid and a connection name, which indicates that we are editing an existing connection. // There are similar combinations for output connections. int model = IRepositoryConnector.MODEL_ADD_CHANGE_DELETE; String[] relationshipTypes = null; ArrayList tabsArray = new ArrayList(); IRepositoryConnection connection = null; IOutputConnection outputConnection = null; if (connectionName.length() > 0) { connection = connMgr.load(connectionName); model = RepositoryConnectorFactory.getConnectorModel(threadContext,connection.getClassName()); relationshipTypes = RepositoryConnectorFactory.getRelationshipTypes(threadContext,connection.getClassName()); } if (outputName.length() > 0) { outputConnection = outputMgr.load(outputName); } // Set up the predefined tabs tabsArray.add(Messages.getString(pageContext.getRequest().getLocale(),"editjob.Name")); tabsArray.add(Messages.getString(pageContext.getRequest().getLocale(),"editjob.Connection")); if (connectionName.length() > 0) { tabsArray.add(Messages.getString(pageContext.getRequest().getLocale(),"editjob.Scheduling")); if (relationshipTypes != null && relationshipTypes.length > 0) tabsArray.add(Messages.getString(pageContext.getRequest().getLocale(),"editjob.HopFilters")); } %> <%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.ApacheManifoldCFEditJob")%> <% if (outputConnection != null) { IOutputConnector outputConnector = OutputConnectorFactory.grab(threadContext,outputConnection.getClassName(),outputConnection.getConfigParams(), outputConnection.getMaxConnections()); if (outputConnector != null) { try { outputConnector.outputSpecificationHeader(new org.apache.manifoldcf.ui.jsp.JspWrapper(out),pageContext.getRequest().getLocale(),outputSpecification,tabsArray); } finally { OutputConnectorFactory.release(outputConnector); } } } %> <% if (connection != null) { IRepositoryConnector repositoryConnector = RepositoryConnectorFactory.grab(threadContext,connection.getClassName(),connection.getConfigParams(), connection.getMaxConnections()); if (repositoryConnector != null) { try { repositoryConnector.outputSpecificationHeader(new org.apache.manifoldcf.ui.jsp.JspWrapper(out),pageContext.getRequest().getLocale(),documentSpecification,tabsArray); } finally { RepositoryConnectorFactory.release(repositoryConnector); } } } %>
<% if (connList.length == 0) { %>

<%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.EditaJob")%>

<%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.NoRepositoryConnectionsDefinedCreateOneFirst")%>
<% } else if (outputList.length == 0) { %>

<%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.EditaJob")%>

<%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.NoOutputConnectionsDefinedCreateOneFirst")%>
<% } else { %>
<% if (jobID != null) { %> <% } %> <% int tabNum = 0; while (tabNum < tabsArray.size()) { String tab = (String)tabsArray.get(tabNum++); if (tab.equals(tabName)) { %> <% } else { %> <% } } %>
<%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(tab)%><%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(tab)%> <% if (description.length() > 0) { %> <%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.EditJob")%> '<%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(description)%>' <% } else { %> <%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.EditaJob")%> <% } %>
<% // The NAME tab if (tabName.equals(Messages.getString(pageContext.getRequest().getLocale(),"editjob.Name"))) { %>

<%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.NameColon")%>
<% } else { %> <% } // Hop Filters tab if (tabName.equals(Messages.getString(pageContext.getRequest().getLocale(),"editjob.HopFilters"))) { if (relationshipTypes != null) { %> <% int i = 0; while (i < relationshipTypes.length) { String relationshipType = relationshipTypes[i++]; String mapField = ""; Long mapValue = (Long)hopFilterMap.get(relationshipType); if (mapValue != null) mapField = mapValue.toString(); %> <% } %>

<%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.MaximumHopCountForType")%> '<%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(relationshipType)%>'<%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.colon")%>

<%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.HopCountModeColon")%> ><%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.DeleteUnreachableDocuments")%>
><%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.KeepUnreachableDocumentsForNow")%>
><%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.KeepUnreachableDocumentsForever")%>
<% } } else { if (relationshipTypes != null) { %> <% int i = 0; while (i < relationshipTypes.length) { String relationshipType = relationshipTypes[i++]; String mapField = ""; Long mapValue = (Long)hopFilterMap.get(relationshipType); if (mapValue != null) mapField = mapValue.toString(); %> <% } } } // Connection tab if (tabName.equals(Messages.getString(pageContext.getRequest().getLocale(),"editjob.Connection"))) { %> <% if (outputName.length() == 0) { %> <% } else { %> <% } %> <% if (connectionName.length() == 0) { %> <% } else { %> <% } %>

<%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.OutputConnectionColon")%> <%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.OutputConnectionColon")%> <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(outputName)%><%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.RepositoryConnectionColon")%> <%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.RepositoryConnectionColon")%> <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(connectionName)%>
<%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.PriorityColon")%> <%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.StartMethodColon")%>
<% } else { %> <% } // Scheduling tab if (tabName.equals(Messages.getString(pageContext.getRequest().getLocale(),"editjob.Scheduling"))) { %> <% if (model != -1 && model != IRepositoryConnector.MODEL_ADD_CHANGE_DELETE) { %> <% } else { %> <% } %> <% if (scheduleRecords.size() == 0) { %> <% } else { int l = 0; while (l < scheduleRecords.size()) { ScheduleRecord sr = (ScheduleRecord)scheduleRecords.get(l); Long srDuration = sr.getDuration(); EnumeratedValues srDayOfWeek = sr.getDayOfWeek(); EnumeratedValues srMonthOfYear = sr.getMonthOfYear(); EnumeratedValues srDayOfMonth = sr.getDayOfMonth(); EnumeratedValues srYear = sr.getYear(); EnumeratedValues srHourOfDay = sr.getHourOfDay(); EnumeratedValues srMinutesOfHour = sr.getMinutesOfHour(); String postFix = Integer.toString(l); int k; if (l > 0) { %> <% } %> <% l++; } } %>

<%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.ScheduleTypeColon")%><%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.RecrawlIntervalIfContinuousColon")%> <%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.minutesBlankInfinity")%>
<%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.ExpirationIntervalIfContinuousColon")%> <%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.minutesBlankInfinity")%> <%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.ReseedIntervalIfContinuousColon")%> <%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.minutesBlankInfinity")%>

<%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.NoScheduleSpecified")%>

<%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.ScheduledTimeColon")%> <%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.at")%> <%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.plus")%> <%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.in")%> <%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.on")%>
<%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.MaximumRunTimeColon")%> <%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.minutes")%>
" onClick='<%="Javascript:RemoveSchedule("+Integer.toString(l)+")"%>' alt='<%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.RemoveScheduleRecord")+Integer.toString(l)%>'/>

<%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.ScheduledTimeColon")%> <%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.at")%> <%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.plus")%> <%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.in")%> <%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.on")%>
<%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.MaximumRunTimeColon")%> <%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.minutes")%>
" onClick="javascript:AddScheduledTime()" alt="<%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.AddNewScheduleRecord")%>"/>
<% } else { %> <% int l = 0; while (l < scheduleRecords.size()) { ScheduleRecord sr = (ScheduleRecord)scheduleRecords.get(l); Long srDuration = sr.getDuration(); EnumeratedValues srDayOfWeek = sr.getDayOfWeek(); EnumeratedValues srMonthOfYear = sr.getMonthOfYear(); EnumeratedValues srDayOfMonth = sr.getDayOfMonth(); EnumeratedValues srYear = sr.getYear(); EnumeratedValues srHourOfDay = sr.getHourOfDay(); EnumeratedValues srMinutesOfHour = sr.getMinutesOfHour(); String postFix = Integer.toString(l); if (srDayOfWeek == null) { %> <% } else { Iterator iter = srDayOfWeek.getValues(); while (iter.hasNext()) { Integer value = (Integer)iter.next(); %> <% } } if (srHourOfDay == null) { %> <% } else { Iterator iter = srHourOfDay.getValues(); while (iter.hasNext()) { Integer value = (Integer)iter.next(); %> <% } } if (srMinutesOfHour == null) { %> <% } else { Iterator iter = srMinutesOfHour.getValues(); while (iter.hasNext()) { Integer value = (Integer)iter.next(); %> <% } } if (srDayOfMonth == null) { %> <% } else { Iterator iter = srDayOfMonth.getValues(); while (iter.hasNext()) { Integer value = (Integer)iter.next(); %> <% } } if (srMonthOfYear == null) { %> <% } else { Iterator iter = srMonthOfYear.getValues(); while (iter.hasNext()) { Integer value = (Integer)iter.next(); %> <% } } %> <% l++; } } if (outputConnection != null) { IOutputConnector outputConnector = OutputConnectorFactory.grab(threadContext,outputConnection.getClassName(),outputConnection.getConfigParams(), outputConnection.getMaxConnections()); if (outputConnector != null) { try { outputConnector.outputSpecificationBody(new org.apache.manifoldcf.ui.jsp.JspWrapper(out),pageContext.getRequest().getLocale(),outputSpecification,tabName); } finally { OutputConnectorFactory.release(outputConnector); } %> <% } } if (connection != null) { IRepositoryConnector repositoryConnector = RepositoryConnectorFactory.grab(threadContext,connection.getClassName(),connection.getConfigParams(), connection.getMaxConnections()); if (repositoryConnector != null) { try { repositoryConnector.outputSpecificationBody(new org.apache.manifoldcf.ui.jsp.JspWrapper(out),pageContext.getRequest().getLocale(),documentSpecification,tabName); } finally { RepositoryConnectorFactory.release(repositoryConnector); } %> <% } } %>

<% if (connectionName.length() > 0 && outputName.length() > 0) { %> " onClick="javascript:Save()" alt="<%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.SaveThisJob")%>"/> <% } else { if (tabName.equals(Messages.getString(pageContext.getRequest().getLocale(),"editjob.Connection"))) { %> " onClick="javascript:Continue()" alt="<%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.ContinueToNextScreen")%>"/> <% } } %>  " onClick="javascript:Cancel()" alt="<%=Messages.getString(pageContext.getRequest().getLocale(),"editjob.CancelJobEditing")%>"/>
<% } %>
<% } catch (ManifoldCFException e) { e.printStackTrace(); variableContext.setParameter("text",e.getMessage()); variableContext.setParameter("target","listjobs.jsp"); %> <% } %>