Modified: manifoldcf/trunk/framework/crawler-ui/src/main/webapp/editmapper.jsp URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/crawler-ui/src/main/webapp/editmapper.jsp?rev=1685010&r1=1685009&r2=1685010&view=diff ============================================================================== --- manifoldcf/trunk/framework/crawler-ui/src/main/webapp/editmapper.jsp (original) +++ manifoldcf/trunk/framework/crawler-ui/src/main/webapp/editmapper.jsp Fri Jun 12 00:55:35 2015 @@ -2,92 +2,86 @@ <% -/* $Id$ */ + /* $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. -*/ + * 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 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 - IMappingConnectionManager connMgr = MappingConnectionManagerFactory.make(threadContext); - // Also get the list of available connectors - IMappingConnectorManager connectorManager = MappingConnectorManagerFactory.make(threadContext); - - // Figure out what the current tab name is. - String tabName = variableContext.getParameter("tabname"); - if (tabName == null || tabName.length() == 0) - tabName = Messages.getString(pageContext.getRequest().getLocale(),"editmapper.Name"); - - String connectionName = null; - IMappingConnection connection = (IMappingConnection)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 - boolean isNew = true; - String description = ""; - String className = ""; - int maxConnections = 10; - ConfigParams parameters = new ConfigParams(); - String prereq = null; - - if (connection != null) - { - // Set up values - isNew = connection.getIsNew(); - connectionName = connection.getName(); - description = connection.getDescription(); - className = connection.getClassName(); - parameters = connection.getConfigParams(); - maxConnections = connection.getMaxConnections(); - prereq = connection.getPrerequisiteMapping(); - } - else - connectionName = null; - - if (connectionName == null) - connectionName = ""; - - // Initialize tabs array - ArrayList tabsArray = new ArrayList(); - - // Set up the predefined tabs - tabsArray.add(Messages.getString(pageContext.getRequest().getLocale(),"editmapper.Name")); - tabsArray.add(Messages.getString(pageContext.getRequest().getLocale(),"editmapper.Type")); - if (className.length() > 0) - { - tabsArray.add(Messages.getString(pageContext.getRequest().getLocale(),"editmapper.Prerequisites")); - tabsArray.add(Messages.getString(pageContext.getRequest().getLocale(),"editmapper.Throttling")); - } + // 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 + IMappingConnectionManager connMgr = MappingConnectionManagerFactory.make(threadContext); + // Also get the list of available connectors + IMappingConnectorManager connectorManager = MappingConnectorManagerFactory.make(threadContext); + + // Figure out what the current tab name is. + String tabName = variableContext.getParameter("tabname"); + if (tabName == null || tabName.length() == 0) + tabName = Messages.getString(pageContext.getRequest().getLocale(), "editmapper.Name"); + + String connectionName = null; + IMappingConnection connection = (IMappingConnection) 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 + boolean isNew = true; + String description = ""; + String className = ""; + int maxConnections = 10; + ConfigParams parameters = new ConfigParams(); + String prereq = null; + + if (connection != null) { + // Set up values + isNew = connection.getIsNew(); + connectionName = connection.getName(); + description = connection.getDescription(); + className = connection.getClassName(); + parameters = connection.getConfigParams(); + maxConnections = connection.getMaxConnections(); + prereq = connection.getPrerequisiteMapping(); + } else + connectionName = null; + + if (connectionName == null) + connectionName = ""; + + // Initialize tabs array + ArrayList tabsArray = new ArrayList(); + + // Set up the predefined tabs + tabsArray.add(Messages.getString(pageContext.getRequest().getLocale(), "editmapper.Name")); + tabsArray.add(Messages.getString(pageContext.getRequest().getLocale(), "editmapper.Type")); + if (className.length() > 0) { + tabsArray.add(Messages.getString(pageContext.getRequest().getLocale(), "editmapper.Prerequisites")); + tabsArray.add(Messages.getString(pageContext.getRequest().getLocale(), "editmapper.Throttling")); + } %> @@ -97,453 +91,455 @@ - - - - <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"editmapper.ApacheManifoldCFEditMapping")%> - - - -<% - MappingConnectorFactory.outputConfigurationHeader(threadContext,className,new org.apache.manifoldcf.ui.jsp.JspWrapper(out,adminprofile),pageContext.getRequest().getLocale(),parameters,tabsArray); + // Use this method to repost the form, + // and set the anchor request. + function postFormSetAnchor(anchorValue) { + if (checkForm()) { + if (anchorValue != "") + document.editconnection.action = document.editconnection.action + "#" + anchorValue; + document.editconnection.submit(); + } + } - // Get connectors, since this will be needed to determine what to display. - IResultSet set = connectorManager.getConnectors(); + // Use this method to repost the form + function postForm() { + if (checkForm()) { + document.editconnection.submit(); + } + } -%> + function Save() { + if (checkForm()) { + // Can't submit until all required fields have been set. + // Some of these don't live on the current tab, so don't set + // focus. + + // Check our part of the form, for save + if (editconnection.connname.value == "") { + alert("<%=Messages.getBodyJavascriptString(pageContext.getRequest().getLocale(),"editmapper.ConnectionMustHaveAName")%>"); + SelectTab("<%=Messages.getBodyJavascriptString(pageContext.getRequest().getLocale(),"editmapper.Name")%>"); + document.editconnection.connname.focus(); + return; + } + if (window.checkConfigForSave) { + if (!checkConfigForSave()) + return; + } + document.editconnection.op.value = "Save"; + document.editconnection.submit(); + } + } - + function Continue() { + document.editconnection.op.value = "Continue"; + postForm(); + } - + function Cancel() { + document.editconnection.op.value = "Cancel"; + document.editconnection.submit(); + } - - - - - -
+ function checkForm() { + if (!checkConnectionCount()) + return false; + if (window.checkConfig) + return checkConfig(); + return true; + } + function checkConnectionCount() { + if (!isInteger(editconnection.maxconnections.value)) { + alert("<%=Messages.getBodyJavascriptString(pageContext.getRequest().getLocale(),"editmapper.TheMaximumNumberOfConnectionsMustBeAValidInteger")%>"); + editconnection.maxconnections.focus(); + return false; + } + return true; + } -<% - if (set.getRowCount() == 0) - { -%> -

<%=Messages.getBodyString(pageContext.getRequest().getLocale(),"editmapper.EditMappingConnection")%>

-
<%=Messages.getBodyString(pageContext.getRequest().getLocale(),"editmapper.NoMappingConnectorsRegistered")%>
-<% - } - else - { -%> -
- - - - - - - - - - - - - -<% - int tabNum = 0; - while (tabNum < tabsArray.size()) - { - String tab = (String)tabsArray.get(tabNum++); - if (tab.equals(tabName)) - { -%> - -<% - } - else - { -%> - -<% - } - } -%> - - - - -
-<% - if (description.length() > 0) - { -%> - <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"editmapper.EditMapping")%> '<%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(description)%>' -<% - } - else - { -%> - <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"editmapper.EditAMapping")%> -<% - } -%> -
<%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(tab)%><%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(tab)%>
+ function isRegularExpression(value) { + try { + var foo = "teststring"; + foo.search(value.replace(/\(\?i\)/, "")); + return true; + } + catch (e) { + return false; + } -<% + } - // Name tab - if (tabName.equals(Messages.getString(pageContext.getRequest().getLocale(),"editmapper.Name"))) - { -%> - - - - - - - - - - -

