|
ModeShape Distribution 3.1.0.Final | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.modeshape.jcr.federation.spi.Connector
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 BinaryValue |
binaryFor(File file)
Utility method for creating a BinaryValue for the given File object. |
protected void |
checkWritable(String id,
File file)
Utility method to ensure that the file is writable by this connector. |
protected BinaryValue |
createBinaryValue(BinaryKey key,
File file)
Utility method to create a BinaryValue object for the given file. |
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. |
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. |
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.Connector |
|---|
checkFieldNotNull, extraPropertiesFor, extraPropertiesStore, factories, getBinaryValue, 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
ConnectorConnector.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 Connectorregistry - 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 BinaryValue binaryFor(File file)
BinaryValue for the given File object. Subclasses should rarely override this
method.
file - the file; may not be null
protected BinaryValue 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 value
protected 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 boolean isExcluded(File file)
file - the file
protected void checkWritable(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 Connectorid - a non-null string.
true if such a document exists, false otherwise.public Document getDocumentById(String id)
ConnectorDocument 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 Connectorid - a non-null string
Document instance or nullpublic String getDocumentId(String path)
Connector
getDocumentId in class Connectorpath - a non-null string representing an exeternal path.
nullpublic boolean removeDocument(String id)
Connector
removeDocument in class Connectorid - a non-null string.
public void storeDocument(Document document)
Connector
storeDocument in class Connectordocument - a non-null Document instance.public void updateDocument(DocumentChanges documentChanges)
Connector
updateDocument in class ConnectordocumentChanges - a non-null DocumentChanges object which contains
granular information about all the changes.
|
ModeShape Distribution 3.1.0.Final | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||