|
ModeShape Distribution 3.2.0.Final | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.modeshape.jcr.federation.spi.Connector org.modeshape.jcr.federation.spi.WritableConnector org.modeshape.connector.filesystem.FileSystemConnector
public class FileSystemConnector
Connector
implementation that exposes a single directory on the local file system. This connector has several
properties that must be configured via the RepositoryConfiguration
:
directoryPath
- The path to the file or folder that is to be accessed by this connector.readOnly
- A boolean flag that specifies whether this source can create/modify/remove files
and directories on the file system to reflect changes in the JCR content. By default, sources are not read-only.addMimeTypeMixin
- A boolean flag that specifies whether this connector should add the
'mix:mimeType' mixin to the 'nt:resource' nodes to include the 'jcr:mimeType' property. If set to true
, the MIME
type is computed immediately when the 'nt:resource' node is accessed, which might be expensive for larger files. This is
false
by default.extraPropertyStorage
- An optional string flag that specifies how this source handles "extra"
properties that are not stored via file system attributes. See extraPropertiesStorage
for details. By default, extra
properties are stored in the same Infinispan cache that the repository uses.exclusionPattern
- Optional property that specifies a regular expression that is used to
determine which files and folders in the underlying file system are not exposed through this connector. Files and folders with
a name that matches the provided regular expression will not be exposed by this source.inclusionPattern
- Optional property that specifies a regular expression that is used to
determine which files and folders in the underlying file system are exposed through this connector. Files and folders with a
name that matches the provided regular expression will be exposed by this source.Inclusion Pattern | Exclusion Pattern | Examples |
---|---|---|
(.+)\\.txt$ | Includes only files and directories whose names end in ".txt " (e.g., "something.txt " ), but does
not include files and other folders such as "something.jar " or "something.txt.zip ". |
|
(.+)\\.txt$ | my.txt | Includes only files and directories whose names end in ".txt " (e.g., "something.txt " ) with the
exception of "my.txt ", and does not include files and other folders such as "something.jar " or "
something.txt.zip ". |
my.txt | .+ | Excludes all files and directories except any named "my.txt ". |
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.modeshape.jcr.federation.spi.Connector |
---|
Connector.ExtraProperties |
Constructor Summary | |
---|---|
FileSystemConnector()
|
Method Summary | |
---|---|
protected ExternalBinaryValue |
binaryFor(File file)
Utility method for creating a BinaryValue for the given File object. |
protected void |
checkFileNotExcluded(String id,
File file)
Utility method to ensure that the file is writable by this connector. |
protected ExternalBinaryValue |
createBinaryValue(BinaryKey key,
File file)
Utility method to create a BinaryValue object for the given file. |
protected File |
createFileForUrl(URL url)
|
protected URL |
createUrlForFile(File file)
Construct a URL object for the given file, to be used within the Binary value representing the "jcr:data"
property of a 'nt:resource' node. |
protected File |
fileFor(String id)
Utility method for obtaining the File object that corresponds to the supplied identifier. |
ExternalBinaryValue |
getBinaryValue(String id)
Returns a binary value which is connector specific and which is never stored by ModeShape. |
Document |
getDocumentById(String id)
Returns a Document instance representing the document with a given id. |
String |
getDocumentId(String path)
Returns the id of an external node located at the given path. |
boolean |
hasDocument(String id)
Checks if a document with the given id exists in the end-source. |
protected String |
idFor(File file)
Utility method for determining the node identifier for the supplied file. |
void |
initialize(NamespaceRegistry registry,
NodeTypeManager nodeTypeManager)
Initialize the connector. |
protected boolean |
isContentNode(String id)
Utility method for determining if the supplied identifier is for the "jcr:content" child node of a file. * Subclasses may override this method to change the format of the identifiers, but in that case should also override the fileFor(String) , isRoot(String) , and idFor(File) methods. |
protected boolean |
isExcluded(File file)
Utility method to determine if the file is excluded by the inclusion/exclusion filter. |
protected boolean |
isRoot(String id)
Utility method for determining if the node identifier is the identifier of the root node in this external source. |
String |
newDocumentId(String parentId,
Name newDocumentName,
Name newDocumentPrimaryType)
Generates an identifier which will be assigned when a new document (aka. child) is created under an existing document (aka.parent). |
boolean |
removeDocument(String id)
Removes the document with the given id. |
void |
storeDocument(Document document)
Stores the given document. |
void |
updateDocument(DocumentChanges documentChanges)
Updates a document using the provided changes. |
Methods inherited from class org.modeshape.jcr.federation.spi.WritableConnector |
---|
isReadonly |
Methods inherited from class org.modeshape.jcr.federation.spi.Connector |
---|
checkFieldNotNull, extraPropertiesFor, extraPropertiesStore, factories, getCacheTtlSeconds, getChildReference, getContext, getLogger, getMimeTypeDetector, getRepositoryName, getSourceName, getTransactionManager, isQueryable, nameFrom, nameFrom, nameFrom, newChildReference, newDocument, newPageDocument, propertyFactory, readDocument, setExtraPropertiesStore, shutdown, translator |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FileSystemConnector()
Method Detail |
---|
public void initialize(NamespaceRegistry registry, NodeTypeManager nodeTypeManager) throws RepositoryException, IOException
Connector
Connector.context
,
Connector.logger
, Connector.name
, and Connector.repositoryName
plus any fields that match configuration properties for the
connector.
By default this method does nothing, so it should be overridden by implementations to do a one-time initialization of any
internal components. For example, connectors can use the supplied registry
and nodeTypeManager
objects to register custom namesapces and node types required by the external content.
This is an excellent place for connector to validate the connector-specific fields set by ModeShape via reflection during instantiation.
initialize
in class Connector
registry
- the namespace registry that can be used to register custom namespaces; never nullnodeTypeManager
- the node type manager that can be used to register custom node types; never null
RepositoryException
- if operations on the NamespaceRegistry
or NodeTypeManager
fail
IOException
- if any stream based operations fail (like importing cnd files)protected boolean isContentNode(String id)
fileFor(String)
, isRoot(String)
, and idFor(File)
methods.
id
- the identifier; may not be null
isRoot(String)
,
fileFor(String)
,
idFor(File)
protected File fileFor(String id)
File
object that corresponds to the supplied identifier. Subclasses may override
this method to change the format of the identifiers, but in that case should also override the isRoot(String)
,
isContentNode(String)
, and idFor(File)
methods.
id
- the identifier; may not be null
isRoot(String)
,
isContentNode(String)
,
idFor(File)
protected boolean isRoot(String id)
fileFor(String)
, isContentNode(String)
, and idFor(File)
methods.
id
- the identifier; may not be null
isContentNode(String)
,
fileFor(String)
,
idFor(File)
protected String idFor(File file)
fileFor(String)
,
isContentNode(String)
, and isRoot(String)
methods.
file
- the file; may not be null
isRoot(String)
,
isContentNode(String)
,
fileFor(String)
protected ExternalBinaryValue binaryFor(File file)
BinaryValue
for the given File
object. Subclasses should rarely override this
method.
file
- the file; may not be null
protected ExternalBinaryValue createBinaryValue(BinaryKey key, File file) throws IOException
BinaryValue
object for the given file. Subclasses should rarely override this method,
since the UrlBinaryValue
will be applicable in most situations.
key
- the binary key; never nullfile
- the file for which the BinaryValue
is to be created; never null
IOException
- if there is an error creating the valueprotected URL createUrlForFile(File file) throws IOException
URL
object for the given file, to be used within the Binary
value representing the "jcr:data"
property of a 'nt:resource' node.
Subclasses can override this method to transform the URL into something different. For example, if the files are being served by a web server, the overridden method might transform the file-based URL into the corresponding HTTP-based URL.
file
- the file for which the URL is to be created; never null
IOException
- if there is an error creating the URLprotected File createFileForUrl(URL url) throws URISyntaxException
URISyntaxException
protected boolean isExcluded(File file)
file
- the file
protected void checkFileNotExcluded(String id, File file)
id
- the identifier of the nodefile
- the file
DocumentStoreException
- if the file is expected to be writable but is not or is excluded, or if the connector is
readonlypublic boolean hasDocument(String id)
Connector
hasDocument
in class Connector
id
- a non-null
string.
true
if such a document exists, false
otherwise.public Document getDocumentById(String id)
Connector
Document
instance representing the document with a given id. The document should have a "proper"
structure for it to be usable by ModeShape.
getDocumentById
in class Connector
id
- a non-null
string
Document
instance or null
public String getDocumentId(String path)
Connector
getDocumentId
in class Connector
path
- a non-null
string representing an exeternal path.
null
public ExternalBinaryValue getBinaryValue(String id)
Connector
ExternalBinaryValue
, either UrlBinaryValue
or
a custom subclass with connector-specific information.
Normally, the Connector.getDocumentById(String)
method implementation will set binary values on properties of nodes, which
should create the same ExternalBinaryValue subclass that is returned by this method. The
ExternalBinaryValue.getId()
value from that instance will be passed into this method.
getBinaryValue
in class Connector
id
- a String
representing the identifier of the external binary which should have connector-specific meaning.
This identifier need not be the SHA-1 hash of the content.
null
if there is no such value with the given id.public boolean removeDocument(String id)
Connector
removeDocument
in class Connector
id
- a non-null
string.
public void storeDocument(Document document)
Connector
storeDocument
in class Connector
document
- a non-null
Document
instance.public String newDocumentId(String parentId, Name newDocumentName, Name newDocumentPrimaryType)
Connector
newDocumentId
in class Connector
parentId
- a non-null
String
which represents the identifier of the parent under which the new
document will be created.newDocumentName
- a non-null
Name
which represents the name that will be given
to the child documentnewDocumentPrimaryType
- a non-null
Name
which represents the child document's
primary type.
non-null
String
which will be assigned as the new identifier, or null
which means
that no "special" id format is required. In this last case, the repository will auto-generate a random id.public void updateDocument(DocumentChanges documentChanges)
Connector
updateDocument
in class Connector
documentChanges
- a non-null
DocumentChanges
object which contains
granular information about all the changes.
|
ModeShape Distribution 3.2.0.Final | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |