<%@ 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 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 { // Check if authorized if (!adminprofile.checkAllowed(threadContext,IAuthorizer.CAPABILITY_EDIT_CONNECTIONS)) { variableContext.setParameter("target","listconnections.jsp"); %> <% } // Get the connection manager handle IRepositoryConnectionManager connMgr = RepositoryConnectionManagerFactory.make(threadContext); // Also get the list of available connectors IConnectorManager connectorManager = ConnectorManagerFactory.make(threadContext); IAuthorityGroupManager authGroupManager = AuthorityGroupManagerFactory.make(threadContext); IAuthorityGroup[] set2 = authGroupManager.getAllGroups(); IResultSet set = connectorManager.getConnectors(); // 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(),"editconnection.Name"); 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. boolean isNew = true; String description = ""; String className = ""; String authorityName = null; int maxConnections = 10; // Fetches per minute ArrayList throttles = new ArrayList(); 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(); 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 = null; if (connectionName == null) connectionName = ""; // Initialize tabs array. ArrayList tabsArray = new ArrayList(); // Set up the predefined tabs tabsArray.add(Messages.getString(pageContext.getRequest().getLocale(),"editconnection.Name")); tabsArray.add(Messages.getString(pageContext.getRequest().getLocale(),"editconnection.Type")); if (className.length() > 0) tabsArray.add(Messages.getString(pageContext.getRequest().getLocale(),"editconnection.Throttling")); %> <% RepositoryConnectorFactory.outputConfigurationHeader(threadContext,className,new org.apache.manifoldcf.ui.jsp.JspWrapper(out,adminprofile),pageContext.getRequest().getLocale(),parameters,tabsArray); %>
<% // Get connector list; need this to decide what to do if (set.getRowCount() == 0) { %>

<%=Messages.getBodyString(pageContext.getRequest().getLocale(),"editconnection.NoRepositoryConnectorsRegistered")%>

<% } else { %>
<% // Name tab if (tabName.equals(Messages.getString(pageContext.getRequest().getLocale(),"editconnection.Name"))) { %>
<% // If the connection doesn't exist yet, we are allowed to change the name. if (isNew) { %> <% } else { %> <% } %>
<% } else { // Hiddens for the Name tab %> <% } // "Type" tab if (tabName.equals(Messages.getString(pageContext.getRequest().getLocale(),"editconnection.Type"))) { %>
<% if (className.length() > 0) { String value = connectorManager.getDescription(className); if (value == null) { %> <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"editconnection.UNREGISTERED")%> <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(className)%> <% } else { %> <% } %> <% } else { int i = 0; %> <% } %>
<% int i = 0; %>
<% } else { // Hiddens for the "Type" tab %> <% } // The "Throttling" tab %> <% if (tabName.equals(Messages.getString(pageContext.getRequest().getLocale(),"editconnection.Throttling"))) { %>
<% int k = 0; while (k < throttles.size()) { Map map = (Map)throttles.get(k); String regexp = (String)map.get("regexp"); String desc = (String)map.get("description"); if (desc == null) desc = ""; Long value = (Long)map.get("value"); %> <% k++; } if (k == 0) { %>
<%=Messages.getBodyString(pageContext.getRequest().getLocale(),"editconnection.NoThrottlingSpecified")%>
<% } %>
Action <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"editconnection.BinRegularExpression")%> <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"editconnection.Description")%> <%=Messages.getBodyString(pageContext.getRequest().getLocale(),"editconnection.MaxAvgFetchesMin")%>
" alt='<%=Messages.getBodyString(pageContext.getRequest().getLocale(),"editconnection.Deletethrottle")+" "+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(regexp)%>' onclick='<%="javascript:DeleteThrottle("+Integer.toString(k)+");"%>'/> <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(regexp)%> <% if (desc.length() > 0) { %> <%=org.apache.manifoldcf.ui.util.Encoder.bodyEscape(desc)%> <% } %> <%=value.toString()%>
" alt="<%=Messages.getAttributeString(pageContext.getRequest().getLocale(),"editconnection.Addthrottle")%>" onclick="javascript:AddThrottle();"/>
<% } else { // Hiddens for "Throttling" tab %> <% int k = 0; while (k < throttles.size()) { Map map = (Map)throttles.get(k); String regexp = (String)map.get("regexp"); String desc = (String)map.get("description"); if (desc == null) desc = ""; Long value = (Long)map.get("value"); %> <% k++; } } if (className.length() > 0) { RepositoryConnectorFactory.outputConfigurationBody(threadContext,className,new org.apache.manifoldcf.ui.jsp.JspWrapper(out,adminprofile),pageContext.getRequest().getLocale(),parameters,tabName); } %>
<% } %> <% } catch (ManifoldCFException e) { e.printStackTrace(); variableContext.setParameter("text",e.getMessage()); variableContext.setParameter("target","listconnections.jsp"); %> <% } %>