<%=Messages.getBodyString(pageContext.getRequest().getLocale(),"editmapper.NameColon")%> -<% - // If the connection doesn't exist yet, we are allowed to change the name. - if (isNew) - { -%> - -<% - } - else - { -%> - <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(connectionName)%> - -<% - } -%> -
<%=Messages.getBodyString(pageContext.getRequest().getLocale(),"editmapper.DescriptionColon")%> - -
-<% - } - else - { - // Hiddens for the Name tab -%> - - -<% - } + function isInteger(value) { + var anum = /(^\d+$)/; + return anum.test(value); + } + //--> + + <% + MappingConnectorFactory.outputConfigurationHeader(threadContext, className, new org.apache.manifoldcf.ui.jsp.JspWrapper(out, adminprofile), pageContext.getRequest().getLocale(), parameters, tabsArray); - // "Type" tab - if (tabName.equals(Messages.getString(pageContext.getRequest().getLocale(),"editmapper.Type"))) - { -%> - - - - - -

<%=Messages.getBodyString(pageContext.getRequest().getLocale(),"editmapper.ConnectionTypeColon")%> -<% - if (className.length() > 0) - { - String value = connectorManager.getDescription(className); - if (value == null) - { -%> - <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"editmapper.UNREGISTERED")%> <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(className)%> -<% - } - else - { -%> - <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(value)%> -<% - } -%> - -<% - } - else - { - int i = 0; -%> - -<% - } -%> -
-<% - } - else - { - // Hiddens for the "Type" tab -%> - -<% - } + // Get connectors, since this will be needed to determine what to display. + IResultSet set = connectorManager.getConnectors(); - // The "Prerequisites" tab - IMappingConnection[] mappingConnections = connMgr.getAllNonLoopingConnections((connection==null)?null:connection.getName()); - if (tabName.equals(Messages.getString(pageContext.getRequest().getLocale(),"editmapper.Prerequisites"))) - { -%> - - - - - - -

<%=Messages.getBodyString(pageContext.getRequest().getLocale(),"editmapper.PrerequisiteUserMappingColon")%> - -<% - if (prereq == null) - { -%> -  <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"editmapper.NoPrerequisites")%>
-<% - } - else - { -%> -  <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"editmapper.NoPrerequisites")%>
-<% - } + %> - for (IMappingConnection mappingConnection : mappingConnections) - { - String mappingName = mappingConnection.getName(); - String mappingDescription = mappingName; - if (mappingConnection.getDescription() != null && mappingConnection.getDescription().length() > 0) - mappingDescription += " (" + mappingConnection.getDescription()+")"; - if (prereq != null && prereq.equals(mappingName)) - { -%> -  <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(mappingDescription)%>
-<% - } - else - { -%> -  <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(mappingDescription)%>
-<% - } - } -%> -
-<% - } - else - { - // Hiddens for Prerequisites tab -%> - -<% - if (prereq != null) - { -%> - -<% - } - } + - // The "Throttling" tab - if (tabName.equals(Messages.getString(pageContext.getRequest().getLocale(),"editmapper.Throttling"))) - { -%> - - - - - - -

<%=Messages.getBodyString(pageContext.getRequest().getLocale(),"editmapper.MaxConnectionsColon")%>
-<% - } - else - { - // Hiddens for "Throttling" tab -%> - -<% - } + - if (className.length() > 0) - MappingConnectorFactory.outputConfigurationBody(threadContext,className,new org.apache.manifoldcf.ui.jsp.JspWrapper(out,adminprofile),pageContext.getRequest().getLocale(),parameters,tabName); -%> - - - - -

-<% - if (className.length() > 0) - { -%> - " onClick="javascript:Save()" alt="<%=Messages.getAttributeString(pageContext.getRequest().getLocale(),"editmapper.SaveThisMappingConnection")%>"/> -<% - } - else - { - if (tabName.equals(Messages.getString(pageContext.getRequest().getLocale(),"editmapper.Type"))) - { -%> - " onClick="javascript:Continue()" alt="<%=Messages.getAttributeString(pageContext.getRequest().getLocale(),"editmapper.ContinueToNextPage")%>"/> -<% - } - } -%> -  " onClick="javascript:Cancel()" alt="<%=Messages.getAttributeString(pageContext.getRequest().getLocale(),"editmapper.CancelMappingEditing")%>"/>
-
-
-<% - } -%> -
+ + + + + + + + +
+ + + <% + if (set.getRowCount() == 0) { + %> +

<%=Messages.getBodyString(pageContext.getRequest().getLocale(), "editmapper.EditMappingConnection")%> +

+ + + + +
<%=Messages.getBodyString(pageContext.getRequest().getLocale(), "editmapper.NoMappingConnectorsRegistered")%> +
+ <% + } else { + %> +
+ + + + + + + + + + + + + + <% + int tabNum = 0; + while (tabNum < tabsArray.size()) { + String tab = (String) tabsArray.get(tabNum++); + if (tab.equals(tabName)) { + %> + + <% + } else { + %> + + <% + } + } + %> + + + + +
+ <% + if (description.length() > 0) { + %> + <%=Messages.getBodyString(pageContext.getRequest().getLocale(), "editmapper.EditMapping")%> '<%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(description)%>' + <% + } else { + %> + <%=Messages.getBodyString(pageContext.getRequest().getLocale(), "editmapper.EditAMapping")%> + + <% + } + %> +
+ <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(tab)%> + + + + <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(tab)%> + +
+ + <% + + // Name tab + if (tabName.equals(Messages.getString(pageContext.getRequest().getLocale(), "editmapper.Name"))) { + %> + + + + + + + + + + + + +
+
+
+ <%=Messages.getBodyString(pageContext.getRequest().getLocale(), "editmapper.NameColon")%> + + + <% + // If the connection doesn't exist yet, we are allowed to change the name. + if (isNew) { + %> + + <% + } else { + %> + <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(connectionName)%> + + <% + } + %> +
+ <%=Messages.getBodyString(pageContext.getRequest().getLocale(), "editmapper.DescriptionColon")%> + + + +
+ <% + } else { + // Hiddens for the Name tab + %> + + + <% + } + + + // "Type" tab + if (tabName.equals(Messages.getString(pageContext.getRequest().getLocale(), "editmapper.Type"))) { + %> + + + + + + + + +
+
+
+ <%=Messages.getBodyString(pageContext.getRequest().getLocale(), "editmapper.ConnectionTypeColon")%> + + + <% + if (className.length() > 0) { + String value = connectorManager.getDescription(className); + if (value == null) { + %> + <%=Messages.getBodyString(pageContext.getRequest().getLocale(), "editmapper.UNREGISTERED")%> <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(className)%> + + <% + } else { + %> + <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(value)%> + <% + } + %> + + <% + } else { + int i = 0; + %> + + <% + } + %> +
+ <% + } else { + // Hiddens for the "Type" tab + %> + + <% + } + + // The "Prerequisites" tab + IMappingConnection[] mappingConnections = connMgr.getAllNonLoopingConnections((connection == null) ? null : connection.getName()); + if (tabName.equals(Messages.getString(pageContext.getRequest().getLocale(), "editmapper.Prerequisites"))) { + %> + + + + + + + + +
+
+
+ <%=Messages.getBodyString(pageContext.getRequest().getLocale(), "editmapper.PrerequisiteUserMappingColon")%> + + + + <% + if (prereq == null) { + %> +  <%=Messages.getBodyString(pageContext.getRequest().getLocale(), "editmapper.NoPrerequisites")%> +
+ <% + } else { + %> +  <%=Messages.getBodyString(pageContext.getRequest().getLocale(), "editmapper.NoPrerequisites")%> +
+ <% + } + + for (IMappingConnection mappingConnection : mappingConnections) { + String mappingName = mappingConnection.getName(); + String mappingDescription = mappingName; + if (mappingConnection.getDescription() != null && mappingConnection.getDescription().length() > 0) + mappingDescription += " (" + mappingConnection.getDescription() + ")"; + if (prereq != null && prereq.equals(mappingName)) { + %> +  <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(mappingDescription)%> +
+ <% + } else { + %> +  <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(mappingDescription)%> +
+ <% + } + } + %> +
+ <% + } else { + // Hiddens for Prerequisites tab + %> + + <% + if (prereq != null) { + %> + + <% + } + } + + // The "Throttling" tab + if (tabName.equals(Messages.getString(pageContext.getRequest().getLocale(), "editmapper.Throttling"))) { + %> + + + + + + + + +
+
+
+ <%=Messages.getBodyString(pageContext.getRequest().getLocale(), "editmapper.MaxConnectionsColon")%> + +
+ <% + } else { + // Hiddens for "Throttling" tab + %> + + <% + } + + if (className.length() > 0) + MappingConnectorFactory.outputConfigurationBody(threadContext, className, new org.apache.manifoldcf.ui.jsp.JspWrapper(out, adminprofile), pageContext.getRequest().getLocale(), parameters, tabName); + %> + + + + + + + +
+
+
+ + <% + if (className.length() > 0) { + %> + " onClick="javascript:Save()" alt="<%=Messages.getAttributeString(pageContext.getRequest().getLocale(),"editmapper.SaveThisMappingConnection")%>"/> + <% + } else { + if (tabName.equals(Messages.getString(pageContext.getRequest().getLocale(), "editmapper.Type"))) { + %> + " onClick="javascript:Continue()" alt="<%=Messages.getAttributeString(pageContext.getRequest().getLocale(),"editmapper.ContinueToNextPage")%>"/> + <% + } + } + %> +  " onClick="javascript:Cancel()" alt="<%=Messages.getAttributeString(pageContext.getRequest().getLocale(),"editmapper.CancelMappingEditing")%>"/> + +
+
+
+ <% + } + %> +
<% - } - catch (ManifoldCFException e) - { - e.printStackTrace(); - variableContext.setParameter("text",e.getMessage()); - variableContext.setParameter("target","listmappers.jsp"); +} catch (ManifoldCFException e) { + e.printStackTrace(); + variableContext.setParameter("text", e.getMessage()); + variableContext.setParameter("target", "listmappers.jsp"); %> - + <% - } + } %> Modified: manifoldcf/trunk/framework/crawler-ui/src/main/webapp/editnotification.jsp URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/crawler-ui/src/main/webapp/editnotification.jsp?rev=1685010&r1=1685009&r2=1685010&view=diff ============================================================================== --- manifoldcf/trunk/framework/crawler-ui/src/main/webapp/editnotification.jsp (original) +++ manifoldcf/trunk/framework/crawler-ui/src/main/webapp/editnotification.jsp Fri Jun 12 00:55:35 2015 @@ -2,87 +2,82 @@ <% -/* $Id$ */ + /* $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. -*/ + * 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 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 - INotificationConnectionManager connMgr = NotificationConnectionManagerFactory.make(threadContext); - // Also get the list of available connectors - INotificationConnectorManager connectorManager = NotificationConnectorManagerFactory.make(threadContext); - - // Figure out what the current tab name is. - String tabName = variableContext.getParameter("tabname"); - if (tabName == null || tabName.length() == 0) - tabName = Messages.getString(pageContext.getRequest().getLocale(),"editnotification.Name"); - String connectionName = null; - INotificationConnection connection = (INotificationConnection)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. - boolean isNew = true; - String description = ""; - String className = ""; - int maxConnections = 10; - ConfigParams parameters = new ConfigParams(); - - // If there's a connection object, set up all our parameters from it. - if (connection != null) - { - // Set up values - isNew = connection.getIsNew(); - connectionName = connection.getName(); - description = connection.getDescription(); - className = connection.getClassName(); - parameters = connection.getConfigParams(); - maxConnections = connection.getMaxConnections(); - } - else - connectionName = null; - - if (connectionName == null) - connectionName = ""; - - // Initialize tabs array. - ArrayList tabsArray = new ArrayList(); - - // Set up the predefined tabs - tabsArray.add(Messages.getString(pageContext.getRequest().getLocale(),"editnotification.Name")); - tabsArray.add(Messages.getString(pageContext.getRequest().getLocale(),"editnotification.Type")); - if (className.length() > 0) - tabsArray.add(Messages.getString(pageContext.getRequest().getLocale(),"editnotification.Throttling")); + // 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 + INotificationConnectionManager connMgr = NotificationConnectionManagerFactory.make(threadContext); + // Also get the list of available connectors + INotificationConnectorManager connectorManager = NotificationConnectorManagerFactory.make(threadContext); + + // Figure out what the current tab name is. + String tabName = variableContext.getParameter("tabname"); + if (tabName == null || tabName.length() == 0) + tabName = Messages.getString(pageContext.getRequest().getLocale(), "editnotification.Name"); + String connectionName = null; + INotificationConnection connection = (INotificationConnection) 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. + boolean isNew = true; + String description = ""; + String className = ""; + int maxConnections = 10; + ConfigParams parameters = new ConfigParams(); + + // If there's a connection object, set up all our parameters from it. + if (connection != null) { + // Set up values + isNew = connection.getIsNew(); + connectionName = connection.getName(); + description = connection.getDescription(); + className = connection.getClassName(); + parameters = connection.getConfigParams(); + maxConnections = connection.getMaxConnections(); + } else + connectionName = null; + + if (connectionName == null) + connectionName = ""; + + // Initialize tabs array. + ArrayList tabsArray = new ArrayList(); + + // Set up the predefined tabs + tabsArray.add(Messages.getString(pageContext.getRequest().getLocale(), "editnotification.Name")); + tabsArray.add(Messages.getString(pageContext.getRequest().getLocale(), "editnotification.Type")); + if (className.length() > 0) + tabsArray.add(Messages.getString(pageContext.getRequest().getLocale(), "editnotification.Throttling")); %> @@ -92,390 +87,394 @@ - - - - <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"editnotification.ApacheManifoldCFEditNotificationConnection")%> - - - -<% - NotificationConnectorFactory.outputConfigurationHeader(threadContext,className,new org.apache.manifoldcf.ui.jsp.JspWrapper(out,adminprofile),pageContext.getRequest().getLocale(),parameters,tabsArray); -%> - - + + + + <%=Messages.getBodyString(pageContext.getRequest().getLocale(), "editnotification.ApacheManifoldCFEditNotificationConnection")%> + + + + <% + NotificationConnectorFactory.outputConfigurationHeader(threadContext, className, new org.apache.manifoldcf.ui.jsp.JspWrapper(out, adminprofile), pageContext.getRequest().getLocale(), parameters, tabsArray); + %> -%> - - - - -

