You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by rh...@apache.org on 2015/03/21 18:53:34 UTC

svn commit: r1668309 - in /manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src: main/java/org/apache/manifoldcf/agents/output/searchblox/ main/resources/org/apache/manifoldcf/agents/output/searchblox/ test/java/org/apache/manifoldcf...

Author: rharo
Date: Sat Mar 21 17:53:34 2015
New Revision: 1668309

URL: http://svn.apache.org/r1668309
Log:
CONNECTORS-1168: Completing JSON support

Modified:
    manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/java/org/apache/manifoldcf/agents/output/searchblox/SearchBloxClient.java
    manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/java/org/apache/manifoldcf/agents/output/searchblox/SearchBloxConnector.java
    manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/java/org/apache/manifoldcf/agents/output/searchblox/SearchBloxDocument.java
    manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/resources/org/apache/manifoldcf/agents/output/searchblox/editConfiguration_Parameters.html
    manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/resources/org/apache/manifoldcf/agents/output/searchblox/editSpecification_Configuration.html
    manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/resources/org/apache/manifoldcf/agents/output/searchblox/viewConfiguration.html
    manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/resources/org/apache/manifoldcf/agents/output/searchblox/viewSpecification.html
    manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/test/java/org/apache/manifoldcf/agents/output/searchblox/tests/SearchBloxDocumentTest.java

Modified: manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/java/org/apache/manifoldcf/agents/output/searchblox/SearchBloxClient.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/java/org/apache/manifoldcf/agents/output/searchblox/SearchBloxClient.java?rev=1668309&r1=1668308&r2=1668309&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/java/org/apache/manifoldcf/agents/output/searchblox/SearchBloxClient.java (original)
+++ manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/java/org/apache/manifoldcf/agents/output/searchblox/SearchBloxClient.java Sat Mar 21 17:53:34 2015
@@ -35,8 +35,6 @@ import org.apache.manifoldcf.agents.outp
 import org.apache.manifoldcf.crawler.system.Logging;
 import org.apache.xerces.parsers.DOMParser;
 import org.jboss.resteasy.plugins.providers.StringTextStar;
-import org.json.JSONException;
-import org.json.JSONObject;
 import org.w3c.dom.Document;
 import org.w3c.dom.NodeList;
 import org.xml.sax.InputSource;
