Return-Path: Delivered-To: apmail-incubator-connectors-commits-archive@minotaur.apache.org Received: (qmail 33620 invoked from network); 26 Jun 2010 10:30:11 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 26 Jun 2010 10:30:11 -0000 Received: (qmail 70785 invoked by uid 500); 26 Jun 2010 10:30:10 -0000 Delivered-To: apmail-incubator-connectors-commits-archive@incubator.apache.org Received: (qmail 70741 invoked by uid 500); 26 Jun 2010 10:30:09 -0000 Mailing-List: contact connectors-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: connectors-dev@incubator.apache.org Delivered-To: mailing list connectors-commits@incubator.apache.org Received: (qmail 70728 invoked by uid 99); 26 Jun 2010 10:30:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 26 Jun 2010 10:30:08 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED,WEIRD_QUOTING X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 26 Jun 2010 10:30:00 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id B4C18238890A; Sat, 26 Jun 2010 10:29:06 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r958211 - in /incubator/lcf/branches/CONNECTORS-40/modules/connectors/memex: connector/org/apache/lcf/crawler/connectors/memex/MemexConnector.java crawler-ui/connectors/ Date: Sat, 26 Jun 2010 10:29:06 -0000 To: connectors-commits@incubator.apache.org From: kwright@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100626102906.B4C18238890A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kwright Date: Sat Jun 26 10:29:06 2010 New Revision: 958211 URL: http://svn.apache.org/viewvc?rev=958211&view=rev Log: Port memex connector UI from JSPs to connector methods. Removed: incubator/lcf/branches/CONNECTORS-40/modules/connectors/memex/crawler-ui/connectors/ Modified: incubator/lcf/branches/CONNECTORS-40/modules/connectors/memex/connector/org/apache/lcf/crawler/connectors/memex/MemexConnector.java Modified: incubator/lcf/branches/CONNECTORS-40/modules/connectors/memex/connector/org/apache/lcf/crawler/connectors/memex/MemexConnector.java URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-40/modules/connectors/memex/connector/org/apache/lcf/crawler/connectors/memex/MemexConnector.java?rev=958211&r1=958210&r2=958211&view=diff ============================================================================== --- incubator/lcf/branches/CONNECTORS-40/modules/connectors/memex/connector/org/apache/lcf/crawler/connectors/memex/MemexConnector.java (original) +++ incubator/lcf/branches/CONNECTORS-40/modules/connectors/memex/connector/org/apache/lcf/crawler/connectors/memex/MemexConnector.java Sat Jun 26 10:29:06 2010 @@ -1386,6 +1386,2005 @@ public class MemexConnector extends org. return 1; } + // UI support methods. + // + // These support methods come in two varieties. The first bunch is involved in setting up connection configuration information. The second bunch + // is involved in presenting and editing document specification information for a job. The two kinds of methods are accordingly treated differently, + // in that the first bunch cannot assume that the current connector object is connected, while the second bunch can. That is why the first bunch + // receives a thread context argument for all UI methods, while the second bunch does not need one (since it has already been applied via the connect() + // method, above). + + /** Output the configuration header section. + * This method is called in the head section of the connector's configuration page. Its purpose is to add the required tabs to the list, and to output any + * javascript methods that might be needed by the configuration editing HTML. + *@param threadContext is the local thread context. + *@param out is the output to which any HTML should be sent. + *@param parameters are the configuration parameters, as they currently exist, for this connection being configured. + *@param tabsArray is an array of tab names. Add to this array any tab names that are specific to the connector. + */ + public void outputConfigurationHeader(IThreadContext threadContext, IHTTPOutput out, ConfigParams parameters, ArrayList tabsArray) + throws LCFException, IOException + { + tabsArray.add("Memex Server"); + tabsArray.add("Web Server"); + out.print( +"\n" + ); + } + + // Legal character sets for java 1.5 + private static String[] legalCharsets; + private static String[] legalTimezones; + + static + { + legalCharsets = new String[] + { + "ISO-8859-1", + "ISO-8859-2", + "ISO-8859-4", + "ISO-8859-5", + "ISO-8859-7", + "ISO-8859-9", + "ISO-8859-13", + "ISO-8859-15", + "KOI8-R", + "US-ASCII", + "UTF-8", + "UTF-16", + "UTF-16BE", + "UTF-16LE", + "windows-1250", + "windows-1251", + "windows-1252", + "windows-1253", + "windows-1254", + "windows-1257", + "Big5", + "Big5-HKSCS", + "EUC-JP", + "EUC-KR", + "GB18030", + "GB2312", + "GBK", + "IBM-Thai", + "IBM00858", + "IBM01140", + "IBM01141", + "IBM01142", + "IBM01143", + "IBM01144", + "IBM01145", + "IBM01146", + "IBM01147", + "IBM01148", + "IBM01149", + "IBM037", + "IBM1026", + "IBM1047", + "IBM273", + "IBM277", + "IBM278", + "IBM280", + "IBM284", + "IBM285", + "IBM297", + "IBM420", + "IBM424", + "IBM437", + "IBM500", + "IBM775", + "IBM850", + "IBM852", + "IBM855", + "IBM857", + "IBM860", + "IBM861", + "IBM862", + "IBM863", + "IBM864", + "IBM865", + "IBM866", + "IBM868", + "IBM869", + "IBM870", + "IBM871", + "IBM918", + "ISO-2022-CN", + "ISO-2022-JP", + "ISO-2022-KR", + "ISO-8859-3", + "ISO-8859-6", + "ISO-8859-8", + "Shift_JIS", + "TIS-620", + "windows-1255", + "windows-1256", + "windows-1258", + "windows-31j", + "x-Big5_Solaris", + "x-euc-jp-linux", + "x-EUC-TW", + "x-eucJP-Open", + "x-IBM1006", + "x-IBM1025", + "x-IBM1046", + "x-IBM1097", + "x-IBM1098", + "x-IBM1112", + "x-IBM1122", + "x-IBM1123", + "x-IBM1124", + "x-IBM1381", + "x-IBM1383", + "x-IBM33722", + "x-IBM737", + "x-IBM856", + "x-IBM874", + "x-IBM875", + "x-IBM921", + "x-IBM922", + "x-IBM930", + "x-IBM933", + "x-IBM935", + "x-IBM937", + "x-IBM939", + "x-IBM942", + "x-IBM942C", + "x-IBM943", + "x-IBM943C", + "x-IBM948", + "x-IBM949", + "x-IBM949C", + "x-IBM950", + "x-IBM964", + "x-IBM970", + "x-ISCII91", + "x-ISO2022-CN-CNS", + "x-ISO2022-CN-GB", + "x-iso-8859-11", + "x-Johab", + "x-MacArabic", + "x-MacCentralEurope", + "x-MacCroatian", + "x-MacCyrillic", + "x-MacDingbat", + "x-MacGreek", + "x-MacHebrew", + "x-MacIceland", + "x-MacRoman", + "x-MacRomania", + "x-MacSymbol", + "x-MacThai", + "x-MacTurkish", + "x-MacUkraine", + "x-MS950-HKSCS", + "x-mswin-936", + "x-PCK", + "x-windows-874", + "x-windows-949", + "x-windows-950" + }; + + legalTimezones = java.util.TimeZone.getAvailableIDs(); + + java.util.Arrays.sort(legalTimezones); + java.util.Arrays.sort(legalCharsets); + } + + /** Output the configuration body section. + * This method is called in the body section of the connector's configuration page. Its purpose is to present the required form elements for editing. + * The coder can presume that the HTML that is output from this configuration will be within appropriate , , and
tags. The name of the + * form is "editconnection". + *@param threadContext is the local thread context. + *@param out is the output to which any HTML should be sent. + *@param parameters are the configuration parameters, as they currently exist, for this connection being configured. + *@param tabName is the current tab name. + */ + public void outputConfigurationBody(IThreadContext threadContext, IHTTPOutput out, ConfigParams parameters, String tabName) + throws LCFException, IOException + { + String memexServerName = parameters.getParameter(org.apache.lcf.crawler.connectors.memex.MemexConnector.CONFIG_PARAM_MEMEXSERVERNAME); + if (memexServerName == null) + memexServerName = ""; + String memexServerPort = parameters.getParameter(org.apache.lcf.crawler.connectors.memex.MemexConnector.CONFIG_PARAM_MEMEXSERVERPORT); + if (memexServerPort == null) + memexServerPort = ""; + String crawlUser = parameters.getParameter(org.apache.lcf.crawler.connectors.memex.MemexConnector.CONFIG_PARAM_USERID); + if (crawlUser == null) + crawlUser = ""; + String crawlUserPassword = parameters.getObfuscatedParameter(org.apache.lcf.crawler.connectors.memex.MemexConnector.CONFIG_PARAM_PASSWORD); + if (crawlUserPassword == null) + crawlUserPassword = ""; + String webServerProtocol = parameters.getParameter(org.apache.lcf.crawler.connectors.memex.MemexConnector.CONFIG_PARAM_WEBSERVERPROTOCOL); + if (webServerProtocol == null) + webServerProtocol = "http"; + String webServerName = parameters.getParameter(org.apache.lcf.crawler.connectors.memex.MemexConnector.CONFIG_PARAM_WEBSERVERNAME); + if (webServerName == null) + webServerName = ""; + String webServerPort = parameters.getParameter(org.apache.lcf.crawler.connectors.memex.MemexConnector.CONFIG_PARAM_WEBSERVERPORT); + if (webServerPort == null) + webServerPort = ""; + String characterEncoding = parameters.getParameter(org.apache.lcf.crawler.connectors.memex.MemexConnector.CONFIG_PARAM_CHARACTERENCODING); + if (characterEncoding == null) + characterEncoding = "windows-1252"; + String serverTimezone = parameters.getParameter(org.apache.lcf.crawler.connectors.memex.MemexConnector.CONFIG_PARAM_SERVERTIMEZONE); + if (serverTimezone == null) + serverTimezone = "GMT"; + + // "Memex Server" tab + if (tabName.equals("Memex Server")) + { + out.print( +"\n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +"

Memex server name:
Memex server port:
Crawl user name:
Crawl user password:
Character encoding:\n"+ +" \n"+ +"
Server time zone:\n"+ +" \n"+ +"
\n" + ); + } + else + { + // Hiddens for Memex Server tab + out.print( +"\n"+ +"\n"+ +"\n"+ +"\n"+ +"\n"+ +"\n" + ); + } + + // "Web Server" tab + if (tabName.equals("Web Server")) + { + out.print( +"\n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +"

Web server protocol:\n"+ +" \n"+ +"
Web server name:
(blank if same as Memex server)
Web server port:
\n" + ); + } + else + { + // Hiddens for Web Server tab + out.print( +"\n"+ +"\n"+ +"\n" + ); + } + } + + /** Process a configuration post. + * This method is called at the start of the connector's configuration page, whenever there is a possibility that form data for a connection has been + * posted. Its purpose is to gather form information and modify the configuration parameters accordingly. + * The name of the posted form is "editconnection". + *@param threadContext is the local thread context. + *@param variableContext is the set of variables available from the post, including binary file post information. + *@param parameters are the configuration parameters, as they currently exist, for this connection being configured. + *@return null if all is well, or a string error message if there is an error that should prevent saving of the connection (and cause a redirection to an error page). + */ + public String processConfigurationPost(IThreadContext threadContext, IPostParameters variableContext, ConfigParams parameters) + throws LCFException + { + String memexServerName = variableContext.getParameter("memexservername"); + if (memexServerName != null) + parameters.setParameter(org.apache.lcf.crawler.connectors.memex.MemexConnector.CONFIG_PARAM_MEMEXSERVERNAME,memexServerName); + + String memexServerPort = variableContext.getParameter("memexserverport"); + if (memexServerPort != null) + parameters.setParameter(org.apache.lcf.crawler.connectors.memex.MemexConnector.CONFIG_PARAM_MEMEXSERVERPORT,memexServerPort); + + String crawlUser = variableContext.getParameter("crawluser"); + if (crawlUser != null) + parameters.setParameter(org.apache.lcf.crawler.connectors.memex.MemexConnector.CONFIG_PARAM_USERID,crawlUser); + + String crawlUserPassword = variableContext.getParameter("crawluserpassword"); + if (crawlUserPassword != null) + parameters.setObfuscatedParameter(org.apache.lcf.crawler.connectors.memex.MemexConnector.CONFIG_PARAM_PASSWORD,crawlUserPassword); + + String webServerProtocol = variableContext.getParameter("webserverprotocol"); + if (webServerProtocol != null) + parameters.setParameter(org.apache.lcf.crawler.connectors.memex.MemexConnector.CONFIG_PARAM_WEBSERVERPROTOCOL,webServerProtocol); + + String webServerName = variableContext.getParameter("webservername"); + if (webServerName != null) + parameters.setParameter(org.apache.lcf.crawler.connectors.memex.MemexConnector.CONFIG_PARAM_WEBSERVERNAME,webServerName); + + String webServerPort = variableContext.getParameter("webserverport"); + if (webServerPort != null) + parameters.setParameter(org.apache.lcf.crawler.connectors.memex.MemexConnector.CONFIG_PARAM_WEBSERVERPORT,webServerPort); + + String characterEncoding = variableContext.getParameter("characterencoding"); + if (characterEncoding != null) + parameters.setParameter(org.apache.lcf.crawler.connectors.memex.MemexConnector.CONFIG_PARAM_CHARACTERENCODING,characterEncoding); + + String serverTimezone = variableContext.getParameter("servertimezone"); + if (serverTimezone != null) + parameters.setParameter(org.apache.lcf.crawler.connectors.memex.MemexConnector.CONFIG_PARAM_SERVERTIMEZONE,serverTimezone); + return null; + } + + /** View configuration. + * This method is called in the body section of the connector's view configuration page. Its purpose is to present the connection information to the user. + * The coder can presume that the HTML that is output from this configuration will be within appropriate and tags. + *@param threadContext is the local thread context. + *@param out is the output to which any HTML should be sent. + *@param parameters are the configuration parameters, as they currently exist, for this connection being configured. + */ + public void viewConfiguration(IThreadContext threadContext, IHTTPOutput out, ConfigParams parameters) + throws LCFException, IOException + { + out.print( +"\n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +"
Parameters:\n" + ); + Iterator iter = parameters.listParameters(); + while (iter.hasNext()) + { + String param = (String)iter.next(); + String value = parameters.getParameter(param); + if (param.length() >= "password".length() && param.substring(param.length()-"password".length()).equalsIgnoreCase("password")) + { + out.print( +" "+org.apache.lcf.ui.util.Encoder.bodyEscape(param)+"=********
\n" + ); + } + else if (param.length() >="keystore".length() && param.substring(param.length()-"keystore".length()).equalsIgnoreCase("keystore")) + { + IKeystoreManager kmanager = KeystoreManagerFactory.make("",value); + out.print( +" "+org.apache.lcf.ui.util.Encoder.bodyEscape(param)+"=<"+Integer.toString(kmanager.getContents().length)+" certificate(s)>
\n" + ); + } + else + { + out.print( +" "+org.apache.lcf.ui.util.Encoder.bodyEscape(param)+"="+org.apache.lcf.ui.util.Encoder.bodyEscape(value)+"
\n" + ); + } + } + out.print( +"
\n" + ); + } + + /** Output the specification header section. + * This method is called in the head section of a job page which has selected a repository connection of the current type. Its purpose is to add the required tabs + * to the list, and to output any javascript methods that might be needed by the job editing HTML. + *@param out is the output to which any HTML should be sent. + *@param ds is the current document specification for this job. + *@param tabsArray is an array of tab names. Add to this array any tab names that are specific to the connector. + */ + public void outputSpecificationHeader(IHTTPOutput out, DocumentSpecification ds, ArrayList tabsArray) + throws LCFException, IOException + { + tabsArray.add("Record Criteria"); + tabsArray.add("Entities"); + tabsArray.add("Security"); + out.print( +"\n" + ); + } + + /** Output the specification body section. + * This method is called in the body section of a job page which has selected a repository connection of the current type. Its purpose is to present the required form elements for editing. + * The coder can presume that the HTML that is output from this configuration will be within appropriate , , and tags. The name of the + * form is "editjob". + *@param out is the output to which any HTML should be sent. + *@param ds is the current document specification for this job. + *@param tabName is the current tab name. + */ + public void outputSpecificationBody(IHTTPOutput out, DocumentSpecification ds, String tabName) + throws LCFException, IOException + { + int i; + int k; + + // Entities tab + + // Always build a hash map containing all the currently selected entities, primary fields, and corresponding metafields first + // Primary fields are ordered. This map is keyed by entity name, and has an arraylist of primary fields as contents. + HashMap entityMap = new HashMap(); + // Metadata fields are not ordered. This map is keyed by entity name, and contains a hashmap of metadata field names. + HashMap entityMetadataMap = new HashMap(); + // Finally, a map describing *all* the fields that have been selected for one purpose or another + HashMap overallEntityFieldMap = new HashMap(); + // Descriptions are used to make the 'view' look interpretable + HashMap descriptionMap = new HashMap(); + i = 0; + while (i < ds.getChildCount()) + { + SpecificationNode sn = ds.getChild(i++); + if (sn.getType().equals(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_NODE_ENTITY)) + { + String entityName = sn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_NAME); + String entityDescription = sn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_DESCRIPTION); + if (entityDescription == null) + entityDescription = entityName; + + HashMap attrMap = new HashMap(); + ArrayList primaryList = new ArrayList(); + HashMap overallMap = new HashMap(); + // Go through the children and look for metafield records + int kk = 0; + while (kk < sn.getChildCount()) + { + SpecificationNode dsn = sn.getChild(kk++); + if (dsn.getType().equals(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_NODE_PRIMARYFIELD)) + { + String fieldName = dsn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_NAME); + primaryList.add(fieldName); + overallMap.put(fieldName,fieldName); + } + else if (dsn.getType().equals(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_NODE_METAFIELD)) + { + String fieldName = dsn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_NAME); + attrMap.put(fieldName,fieldName); + overallMap.put(fieldName,fieldName); + } + } + + entityMap.put(entityName,primaryList); + entityMetadataMap.put(entityName,attrMap); + overallEntityFieldMap.put(entityName,overallMap); + descriptionMap.put(entityName,entityDescription); + } + } + + if (tabName.equals("Entities")) + { + out.print( +"\n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n" + ); + // Need to catch a potential license exception here + try + { + org.apache.lcf.crawler.connectors.memex.NameDescription[] entityTypes = listEntityTypes(); + out.print( +" \n" + ); + int ii = 0; + while (ii < entityTypes.length) + { + org.apache.lcf.crawler.connectors.memex.NameDescription entityType = entityTypes[ii]; + String entityPrefix = entityType.getSymbolicName(); + String entityDisplayName = entityType.getDisplayName(); + ArrayList primaryFields = (ArrayList)entityMap.get(entityPrefix); + HashMap attrMap = (HashMap)entityMetadataMap.get(entityPrefix); + HashMap overallMap = (HashMap)overallEntityFieldMap.get(entityPrefix); + + // For this entity type, grab a complete list of metadata fields + String[] legalFields = listFieldNames(entityPrefix); + out.print( +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n" + ); + ii++; + } + } + catch (LCFException e) + { + out.print( +" \n"+ +" \n"+ +" \n" + ); + } + catch (ServiceInterruption e) + { + out.print( +" \n"+ +" \n"+ +" \n" + ); + } + out.print( +"
Entity nameTagged fieldsAvailable fieldsMetadata fields
\n"+ +" \n"+ +" \n"+ +" "+org.apache.lcf.ui.util.Encoder.bodyEscape(entityDisplayName)+":\n"+ +" \n"+ +" \n"+ +" \n"+ +"
\n"+ +"
\n"+ +"
\n"+ +" \n"+ +" \n"+ +"
\n"+ +"
\n"+ +"
\n"+ +" \n"+ +"
\n"+ +" "+org.apache.lcf.ui.util.Encoder.bodyEscape(e.getMessage())+"\n"+ +"
\n"+ +" Service interruption - check your repository connection\n"+ +"
\n" + ); + } + else + { + // Do the hiddens for the Entities tab + out.print( +"\n" + ); + Iterator iter = entityMap.keySet().iterator(); + int ii = 0; + while (iter.hasNext()) + { + String entityType = (String)iter.next(); + String displayName = (String)descriptionMap.get(entityType); + ArrayList primaryFields = (ArrayList)entityMap.get(entityType); + HashMap attrMap = (HashMap)entityMetadataMap.get(entityType); + out.print( +"\n"+ +"\n" + ); + int jj = 0; + while (jj < primaryFields.size()) + { + String primaryField = (String)primaryFields.get(jj++); + out.print( +"\n" + ); + } + Iterator iter2 = attrMap.keySet().iterator(); + while (iter2.hasNext()) + { + String attrName = (String)iter2.next(); + out.print( +"\n" + ); + } + ii++; + } + } + + // Record Criteria tab + + // This tab displays a sequence of rules. Rules are constructed from (in order) virtual server, entity, and a (fieldname,operation,fieldvalue) tuple + + if (tabName.equals("Record Criteria")) + { + out.print( +"\n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +"

Record inclusion rules:\n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n" + ); + // Loop through the existing rules + int q = 0; + int l = 0; + while (q < ds.getChildCount()) + { + SpecificationNode sn = ds.getChild(q++); + if (sn.getType().equals(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_NODE_SPECIFICATIONRULE)) + { + // Grab the appropriate rule data + String virtualServer = sn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_VIRTUALSERVER); + if (virtualServer == null) + virtualServer = ""; + String entityPrefix = sn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_ENTITY); + if (entityPrefix == null) + entityPrefix = ""; + String entityDescription = sn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_DESCRIPTION); + if (entityDescription == null) + entityDescription = entityPrefix; + String fieldName = sn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_FIELDNAME); + if (fieldName == null) + fieldName = ""; + String operation = sn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_OPERATION); + if (operation == null) + operation = ""; + String fieldValue = sn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_FIELDVALUE); + if (fieldValue == null) + fieldValue = ""; + + String pathDescription = "_"+Integer.toString(l); + String pathOpName = "specop"+pathDescription; + + out.print( +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n" + ); + l++; + } + } + if (l == 0) + { + out.print( +" \n" + ); + } + + // Now, present the rule building area + + out.print( +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +"
Virtual ServerEntity NameMatch Criteria
\n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" "+org.apache.lcf.ui.util.Encoder.bodyEscape((virtualServer.length()==0)?"(All)":virtualServer)+"\n"+ +" \n"+ +" "+org.apache.lcf.ui.util.Encoder.bodyEscape((entityPrefix.length()==0)?"(All)":(entityDescription==null)?entityPrefix:entityDescription)+"\n"+ +" \n"+ +" "+org.apache.lcf.ui.util.Encoder.bodyEscape((fieldName.length()==0)?"(All)":(fieldName+" "+operation+" "+fieldValue))+"\n"+ +"
No records currently included
\n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +"

