本文整理汇总了Java中org.alfresco.service.cmr.repository.MimetypeService.getExtension方法的典型用法代码示例。如果您正苦于以下问题:Java MimetypeService.getExtension方法的具体用法?Java MimetypeService.getExtension怎么用?Java MimetypeService.getExtension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.alfresco.service.cmr.repository.MimetypeService
的用法示例。
在下文中一共展示了MimetypeService.getExtension方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMatchingExtensionsFromMimetypes
import org.alfresco.service.cmr.repository.MimetypeService; //导入方法依赖的package包/类
/**
* Gets the extensions of the mimetypes that match the given expression.
* However if the expression is "*", only the ANY ("*") extension is returned.
* @param expression which may contain '*' to represent zero or more characters.
* @param mimetypeService MimetypeService
* @return the list of extensions of mimetypes that match
*/
List<String> getMatchingExtensionsFromMimetypes(
String expression, MimetypeService mimetypeService)
{
if (ANY.equals(expression))
{
return Collections.singletonList(ANY);
}
Pattern pattern = pattern(expression);
List<String> matchingMimetypes = new ArrayList<String>(1);
for (String mimetype : mimetypeService.getMimetypes())
{
if (pattern.matcher(mimetype).matches())
{
String ext = mimetypeService.getExtension(mimetype);
matchingMimetypes.add(ext);
}
}
return matchingMimetypes;
}
示例2: getMatchingExtensionsFromExtensions
import org.alfresco.service.cmr.repository.MimetypeService; //导入方法依赖的package包/类
/**
* Gets the extensions that match the given expression. Only the main extension
* of each mimetype is checked.
* However if the expression is "*", only the ANY ("*") extension is returned.
* @param expression which may contain '*' to represent zero or more characters.
* @param mimetypeService MimetypeService
* @return the list of extensions that match
*/
List<String> getMatchingExtensionsFromExtensions(
String expression, MimetypeService mimetypeService)
{
if (ANY.equals(expression))
{
return Collections.singletonList(ANY);
}
Pattern pattern = pattern(expression);
List<String> matchingMimetypes = new ArrayList<String>(1);
for (String mimetype : mimetypeService.getMimetypes())
{
String ext = mimetypeService.getExtension(mimetype);
if (pattern.matcher(ext).matches())
{
matchingMimetypes.add(ext);
}
}
return matchingMimetypes;
}
示例3: addWildCardInName
import org.alfresco.service.cmr.repository.MimetypeService; //导入方法依赖的package包/类
private String addWildCardInName(String name, String mimetype)
{
MimetypeService mimetypeService = ctx.getBean("mimetypeService",
MimetypeService.class);
String extension = mimetypeService.getExtension(mimetype);
return name.substring(0,
name.length() - (extension.length() + 1))
.concat("*." + extension);
}
示例4: transform
import org.alfresco.service.cmr.repository.MimetypeService; //导入方法依赖的package包/类
/**
* @see #transformInternal(File, String, File, String, TransformationOptions)
*/
public final void transform(
ContentReader reader,
ContentWriter writer,
TransformationOptions options) throws Exception
{
// get mimetypes
String sourceMimetype = getMimetype(reader);
String targetMimetype = getMimetype(writer);
// get the extensions to use
MimetypeService mimetypeService = getMimetypeService();
String sourceExtension = mimetypeService.getExtension(sourceMimetype);
String targetExtension = mimetypeService.getExtension(targetMimetype);
if (sourceExtension == null || targetExtension == null)
{
throw new AlfrescoRuntimeException("Unknown extensions for mimetypes: \n" +
" source mimetype: " + sourceMimetype + "\n" +
" source extension: " + sourceExtension + "\n" +
" target mimetype: " + targetMimetype + "\n" +
" target extension: " + targetExtension);
}
// create required temp files
File sourceFile = TempFileProvider.createTempFile(
getClass().getSimpleName() + "_source_",
"." + sourceExtension);
File targetFile = TempFileProvider.createTempFile(
getClass().getSimpleName() + "_target_",
"." + targetExtension);
// pull reader file into source temp file
reader.getContent(sourceFile);
// For most target mimetypes, it only makes sense to read the first page of the
// source, as the target is a single page, so set the pageLimit automatically.
// However for others, such as PDF (see ALF-7278) all pages should be read.
// transform the source temp file to the target temp file
transformInternal(sourceFile, sourceMimetype, targetFile, targetMimetype, options);
// check that the file was created
if (!targetFile.exists() || targetFile.length() == 0)
{
throw new ContentIOException("JMagick transformation failed to write output file");
}
// upload the output image
writer.putContent(targetFile);
// done
if (logger.isDebugEnabled())
{
logger.debug("Transformation completed: \n" +
" source: " + reader + "\n" +
" target: " + writer + "\n" +
" options: " + options);
}
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:59,代码来源:AbstractImageMagickContentTransformerWorker.java
示例5: isTransformable
import org.alfresco.service.cmr.repository.MimetypeService; //导入方法依赖的package包/类
/**
* @see DocumentFormatRegistry
*/
public boolean isTransformable(String sourceMimetype, String targetMimetype, TransformationOptions options)
{
// Use BinaryPassThroughContentTransformer if mimetypes are the same.
if (sourceMimetype.equals(targetMimetype))
{
return false;
}
if (!isAvailable())
{
// The connection management is must take care of this
return false;
}
if (isTransformationBlocked(sourceMimetype, targetMimetype))
{
if (getLogger().isDebugEnabled())
{
StringBuilder msg = new StringBuilder();
msg.append("Transformation from ")
.append(sourceMimetype).append(" to ")
.append(targetMimetype)
.append(" is blocked and therefore unavailable.");
getLogger().debug(msg.toString());
}
return false;
}
MimetypeService mimetypeService = getMimetypeService();
String sourceExtension = mimetypeService.getExtension(sourceMimetype);
String targetExtension = mimetypeService.getExtension(targetMimetype);
// query the registry for the source format
DocumentFormat sourceFormat = formatRegistry.getFormatByExtension(sourceExtension);
if (sourceFormat == null)
{
// no document format
return false;
}
// query the registry for the target format
DocumentFormat targetFormat = formatRegistry.getFormatByExtension(targetExtension);
if (targetFormat == null)
{
// no document format
return false;
}
// get the family of the target document
DocumentFamily sourceFamily = sourceFormat.getInputFamily();
// does the format support the conversion
boolean transformable = formatRegistry.getOutputFormats(sourceFamily).contains(targetFormat); // same as: targetFormat.getStoreProperties(sourceFamily) != null
return transformable;
}
示例6: transform
import org.alfresco.service.cmr.repository.MimetypeService; //导入方法依赖的package包/类
@Override
public void transform(ContentReader reader, ContentWriter writer, TransformationOptions options) throws Exception
{
// get mimetypes
String sourceMimetype = getMimetype(reader);
String targetMimetype = getMimetype(writer);
// get the extensions to use
MimetypeService mimetypeService = getMimetypeService();
String sourceExtension = mimetypeService.getExtension(sourceMimetype);
String targetExtension = mimetypeService.getExtension(targetMimetype);
if (sourceExtension == null || targetExtension == null)
{
throw new AlfrescoRuntimeException("Unknown extensions for mimetypes: \n" +
" source mimetype: " + sourceMimetype + "\n" +
" source extension: " + sourceExtension + "\n" +
" target mimetype: " + targetMimetype + "\n" +
" target extension: " + targetExtension);
}
// create required temp files
File sourceFile = TempFileProvider.createTempFile(getClass().getSimpleName() + "_source_", "." + sourceExtension);
File targetFile = TempFileProvider.createTempFile(getClass().getSimpleName() + "_target_", "." + targetExtension);
// pull reader file into source temp file
reader.getContent(sourceFile);
transformInternal(sourceFile, sourceMimetype, targetFile, targetMimetype, options);
// check that the file was created
if (!targetFile.exists() || targetFile.length() == 0)
{
throw new ContentIOException("alfresco-pdf-renderer transformation failed to write output file");
}
// upload the output image
writer.putContent(targetFile);
// done
if (logger.isDebugEnabled())
{
logger.debug("Transformation completed: \n" +
" source: " + reader + "\n" +
" target: " + writer + "\n" +
" options: " + options);
}
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:49,代码来源:AlfrescoPdfRendererContentTransformerWorker.java
示例7: isTransformable
import org.alfresco.service.cmr.repository.MimetypeService; //导入方法依赖的package包/类
/**
* @see DocumentFormatRegistry
*/
public boolean isTransformable(String sourceMimetype, String targetMimetype, TransformationOptions options)
{
// Use BinaryPassThroughContentTransformer if mimetypes are the same.
if (sourceMimetype.equals(targetMimetype))
{
return false;
}
if (!isAvailable())
{
// The connection management is must take care of this
return false;
}
if (isTransformationBlocked(sourceMimetype, targetMimetype))
{
if (getLogger().isDebugEnabled())
{
StringBuilder msg = new StringBuilder();
msg.append("Transformation from ")
.append(sourceMimetype).append(" to ")
.append(targetMimetype)
.append(" is blocked and therefore unavailable.");
getLogger().debug(msg.toString());
}
return false;
}
MimetypeService mimetypeService = getMimetypeService();
String sourceExtension = mimetypeService.getExtension(sourceMimetype);
String targetExtension = mimetypeService.getExtension(targetMimetype);
// query the registry for the source format
DocumentFormat sourceFormat = formatRegistry.getFormatByFileExtension(sourceExtension);
if (sourceFormat == null)
{
// no document format
return false;
}
// query the registry for the target format
DocumentFormat targetFormat = formatRegistry.getFormatByFileExtension(targetExtension);
if (targetFormat == null)
{
// no document format
return false;
}
// get the family of the target document
DocumentFamily sourceFamily = sourceFormat.getFamily();
// does the format support the conversion
if (!targetFormat.isExportableFrom(sourceFamily))
{
// unable to export from source family of documents to the target format
return false;
}
else
{
return true;
}
}