-<% - if (className.length() > 0) - { -%> - " onClick="javascript:Save()" alt="<%=Messages.getAttributeString(pageContext.getRequest().getLocale(),"editnotification.SaveThisNotificationConnection")%>"/> -<% - } - else - { - if (tabName.equals(Messages.getString(pageContext.getRequest().getLocale(),"editnotification.Type"))) - { -%> - " onClick="javascript:Continue()" alt="<%=Messages.getAttributeString(pageContext.getRequest().getLocale(),"editnotification.ContinueToNextPage")%>"/> -<% - } - } -%> -  " onClick="javascript:Cancel()" alt="<%=Messages.getAttributeString(pageContext.getRequest().getLocale(),"editnotification.CancelNotificationConnectionEditing")%>"/>
- - - - + -<% - } -%> + - - - + + + + + + + + +
+ <% + // Get connector list; need this to decide what to do + IResultSet set = connectorManager.getConnectors(); + if (set.getRowCount() == 0) { + %> +

<%=Messages.getBodyString(pageContext.getRequest().getLocale(), "editnotification.EditNotificationConnection2")%> +

+ + + + +
<%=Messages.getBodyString(pageContext.getRequest().getLocale(), "editnotification.NoNotificationConnectorsRegistered")%> +
+ <% + } else { + %> + +
+ + + + + + + + + + + + + + <% + int tabNum = 0; + while (tabNum < tabsArray.size()) { + String tab = (String) tabsArray.get(tabNum++); + if (tab.equals(tabName)) { + %> + + <% + } else { + %> + + <% + } + } + %> + + + + +
+ <% + if (description.length() > 0) { + %> + <%=Messages.getBodyString(pageContext.getRequest().getLocale(), "editnotification.EditNotificationConnection")%> '<%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(description)%>' + <% + } else { + %> + + <%=Messages.getBodyString(pageContext.getRequest().getLocale(), "editnotification.EditANotificationConnection")%> + + <% + } + %> +
+ <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(tab)%> + + + + <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(tab)%> + +
+ <% + + + // Name tab + if (tabName.equals(Messages.getString(pageContext.getRequest().getLocale(), "editnotification.Name"))) { + %> + + + + + + + + + + + + +
+
+
+ <%=Messages.getBodyString(pageContext.getRequest().getLocale(), "editnotification.NameColon")%> + + + <% + // If the connection doesn't exist yet, we are allowed to change the name. + if (connection == null || connectionName.length() < 1) { + %> + + <% + } else { + %> + <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(connectionName)%> + + <% + } + %> +
+ <%=Messages.getBodyString(pageContext.getRequest().getLocale(), "editnotification.DescriptionColon")%> + + + +
+ <% + } else { + // Hiddens for the Name tab + %> + + + <% + } + + + // "Type" tab + if (tabName.equals(Messages.getString(pageContext.getRequest().getLocale(), "editnotification.Type"))) { + %> + + + + + + + + +
+
+
+ <%=Messages.getBodyString(pageContext.getRequest().getLocale(), "editnotification.ConnectionTypeColon")%> + + + <% + if (className.length() > 0) { + String value = connectorManager.getDescription(className); + if (value == null) { + %> + <%=Messages.getBodyString(pageContext.getRequest().getLocale(), "editnotification.UNREGISTERED")%> <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(className)%> + + <% + } else { + %> + <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(value)%> + <% + } + %> + + <% + } else { + int i = 0; + %> + + <% + } + %> +
+ <% + } else { + // Hiddens for the "Type" tab + %> + + <% + } + + + // The "Throttling" tab + if (tabName.equals(Messages.getString(pageContext.getRequest().getLocale(), "editnotification.Throttling"))) { + %> + + + + + + + + +
+
+
+ <%=Messages.getBodyString(pageContext.getRequest().getLocale(), "editnotification.MaxConnectionsColon")%> + +
+ <% + } else { + // Hiddens for "Throttling" tab + %> + + <% + } + + if (className.length() > 0) + NotificationConnectorFactory.outputConfigurationBody(threadContext, className, new org.apache.manifoldcf.ui.jsp.JspWrapper(out, adminprofile), pageContext.getRequest().getLocale(), parameters, tabName); + + %> + + + + + + + +
+
+
+ + <% + if (className.length() > 0) { + %> + " onClick="javascript:Save()" alt="<%=Messages.getAttributeString(pageContext.getRequest().getLocale(),"editnotification.SaveThisNotificationConnection")%>"/> + <% + } else { + if (tabName.equals(Messages.getString(pageContext.getRequest().getLocale(), "editnotification.Type"))) { + %> + " onClick="javascript:Continue()" alt="<%=Messages.getAttributeString(pageContext.getRequest().getLocale(),"editnotification.ContinueToNextPage")%>"/> + <% + } + } + %> +  " onClick="javascript:Cancel()" alt="<%=Messages.getAttributeString(pageContext.getRequest().getLocale(),"editnotification.CancelNotificationConnectionEditing")%>"/> + +
+
+
+ + <% + } + %> + +
<% - } - catch (ManifoldCFException e) - { - e.printStackTrace(); - variableContext.setParameter("text",e.getMessage()); - variableContext.setParameter("target","listnotifications.jsp"); +} catch (ManifoldCFException e) { + e.printStackTrace(); + variableContext.setParameter("text", e.getMessage()); + variableContext.setParameter("target", "listnotifications.jsp"); %> - + <% - } + } %>