本文整理汇总了Java中org.alfresco.service.cmr.repository.ContentWriter.getMimetype方法的典型用法代码示例。如果您正苦于以下问题:Java ContentWriter.getMimetype方法的具体用法?Java ContentWriter.getMimetype怎么用?Java ContentWriter.getMimetype使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.alfresco.service.cmr.repository.ContentWriter
的用法示例。
在下文中一共展示了ContentWriter.getMimetype方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getWriter
import org.alfresco.service.cmr.repository.ContentWriter; //导入方法依赖的package包/类
@Override
public ContentWriter getWriter(NodeRef nodeRef)
{
FileInfo fileInfo = toFileInfo(nodeRef, false);
if (fileInfo.isFolder())
{
throw new InvalidTypeException("Unable to get a content writer for a folder: " + fileInfo);
}
final ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true);
// Ensure that a mimetype is set based on the filename (ALF-6560)
// This has been removed from the create code in 3.4 to prevent insert-update behaviour
// of the ContentData.
if (writer.getMimetype() == null)
{
final String name = fileInfo.getName();
writer.guessMimetype(name);
}
// Done
return writer;
}
示例2: checkIsEmbedSupported
import org.alfresco.service.cmr.repository.ContentWriter; //导入方法依赖的package包/类
/**
* Checks if embedding for the mimetype is supported.
*
* @param writer the writer to check
* @throws AlfrescoRuntimeException if embedding for the mimetype is not supported
*/
protected void checkIsEmbedSupported(ContentWriter writer)
{
String mimetype = writer.getMimetype();
if (!isEmbeddingSupported(mimetype))
{
throw new AlfrescoRuntimeException(
"Metadata extracter does not support embedding mimetype: \n" +
" writer: " + writer + "\n" +
" supported: " + supportedEmbedMimetypes + "\n" +
" extracter: " + this);
}
}
示例3: isTransformable
import org.alfresco.service.cmr.repository.ContentWriter; //导入方法依赖的package包/类
/**
* @see org.alfresco.service.cmr.repository.ContentService#isTransformable(org.alfresco.service.cmr.repository.ContentReader, org.alfresco.service.cmr.repository.ContentWriter, org.alfresco.service.cmr.repository.TransformationOptions)
*/
public boolean isTransformable(ContentReader reader, ContentWriter writer, TransformationOptions options)
{
// check that source and target mimetypes are available
String sourceMimetype = reader.getMimetype();
if (sourceMimetype == null)
{
throw new AlfrescoRuntimeException("The content reader mimetype must be set: " + reader);
}
String targetMimetype = writer.getMimetype();
if (targetMimetype == null)
{
throw new AlfrescoRuntimeException("The content writer mimetype must be set: " + writer);
}
long sourceSize = reader.getSize();
try
{
// look for a transformer
transformerDebug.pushAvailable(reader.getContentUrl(), sourceMimetype, targetMimetype, options);
List<ContentTransformer> transformers = getActiveTransformers(sourceMimetype, sourceSize, targetMimetype, options);
transformerDebug.availableTransformers(transformers, sourceSize, options, "ContentService.isTransformable(...)");
return transformers.size() > 0;
}
finally
{
transformerDebug.popAvailable();
}
}
示例4: transformInternal
import org.alfresco.service.cmr.repository.ContentWriter; //导入方法依赖的package包/类
@Override
protected void transformInternal(ContentReader reader,
ContentWriter writer,
TransformationOptions options) throws Exception
{
final String sourceMimetype = reader.getMimetype();
final String sourceExtension = getMimetypeService().getExtension(sourceMimetype);
final String targetMimetype = writer.getMimetype();
if (log.isDebugEnabled())
{
StringBuilder msg = new StringBuilder();
msg.append("Transforming from ").append(sourceMimetype)
.append(" to ").append(targetMimetype);
log.debug(msg.toString());
}
OPCPackage pkg = null;
try
{
File ooxmlTempFile = TempFileProvider.createTempFile(this.getClass().getSimpleName() + "_ooxml", sourceExtension);
reader.getContent(ooxmlTempFile);
// Load the file
pkg = OPCPackage.open(ooxmlTempFile.getPath());
// Does it have a thumbnail?
PackageRelationshipCollection rels =
pkg.getRelationshipsByType(PackageRelationshipTypes.THUMBNAIL);
if (rels.size() > 0)
{
// Get the thumbnail part
PackageRelationship tRel = rels.getRelationship(0);
PackagePart tPart = pkg.getPart(tRel);
// Write it to the target
InputStream tStream = tPart.getInputStream();
writer.putContent( tStream );
tStream.close();
}
else
{
log.debug("No thumbnail present in " + reader.toString());
throw new UnimportantTransformException(NO_THUMBNAIL_PRESENT_IN_FILE + targetMimetype);
}
}
catch (IOException e)
{
throw new AlfrescoRuntimeException("Unable to transform " + sourceExtension + " file.", e);
}
finally
{
if (pkg != null)
{
pkg.close();
}
}
}
示例5: transform
import org.alfresco.service.cmr.repository.ContentWriter; //导入方法依赖的package包/类
/**
* @see org.alfresco.repo.content.transform.ContentTransformerRegistry
* @see org.alfresco.repo.content.transform.ContentTransformer
*/
public void transform(ContentReader reader, ContentWriter writer, TransformationOptions options)
throws NoTransformerException, ContentIOException
{
// check that source and target mimetypes are available
if (reader == null)
{
throw new AlfrescoRuntimeException("The content reader must be set");
}
String sourceMimetype = reader.getMimetype();
if (sourceMimetype == null)
{
throw new AlfrescoRuntimeException("The content reader mimetype must be set: " + reader);
}
String targetMimetype = writer.getMimetype();
if (targetMimetype == null)
{
throw new AlfrescoRuntimeException("The content writer mimetype must be set: " + writer);
}
long sourceSize = reader.getSize();
try
{
// look for a transformer
transformerDebug.pushAvailable(reader.getContentUrl(), sourceMimetype, targetMimetype, options);
List<ContentTransformer> transformers = getActiveTransformers(sourceMimetype, sourceSize, targetMimetype, options);
transformerDebug.availableTransformers(transformers, sourceSize, options, "ContentService.transform(...)");
int count = transformers.size();
if (count == 0)
{
throw new NoTransformerException(sourceMimetype, targetMimetype);
}
if (count == 1 || !transformerFailover)
{
ContentTransformer transformer = transformers.size() == 0 ? null : transformers.get(0);
transformer.transform(reader, writer, options);
}
else
{
failoverTransformers(reader, writer, options, targetMimetype, transformers);
}
}
finally
{
if (transformerDebug.isEnabled())
{
transformerDebug.popAvailable();
debugTransformations(sourceMimetype, targetMimetype, sourceSize, options);
}
}
}
示例6: executeImpl
import org.alfresco.service.cmr.repository.ContentWriter; //导入方法依赖的package包/类
/**
* @see org.alfresco.repo.action.executer.ActionExecuter#execute(Action, NodeRef)
*/
public void executeImpl(Action ruleAction, NodeRef actionedUponNodeRef)
{
if (!nodeService.exists(actionedUponNodeRef))
{
// Node is gone
return;
}
ContentReader reader = contentService.getReader(actionedUponNodeRef, ContentModel.PROP_CONTENT);
// The reader may be null, e.g. for folders and the like
if (reader == null || reader.getMimetype() == null)
{
if(logger.isDebugEnabled())
{
logger.debug("no content or mimetype - do nothing");
}
// No content to extract data from
return;
}
String mimetype = reader.getMimetype();
MetadataEmbedder embedder = metadataExtracterRegistry.getEmbedder(mimetype);
if (embedder == null)
{
if(logger.isDebugEnabled())
{
logger.debug("no embedder for mimetype:" + mimetype);
}
// There is no embedder to use
return;
}
ContentWriter writer = contentService.getWriter(actionedUponNodeRef, ContentModel.PROP_CONTENT, true);
// The writer may be null, e.g. for folders and the like
if (writer == null || writer.getMimetype() == null)
{
if(logger.isDebugEnabled())
{
logger.debug("no content or mimetype - do nothing");
}
// No content to embed data in
return;
}
// Get all the node's properties
Map<QName, Serializable> nodeProperties = nodeService.getProperties(actionedUponNodeRef);
try
{
embedder.embed(nodeProperties, reader, writer);
}
catch (Throwable e)
{
// Extracters should attempt to handle all error conditions and embed
// as much as they can. If, however, one should fail, we don't want the
// action itself to fail. We absorb and report the exception here.
if (logger.isDebugEnabled())
{
logger.debug(
"Metadata embedding failed: \n" +
" Extracter: " + this + "\n" +
" Node: " + actionedUponNodeRef + "\n" +
" Content: " + writer,
e);
}
else
{
logger.warn(
"Metadata embedding failed (turn on DEBUG for full error): \n" +
" Extracter: " + this + "\n" +
" Node: " + actionedUponNodeRef + "\n" +
" Content: " + writer + "\n" +
" Failure: " + e.getMessage());
}
}
}