当前位置: 首页>>代码示例>>Java>>正文


Java MimetypeService类代码示例

本文整理汇总了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);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:27,代码来源:AbstractEmailMessageHandler.java

示例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;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:27,代码来源:TransformerPropertyNameExtractor.java

示例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;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:28,代码来源:TransformerPropertyNameExtractor.java

示例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));
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:27,代码来源:TransformerPropertyGetter.java

示例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();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:ContentTransformerRegistryTest.java

示例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));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:27,代码来源:TransformerPropertyNameExtractorTest.java

示例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);
    }
}
 
开发者ID:Acosix,项目名称:alfresco-simple-content-stores,代码行数:20,代码来源:CompressingContentWriter.java

示例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;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:20,代码来源:MimeTypeConverter.java

示例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;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:26,代码来源:UIMimeTypeSelector.java

示例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();
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:29,代码来源:AdvancedSearchDialog.java

示例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;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:26,代码来源:DocumentPropertiesDialog.java

示例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;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:23,代码来源:ContentNetworkFile.java

示例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>(); 
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:23,代码来源:MSOfficeContentNetworkFile.java

示例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));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:24,代码来源:OpenOfficeContentNetworkFile.java

示例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);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:44,代码来源:ACPExportPackageHandler.java


注:本文中的org.alfresco.service.cmr.repository.MimetypeService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。