@@ -50,7 +48,7 @@ import org.xml.sax.SAXException;
 public class SearchBloxClient {
 
     // TODO All this might need to be included in a configuration file
-    public static final String DEFAULT_ENDPOINT = "http://localhost:8080/searchblox/api/rest";
+    public static final String DEFAULT_ENDPOINT = "http://localhost:8080/searchblox/rest/v1/api";
 
     private static final String ADD_PATH = "add";
 
@@ -64,18 +62,18 @@ public class SearchBloxClient {
 
     private static final String STATUS_NODE = "statuscode";
     
-    private static final Pattern status_pattern = Pattern.compile("^status code\\s:\\s([0-9]+)$");
+    private static final Pattern status_pattern = Pattern.compile("^status code\\s?:\\s([0-9]+)$");
 
     public static enum ResponseCode {
         DOCUMENT_INDEXED(100),
         DOCUMENT_REJECTED(101),
-        DOCUMENT_DELETED(200),
-        DOCUMENT_NOT_EXIST(201),
+        DOCUMENT_DELETED(200, 2001),
+        DOCUMENT_NOT_EXIST(201, 2002),
         DOCUMENT_NOT_FOUND(301),
         COLLECTION_CLEARED(400),
         ERROR_CLEARING_COLLECTION(401),
         COLLECTION_CREATED(900),
-        INVALID_COLLECTION_NAME(500),
+        INVALID_COLLECTION_NAME(500, 501),
         INVALID_REQUEST(501),
         INVALID_DOCUMENT_LOCATION(502),
         NOT_CUSTOM_COLLECTION(503),
@@ -84,11 +82,17 @@ public class SearchBloxClient {
         SERVER_UNREACHABLE(700);
 
         private int code;
-
+        private int jsonCode;
+        
         ResponseCode(int code) {
             this.code = code;
         }
         
+        ResponseCode(int code, int jsonCode) {
+            this.code = code;
+            this.jsonCode = jsonCode;
+        }
+        
         static ResponseCode getCodeFromValue(int value){
         	for(ResponseCode e:ResponseCode.values())
         		if(value == e.code)
@@ -96,11 +100,23 @@ public class SearchBloxClient {
         	return null;
         }
         
+        static ResponseCode getCodeFromValue(int value, boolean json){
+        	for(ResponseCode e:ResponseCode.values())
+        		if((json && value == e.jsonCode) || (value == e.code)) {
+        			return e;
+        		}
+        	return null;
+        }
+        
         int getCode(){
         	return code;
         }
+        
+        int getJsonCode() {
+        	return jsonCode;
+        }
     }
-
+    
 
     private String apikey;
     private Client client;
@@ -128,26 +144,26 @@ public class SearchBloxClient {
         return post(document, format, SearchBloxDocument.DocumentAction.DELETE);
     }
 
-    public ResponseCode createCollection(String colname)
+    public ResponseCode createCollection(String colname, String format)
             throws SearchBloxException {
         SearchBloxDocument document = new SearchBloxDocument(apikey);
         document.colName = colname;
-        return post(document, SearchBloxDocument.IndexingFormat.XML.name(), SearchBloxDocument.DocumentAction.CREATE);
+        return post(document, format, SearchBloxDocument.DocumentAction.CREATE);
     }
 
-    public ResponseCode clearCollection(String colname)
+    public ResponseCode clearCollection(String colname, String format)
             throws SearchBloxException {
         SearchBloxDocument document = new SearchBloxDocument(apikey);
         document.colName = colname;
-        return post(document, SearchBloxDocument.IndexingFormat.XML.name(), SearchBloxDocument.DocumentAction.CLEAR);
+        return post(document, format, SearchBloxDocument.DocumentAction.CLEAR);
     }
 
-    public boolean ping()
+    public boolean ping(String format)
             throws SearchBloxException {
         SearchBloxDocument document = new SearchBloxDocument(apikey);
         document.colName = UUID.randomUUID().toString();
         document.uid = UUID.randomUUID().toString();
-        ResponseCode result = post(document, SearchBloxDocument.IndexingFormat.XML.name(), SearchBloxDocument.DocumentAction.STATUS);
+        ResponseCode result = post(document, format, SearchBloxDocument.DocumentAction.STATUS);
         return result == ResponseCode.INVALID_COLLECTION_NAME;
     }
 
@@ -155,10 +171,15 @@ public class SearchBloxClient {
             throws SearchBloxException {
         
     	SearchBloxDocument.IndexingFormat iFormat = SearchBloxDocument.IndexingFormat.valueOf(format.toUpperCase());
-        if (iFormat == null) {
+    	
+    	if (iFormat == null) {
             Logging.connectors.error("[Post request] Format not recognized " +format);
             throw new SearchBloxException("Unknown Serialization Format " + format);
         }
+    	
+    	boolean isJson = iFormat.equals(SearchBloxDocument.IndexingFormat.JSON);
+    	
+        
 
         UriBuilder uri = uriBuilder.clone();
         if (action == SearchBloxDocument.DocumentAction.ADD_UPDATE) {
@@ -221,7 +242,7 @@ public class SearchBloxClient {
         	}
         	String codeStr = nodeList.item(0).getTextContent();
         	int statusCode = Integer.parseInt(codeStr);
-        	return ResponseCode.getCodeFromValue(statusCode);
+        	return ResponseCode.getCodeFromValue(statusCode, isJson);
         }else{
 //        	try {
 //				JSONObject json = new JSONObject(rawResponse);
@@ -229,15 +250,15 @@ public class SearchBloxClient {
         		Matcher matcher = status_pattern.matcher(rawResponse);
         		String codeStr = null;
         		if(matcher.find())
-        			codeStr = matcher.group();
+        			codeStr = matcher.group(1);
         		if(codeStr == null){
-        			String message = "[Response parsing] Resoponse code parsing error";
+        			String message = "[Response parsing] Response code parsing error";
         			Logging.connectors.error(message);
             		throw new SearchBloxException(message);
         		}
         			
 				int statusCode = Integer.parseInt(codeStr);
-	        	return ResponseCode.getCodeFromValue(statusCode);
+	        	return ResponseCode.getCodeFromValue(statusCode, isJson);
 //			} catch (JSONException e) {
 //				Logging.connectors.error("[Response parsing] Response JSON parsing error", e);
 //        		throw new SearchBloxException(e);

Modified: manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/java/org/apache/manifoldcf/agents/output/searchblox/SearchBloxConnector.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/java/org/apache/manifoldcf/agents/output/searchblox/SearchBloxConnector.java?rev=1668309&r1=1668308&r2=1668309&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/java/org/apache/manifoldcf/agents/output/searchblox/SearchBloxConnector.java (original)
+++ manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/java/org/apache/manifoldcf/agents/output/searchblox/SearchBloxConnector.java Sat Mar 21 17:53:34 2015
@@ -187,7 +187,8 @@ public class SearchBloxConnector extends
 	public String check() throws ManifoldCFException {
 		getSession(null, null);
 		try {
-			if (client.ping()) {
+			String format = getConfiguration().getParameter(SEARCHBLOX_INDEXING_FORMAT);
+			if (client.ping(format)) {
 				return super.check();
 			} else {
 				return "Connection Not Working!. Check SearchBlox Server is up and the configuration is correct.";
@@ -312,7 +313,7 @@ public class SearchBloxConnector extends
 
 		SearchBloxDocument sbDoc = new SearchBloxDocument(this.apiKey,
 				documentURI, document, sp.getArgs());
-		String format = args.get(SEARCHBLOX_INDEXING_FORMAT).get(0);
+		String format = this.getConfiguration().getParameter(SEARCHBLOX_INDEXING_FORMAT);
 		long startTime = System.currentTimeMillis();
 		try {
 			ResponseCode code = client.addUpdateDocument(sbDoc, format);
@@ -476,6 +477,10 @@ public class SearchBloxConnector extends
 		}
 		map.put(SEARCHBLOX_ENDPOINT,
 				endpoint);
+		
+		String indexFormat = configParams.getParameter(SEARCHBLOX_INDEXING_FORMAT);
+		indexFormat = indexFormat == null ? IndexingFormat.JSON.name() : indexFormat;
+		map.put(SEARCHBLOX_INDEXING_FORMAT, indexFormat);
 		return map;
 	}
 
@@ -517,6 +522,10 @@ public class SearchBloxConnector extends
 		String endpoint = variableContext.getParameter(SEARCHBLOX_ENDPOINT);
 		if (endpoint != null)
 			parameters.setParameter(SEARCHBLOX_ENDPOINT, endpoint);
+		
+		String indexformat = variableContext.getParameter(SEARCHBLOX_INDEXING_FORMAT);
+		if (indexformat != null)
+			parameters.setParameter(SEARCHBLOX_INDEXING_FORMAT, indexformat);
 
 		return null;
 	}
@@ -600,14 +609,6 @@ public class SearchBloxConnector extends
 				if (collection == null)
 					collection = DEFAULT_COLLECTION;
 				
-				String indexFormat = sn
-						.getAttributeValue(SearchBloxConfig.ATTRIBUTE_INDEX_FORMAT);
-				IndexingFormat format = IndexingFormat.valueOf(indexFormat.toUpperCase());
-				if (format == null)
-					indexFormat = IndexingFormat.XML.name();
-				else
-					indexFormat = format.name();
-
 				paramMap.put(SearchBloxConfig.ATTRIBUTE_TITLEBOOST.toUpperCase(),
 						titleBoost);
 				paramMap.put(SearchBloxConfig.ATTRIBUTE_CONTENTBOOST.toUpperCase(),
@@ -623,9 +624,6 @@ public class SearchBloxConnector extends
 				paramMap.put(
 						SearchBloxConfig.ATTRIBUTE_TIMEOUT_SOCKET.toUpperCase(),
 						timeoutSocket);
-				paramMap.put(
-						SearchBloxConfig.ATTRIBUTE_INDEX_FORMAT.toUpperCase(),
-						indexFormat);
 				paramMap.put(SearchBloxConfig.ATTRIBUTE_COLLECTION_NAME
 						.toUpperCase(), collection);
 
@@ -831,16 +829,14 @@ public class SearchBloxConnector extends
 	          String poolSize = node.getAttributeValue(SearchBloxConfig.ATTRIBUTE_POOLSIZE);
 	          String connectTimeout = node.getAttributeValue(SearchBloxConfig.ATTRIBUTE_TIMEOUT_CONNECTION);
 	          String socketTimeout = node.getAttributeValue(SearchBloxConfig.ATTRIBUTE_TIMEOUT_SOCKET);
-	          String indexingFormat = node.getAttributeValue(SearchBloxConfig.ATTRIBUTE_INDEX_FORMAT);
 	          args.put(SearchBloxConfig.ATTRIBUTE_TITLEBOOST, titleBoost);
 	          args.put(SearchBloxConfig.ATTRIBUTE_CONTENTBOOST, contentBoost);
 	          args.put(SearchBloxConfig.ATTRIBUTE_KEYWORDSBOOST, keywordsBoost);
-	          args.put(SearchBloxConfig.ATTRIBUTE_COLLECTION_NAME, descriptionBoost);
+	          args.put(SearchBloxConfig.ATTRIBUTE_DESCRIPTIONBOOST, descriptionBoost);
 	          args.put(SearchBloxDocument.SEARCHBLOX_COLLECTION, collection);
 	          args.put(SearchBloxConfig.ATTRIBUTE_POOLSIZE, poolSize);
 	          args.put(SearchBloxConfig.ATTRIBUTE_TIMEOUT_CONNECTION, connectTimeout);
 	          args.put(SearchBloxConfig.ATTRIBUTE_TIMEOUT_SOCKET, socketTimeout);
-	          args.put(SearchBloxConfig.ATTRIBUTE_INDEX_FORMAT, indexingFormat);
 	          
 	        }
 	      }

Modified: manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/java/org/apache/manifoldcf/agents/output/searchblox/SearchBloxDocument.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/java/org/apache/manifoldcf/agents/output/searchblox/SearchBloxDocument.java?rev=1668309&r1=1668308&r2=1668309&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/java/org/apache/manifoldcf/agents/output/searchblox/SearchBloxDocument.java (original)
+++ manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/java/org/apache/manifoldcf/agents/output/searchblox/SearchBloxDocument.java Sat Mar 21 17:53:34 2015
@@ -16,24 +16,9 @@
  */
 package org.apache.manifoldcf.agents.output.searchblox;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.text.SimpleDateFormat;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Multimap;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.manifoldcf.agents.interfaces.RepositoryDocument;
@@ -45,9 +30,18 @@ import org.jsoup.Jsoup;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Multimap;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.text.SimpleDateFormat;
+import java.util.*;
 
 /**
  * "Package" class modeling a SearchBox document as a POJO
@@ -150,11 +144,11 @@ public class SearchBloxDocument {
 				String[] values = rd.getFieldAsStrings(name);
 				for (String value : values) {
 					String key = name.toLowerCase();
-					int indexOf = xmlElements.indexOf(key); 
-					if (indexOf != -1 && 
+					int indexOf = xmlElements.indexOf(key);
+					if(indexOf != 5)
+                    if (indexOf != -1 &&
 							indexOf != 0 &&
-							indexOf != 5 &&
-							indexOf != 7 && 
+							indexOf != 7 &&
 							indexOf != 8) {
 						data_fields.put(key, value);
 					} else
@@ -235,12 +229,6 @@ public class SearchBloxDocument {
 									document.put(element, StringUtils.join(values, ','));
 								else
 									document.put(element, value);
-//								Collection<Object> boostElement = data_fields
-//										.get(element + "_boost");
-//								if(boostElement!=null && boostElement.size()>0){
-//									String value_boost = (String) boostElement.iterator()
-//											.next();
-//									eValue.setAttribute(BOOST_ATTRIBUTE, "" + value_boost);
 //								}
 								
 							}

Modified: manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/resources/org/apache/manifoldcf/agents/output/searchblox/editConfiguration_Parameters.html
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/resources/org/apache/manifoldcf/agents/output/searchblox/editConfiguration_Parameters.html?rev=1668309&r1=1668308&r2=1668309&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/resources/org/apache/manifoldcf/agents/output/searchblox/editConfiguration_Parameters.html (original)
+++ manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/resources/org/apache/manifoldcf/agents/output/searchblox/editConfiguration_Parameters.html Sat Mar 21 17:53:34 2015
@@ -31,12 +31,25 @@
     <td class="value"><input name="endpoint" type="text" value="$Encoder.attributeEscape($ENDPOINT)"
       size="24" /></td>
   </tr>
+  <tr>
+    <td class="description"><nobr>$Encoder.bodyEscape($ResourceBundle.getString('SearchBloxConnector.IndexFormat'))</nobr></td>
+    <td class="value">
+      <select name="indexformat">
+  
+        <option value="JSON" #if($INDEXFORMAT == 'JSON') selected="true" #end>$Encoder.bodyEscape($ResourceBundle.getString('SearchBloxConnector.JSON'))</option>
+ 
+        <option value="XML" #if($INDEXFORMAT == 'XML') selected="true" #end>$Encoder.bodyEscape($ResourceBundle.getString('SearchBloxConnector.XML'))</option>
+ 	  </select>
+    </td>
+  </tr>
 </table>
 
 #else
 
 <input type="hidden" name="apikey" value="$Encoder.attributeEscape($APIKEY)" />
 <input type="hidden" name="endpoint" value="$Encoder.attributeEscape($ENDPOINT)" />
+<input type="hidden" name="indexformat" value="$Encoder.attributeEscape($INDEXFORMAT)"/>
+
 
 
 #end

Modified: manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/resources/org/apache/manifoldcf/agents/output/searchblox/editSpecification_Configuration.html
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/resources/org/apache/manifoldcf/agents/output/searchblox/editSpecification_Configuration.html?rev=1668309&r1=1668308&r2=1668309&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/resources/org/apache/manifoldcf/agents/output/searchblox/editSpecification_Configuration.html (original)
+++ manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/resources/org/apache/manifoldcf/agents/output/searchblox/editSpecification_Configuration.html Sat Mar 21 17:53:34 2015
@@ -67,17 +67,6 @@
       <input type="text" name="s${SEQNUM}_collection" value="$Encoder.attributeEscape($COLLECTION)" />
     </td>
   </tr>
-  <tr>
-    <td class="description"><nobr>$Encoder.bodyEscape($ResourceBundle.getString('SearchBloxConnector.IndexFormat'))</nobr></td>
-    <td class="value">
-      <select name="s${SEQNUM}_indexformat">
-  
-        <option value="JSON" #if($INDEXFORMAT == 'JSON') selected="true" #end>$Encoder.bodyEscape($ResourceBundle.getString('SearchBloxConnector.JSON'))</option>
- 
-        <option value="XML" #if($INDEXFORMAT == 'XML') selected="true" #end>$Encoder.bodyEscape($ResourceBundle.getString('SearchBloxConnector.XML'))</option>
- 	  </select>
-    </td>
-  </tr>
   
 </table>
       
@@ -91,6 +80,5 @@
 <input type="hidden" name="s${SEQNUM}_timeoutconnection" value="${TIMEOUTCONNECTION}"/>
 <input type="hidden" name="s${SEQNUM}_timeoutsocket" value="${TIMEOUTSOCKET}"/>
 <input type="hidden" name="s${SEQNUM}_collection" value="${COLLECTION}"/>
-<input type="hidden" name="s${SEQNUM}_indexformat" value="${INDEXFORMAT}"/>
 
 #end
\ No newline at end of file

Modified: manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/resources/org/apache/manifoldcf/agents/output/searchblox/viewConfiguration.html
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/resources/org/apache/manifoldcf/agents/output/searchblox/viewConfiguration.html?rev=1668309&r1=1668308&r2=1668309&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/resources/org/apache/manifoldcf/agents/output/searchblox/viewConfiguration.html (original)
+++ manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/resources/org/apache/manifoldcf/agents/output/searchblox/viewConfiguration.html Sat Mar 21 17:53:34 2015
@@ -24,4 +24,8 @@
     <td class="description"><nobr>$Encoder.bodyEscape($ResourceBundle.getString('SearchBloxConnector.ApiKey'))</nobr></td>
     <td class="value">$Encoder.bodyEscape($APIKEY)</td>
   </tr>
+  <tr>
+    <td class="description"><nobr>$Encoder.bodyEscape($ResourceBundle.getString('SearchBloxConnector.IndexFormat'))</nobr></td>
+    <td class="value">$Encoder.bodyEscape($INDEXFORMAT)</td>
+  </tr>
 </table>
\ No newline at end of file

Modified: manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/resources/org/apache/manifoldcf/agents/output/searchblox/viewSpecification.html
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/resources/org/apache/manifoldcf/agents/output/searchblox/viewSpecification.html?rev=1668309&r1=1668308&r2=1668309&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/resources/org/apache/manifoldcf/agents/output/searchblox/viewSpecification.html (original)
+++ manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/main/resources/org/apache/manifoldcf/agents/output/searchblox/viewSpecification.html Sat Mar 21 17:53:34 2015
@@ -57,10 +57,6 @@
     <td class="value"><nobr>$Encoder.bodyEscape($COLLECTION)</nobr></td>
   </tr>
   <tr><td class="separator" colspan="2"><hr/></td></tr>
-  <tr>
-    <td class="description"><nobr>$Encoder.bodyEscape($ResourceBundle.getString('SearchBloxConnector.IndexFormat'))</nobr></td>
-    <td class="value"><nobr>$Encoder.bodyEscape($INDEXFORMAT)</nobr></td>
-  </tr>
-  
+ 
 
 </table>

Modified: manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/test/java/org/apache/manifoldcf/agents/output/searchblox/tests/SearchBloxDocumentTest.java
URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/test/java/org/apache/manifoldcf/agents/output/searchblox/tests/SearchBloxDocumentTest.java?rev=1668309&r1=1668308&r2=1668309&view=diff
==============================================================================
--- manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/test/java/org/apache/manifoldcf/agents/output/searchblox/tests/SearchBloxDocumentTest.java (original)
+++ manifoldcf/branches/CONNECTORS-1168/connectors/searchblox/connector/src/test/java/org/apache/manifoldcf/agents/output/searchblox/tests/SearchBloxDocumentTest.java Sat Mar 21 17:53:34 2015
@@ -37,6 +37,46 @@ public class SearchBloxDocumentTest exte
        toTest=new SearchBloxDocument(apikey, docURI,rd,args);
    }
 
+    @Test
+    public void testUpdateXmlString() throws SearchBloxException {
+        String xmlGenerated=toTest.toString(IndexingFormat.XML, DocumentAction.ADD_UPDATE);
+        System.out.println(xmlGenerated);
+        String xmlExpected="<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+                "<searchblox apikey=\"apikey\"><document colname=\"collection1\">" +
+                "<uid>URI</uid><title boost=\"1\">I am a nice title</title><content boost=\"2\">I am a nice content in english!</content>" +
+                "<description boost=\"4\">I am a little tiny description</description><size>100</size><contenttype>html</contenttype>" +
+                "<meta name=\"meta2\">I am META2!</meta><meta name=\"share_allow\">user3</meta>" +
+                "<meta name=\"share_allow\">user2</meta><meta name=\"share_allow\">user1</meta>" +
+                "<meta name=\"meta1\">I am META1!</meta><meta name=\"share_deny\">user4</meta>" +
+                "<meta name=\"share_deny\">user5</meta><meta name=\"document_deny\">user52</meta>" +
+                "<meta name=\"document_deny\">user42</meta><meta name=\"document_allow\">user22</meta>" +
+                "<meta name=\"document_allow\">user12</meta><meta name=\"document_allow\">user33</meta></document></searchblox>";
+        assertEquals(xmlExpected,xmlGenerated);
+    }
+
+    @Test
+    public void testUpdateJsonString() throws SearchBloxException {
+        String jsonGenerated=toTest.toString(IndexingFormat.JSON, DocumentAction.ADD_UPDATE);
+        String expectedJson="{\"document\":{\"content\":\"I am a nice content in english!\",\"uid\":\"URI\",\"title\":\"I am a nice title\",\"description\":\"I am a little tiny description\",\"contenttype\":\"html\",\"colname\":\"collection1\",\"meta\":{\"meta2\":[\"I am META2!\"],\"meta1\":[\"I am META1!\"],\"share_allow\":[\"user3\",\"user2\",\"user1\"],\"share_deny\":[\"user4\",\"user5\"],\"document_deny\":[\"user52\",\"user42\"],\"document_allow\":[\"user22\",\"user12\",\"user33\"]},\"size\":\"100\"},\"apikey\":\"apikey\"}";
+        assertEquals(expectedJson,jsonGenerated);
+    }
+
+    @Test
+    public void testDeleteJsonString() throws SearchBloxException {
+        String jsonGenerated=toTest.toString(IndexingFormat.JSON, DocumentAction.DELETE);
+        System.out.println(jsonGenerated);
+        String xmlExpected="{\"document\":{\"uid\":\"URI\",\"colname\":\"collection1\"},\"apikey\":\"apikey\"}";
+        assertEquals(xmlExpected,jsonGenerated);
+    }
+
+    @Test
+    public void testDeleteXmlString() throws SearchBloxException {
+        String xmlGenerated=toTest.toString(IndexingFormat.XML, DocumentAction.DELETE);
+        System.out.println(xmlGenerated);
+        String xmlExpected="<?xml version=\"1.0\" encoding=\"UTF-8\"?><searchblox apikey=\"apikey\"><document colname=\"collection1\" uid=\"URI\"/></searchblox>";
+        assertEquals(xmlExpected,xmlGenerated);
+    }
+
     private Map<String, List<String>> initArgs() {
         Map<String, List<String>> argMap=new HashMap<String, List<String>>();
         argMap.put("collection", Lists.newArrayList("collection1"));
@@ -69,29 +109,4 @@ public class SearchBloxDocumentTest exte
         return realRepoDoc;
     }
 
-    @Test
-    public void testUpdateXmlString() throws SearchBloxException {
-        String xmlGenerated=toTest.toString(IndexingFormat.XML, DocumentAction.ADD_UPDATE);
-        System.out.println(xmlGenerated);
-        String xmlExpected="<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
-                "<searchblox apikey=\"apikey\"><document colname=\"collection1\">" +
-                "<uid>URI</uid><title boost=\"1\">I am a nice title</title><content boost=\"2\">I am a nice content in english!</content>" +
-                "<description boost=\"4\">I am a little tiny description</description><size>100</size><contenttype>html</contenttype>" +
-                "<meta name=\"meta2\">I am META2!</meta><meta name=\"share_allow\">user3</meta>" +
-                "<meta name=\"share_allow\">user2</meta><meta name=\"share_allow\">user1</meta>" +
-                "<meta name=\"meta1\">I am META1!</meta><meta name=\"share_deny\">user4</meta>" +
-                "<meta name=\"share_deny\">user5</meta><meta name=\"document_deny\">user52</meta>" +
-                "<meta name=\"document_deny\">user42</meta><meta name=\"document_allow\">user22</meta>" +
-                "<meta name=\"document_allow\">user12</meta><meta name=\"document_allow\">user33</meta></document></searchblox>";
-        assertEquals(xmlExpected,xmlGenerated);
-    }
-
-    @Test
-    public void testDeleteXmlString() throws SearchBloxException {
-        String xmlGenerated=toTest.toString(IndexingFormat.XML, DocumentAction.DELETE);
-        System.out.println(xmlGenerated);
-        String xmlExpected="<?xml version=\"1.0\" encoding=\"UTF-8\"?><searchblox apikey=\"apikey\"><document colname=\"collection1\" uid=\"URI\"/></searchblox>";
-        assertEquals(xmlExpected,xmlGenerated);
-    }
-
 }