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


Java ContentModel.PROP_CONTENT属性代码示例

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


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

示例1: execute

@Override
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException
{
    // create empty map of args
    Map<String, String> args = new HashMap<String, String>(0, 1.0f);
    // create map of template vars
    Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
    // create object reference from url
    ObjectReference reference = createObjectReferenceFromUrl(args, templateVars);
    NodeRef nodeRef = reference.getNodeRef();
    if (nodeRef == null)
    {
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find " + reference.toString());
    }

    // render content
    QName propertyQName = ContentModel.PROP_CONTENT;

    // Stream the content
    streamContent(req, res, nodeRef, propertyQName, false, null, null);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:21,代码来源:ContentInfo.java

示例2: executeImpl

protected void executeImpl(NodeRef nodeRef, Map<String, String> templateVars, WebScriptRequest req, WebScriptResponse res, Map<String, Object> model) throws IOException
{
    // render content
       QName propertyQName = ContentModel.PROP_CONTENT;
       String contentPart = templateVars.get("property");
       if (contentPart.length() > 0 && contentPart.charAt(0) == ';')
       {
           if (contentPart.length() < 2)
           {
               throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Content property malformed");
           }
           String propertyName = contentPart.substring(1);
           if (propertyName.length() > 0)
           {
               propertyQName = QName.createQName(propertyName, namespaceService);
           }
       }
       
       // determine attachment
       boolean attach = Boolean.valueOf(req.getParameter("a"));
       
       // Stream the content
       streamContentLocal(req, res, nodeRef, attach, propertyQName, model);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:24,代码来源:QuickShareContentGet.java

示例3: execute

/**
 * @see org.alfresco.service.cmr.repository.ScriptProcessor#execute(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName, java.util.Map)
 */
public Object execute(NodeRef nodeRef, QName contentProp, Map<String, Object> model)
{
    try
    {
        if (this.services.getNodeService().exists(nodeRef) == false)
        {
            throw new AlfrescoRuntimeException("Script Node does not exist: " + nodeRef);
        }
        
        if (contentProp == null)
        {
            contentProp = ContentModel.PROP_CONTENT;
        }
        ContentReader cr = this.services.getContentService().getReader(nodeRef, contentProp);
        if (cr == null || cr.exists() == false)
        {
            throw new AlfrescoRuntimeException("Script Node content not found: " + nodeRef);
        }
        
        // compile the script based on the node content
        Script script;
        Context cx = Context.enter();
        try
        {
            script = cx.compileString(resolveScriptImports(cr.getContentString()), nodeRef.toString(), 1, null);
        }
        finally
        {
            Context.exit();
        }
        
        return executeScriptImpl(script, model, false, nodeRef.toString());
    }
    catch (Throwable err)
    {
        throw new ScriptException("Failed to execute script '" + nodeRef.toString() + "': " + err.getMessage(), err);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:41,代码来源:RhinoScriptProcessor.java

示例4: getQNameId

private Long getQNameId(QName sortPropQName)
{
    if (sortPropQName.equals(SORT_QNAME_CONTENT_SIZE) || sortPropQName.equals(SORT_QNAME_CONTENT_MIMETYPE))
    {
        sortPropQName = ContentModel.PROP_CONTENT;
    }
    
    Pair<Long, QName> qnamePair = qnameDAO.getQName(sortPropQName);
    return (qnamePair == null ? null : qnamePair.getFirst());
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:10,代码来源:GetChildrenCannedQuery.java

示例5: execute

/**
 * @see org.springframework.extensions.webscripts.WebScript#execute(WebScriptRequest, WebScriptResponse)
 */
public void execute(WebScriptRequest req, WebScriptResponse res)
    throws IOException
{
    // create map of args
    String[] names = req.getParameterNames();
    Map<String, String> args = new HashMap<String, String>(names.length, 1.0f);
    for (String name : names)
    {
        args.put(name, req.getParameter(name));
    }
    
    // create map of template vars
    Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
    
    // create object reference from url
    ObjectReference reference = createObjectReferenceFromUrl(args, templateVars);
    NodeRef nodeRef = reference.getNodeRef();
    if (nodeRef == null)
    {
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find " + reference.toString());
    }
    
    // determine attachment
    boolean attach = Boolean.valueOf(req.getParameter("a"));
    
    // render content
    QName propertyQName = ContentModel.PROP_CONTENT;
    String contentPart = templateVars.get("property");
    if (contentPart.length() > 0 && contentPart.charAt(0) == ';')
    {
        if (contentPart.length() < 2)
        {
            throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Content property malformed");
        }
        String propertyName = contentPart.substring(1);
        if (propertyName.length() > 0)
        {
            propertyQName = QName.createQName(propertyName, namespaceService);
        }
    }

    // Stream the content
    streamContentLocal(req, res, nodeRef, attach, propertyQName, null);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:47,代码来源:ContentGet.java

示例6: executeImpl

/**
 * @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,代码行数:71,代码来源:UpdateThumbnailActionExecuter.java

示例7: getQNameForExists

protected QName getQNameForExists()
{
    return ContentModel.PROP_CONTENT;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:4,代码来源:ContentStreamMimetypeProperty.java

示例8: testCreateRenditionNodeAssoc

@SuppressWarnings({"unchecked" , "rawtypes"})
public void testCreateRenditionNodeAssoc() throws Exception
{
    QName assocType = RenditionModel.ASSOC_RENDITION;
    when(nodeService.exists(source)).thenReturn(true);
    QName nodeType = ContentModel.TYPE_CONTENT;
    ChildAssociationRef renditionAssoc = makeRenditionAssoc();
    RenditionDefinition definition = makeRenditionDefinition(renditionAssoc);

    // Stub the createNode() method to return renditionAssoc.
    when(nodeService.createNode(eq(source), eq(assocType), any(QName.class), any(QName.class), anyMap()))
        .thenReturn(renditionAssoc);
    engine.execute(definition, source);

    // Check the createNode method was called with the correct parameters.
    // Check the nodeType defaults to cm:content.
    ArgumentCaptor<Map> captor = ArgumentCaptor.forClass(Map.class);
    verify(nodeService).createNode(eq(source), eq(assocType), any(QName.class), eq(nodeType), captor.capture());
    Map<String, Serializable> props = captor.getValue();

    // Check the node name is set to match teh rendition name local name.
    assertEquals(renditionAssoc.getQName().getLocalName(), props.get(ContentModel.PROP_NAME));

    // Check content property name defaults to cm:content
    assertEquals(ContentModel.PROP_CONTENT, props.get(ContentModel.PROP_CONTENT_PROPERTY_NAME));

    // Check the returned result is the association created by the call to
    // nodeServcie.createNode().
    Serializable result = definition.getParameterValue(ActionExecuter.PARAM_RESULT);
    assertEquals("The returned rendition association is not the one created by the node service!", renditionAssoc,
                result);

    // Check that setting the default content property and default node type
    // on the rendition engine works.
    nodeType = QName.createQName("url", "someNodeType");
    QName contentPropName = QName.createQName("url", "someContentProp");
    engine.setDefaultRenditionContentProp(contentPropName.toString());
    engine.setDefaultRenditionNodeType(nodeType.toString());
    engine.execute(definition, source);
    verify(nodeService).createNode(eq(source), eq(assocType), any(QName.class), eq(nodeType), captor.capture());
    props = captor.getValue();
    assertEquals(contentPropName, props.get(ContentModel.PROP_CONTENT_PROPERTY_NAME));

    // Check that setting the rendition node type param works.
    nodeType = ContentModel.TYPE_THUMBNAIL;
    contentPropName = ContentModel.PROP_CONTENT;
    definition.setParameterValue(RenditionService.PARAM_RENDITION_NODETYPE, nodeType);
    definition.setParameterValue(AbstractRenderingEngine.PARAM_TARGET_CONTENT_PROPERTY, contentPropName);
    engine.execute(definition, source);
    verify(nodeService).createNode(eq(source), eq(assocType), any(QName.class), eq(nodeType), captor.capture());
    props = captor.getValue();
    assertEquals(contentPropName, props.get(ContentModel.PROP_CONTENT_PROPERTY_NAME));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:53,代码来源:AbstractRenderingEngineTest.java

示例9: getQNameForExists

@Override
protected QName getQNameForExists()
{
    return ContentModel.PROP_CONTENT;
}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:5,代码来源:ContentStreamMimetypeLuceneBuilder.java

示例10: getContent

@Override
public BinaryResource getContent(NodeRef nodeRef, Parameters parameters, boolean recordActivity)
{
    if (!nodeMatches(nodeRef, Collections.singleton(ContentModel.TYPE_CONTENT), null, false))
    {
        throw new InvalidArgumentException("NodeId of content is expected: " + nodeRef.getId());
    }

    Map<QName, Serializable> nodeProps = nodeService.getProperties(nodeRef);
    ContentData cd = (ContentData) nodeProps.get(ContentModel.PROP_CONTENT);
    String name = (String) nodeProps.get(ContentModel.PROP_NAME);

    org.alfresco.rest.framework.resource.content.ContentInfo ci = null;
    String mimeType = null;
    if (cd != null)
    {
        mimeType = cd.getMimetype();
        ci = new org.alfresco.rest.framework.resource.content.ContentInfoImpl(mimeType, cd.getEncoding(), cd.getSize(), cd.getLocale());
    }

    // By default set attachment header (with filename) unless attachment=false *and* content type is pre-configured as non-attach
    boolean attach = true;
    String attachment = parameters.getParameter("attachment");
    if (attachment != null)
    {
        Boolean a = Boolean.valueOf(attachment);
        if (!a)
        {
            if (nonAttachContentTypes.contains(mimeType))
            {
                attach = false;
            }
            else
            {
                logger.warn("Ignored attachment=false for "+nodeRef.getId()+" since "+mimeType+" is not in the whitelist for non-attach content types");
            }
        }
    }
    String attachFileName = (attach ? name : null);

    if (recordActivity)
    {
        final ActivityInfo activityInfo = getActivityInfo(getParentNodeRef(nodeRef), nodeRef);
        postActivity(Activity_Type.DOWNLOADED, activityInfo, true);
    }

    return new NodeBinaryResource(nodeRef, ContentModel.PROP_CONTENT, ci, attachFileName);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:48,代码来源:NodesImpl.java


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