本文整理了Java中org.modeshape.jcr.api.Binary.getMimeType()
方法的一些代码示例,展示了Binary.getMimeType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Binary.getMimeType()
方法的具体详情如下:
包路径:org.modeshape.jcr.api.Binary
类名称:Binary
方法名:getMimeType
[英]Get the MIME type for this binary value.
[中]获取此二进制值的MIME类型。
代码示例来源:origin: ModeShape/modeshape
@Override
public long setContent( Node parentNode,
String resourceName,
InputStream newContent,
String contentType,
String characterEncoding ) throws RepositoryException, IOException {
Node contentNode;
if (parentNode.hasNode(CONTENT_NODE_NAME)) {
contentNode = parentNode.getNode(CONTENT_NODE_NAME);
} else {
contentNode = parentNode.addNode(CONTENT_NODE_NAME, newContentPrimaryType);
}
// contentNode.setProperty(MIME_TYPE_PROP_NAME, contentType != null ? contentType : "application/octet-stream");
contentNode.setProperty(ENCODING_PROP_NAME, characterEncoding != null ? characterEncoding : "UTF-8");
org.modeshape.jcr.api.Binary binary = (org.modeshape.jcr.api.Binary)parentNode.getSession()
.getValueFactory()
.createBinary(newContent);
contentNode.setProperty(DATA_PROP_NAME, binary);
contentNode.setProperty(MODIFIED_PROP_NAME, Calendar.getInstance());
// Copy the content to the property, THEN re-read the content from the Binary value to avoid discarding the first
// bytes of the stream
if (contentType == null) {
contentType = binary.getMimeType(resourceName);
}
if (contentType != null) {
contentNode.setProperty(MIME_TYPE_PROP_NAME, contentType);
}
return contentNode.getProperty(DATA_PROP_NAME).getLength();
}
代码示例来源:origin: ModeShape/modeshape
private void addFileContent( ZipInputStream zipInputStream,
ZipEntry entry,
Context context,
Node zipFileNode ) throws RepositoryException, IOException {
Node contentNode = zipFileNode.addNode(JcrConstants.JCR_CONTENT, JcrConstants.NT_RESOURCE);
// on session pre-save the appropriate properties should be set automatically
contentNode.addMixin(JcrConstants.MIX_LAST_MODIFIED);
// set the content bytes
byte[] contentBytes = readContent(zipInputStream);
org.modeshape.jcr.api.Binary contentBinary = context.valueFactory().createBinary(contentBytes);
contentNode.setProperty(JcrConstants.JCR_DATA, contentBinary);
// Figure out the mime type ...
String mimeType = contentBinary.getMimeType(entry.getName());
if (mimeType != null) {
contentNode.setProperty(JcrConstants.JCR_MIME_TYPE, mimeType);
}
}
代码示例来源:origin: ModeShape/modeshape
/**
* Returns the default mime-type of a given binary property.
*
* @param binaryProperty a non-null {@link Property}
* @return a non-null String which represents the mime-type of the binary property.
* @throws RepositoryException if any JCR related operation involving the binary property fail.
*/
public String getDefaultMimeType( Property binaryProperty ) throws RepositoryException {
try {
Binary binary = binaryProperty.getBinary();
return binary instanceof org.modeshape.jcr.api.Binary ? ((org.modeshape.jcr.api.Binary)binary)
.getMimeType() : DEFAULT_MIME_TYPE;
} catch (IOException e) {
logger.warn("Cannot determine default mime-type", e);
return DEFAULT_MIME_TYPE;
}
}
代码示例来源:origin: ModeShape/modeshape
mimeType = ((org.modeshape.jcr.api.Binary)binary).getMimeType(parent.getName());
代码示例来源:origin: org.fcrepo/modeshape-jcr
mimeType = ((org.modeshape.jcr.api.Binary)binary).getMimeType(parent.getName());
代码示例来源:origin: ModeShape/modeshape
@Override
public boolean execute( Property inputProperty,
Node outputNode,
Context context ) throws Exception {
Binary binaryValue = (Binary) inputProperty.getBinary();
CheckArg.isNotNull(binaryValue, "binary");
String mimeType = binaryValue.getMimeType();
Node sequencedNode = getMetadataNode(outputNode);
setPropertyIfMetadataPresent(sequencedNode, JcrConstants.JCR_MIME_TYPE, mimeType);
return processBasicMetadata(sequencedNode, binaryValue);
}
代码示例来源:origin: ModeShape/modeshape
@Override
public boolean execute( Property inputProperty,
Node outputNode,
Context context ) throws Exception {
Binary binaryValue = (Binary) inputProperty.getBinary();
CheckArg.isNotNull(binaryValue, "binary");
String mimeType = binaryValue.getMimeType();
Node sequencedNode = getMetadataNode(outputNode);
setPropertyIfMetadataPresent(sequencedNode, JcrConstants.JCR_MIME_TYPE, mimeType);
return processBasicMetadata(sequencedNode, binaryValue);
}
代码示例来源:origin: ModeShape/modeshape
@Override
public boolean execute( Property inputProperty,
Node outputNode,
Context context ) throws Exception {
Binary binaryValue = (Binary) inputProperty.getBinary();
CheckArg.isNotNull(binaryValue, "binary");
String mimeType = binaryValue.getMimeType();
Node sequencedNode = getMetadataNode(outputNode);
setPropertyIfMetadataPresent(sequencedNode, JcrConstants.JCR_MIME_TYPE, mimeType);
return processBasicMetadata(sequencedNode, binaryValue);
}
代码示例来源:origin: ModeShape/modeshape
/**
* Creates a new tika metadata object used by the parser. This will contain the mime-type of the content being parsed, if this
* is available to the underlying context. If not, Tika's autodetection mechanism is used to try and get the mime-type.
*
* @param binary a <code>org.modeshape.jcr.api.Binary</code> instance of the content being parsed
* @param context the extraction context; may not be null
* @return a <code>Metadata</code> instance.
* @throws java.io.IOException if auto-detecting the mime-type via Tika fails
* @throws RepositoryException if error obtaining MIME-type of the binary parameter
*/
protected final Metadata prepareMetadata( final Binary binary,
final Context context ) throws IOException, RepositoryException {
Metadata metadata = new Metadata();
String mimeType = binary.getMimeType();
if (StringUtil.isBlank(mimeType)) {
// Call the detector (we don't know the name) ...
mimeType = context.mimeTypeOf(null, binary);
}
if (!StringUtil.isBlank(mimeType)) {
metadata.set(Metadata.CONTENT_TYPE, mimeType);
}
return metadata;
}
代码示例来源:origin: ModeShape/modeshape
assertEquals("Invalid mime-type", "text/plain", file1Binary.getMimeType());
assertEquals("Invalid mime-type", "text/plain", file2Binary.getMimeType());
代码示例来源:origin: ModeShape/modeshape
Binary binaryValue = (Binary) inputProperty.getBinary();
CheckArg.isNotNull(binaryValue, "binary");
final String mimeType = binaryValue.getMimeType();
boolean isValid = false;
AudioMetadata metadata = null;
代码示例来源:origin: ModeShape/modeshape
String mimeType = binaryValue.getMimeType(inputFileName);
代码示例来源:origin: org.modeshape/modeshape-sequencer-msoffice
String mimeType = binaryValue.getMimeType(inputFileName);
代码示例来源:origin: org.fcrepo/modeshape-jcr
fileName = stringFactory().create(parentName);
String mimeType = binaryValue.getMimeType(fileName);
if (mimeType != null) {
node.setProperty(cache, propertyFactory.create(JcrLexicon.MIMETYPE, mimeType));
代码示例来源:origin: ModeShape/modeshape
fileName = stringFactory().create(parentName);
String mimeType = binaryValue.getMimeType(fileName);
if (mimeType != null) {
node.setProperty(cache, propertyFactory.create(JcrLexicon.MIMETYPE, mimeType));
内容来源于网络,如有侵权,请联系作者删除!