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


Java ContentData.getMimetype方法代码示例

本文整理汇总了Java中org.alfresco.service.cmr.repository.ContentData.getMimetype方法的典型用法代码示例。如果您正苦于以下问题:Java ContentData.getMimetype方法的具体用法?Java ContentData.getMimetype怎么用?Java ContentData.getMimetype使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.alfresco.service.cmr.repository.ContentData的用法示例。


在下文中一共展示了ContentData.getMimetype方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getThumbnailDefinitions

import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
/**
 * Returns the names of the thumbnail defintions that can be applied to the content property of
 * this node.
 * <p>
 * Thumbanil defintions only appear in this list if they can produce a thumbnail for the content
 * found in the content property.  This will be determined by looking at the mimetype of the content
 * and the destinatino mimetype of the thumbnail.
 * 
 * @return  String[]    array of thumbnail names that are valid for the current content type
 */
public String[] getThumbnailDefinitions()
{
    ThumbnailService thumbnailService = this.services.getThumbnailService();
    
    List<String> result = new ArrayList<String>(7);
    
    Serializable value = this.nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT);
    ContentData contentData = DefaultTypeConverter.INSTANCE.convert(ContentData.class, value);
    
    if (ContentData.hasContent(contentData))
    {
        String mimetype = contentData.getMimetype();
        List<ThumbnailDefinition> thumbnailDefinitions = thumbnailService.getThumbnailRegistry().getThumbnailDefinitions(mimetype, contentData.getSize());
        for (ThumbnailDefinition thumbnailDefinition : thumbnailDefinitions)
        {
            result.add(thumbnailDefinition.getName());
        }
    }
    
    return (String[])result.toArray(new String[result.size()]);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:32,代码来源:ScriptNode.java

示例2: checkContentDetails

