Package org.alfresco.solr.content
Class SolrContentUrlBuilder
- java.lang.Object
-
- org.alfresco.solr.content.SolrContentUrlBuilder
-
public class SolrContentUrlBuilder extends Object
Utility class that wraps up the creation of SOLR content URLs given arbitrary, string-based metadata. The URL is constructed from a 19 digit number (zero-padded long), which is built from the ACL ID, the DB ID or a CRC32 of the provided metadata, and a numerical version starting with "000".
For example, the DB ID "4775808" will generate "someprefix:///db/4775/808.gz"
The- Since:
- 5.0
- Author:
- Derek Hulley
-
-
Field Summary
Fields Modifier and Type Field Description static StringFILE_EXTENSIONstatic StringKEY_ACL_IDThe key for the ACL IDstatic StringKEY_DB_IDThe key for the DB IDstatic StringKEY_TENANTThe key for the tenant nameprotected static org.slf4j.Loggerloggerstatic StringSOLR_PROTOCOLsolr is the prefix for SOLR content URLsstatic StringSOLR_PROTOCOL_PREFIX
-
Constructor Summary
Constructors Modifier Constructor Description protectedSolrContentUrlBuilder()Protected constructor used bystart()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SolrContentUrlBuilderadd(String key, String value)Add some metadata to the URL generator.Stringget()Get the final content URL using thesupplied metadata.org.alfresco.repo.content.ContentContextgetContentContext()Helper method to retrieve aContentContextconstructed using the finalget()url.static SolrContentUrlBuilderstart()Factory method to start building the SOLR content URL.
-
-
-
Field Detail
-
SOLR_PROTOCOL
public static final String SOLR_PROTOCOL
solr is the prefix for SOLR content URLs- See Also:
#isContentUrlSupported(String), Constant Field Values
-
SOLR_PROTOCOL_PREFIX
public static final String SOLR_PROTOCOL_PREFIX
- See Also:
- Constant Field Values
-
FILE_EXTENSION
public static final String FILE_EXTENSION
- See Also:
- Constant Field Values
-
KEY_TENANT
public static final String KEY_TENANT
The key for the tenant name- See Also:
- Constant Field Values
-
KEY_DB_ID
public static final String KEY_DB_ID
The key for the DB ID- See Also:
- Constant Field Values
-
KEY_ACL_ID
public static final String KEY_ACL_ID
The key for the ACL ID- See Also:
- Constant Field Values
-
logger
protected static final org.slf4j.Logger logger
-
-
Constructor Detail
-
SolrContentUrlBuilder
protected SolrContentUrlBuilder()
Protected constructor used bystart()
-
-
Method Detail
-
start
public static SolrContentUrlBuilder start()
Factory method to start building the SOLR content URL.- Returns:
- an instance of the builder
-
add
public SolrContentUrlBuilder add(String key, String value)
Add some metadata to the URL generator. The order in which metadata is added is irrelevant. Note that there are specific keys that are commonly used and, if provided, may not be null or empty.KEY_TENANT: The name of the tenant or 'default' if missing.KEY_DB_ID: The database ID.KEY_ACL_ID: The ACL ID.
- Parameters:
key- an arbitrary metadata key (never null>value- some metadata value (null is supported)- Returns:
- this builder for more building
- Throws:
IllegalArgumentException- if the key is nullIllegalStateException- if the key has been used already
-
get
public String get()
Get the final content URL using thesupplied metadata.- Returns:
- the SOLR content URL
- Throws:
IllegalStateException- if no metadata has been added
-
getContentContext
public org.alfresco.repo.content.ContentContext getContentContext()
Helper method to retrieve aContentContextconstructed using the finalget()url.
-
-