本文整理汇总了Java中org.alfresco.service.cmr.repository.MimetypeService类的典型用法代码示例。如果您正苦于以下问题:Java MimetypeService类的具体用法?Java MimetypeService怎么用?Java MimetypeService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MimetypeService类属于org.alfresco.service.cmr.repository包,在下文中一共展示了MimetypeService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addAttachments
import org.alfresco.service.cmr.repository.MimetypeService; //导入依赖的package包/类
/**
* Extracts the attachments from the given message and adds them to the space. All attachments
* are linked back to the original node that they are attached to.
*
* @param spaceNodeRef the space to add the documents into
* @param nodeRef the node to which the documents will be attached
* @param message the email message
*/
protected void addAttachments(NodeRef spaceNodeRef, NodeRef nodeRef, EmailMessage message)
{
// Add attachments
EmailMessagePart[] attachments = message.getAttachments();
for (EmailMessagePart attachment : attachments)
{
String fileName = attachment.getFileName();
InputStream contentIs = attachment.getContent();
MimetypeService mimetypeService = getMimetypeService();
String mimetype = mimetypeService.guessMimetype(fileName);
String encoding = attachment.getEncoding();
NodeRef attachmentNode = addAttachment(getNodeService(), spaceNodeRef, nodeRef, fileName);
writeContent(attachmentNode, contentIs, mimetype, encoding);
}
}
示例2: 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;
}
示例3: 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;
}
示例4: appendUnconfiguredTransformerSettings
import org.alfresco.service.cmr.repository.MimetypeService; //导入依赖的package包/类
private void appendUnconfiguredTransformerSettings(StringBuilder sb, MimetypeService mimetypeService,
Set<String> alreadySpecified, List<ContentTransformer> availableTransformers,
ContentTransformerRegistry transformerRegistry)
{
boolean first = true;
for (ContentTransformer transformer: transformerRegistry.getAllTransformers())
{
String name = transformer.getName();
if (!alreadySpecified.contains(name))
{
if (first)
{
sb.append("\n");
sb.append("# Transformers without extra configuration settings\n");
sb.append("# =================================================\n\n");
first = false;
}
else
{
sb.append('\n');
}
boolean available = availableTransformers.contains(transformer);
sb.append(transformer.getComments(available));
}
}
}
示例5: DummyTransformer
import org.alfresco.service.cmr.repository.MimetypeService; //导入依赖的package包/类
public DummyTransformer(
MimetypeService mimetypeService,
String name,
TransformerDebug transformerDebug, TransformerConfig transformerConfig,
ContentTransformerRegistry registry, String sourceMimetype, String targetMimetype, long transformationTime)
{
super.setMimetypeService(mimetypeService);
super.setTransformerDebug(transformerDebug);
super.setTransformerConfig(transformerConfig);
super.setRegistry(registry);
this.sourceMimetype = sourceMimetype;
this.targetMimetype = targetMimetype;
this.transformationTime = transformationTime;
setRegisterTransformer(true);
setBeanName(name+'.'+System.currentTimeMillis()%100000);
// register
register();
}
示例6: mockMimetypes
import org.alfresco.service.cmr.repository.MimetypeService; //导入依赖的package包/类
/**
* Mock up the responses from the mimetypeService so that it:
* a) returns all the supplied mimetypes
* b) returns the extension given the mimetype
* c) returns the mimetype given the extension.
* @param mimetypeService mimetype service
* @param mimetypesAndExtensions sequence of mimetypes and extenstions.
* @throws IllegalStateException if there is not an extension for every mimetype
*/
public static void mockMimetypes(MimetypeService mimetypeService, String... mimetypesAndExtensions)
{
if (mimetypesAndExtensions.length % 2 != 0)
{
// Not using IllegalArgumentException as this is thrown by classes under test
throw new java.lang.IllegalStateException("There should be an extension for every mimetype");
}
final Set<String> allMimetypes = new HashSet<String>();
for (int i=0; i < mimetypesAndExtensions.length; i+=2)
{
allMimetypes.add(mimetypesAndExtensions[i]);
when(mimetypeService.getExtension(mimetypesAndExtensions[i])).thenReturn(mimetypesAndExtensions[i+1]);
when(mimetypeService.getMimetype(mimetypesAndExtensions[i+1])).thenReturn(mimetypesAndExtensions[i]);
}
when(mimetypeService.getMimetypes()).thenReturn(new ArrayList<String>(allMimetypes));
}
示例7: setMimetypeService
import org.alfresco.service.cmr.repository.MimetypeService; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void setMimetypeService(final MimetypeService mimetypeService)
{
this.mimetypeService = mimetypeService;
super.setMimetypeService(mimetypeService);
if (this.backingWriter instanceof MimetypeServiceAware)
{
((MimetypeServiceAware) this.backingWriter).setMimetypeService(mimetypeService);
}
if (this.temporaryWriter instanceof MimetypeServiceAware)
{
((MimetypeServiceAware) this.temporaryWriter).setMimetypeService(mimetypeService);
}
}
示例8: getAsString
import org.alfresco.service.cmr.repository.MimetypeService; //导入依赖的package包/类
/**
* @see javax.faces.convert.Converter#getAsString(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.Object)
*/
public String getAsString(FacesContext context, UIComponent component, Object value)
{
String result = null;
if (value instanceof String)
{
MimetypeService mimetypeService = Repository.getServiceRegistry(context).getMimetypeService();
result = mimetypeService.getDisplaysByMimetype().get(value.toString());
}
else if (value != null)
{
result = value.toString();
}
return result;
}
示例9: createList
import org.alfresco.service.cmr.repository.MimetypeService; //导入依赖的package包/类
/**
* Creates the list of SelectItem components to represent the list
* of MIME types the user can select from
*
* @return List of SelectItem components
*/
protected List<SelectItem> createList()
{
List<SelectItem> items = new ArrayList<SelectItem>(80);
ServiceRegistry registry = Repository.getServiceRegistry(FacesContext.getCurrentInstance());
MimetypeService mimetypeService = registry.getMimetypeService();
// get the mime type display names
Map<String, String> mimeTypes = mimetypeService.getDisplaysByMimetype();
for (String mimeType : mimeTypes.keySet())
{
items.add(new SelectItem(mimeType, mimeTypes.get(mimeType)));
}
// make sure the list is sorted by the values
QuickSort sorter = new QuickSort(items, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
return items;
}
示例10: getContentFormats
import org.alfresco.service.cmr.repository.MimetypeService; //导入依赖的package包/类
/**
* @return Returns a list of content formats to allow the user to select from
*/
public List<SelectItem> getContentFormats()
{
if ((properties.getContentFormats() == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance())))
{
properties.setContentFormats(new ArrayList<SelectItem>(80));
ServiceRegistry registry = Repository.getServiceRegistry(FacesContext.getCurrentInstance());
MimetypeService mimetypeService = registry.getMimetypeService();
// get the mime type display names
Map<String, String> mimeTypes = mimetypeService.getDisplaysByMimetype();
for (String mimeType : mimeTypes.keySet())
{
properties.getContentFormats().add(new SelectItem(mimeType, mimeTypes.get(mimeType)));
}
// make sure the list is sorted by the values
QuickSort sorter = new QuickSort(properties.getContentFormats(), "label", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
// add the "All Formats" constant marker at the top of the list (default selection)
properties.getContentFormats().add(0, new SelectItem("", Application.getMessage(FacesContext.getCurrentInstance(), MSG_ALL_FORMATS)));
}
return properties.getContentFormats();
}
示例11: getContentTypes
import org.alfresco.service.cmr.repository.MimetypeService; //导入依赖的package包/类
/**
* @return Returns a list of content types to allow the user to select from
*/
public List<SelectItem> getContentTypes()
{
if (this.contentTypes == null)
{
this.contentTypes = new ArrayList<SelectItem>(80);
ServiceRegistry registry = Repository.getServiceRegistry(FacesContext.getCurrentInstance());
MimetypeService mimetypeService = registry.getMimetypeService();
// get the mime type display names
Map<String, String> mimeTypes = mimetypeService.getDisplaysByMimetype();
for (String mimeType : mimeTypes.keySet())
{
this.contentTypes.add(new SelectItem(mimeType, mimeTypes.get(mimeType)));
}
// make sure the list is sorted by the values
QuickSort sorter = new QuickSort(this.contentTypes, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
}
return this.contentTypes;
}
示例12: ContentNetworkFile
import org.alfresco.service.cmr.repository.MimetypeService; //导入依赖的package包/类
/**
* Class constructor
*
* @param nodeService NodeService
* @param contentService ContentService
* @param mimetypeService mimetypeService
* @param nodeRef NodeRef
* @param name String
*/
protected ContentNetworkFile(
NodeService nodeService,
ContentService contentService,
MimetypeService mimetypeService,
NodeRef nodeRef,
String name)
{
super(name, nodeRef);
setFullName(name);
this.nodeService = nodeService;
this.contentService = contentService;
this.mimetypeService = mimetypeService;
}
示例13: MSOfficeContentNetworkFile
import org.alfresco.service.cmr.repository.MimetypeService; //导入依赖的package包/类
/**
* Class constructor
*
* @param nodeService NodeService
* @param contentService ContentService
* @param mimetypeService MimetypeService
* @param nodeRef NodeRef
* @param name String
*/
protected MSOfficeContentNetworkFile(
NodeService nodeService,
ContentService contentService,
MimetypeService mimetypeService,
NodeRef nodeRef,
String name)
{
super(nodeService, contentService, mimetypeService, nodeRef, name);
// Create the buffered write list
m_writeList = new ArrayList<BufferedWrite>();
}
示例14: OpenOfficeContentNetworkFile
import org.alfresco.service.cmr.repository.MimetypeService; //导入依赖的package包/类
/**
* Class constructor
*
* @param nodeService NodeService
* @param contentService ContentService
* @param mimetypeService MimetypeService
* @param nodeRef NodeRef
* @param name String
*/
protected OpenOfficeContentNetworkFile(
NodeService nodeService,
ContentService contentService,
MimetypeService mimetypeService,
NodeRef nodeRef,
String name)
{
super(nodeService, contentService, mimetypeService, nodeRef, name);
// DEBUG
if (logger.isDebugEnabled())
logger.debug("Using OpenOffice network file for " + name + ", versionLabel=" + nodeService.getProperty( nodeRef, ContentModel.PROP_VERSION_LABEL));
}
示例15: ACPExportPackageHandler
import org.alfresco.service.cmr.repository.MimetypeService; //导入依赖的package包/类
/**
* Construct
*
* @param destDir File
* @param zipFile File
* @param dataFile File
* @param contentDir File
* @param overwrite boolean
* @param mimetypeService MimetypeService
*/
public ACPExportPackageHandler(File destDir, File zipFile, File dataFile, File contentDir, boolean overwrite, MimetypeService mimetypeService)
{
try
{
// Ensure ACP file has appropriate ACP extension
String zipFilePath = zipFile.getPath();
if (!zipFilePath.endsWith("." + ACP_EXTENSION))
{
zipFilePath += (zipFilePath.charAt(zipFilePath.length() -1) == '.') ? ACP_EXTENSION : "." + ACP_EXTENSION;
}
File absZipFile = new File(destDir, zipFilePath);
log("Exporting to package zip file " + absZipFile.getAbsolutePath());
if (absZipFile.exists())
{
if (overwrite == false)
{
throw new ExporterException("Package zip file " + absZipFile.getAbsolutePath() + " already exists.");
}
log("Warning: Overwriting existing package zip file " + absZipFile.getAbsolutePath());
}
this.outputStream = new FileOutputStream(absZipFile);
this.dataFile = dataFile;
this.contentDir = contentDir;
this.mimetypeService = mimetypeService;
}
catch (FileNotFoundException e)
{
throw new ExporterException("Failed to create zip file", e);
}
}