import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
private void checkContentDetails(NodeRef node, String expectedName, String expectedTitle, 
            String expectedMimetype, String expectedContent)
{
    Map<QName, Serializable> props = this.nodeService.getProperties(node);
    String name = (String)props.get(ContentModel.PROP_NAME);
    String title = (String)props.get(ContentModel.PROP_TITLE);
    assertEquals(expectedName, name);
    assertEquals(expectedTitle, title);
    
    ContentData contentData = (ContentData) this.nodeService.getProperty(node, ContentModel.PROP_CONTENT);
    assertNotNull(contentData);
    String mimetype = contentData.getMimetype();
    assertEquals(expectedMimetype, mimetype);
    
    ContentReader reader = this.contentService.getReader(node, ContentModel.PROP_CONTENT);
    assertNotNull(reader);
    String content = reader.getContentString();
    assertEquals(expectedContent, content);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:FormServiceImplTest.java

示例3: getDAVPropertyValue

import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
/**
 * Return the Alfresco property value for the specified WebDAV property
 * 
 * @param davPropName String
 * @return Object
 */
public static Object getDAVPropertyValue( Map<QName, Serializable> props, String davPropName)
{
    // Convert the WebDAV property name to the corresponding Alfresco property
    
    QName propName = _propertyNameMap.get( davPropName);
    if ( propName == null)
        throw new AlfrescoRuntimeException("No mapping for WebDAV property " + davPropName);
    
    //  Return the property value
    Object value = props.get(propName);
    if (value instanceof ContentData)
    {
        ContentData contentData = (ContentData) value;
        if (davPropName.equals(WebDAV.XML_GET_CONTENT_TYPE))
        {
            value = contentData.getMimetype();
        }
        else if (davPropName.equals(WebDAV.XML_GET_CONTENT_LENGTH))
        {
            value = new Long(contentData.getSize());
        }
    }
    return value;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:31,代码来源:WebDAV.java

示例4: Document

import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
public Document(NodeRef nodeRef, NodeRef parentNodeRef, Map<QName, Serializable> nodeProps, Map<String, UserInfo> mapUserInfo, ServiceRegistry sr)
{
    super(nodeRef, parentNodeRef, nodeProps, mapUserInfo, sr);

    Serializable val = nodeProps.get(ContentModel.PROP_CONTENT);

    if ((val != null) && (val instanceof ContentData)) {
        ContentData cd = (ContentData)val;
        String mimeType = cd.getMimetype();
        String mimeTypeName = sr.getMimetypeService().getDisplaysByMimetype().get(mimeType);
        contentInfo = new ContentInfo(mimeType, mimeTypeName, cd.getSize(), cd.getEncoding());
    }

    setIsFolder(false);
    setIsFile(true);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:17,代码来源:Document.java

示例5: toApiRendition

import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
protected Rendition toApiRendition(NodeRef renditionNodeRef)
{
    Rendition apiRendition = new Rendition();

    String renditionName = (String) nodeService.getProperty(renditionNodeRef, ContentModel.PROP_NAME);
    apiRendition.setId(renditionName);

    ContentData contentData = getContentData(renditionNodeRef, false);
    ContentInfo contentInfo = null;
    if (contentData != null)
    {
        contentInfo = new ContentInfo(contentData.getMimetype(),
                    getMimeTypeDisplayName(contentData.getMimetype()),
                    contentData.getSize(),
                    contentData.getEncoding());
    }
    apiRendition.setContent(contentInfo);
    apiRendition.setStatus(RenditionStatus.CREATED);

    return apiRendition;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:22,代码来源:RenditionsImpl.java

示例6: NodeContentData

import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
/**
 * Construct
 */
public NodeContentData(NodeRef nodeRef, ContentData contentData)
{
    super(contentData.getContentUrl(), contentData.getMimetype(), contentData.getSize(),
            contentData.getEncoding(), contentData.getLocale());
    this.nodeRef = nodeRef;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:10,代码来源:NodeContentData.java

示例7: ContentDataPart

import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
/**
 * ContentDataPart 
 * @param contentService content service
 * @param partName String
 * @param data data
 */
public ContentDataPart(ContentService contentService, String partName, ContentData data) {
    super(partName, data.getMimetype(), data.getEncoding(), null);
    this.contentService = contentService;
    this.data = data;
    this.filename = partName;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:13,代码来源:ContentDataPart.java

示例8: sanitizeMimetype

import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
private ContentData sanitizeMimetype(ContentData contentData)
{
    String mimetype = contentData.getMimetype();
    if (mimetype != null)
    {
        mimetype = mimetype.toLowerCase();
        contentData = ContentData.setMimetype(contentData, mimetype);
    }
    return contentData;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:11,代码来源:AbstractContentDataDAOImpl.java

示例9: getValueInternal

import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
public Serializable getValueInternal(CMISNodeInfo nodeInfo)
{
    ContentData contentData = getContentData(nodeInfo);

    if (contentData != null)
    {
        return contentData.getMimetype();
    }
    return null;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:11,代码来源:ContentStreamMimetypeProperty.java

示例10: getMimeType

import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
private String getMimeType(ContentData contentProperty)
{
    String mimetype = null;

    if(contentProperty != null)
    {
        mimetype = contentProperty.getMimetype();
    }

    return mimetype;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:12,代码来源:BulkMetadataGet.java

示例11: createRendition

import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
@Override
public void createRendition(String nodeId, Rendition rendition, boolean executeAsync, Parameters parameters)
{
    // If thumbnail generation has been configured off, then don't bother.
    if (!thumbnailService.getThumbnailsEnabled())
    {
        throw new DisabledServiceException("Thumbnail generation has been disabled.");
    }

    final NodeRef sourceNodeRef = validateSourceNode(nodeId);
    final NodeRef renditionNodeRef = getRenditionByName(sourceNodeRef, rendition.getId(), parameters);
    if (renditionNodeRef != null)
    {
        throw new ConstraintViolatedException(rendition.getId() + " rendition already exists.");
    }

    // Use the thumbnail registry to get the details of the thumbnail
    ThumbnailRegistry registry = thumbnailService.getThumbnailRegistry();
    ThumbnailDefinition thumbnailDefinition = registry.getThumbnailDefinition(rendition.getId());
    if (thumbnailDefinition == null)
    {
        throw new NotFoundException(rendition.getId() + " is not registered.");
    }

    ContentData contentData = getContentData(sourceNodeRef, true);
    // Check if anything is currently available to generate thumbnails for the specified mimeType
    if (!registry.isThumbnailDefinitionAvailable(contentData.getContentUrl(), contentData.getMimetype(), contentData.getSize(), sourceNodeRef,
                thumbnailDefinition))
    {
        throw new InvalidArgumentException("Unable to create thumbnail '" + thumbnailDefinition.getName() + "' for " +
                    contentData.getMimetype() + " as no transformer is currently available.");
    }

    Action action = ThumbnailHelper.createCreateThumbnailAction(thumbnailDefinition, serviceRegistry);

    // Create thumbnail - or else queue for async creation
    actionService.executeAction(action, sourceNodeRef, true, executeAsync);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:39,代码来源:RenditionsImpl.java

示例12: cloneNode

import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
/**
 * Clone node
 * 
 * @param newName the new name of the node
 * @param fromNode the node to copy from
 * @param toNode the node to copy to
 * @param ctx
 */
private void cloneNode(String newName, NodeRef fromNode, NodeRef toNode, ContentContext ctx) 
{
    if(logger.isDebugEnabled())
    {
        logger.debug("clone node from fromNode:" + fromNode + "toNode:" + toNode);
    }
    cloneNodeAspects(newName, fromNode, toNode, ctx);

    // copy over the node creator and owner properties
    // need to disable the auditable aspect first to prevent default audit behaviour
    policyBehaviourFilter.disableBehaviour(ContentModel.ASPECT_AUDITABLE);
    try
    {
    	nodeService.setProperty(toNode, ContentModel.PROP_CREATOR, nodeService.getProperty(fromNode, ContentModel.PROP_CREATOR));
    	ownableService.setOwner(toNode, ownableService.getOwner(fromNode));
    }
    finally
    {
        policyBehaviourFilter.enableBehaviour(ContentModel.ASPECT_AUDITABLE);
    }
    
    Set<AccessPermission> permissions = permissionService.getAllSetPermissions(fromNode);
    boolean inheritParentPermissions = permissionService.getInheritParentPermissions(fromNode);
    permissionService.deletePermissions(fromNode);
    
    permissionService.setInheritParentPermissions(toNode, inheritParentPermissions);        
    for(AccessPermission permission : permissions)
    {
        permissionService.setPermission(toNode, permission.getAuthority(), permission.getPermission(), (permission.getAccessStatus() == AccessStatus.ALLOWED));
    }
    
    // Need to take a new guess at the mimetype based upon the new file name.
    ContentData content = (ContentData)nodeService.getProperty(toNode, ContentModel.PROP_CONTENT);
        
    // Take a guess at the mimetype (if it has not been set by something already)
    if (content != null && (content.getMimetype() == null || content.getMimetype().equals(MimetypeMap.MIMETYPE_BINARY)))
    {
        String mimetype = mimetypeService.guessMimetype(newName);
        if(logger.isDebugEnabled())
        {
            logger.debug("set new mimetype to:" + mimetype);
        }
        ContentData replacement = ContentData.setMimetype(content, mimetype);
        nodeService.setProperty(toNode, ContentModel.PROP_CONTENT, replacement);
    }

    // Extract metadata pending change for ALF-5082
    Action action = getActionService().createAction(ContentMetadataExtracter.EXECUTOR_NAME);
    if(action != null)
    {
        getActionService().executeAction(action, toNode);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:62,代码来源:ContentDiskDriver.java

示例13: executeImpl

import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
/**
 * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
 */
@Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef)
{
    // Check if thumbnailing is generally disabled
    if (!thumbnailService.getThumbnailsEnabled())
    {
        if (logger.isDebugEnabled())
        {
            logger.debug("Thumbnail transformations are not enabled");
        }
        return;
    }
    
    // Get the thumbnail
    NodeRef thumbnailNodeRef = (NodeRef)action.getParameterValue(PARAM_THUMBNAIL_NODE);
    if (thumbnailNodeRef == null)
    {
        thumbnailNodeRef = actionedUponNodeRef;
    }
    
    if (this.nodeService.exists(thumbnailNodeRef) == true &&
            renditionService.isRendition(thumbnailNodeRef))
    {            
        // Get the thumbnail Name
        ChildAssociationRef parent = renditionService.getSourceNode(thumbnailNodeRef);
        String thumbnailName = parent.getQName().getLocalName();
        
        // Get the details of the thumbnail
        ThumbnailRegistry registry = this.thumbnailService.getThumbnailRegistry();
        ThumbnailDefinition details = registry.getThumbnailDefinition(thumbnailName);
        if (details == null)
        {
            throw new AlfrescoRuntimeException("The thumbnail name '" + thumbnailName + "' is not registered");
        }
        
        // Get the content property
        QName contentProperty = (QName)action.getParameterValue(PARAM_CONTENT_PROPERTY);
        if (contentProperty == null)
        {
            contentProperty = ContentModel.PROP_CONTENT;
        }
        
        Serializable contentProp = nodeService.getProperty(actionedUponNodeRef, contentProperty);
        if (contentProp == null)
        {
            logger.info("Creation of thumbnail, null content for " + details.getName());
            return;
        }

        if(contentProp instanceof ContentData)
        {
            ContentData content = (ContentData)contentProp;
            String mimetype = content.getMimetype();
            if (mimetypeMaxSourceSizeKBytes != null)
            {
                Long maxSourceSizeKBytes = mimetypeMaxSourceSizeKBytes.get(mimetype);
                if (maxSourceSizeKBytes != null && maxSourceSizeKBytes >= 0 && maxSourceSizeKBytes < (content.getSize()/1024L))
                {
                    logger.debug("Unable to create thumbnail '" + details.getName() + "' for " +
                            mimetype + " as content is too large ("+(content.getSize()/1024L)+"K > "+maxSourceSizeKBytes+"K)");
                    return; //avoid transform
                }
            }
        }
        // Create the thumbnail
        this.thumbnailService.updateThumbnail(thumbnailNodeRef, details.getTransformationOptions());
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:72,代码来源:UpdateThumbnailActionExecuter.java

示例14: createContentDataEntity

import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
/**
 * Translates the {@link ContentData} into persistable values using the helper DAOs
 */
protected ContentDataEntity createContentDataEntity(ContentData contentData)
{
    // Resolve the content URL
    Long contentUrlId = null;
    String contentUrl = contentData.getContentUrl();
    long size = contentData.getSize();
    if (contentUrl != null)
    {
        ContentUrlEntity contentUrlEntity = new ContentUrlEntity();
        contentUrlEntity.setContentUrl(contentUrl);
        contentUrlEntity.setSize(size);
        Pair<Long, ContentUrlEntity> pair = contentUrlCache.createOrGetByValue(contentUrlEntity, controlDAO);
        contentUrlId = pair.getFirst();
    }

    // Resolve the mimetype
    Long mimetypeId = null;
    String mimetype = contentData.getMimetype();
    if (mimetype != null)
    {
        mimetypeId = mimetypeDAO.getOrCreateMimetype(mimetype).getFirst();
    }
    // Resolve the encoding
    Long encodingId = null;
    String encoding = contentData.getEncoding();
    if (encoding != null)
    {
        encodingId = encodingDAO.getOrCreateEncoding(encoding).getFirst();
    }
    // Resolve the locale
    Long localeId = null;
    Locale locale = contentData.getLocale();
    if (locale != null)
    {
        localeId = localeDAO.getOrCreateLocalePair(locale).getFirst();
    }
    
    // Create ContentDataEntity
    ContentDataEntity contentDataEntity = createContentDataEntity(contentUrlId, mimetypeId, encodingId, localeId);
    // Done
    return contentDataEntity;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:46,代码来源:AbstractContentDataDAOImpl.java

示例15: updateContentDataEntity

import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
/**
 * Translates the {@link ContentData} into persistable values using the helper DAOs
 */
protected int updateContentDataEntity(ContentDataEntity contentDataEntity, ContentData contentData)
{
    // Resolve the content URL
    Long oldContentUrlId = contentDataEntity.getContentUrlId();
    ContentUrlEntity contentUrlEntity = null;
    if(oldContentUrlId != null)
    {
        Pair<Long, ContentUrlEntity> entityPair = contentUrlCache.getByKey(oldContentUrlId);
        if (entityPair == null)
        {
            throw new DataIntegrityViolationException("No ContentUrl value exists for ID " + oldContentUrlId);
        }
        contentUrlEntity = entityPair.getSecond();
    }

    String oldContentUrl = (contentUrlEntity != null ? contentUrlEntity.getContentUrl() : null);
    String newContentUrl = contentData.getContentUrl();
    if (!EqualsHelper.nullSafeEquals(oldContentUrl, newContentUrl))
    {
        if (oldContentUrl != null)
        {
            // We have a changed value.  The old content URL has been dereferenced.
            registerDereferencedContentUrl(oldContentUrl);
        }
        if (newContentUrl != null)
        {
            if(contentUrlEntity == null)
            {
                contentUrlEntity = new ContentUrlEntity();
                contentUrlEntity.setContentUrl(newContentUrl);
            }
            Pair<Long, ContentUrlEntity> pair = contentUrlCache.getOrCreateByValue(contentUrlEntity);
            Long newContentUrlId = pair.getFirst();
            contentUrlEntity.setId(newContentUrlId);
            contentDataEntity.setContentUrlId(newContentUrlId);
        }
        else
        {
            contentDataEntity.setId(null);
            contentDataEntity.setContentUrlId(null);
        }
    }

    // Resolve the mimetype
    Long mimetypeId = null;
    String mimetype = contentData.getMimetype();
    if (mimetype != null)
    {
        mimetypeId = mimetypeDAO.getOrCreateMimetype(mimetype).getFirst();
    }
    // Resolve the encoding
    Long encodingId = null;
    String encoding = contentData.getEncoding();
    if (encoding != null)
    {
        encodingId = encodingDAO.getOrCreateEncoding(encoding).getFirst();
    }
    // Resolve the locale
    Long localeId = null;
    Locale locale = contentData.getLocale();
    if (locale != null)
    {
        localeId = localeDAO.getOrCreateLocalePair(locale).getFirst();
    }

    contentDataEntity.setMimetypeId(mimetypeId);
    contentDataEntity.setEncodingId(encodingId);
    contentDataEntity.setLocaleId(localeId);

    return updateContentDataEntity(contentDataEntity);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:75,代码来源:AbstractContentDataDAOImpl.java


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