本文整理汇总了Java中org.modeshape.jcr.federation.spi.DocumentWriter类的典型用法代码示例。如果您正苦于以下问题:Java DocumentWriter类的具体用法?Java DocumentWriter怎么用?Java DocumentWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DocumentWriter类属于org.modeshape.jcr.federation.spi包,在下文中一共展示了DocumentWriter类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newFolderWriter
import org.modeshape.jcr.federation.spi.DocumentWriter; //导入依赖的package包/类
private DocumentWriter newFolderWriter(final String id, final File file,
final int offset) {
final boolean root = isRoot(id);
final DocumentWriter writer = newDocument(id);
writer.setPrimaryType(NT_FOLDER);
writer.addProperty(JCR_CREATED, factories().getDateFactory().create(
file.lastModified()));
writer.addProperty(JCR_CREATED_BY, null); // ignored
final File[] children = file.listFiles(filenameFilter);
long totalChildren = 0;
int nextOffset = 0;
for (int i = 0; i < children.length; i++) {
final File child = children[i];
// Only include as a child if we can access and read the file.
// Permissions might prevent us from reading the file, and the file
// might not exist if it is a broken symlink
// (see MODE-1768 for details).
if (child.exists() && child.canRead() &&
(child.isFile() || child.isDirectory())) {
// we need to count the total accessible children
totalChildren++;
// only add a child if it's in the current page
if (i >= offset && i < offset + pageSize) {
// We use identifiers that contain the file/directory name
final String childName = child.getName();
final String childId =
root ? DELIMITER + childName : id + DELIMITER +
childName;
writer.addChild(childId, childName);
nextOffset = i + 1;
}
}
}
// if there are still accessible children add the next page
if (nextOffset < totalChildren) {
writer.addPage(id, nextOffset, pageSize, totalChildren);
}
return writer;
}
开发者ID:nigelgbanks,项目名称:fcrepo-filesystem-modeshape-federation-connector,代码行数:40,代码来源:FileSystemConnector.java
示例2: getDocumentById
import org.modeshape.jcr.federation.spi.DocumentWriter; //导入依赖的package包/类
/**
* Returns a {@link Document} instance representing the document with a
* given id. The document should have a "proper" structure for it to be
* usable by ModeShape.
*
* @param id a {@code non-null} string
* @return either an {@link Document} instance or {@code null}
*/
@Override
public Document getDocumentById(final String id) {
final File file = fileFor(id);
if (isExcluded(file) || !file.exists()) {
return null;
}
final boolean isRoot = isRoot(id);
final boolean isResource = isContentNode(id);
DocumentWriter writer = null;
File parentFile = file.getParentFile();
if (isResource) {
writer = newDocument(id);
final BinaryValue binaryValue = binaryFor(file);
writer.setPrimaryType(NT_RESOURCE);
writer.addProperty(JCR_DATA, binaryValue);
if (addMimeTypeMixin) {
String mimeType = null;
final String encoding = null; // We don't really know this
try {
mimeType = binaryValue.getMimeType();
} catch (final Throwable e) {
getLogger().error(e, JcrI18n.couldNotGetMimeType,
getSourceName(), id, e.getMessage());
}
writer.addProperty(JCR_ENCODING, encoding);
writer.addProperty(JCR_MIME_TYPE, mimeType);
}
writer.addProperty(JCR_LAST_MODIFIED, factories().getDateFactory()
.create(file.lastModified()));
writer.addProperty(JCR_LAST_MODIFIED_BY, null); // ignored
// make these binary not queryable. If we really want to query them,
// we need to switch to external binaries
writer.setNotQueryable();
parentFile = file;
} else if (file.isFile()) {
writer = newDocument(id);
writer.setPrimaryType(NT_FILE);
writer.addProperty(JCR_CREATED, factories().getDateFactory()
.create(file.lastModified()));
writer.addProperty(JCR_CREATED_BY, null); // ignored
final String childId =
isRoot ? JCR_CONTENT_SUFFIX : id + JCR_CONTENT_SUFFIX;
writer.addChild(childId, JCR_CONTENT);
} else {
writer = newFolderWriter(id, file, 0);
}
if (!isRoot) {
// Set the reference to the parent ...
final String parentId = idFor(parentFile);
writer.setParents(parentId);
}
// Add the extra properties (if there are any), overwriting any
// properties with the same names
// (e.g., jcr:primaryType, jcr:mixinTypes, jcr:mimeType, etc.) ...
writer.addProperties(extraPropertiesStore().getProperties(id));
// Add the 'mix:mixinType' mixin; if other mixins are stored in the
// extra properties, this will append ...
if (addMimeTypeMixin) {
writer.addMixinType(MIX_MIME_TYPE);
}
// Return the document ...
return writer.document();
}
开发者ID:nigelgbanks,项目名称:fcrepo-filesystem-modeshape-federation-connector,代码行数:77,代码来源:FileSystemConnector.java
示例3: newDocumentWriter
import org.modeshape.jcr.federation.spi.DocumentWriter; //导入依赖的package包/类
/**
* Get the default document writer
*
* @param id
* @return
*/
protected DocumentWriter newDocumentWriter(final String id) {
return super.newDocument(id);
}