本文整理汇总了Java中org.modeshape.jcr.JcrI18n类的典型用法代码示例。如果您正苦于以下问题:Java JcrI18n类的具体用法?Java JcrI18n怎么用?Java JcrI18n使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JcrI18n类属于org.modeshape.jcr包,在下文中一共展示了JcrI18n类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkFileNotExcluded
import org.modeshape.jcr.JcrI18n; //导入依赖的package包/类
/**
* Utility method to ensure that the file is writable by this connector.
*
* @param id the identifier of the node
* @param file the file
* @throws DocumentStoreException if the file is expected to be writable but
* is not or is excluded, or if the connector is readonly
*/
protected void checkFileNotExcluded(final String id, final File file) {
if (isExcluded(file)) {
final String msg =
JcrI18n.fileConnectorCannotStoreFileThatIsExcluded.text(
getSourceName(), id, file.getAbsolutePath());
throw new DocumentStoreException(id, msg);
}
}
开发者ID:nigelgbanks,项目名称:fcrepo-filesystem-modeshape-federation-connector,代码行数:17,代码来源:FileSystemConnector.java
示例2: newDocumentId
import org.modeshape.jcr.JcrI18n; //导入依赖的package包/类
/**
* Generates an identifier which will be assigned when a new document (aka.
* child) is created under an existing document (aka.parent). This method
* should be implemented only by connectors which support writing.
*
* @param parentId a {@code non-null} {@link String} which represents the
* identifier of the parent under which the new document will be
* created.
* @param newDocumentName a {@code non-null}
* {@link org.modeshape.jcr.value.Name} which represents the name
* that will be given to the child document
* @param newDocumentPrimaryType a {@code non-null}
* {@link org.modeshape.jcr.value.Name} which represents the child
* document's primary type.
* @return either a {@code non-null} {@link String} which will be assigned
* as the new identifier, or {@code null} which means that no
* "special" id format is required. In this last case, the
* repository will auto-generate a random id.
* @throws org.modeshape.jcr.cache.DocumentStoreException if the connector
* is readonly.
*/
@Override
public String newDocumentId(final String parentId,
final Name newDocumentName, final Name newDocumentPrimaryType) {
final StringBuilder id = new StringBuilder(parentId);
if (!parentId.endsWith(DELIMITER)) {
id.append(DELIMITER);
}
// We're only using the name to check, which can be a bit dangerous if
// users don't follow the JCR conventions. However, it matches what
// "isContentNode(...)" does.
final String childNameStr =
getContext().getValueFactories().getStringFactory().create(
newDocumentName);
if (JCR_CONTENT.equals(childNameStr)) {
// This is for the "jcr:content" node underneath a file node. Since
// this doesn't actually result in a file or folder on the file
// system (it's merged into the file for the parent 'nt:file' node),
// we'll keep the "jcr" namespace prefix in the ID so that
// 'isContentNode(...)' works properly ...
id.append(childNameStr);
} else {
// File systems don't universally deal well with ':' in the names,
// and when they do it can be a bit awkward. Since we don't often
// expect the node NAMES to contain namespaces (at leat with this
// connector), we'll just use the local part for the ID ...
id.append(newDocumentName.getLocalName());
if (!StringUtil.isBlank(newDocumentName.getNamespaceUri())) {
// the FS connector does not support namespaces in names
final String ns = newDocumentName.getNamespaceUri();
getLogger().warn(JcrI18n.fileConnectorNamespaceIgnored,
getSourceName(), ns, id, childNameStr, parentId);
}
}
return id.toString();
}
开发者ID:nigelgbanks,项目名称:fcrepo-filesystem-modeshape-federation-connector,代码行数:59,代码来源:FileSystemConnector.java
示例3: getDocumentById
import org.modeshape.jcr.JcrI18n; //导入依赖的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