public abstract class AbstractCommitter extends Object implements ICommitter, IXMLConfigurable
A base implementation taking care of basic plumbing, such as
firing main Committer events (including exceptions),
storing the Committer context (available via getCommitterContext()),
and adding support for filtering unwanted requests.
Optionally apply a committer only to certain type of documents. Documents are restricted based on their metadata field names and values. This option can be used to perform document routing when you have multiple committers defined.
By default, this abstract class applies field mappings for metadata fields, but leaves the document reference and content (input stream) for concrete implementations to handle. In other words, they only apply to a committer request metadata. Field mappings are performed on committer requests before upserts and deletes are actually performed.
<!-- multiple "restrictTo" tags allowed (only one needs to match) -->
<restrictTo>
<fieldMatcher
method="[basic|csv|wildcard|regex]"
ignoreCase="[false|true]"
ignoreDiacritic="[false|true]"
partial="[false|true]">
(field-matching expression)
</fieldMatcher>
<valueMatcher
method="[basic|csv|wildcard|regex]"
ignoreCase="[false|true]"
ignoreDiacritic="[false|true]"
partial="[false|true]">
(value-matching expression)
</valueMatcher>
</restrictTo>
<fieldMappings>
<!-- Add as many field mappings as needed -->
<mapping
fromField="(source field name)"
toField="(target field name)"/>
</fieldMappings>
Implementing classes inherit the above XML configuration.
| Constructor and Description |
|---|
AbstractCommitter() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
accept(ICommitterRequest request) |
void |
addRestriction(PropertyMatcher... restrictions)
Adds one or more restrictions this committer should be restricted to.
|
void |
addRestrictions(List<PropertyMatcher> restrictions)
Adds restrictions this committer should be restricted to.
|
protected void |
applyFieldMappings(ICommitterRequest req) |
void |
clean()
Cleans any persisted information (e.g.
|
void |
clearFieldMappings() |
void |
clearRestrictions()
Clears all restrictions.
|
void |
close() |
void |
delete(DeleteRequest deleteRequest) |
protected abstract void |
doClean() |
protected abstract void |
doClose()
Subclasses can perform additional closing logic by overriding this
method.
|
protected abstract void |
doDelete(DeleteRequest deleteRequest) |
protected abstract void |
doInit()
Subclasses can perform additional initialization by overriding this
method.
|
protected abstract void |
doUpsert(UpsertRequest upsertRequest) |
boolean |
equals(Object other) |
protected void |
fireDebug(String name) |
protected void |
fireDebug(String name,
ICommitterRequest req) |
protected void |
fireError(String name,
Exception e) |
protected void |
fireError(String name,
ICommitterRequest req,
Exception e) |
protected void |
fireInfo(String name) |
protected void |
fireInfo(String name,
ICommitterRequest req) |
CommitterContext |
getCommitterContext() |
Map<String,String> |
getFieldMappings()
Gets an unmodifiable copy of the metadata mappings.
|
PropertyMatchers |
getRestrictions()
Gets all restrictions
|
int |
hashCode() |
void |
init(CommitterContext committerContext) |
abstract void |
loadCommitterFromXML(XML xml) |
void |
loadFromXML(XML xml) |
String |
removeFieldMapping(String fromField) |
boolean |
removeRestriction(PropertyMatcher restriction)
Removes a restriction.
|
int |
removeRestriction(String field)
Removes all restrictions on a given field.
|
abstract void |
saveCommitterToXML(XML xml) |
void |
saveToXML(XML xml) |
void |
setFieldMapping(String fromField,
String toField)
Sets a metadata field mapping.
|
void |
setFieldMappings(Map<String,String> mappings)
Sets a metadata field mappings, where the key is the source field and
the value is the target field.
|
String |
toString() |
void |
upsert(UpsertRequest upsertRequest) |
public void addRestriction(PropertyMatcher... restrictions)
restrictions - the restrictionspublic void addRestrictions(List<PropertyMatcher> restrictions)
restrictions - the restrictionspublic int removeRestriction(String field)
field - the field to remove restrictions onpublic boolean removeRestriction(PropertyMatcher restriction)
restriction - the restriction to removetrue if this committer contained the restrictionpublic void clearRestrictions()
public PropertyMatchers getRestrictions()
public Map<String,String> getFieldMappings()
public void setFieldMapping(String fromField, String toField)
fromField - source fieldtoField - target fieldpublic void setFieldMappings(Map<String,String> mappings)
mappings - metadata field mappingspublic void clearFieldMappings()
public final void init(CommitterContext committerContext) throws CommitterException
init in interface ICommitterCommitterExceptionpublic boolean accept(ICommitterRequest request) throws CommitterException
accept in interface ICommitterCommitterExceptionpublic final void upsert(UpsertRequest upsertRequest) throws CommitterException
upsert in interface ICommitterCommitterExceptionpublic final void delete(DeleteRequest deleteRequest) throws CommitterException
delete in interface ICommitterCommitterExceptionprotected void applyFieldMappings(ICommitterRequest req)
public final void close()
throws CommitterException
close in interface ICommitterclose in interface AutoCloseableCommitterExceptionpublic final void clean()
throws CommitterException
ICommitterclean in interface ICommitterCommitterException - something went wrong cleaning the committer.public CommitterContext getCommitterContext()
protected abstract void doInit()
throws CommitterException
CommitterContext will be initialized when invoking
getCommitterContext()CommitterException - error initializingprotected abstract void doUpsert(UpsertRequest upsertRequest) throws CommitterException
CommitterExceptionprotected abstract void doDelete(DeleteRequest deleteRequest) throws CommitterException
CommitterExceptionprotected abstract void doClose()
throws CommitterException
CommitterException - error closing committerprotected abstract void doClean()
throws CommitterException
CommitterExceptionprotected final void fireDebug(String name)
protected final void fireDebug(String name, ICommitterRequest req)
protected final void fireInfo(String name)
protected final void fireInfo(String name, ICommitterRequest req)
protected final void fireError(String name, ICommitterRequest req, Exception e)
public final void loadFromXML(XML xml)
loadFromXML in interface IXMLConfigurablepublic final void saveToXML(XML xml)
saveToXML in interface IXMLConfigurablepublic abstract void loadCommitterFromXML(XML xml)
public abstract void saveCommitterToXML(XML xml)
Copyright © 2009–2022 Norconex Inc.. All rights reserved.