use of org.alfresco.repo.content.ContentContext in project SearchServices by Alfresco.
the class SolrContentStoreTest method exampleUsage.
/**
* A demonstration of how the store might be used.
*/
@Test
public void exampleUsage() {
SolrContentStore store = new SolrContentStore(solrHome);
String tenant = "alfresco.com";
long dbId = 12345;
String otherData = "sdfklsfdl";
ContentContext ctxWrite = SolrContentUrlBuilder.start().add(SolrContentUrlBuilder.KEY_DB_ID, String.valueOf(dbId)).add(SolrContentUrlBuilder.KEY_TENANT, tenant).add("otherData", otherData).getContentContext();
ContentWriter writer = store.getWriter(ctxWrite);
writer.putContent("a document in plain text");
// The URL can be reliably rebuilt in any order
String urlRead = SolrContentUrlBuilder.start().add("otherData", otherData).add(SolrContentUrlBuilder.KEY_TENANT, tenant).add(SolrContentUrlBuilder.KEY_DB_ID, String.valueOf(dbId)).get();
ContentReader reader = store.getReader(urlRead);
String documentText = reader.getContentString();
Assert.assertEquals("a document in plain text", documentText);
}
Aggregations