\n"+ +" New rule:\n"+ +" \n" + ); + // These represent the state of the rule building widget, which is maintained in the current thread context from the post element + String ruleVirtualServer = (String)currentContext.get("rulevirtualserver"); + if (ruleVirtualServer == null) + ruleVirtualServer = ""; + String ruleEntityPrefix = (String)currentContext.get("ruleentityprefix"); + if (ruleEntityPrefix == null) + ruleEntityPrefix = ""; + String ruleEntityDescription = (String)currentContext.get("ruleentitydescription"); + if (ruleEntityDescription == null) + ruleEntityDescription = ruleEntityPrefix; + String ruleFieldName = (String)currentContext.get("rulefieldname"); + if (ruleFieldName == null) + ruleFieldName = ""; + String ruleOperation = (String)currentContext.get("ruleoperation"); + if (ruleOperation == null) + ruleOperation = ""; + String ruleFieldValue = (String)currentContext.get("rulefieldvalue"); + if (ruleFieldValue == null) + ruleFieldValue = ""; + + out.print( +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +"
\n"+ +" \n"+ +" \n" + ); + if (ruleFieldName.length() > 0) + { + out.print( +" \n" + ); + } + else + { + if (ruleEntityPrefix.length() > 0) + { + out.print( +" \n" + ); + } + else + { + if (ruleVirtualServer.length() > 0) + { + out.print( +" \n" + ); + } + } + } + out.print( +" \n"+ +"
\n"+ +" \n" + ); + // If we've already selected the virtual server, display it, otherwise create a pulldown for selection + if (ruleVirtualServer.length() > 0) + { + // Display what was chosen + out.print( +" "+org.apache.lcf.ui.util.Encoder.bodyEscape(ruleVirtualServer)+"\n" + ); + } + else + { + // Generate a selection list, and display that + // Need to catch potential license exception here + try + { + // Now, go through the list and preselect those that are selected + // Fetch the legal virtual servers + String[] virtualServers = listVirtualServers(); + out.print( +" \n"+ +" \n" + ); + } + catch (LCFException e) + { + out.print( +" "+org.apache.lcf.ui.util.Encoder.bodyEscape(e.getMessage())+"\n" + ); + } + catch (ServiceInterruption e) + { + out.print( +" Transient service interruption - "+org.apache.lcf.ui.util.Encoder.bodyEscape(e.getMessage())+"\n" + ); + } + + } + out.print( +" \n"+ +" \n"+ +" \n" + ); + // If we've already selected the entity, display it, otherwise create a pulldown for selection + if (ruleEntityPrefix.length() > 0) + { + // Display what was chosen + out.print( +" "+org.apache.lcf.ui.util.Encoder.bodyEscape(ruleEntityDescription)+"\n" + ); + } + else + { + // It's either too early, or we need to display the available entities + if (ruleVirtualServer.length() > 0) + { + // Generate list of available entities + // Need to catch potential license exception here + try + { + // Fetch the legal entity prefixes and descriptions + org.apache.lcf.crawler.connectors.memex.NameDescription[] allowedEntities = listDatabasesForVirtualServer(ruleVirtualServer); + out.print( +" \n"+ +" \n" + ); + } + catch (LCFException e) + { + out.print( +" "+org.apache.lcf.ui.util.Encoder.bodyEscape(e.getMessage())+"\n" + ); + } + catch (ServiceInterruption e) + { + out.print( +" Transient service interruption - "+org.apache.lcf.ui.util.Encoder.bodyEscape(e.getMessage())+"\n" + ); + } + } + else + { + // Display nothing! + } + } + out.print( +" \n"+ +" \n"+ +" \n" + ); + // If we've already selected the criteria, display it, otherwise create a pulldown for selection, and a field value to fill in + if (ruleFieldName.length() > 0) + { + // Display the field criteria + out.print( +" "+org.apache.lcf.ui.util.Encoder.bodyEscape(ruleFieldName)+" "+org.apache.lcf.ui.util.Encoder.bodyEscape(ruleOperation)+" "+org.apache.lcf.ui.util.Encoder.bodyEscape(ruleFieldValue)+"\n" + ); + } + else + { + // It's either too early, or we need to display the available field names etc. + if (ruleEntityPrefix.length() > 0) + { + // Generate list + // Need to catch potential license exception here + try + { + // Fetch the legal field names for this entity + String[] fieldNames = listMatchableFieldNames(ruleEntityPrefix); + out.print( +" \n"+ +" \n"+ +" \n"+ +" \n" + ); + } + catch (LCFException e) + { + out.print( +" "+org.apache.lcf.ui.util.Encoder.bodyEscape(e.getMessage())+"\n" + ); + } + catch (ServiceInterruption e) + { + out.print( +" Transient service interruption - "+org.apache.lcf.ui.util.Encoder.bodyEscape(e.getMessage())+"\n" + ); + } + } + else + { + // Display nothing! + } + } + out.print( +" \n"+ +"
\n"+ +"
\n" + ); + } + else + { + // Loop through the existing rules + int q = 0; + int l = 0; + while (q < ds.getChildCount()) + { + SpecificationNode sn = ds.getChild(q++); + if (sn.getType().equals(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_NODE_SPECIFICATIONRULE)) + { + // Grab the appropriate rule data + String virtualServer = sn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_VIRTUALSERVER); + if (virtualServer == null) + virtualServer = ""; + String entityPrefix = sn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_ENTITY); + if (entityPrefix == null) + entityPrefix = ""; + String entityDescription = sn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_DESCRIPTION); + if (entityDescription == null) + entityDescription = entityPrefix; + String fieldName = sn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_FIELDNAME); + if (fieldName == null) + fieldName = ""; + String operation = sn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_OPERATION); + if (operation == null) + operation = ""; + String fieldValue = sn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_FIELDVALUE); + if (fieldValue == null) + fieldValue = ""; + + String pathDescription = "_"+Integer.toString(l); + out.print( +"\n"+ +"\n"+ +"\n"+ +"\n"+ +"\n"+ +"\n" + ); + l++; + } + } + out.print( +"\n" + ); + } + + // Security tab + // Find whether security is on or off + i = 0; + boolean securityOn = true; + while (i < ds.getChildCount()) + { + SpecificationNode sn = ds.getChild(i++); + if (sn.getType().equals(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_NODE_SECURITY)) + { + String securityValue = sn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_VALUE); + if (securityValue.equals(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_VALUE_OFF)) + securityOn = false; + else if (securityValue.equals(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_VALUE_ON)) + securityOn = true; + } + } + + if (tabName.equals("Security")) + { + out.print( +"\n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n" + ); + // Go through forced ACL + i = 0; + k = 0; + while (i < ds.getChildCount()) + { + SpecificationNode sn = ds.getChild(i++); + if (sn.getType().equals(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_NODE_ACCESS)) + { + String accessDescription = "_"+Integer.toString(k); + String accessOpName = "accessop"+accessDescription; + String token = sn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_TOKEN); + out.print( +" \n"+ +" \n"+ +" \n"+ +" \n" + ); + k++; + } + } + if (k == 0) + { + out.print( +" \n"+ +" \n"+ +" \n" + ); + } + out.print( +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +"

Security:\n"+ +" Enabled \n"+ +" Disabled\n"+ +"

\n"+ +" \n"+ +" \n"+ +"  \n"+ +" \n"+ +" "+org.apache.lcf.ui.util.Encoder.bodyEscape(token)+"\n"+ +"
No access tokens present

\n"+ +" \n"+ +" \n"+ +"  \n"+ +" \n"+ +" \n"+ +"
\n" + ); + } + else + { + out.print( +"\n" + ); + // Finally, go through forced ACL + i = 0; + k = 0; + while (i < ds.getChildCount()) + { + SpecificationNode sn = ds.getChild(i++); + if (sn.getType().equals(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_NODE_ACCESS)) + { + String accessDescription = "_"+Integer.toString(k); + String token = sn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_TOKEN); + out.print( +"\n" + ); + k++; + } + } + out.print( +"\n" + ); + } + } + + /** Process a specification post. + * This method is called at the start of job's edit or view page, whenever there is a possibility that form data for a connection has been + * posted. Its purpose is to gather form information and modify the document specification accordingly. + * The name of the posted form is "editjob". + *@param variableContext contains the post data, including binary file-upload information. + *@param ds is the current document specification for this job. + *@return null if all is well, or a string error message if there is an error that should prevent saving of the job (and cause a redirection to an error page). + */ + public String processSpecificationPost(IPostParameters variableContext, DocumentSpecification ds) + throws LCFException + { + String x = variableContext.getParameter("entitytypecount"); + if (x != null && x.length() > 0) + { + // Delete all entity records first + int i = 0; + while (i < ds.getChildCount()) + { + SpecificationNode sn = ds.getChild(i); + if (sn.getType().equals(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_NODE_ENTITY)) + ds.removeChild(i); + else + i++; + } + + // Loop through specs + int count = Integer.parseInt(x); + i = 0; + while (i < count) + { + String entityType = variableContext.getParameter("entitytype_"+Integer.toString(i)); + String displayName = variableContext.getParameter("entitydesc_"+Integer.toString(i)); + String[] primaryFields = variableContext.getParameterValues("primaryfields_"+Integer.toString(i)); + if (primaryFields != null && primaryFields.length > 0) + { + // At least one primary field was selected for this entity type! + SpecificationNode node = new SpecificationNode(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_NODE_ENTITY); + node.setAttribute(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_NAME,entityType); + node.setAttribute(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_DESCRIPTION,displayName); + + int k = 0; + while (k < primaryFields.length) + { + SpecificationNode primaryNode = new SpecificationNode(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_NODE_PRIMARYFIELD); + primaryNode.setAttribute(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_NAME,primaryFields[k++]); + node.addChild(node.getChildCount(),primaryNode); + } + + String[] z = variableContext.getParameterValues("metadatafields_"+Integer.toString(i)); + if (z != null) + { + k = 0; + while (k < z.length) + { + SpecificationNode attrNode = new SpecificationNode(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_NODE_METAFIELD); + attrNode.setAttribute(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_NAME,z[k++]); + node.addChild(node.getChildCount(),attrNode); + } + } + ds.addChild(ds.getChildCount(),node); + } + i++; + } + } + + // Next, process the record criteria + x = variableContext.getParameter("specrulecount"); + if (x != null && x.length() > 0) + { + // Delete all rules first + int i = 0; + while (i < ds.getChildCount()) + { + SpecificationNode sn = ds.getChild(i); + if (sn.getType().equals(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_NODE_SPECIFICATIONRULE)) + ds.removeChild(i); + else + i++; + } + + // Loop through specs + int count = Integer.parseInt(x); + i = 0; + while (i < count) + { + String ruleSuffix = "_"+Integer.toString(i); + // Grab the rule data + String virtualServer = variableContext.getParameter("virtualserver"+ruleSuffix); + if (virtualServer == null) + virtualServer = ""; + String entityPrefix = variableContext.getParameter("entityprefix"+ruleSuffix); + if (entityPrefix == null) + entityPrefix = ""; + String entityDescription = variableContext.getParameter("entitydescription"+ruleSuffix); + if (entityDescription == null) + entityDescription = ""; + String fieldName = variableContext.getParameter("fieldname"+ruleSuffix); + if (fieldName == null) + fieldName = ""; + String operation = variableContext.getParameter("operation"+ruleSuffix); + if (operation == null) + operation = ""; + String fieldValue = variableContext.getParameter("fieldvalue"+ruleSuffix); + if (fieldValue == null) + fieldValue = ""; + String opcode = variableContext.getParameter("specop"+ruleSuffix); + if (opcode != null && opcode.equals("Delete")) + { + // Do not include this row in the new set + } + else + { + SpecificationNode sn = new SpecificationNode(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_NODE_SPECIFICATIONRULE); + if (virtualServer.length() > 0) + sn.setAttribute(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_VIRTUALSERVER,virtualServer); + if (entityPrefix.length() > 0) + sn.setAttribute(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_ENTITY,entityPrefix); + if (entityDescription.length() > 0) + sn.setAttribute(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_DESCRIPTION,entityDescription); + if (fieldName.length() > 0) + sn.setAttribute(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_FIELDNAME,fieldName); + if (operation.length() > 0) + sn.setAttribute(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_OPERATION,operation); + if (fieldValue.length() > 0) + sn.setAttribute(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_FIELDVALUE,fieldValue); + ds.addChild(ds.getChildCount(),sn); + } + i++; + } + + // Pull out rule fields and put them into the thread context + String ruleVirtualServer = variableContext.getParameter("rulevirtualserver"); + if (ruleVirtualServer == null) + ruleVirtualServer = ""; + String ruleEntityPrefix = variableContext.getParameter("ruleentityprefix"); + if (ruleEntityPrefix == null) + ruleEntityPrefix = ""; + String ruleEntityDescription = variableContext.getParameter("ruleentitydescription"); + if (ruleEntityDescription == null) + ruleEntityDescription = ""; + String ruleFieldName = variableContext.getParameter("rulefieldname"); + if (ruleFieldName == null) + ruleFieldName = ""; + String ruleOperation = variableContext.getParameter("ruleoperation"); + if (ruleOperation == null) + ruleOperation = ""; + String ruleFieldValue = variableContext.getParameter("rulefieldvalue"); + if (ruleFieldValue == null) + ruleFieldValue = ""; + + // Now, look at global opcode. + String globalOpcode = variableContext.getParameter("specop"); + if (globalOpcode != null && globalOpcode.equals("Add")) + { + // Add the specified rule to the end of the list, and clear out all the rule parameters. + SpecificationNode sn = new SpecificationNode(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_NODE_SPECIFICATIONRULE); + if (ruleVirtualServer.length() > 0) + sn.setAttribute(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_VIRTUALSERVER,ruleVirtualServer); + if (ruleEntityPrefix.length() > 0) + sn.setAttribute(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_ENTITY,ruleEntityPrefix); + if (ruleEntityDescription.length() > 0) + sn.setAttribute(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_DESCRIPTION,ruleEntityDescription); + if (ruleFieldName.length() > 0) + sn.setAttribute(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_FIELDNAME,ruleFieldName); + if (ruleOperation.length() > 0) + sn.setAttribute(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_OPERATION,ruleOperation); + if (ruleFieldValue.length() > 0) + sn.setAttribute(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_FIELDVALUE,ruleFieldValue); + ds.addChild(ds.getChildCount(),sn); + ruleVirtualServer = ""; + ruleEntityPrefix = ""; + ruleEntityDescription = ""; + ruleFieldName = ""; + ruleOperation = ""; + ruleFieldValue = ""; + } + + currentContext.save("rulevirtualserver",ruleVirtualServer); + currentContext.save("ruleentityprefix",ruleEntityPrefix); + currentContext.save("ruleentitydescription",ruleEntityDescription); + currentContext.save("rulefieldname",ruleFieldName); + currentContext.save("ruleoperation",ruleOperation); + currentContext.save("rulefieldvalue",ruleFieldValue); + } + + // Look whether security is on or off + String xc = variableContext.getParameter("specsecurity"); + if (xc != null) + { + // Delete all security entries first + int i = 0; + while (i < ds.getChildCount()) + { + SpecificationNode sn = ds.getChild(i); + if (sn.getType().equals(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_NODE_SECURITY)) + ds.removeChild(i); + else + i++; + } + + SpecificationNode node = new SpecificationNode(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_NODE_SECURITY); + node.setAttribute(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_VALUE,xc); + ds.addChild(ds.getChildCount(),node); + + } + + xc = variableContext.getParameter("tokencount"); + if (xc != null) + { + // Delete all file specs first + int i = 0; + while (i < ds.getChildCount()) + { + SpecificationNode sn = ds.getChild(i); + if (sn.getType().equals(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_NODE_ACCESS)) + ds.removeChild(i); + else + i++; + } + + int accessCount = Integer.parseInt(xc); + i = 0; + while (i < accessCount) + { + String accessDescription = "_"+Integer.toString(i); + String accessOpName = "accessop"+accessDescription; + xc = variableContext.getParameter(accessOpName); + if (xc != null && xc.equals("Delete")) + { + // Next row + i++; + continue; + } + // Get the stuff we need + String accessSpec = variableContext.getParameter("spectoken"+accessDescription); + SpecificationNode node = new SpecificationNode(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_NODE_ACCESS); + node.setAttribute(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_TOKEN,accessSpec); + ds.addChild(ds.getChildCount(),node); + i++; + } + + String op = variableContext.getParameter("accessop"); + if (op != null && op.equals("Add")) + { + String accessspec = variableContext.getParameter("spectoken"); + SpecificationNode node = new SpecificationNode(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_NODE_ACCESS); + node.setAttribute(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_TOKEN,accessspec); + ds.addChild(ds.getChildCount(),node); + } + } + return null; + } + + /** View specification. + * This method is called in the body section of a job's view page. Its purpose is to present the document specification information to the user. + * The coder can presume that the HTML that is output from this configuration will be within appropriate and tags. + *@param out is the output to which any HTML should be sent. + *@param ds is the current document specification for this job. + */ + public void viewSpecification(IHTTPOutput out, DocumentSpecification ds) + throws LCFException, IOException + { + out.print( +"\n"+ +" \n" + ); + int i = 0; + int l = 0; + boolean seenAny = false; + while (i < ds.getChildCount()) + { + SpecificationNode sn = ds.getChild(i++); + if (sn.getType().equals(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_NODE_SPECIFICATIONRULE)) + { + String virtualServer = sn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_VIRTUALSERVER); + if (virtualServer == null) + virtualServer = ""; + String entityPrefix = sn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_ENTITY); + if (entityPrefix == null) + entityPrefix = ""; + String entityDescription = sn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_DESCRIPTION); + if (entityDescription == null) + entityDescription = ""; + String fieldName = sn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_FIELDNAME); + if (fieldName == null) + fieldName = ""; + String operation = sn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_OPERATION); + if (operation == null) + operation = ""; + String fieldValue = sn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_FIELDVALUE); + if (fieldValue == null) + fieldValue = ""; + + + if (seenAny == false) + { + seenAny = true; + out.print( +" \n"+ +" \n" + ); + } + else + { + out.print( +" \n" + ); + } + out.print( +" \n"+ +"\n"+ +" \n"+ +"\n"+ +" \n" + ); + seenAny = false; + i = 0; + int z = 0; + while (i < ds.getChildCount()) + { + SpecificationNode sn = ds.getChild(i++); + if (sn.getType().equals(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_NODE_ENTITY)) + { + if (seenAny == false) + { + out.print( +" \n"+ +" \n" + ); + } + else + { + out.print( +" \n" + ); + } + out.print( +" \n" + ); + // Find whether security is on or off + i = 0; + boolean securityOn = true; + while (i < ds.getChildCount()) + { + SpecificationNode sn = ds.getChild(i++); + if (sn.getType().equals(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_NODE_SECURITY)) + { + String securityValue = sn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_VALUE); + if (securityValue.equals(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_VALUE_OFF)) + securityOn = false; + else if (securityValue.equals(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_VALUE_ON)) + securityOn = true; + } + } + out.print( +" \n"+ +"\n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +"\n"+ +" \n" + ); + // Go through looking for access tokens + seenAny = false; + i = 0; + while (i < ds.getChildCount()) + { + SpecificationNode sn = ds.getChild(i++); + if (sn.getType().equals(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_NODE_ACCESS)) + { + if (seenAny == false) + { + out.print( +" \n"+ +" \n"+ +" \n" + ); + } + else + { + out.print( +" \n" + ); + } + out.print( +"
Inclusion rules:\n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n" + ); + } + out.print( +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n" + ); + l++; + } + } + + if (seenAny) + { + out.print( +"
Virtual serverEntityCriteria
"+((virtualServer.length()==0)?"(all)":org.apache.lcf.ui.util.Encoder.bodyEscape(virtualServer))+""+((entityPrefix.length()==0)?"(all)":org.apache.lcf.ui.util.Encoder.bodyEscape(entityDescription))+""+((fieldName.length()==0)?"(all)":org.apache.lcf.ui.util.Encoder.bodyEscape(fieldName+" "+operation+" "+fieldValue))+"
\n"+ +"
No rules specified (no records will be scanned)

Entity tagged fields and metadata:\n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n" + ); + seenAny = true; + } + String strEntityName = sn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_NAME); + String strEntityDescription = sn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_DESCRIPTION); + out.print( +" \n"+ +" \n"+ +" \n"+ +" \n"+ +" \n" + ); + z++; + } + } + if (seenAny) + { + out.print( +"
Entity nameTagged fieldsMetadata fields
\n"+ +" "+org.apache.lcf.ui.util.Encoder.bodyEscape(strEntityDescription)+"\n"+ +" \n" + ); + int k = 0; + while (k < sn.getChildCount()) + { + SpecificationNode dsn = sn.getChild(k++); + if (dsn.getType().equals(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_NODE_PRIMARYFIELD)) + { + String attrName = dsn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_NAME); + out.print( +" "+org.apache.lcf.ui.util.Encoder.bodyEscape(attrName)+"
\n" + ); + } + } + out.print( +"
\n" + ); + l = 0; + k = 0; + while (k < sn.getChildCount()) + { + SpecificationNode dsn = sn.getChild(k++); + if (dsn.getType().equals(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_NODE_METAFIELD)) + { + String attrName = dsn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_NAME); + out.print( +" "+org.apache.lcf.ui.util.Encoder.bodyEscape(attrName)+"
\n" + ); + + l++; + } + } + if (l == 0) + { + out.print( +" (No metadata attributes chosen)\n" + ); + } + out.print( +"
\n"+ +"
No entities specified; nothing will be crawled

Security:"+(securityOn?"Enabled":"Disabled")+"

Access tokens:\n" + ); + seenAny = true; + } + String token = sn.getAttributeValue(org.apache.lcf.crawler.connectors.memex.MemexConnector.SPEC_ATTRIBUTE_TOKEN); + out.print( +" "+org.apache.lcf.ui.util.Encoder.bodyEscape(token)+"
\n" + ); + } + } + + if (seenAny) + { + out.print( +"
No access tokens specified
\n" + ); + } + // UI support methods /** Return a list of databases (instances of an entity type) on a given virtual server*/