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


Java ContentData.getContentUrl方法代码示例

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


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

示例1: deleteContentDataEntity

import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
@Override
protected int deleteContentDataEntity(Long id)
{
    // Get the content urls
    try
    {
        ContentData contentData = getContentData(id).getSecond();
        String contentUrl = contentData.getContentUrl();
        if (contentUrl != null)
        {
            // It has been dereferenced and may be orphaned - we'll check later
            registerDereferencedContentUrl(contentUrl);
        }
    }
    catch (DataIntegrityViolationException e)
    {
        // Doesn't exist.  The node doesn't enforce a FK constraint, so we protect against this.
    }
    // Issue the delete statement
    Map<String, Object> params = new HashMap<String, Object>(11);
    params.put("id", id);
    return template.delete(DELETE_CONTENT_DATA, params);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:24,代码来源:ContentDataDAOImpl.java

示例2: 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

示例3: writeContent

import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
/**
 * @param nodeToUpdate NodeRef
 * @param contentProps Map<QName, Serializable>
 * @return true if any content property has been updated for the needToUpdate node
 */
private boolean writeContent(NodeRef nodeToUpdate, Map<QName, Serializable> contentProps)
{
    boolean contentUpdated = false;
    File stagingDir = getStagingFolder();
    for (Map.Entry<QName, Serializable> contentEntry : contentProps.entrySet())
    {
        ContentData contentData = (ContentData) contentEntry.getValue();
        String contentUrl = contentData.getContentUrl();
        if(contentUrl == null || contentUrl.isEmpty())
        {
            log.debug("content data is null or empty:" + nodeToUpdate);
            ContentData cd = new ContentData(null, null, 0, null);
            nodeService.setProperty(nodeToUpdate, contentEntry.getKey(), cd);
            contentUpdated = true;
        }
        else
        {
            String fileName = TransferCommons.URLToPartName(contentUrl);
            File stagedFile = new File(stagingDir, fileName);
            if (!stagedFile.exists())
            {
                error(MSG_REFERENCED_CONTENT_FILE_MISSING);
            }
            ContentWriter writer = contentService.getWriter(nodeToUpdate, contentEntry.getKey(), true);
            writer.setEncoding(contentData.getEncoding());
            writer.setMimetype(contentData.getMimetype());
            writer.setLocale(contentData.getLocale());
            writer.putContent(stagedFile);
            contentUpdated = true;
        }
    }
    return contentUpdated;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:39,代码来源:RepoPrimaryManifestProcessorImpl.java

示例4: injectTransferred

import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
/**
 * inject transferred
 */
private void injectTransferred(Map<QName, Serializable> props)
{       
    if(!props.containsKey(TransferModel.PROP_REPOSITORY_ID))
    {
        log.debug("injecting repositoryId property");
        props.put(TransferModel.PROP_REPOSITORY_ID, header.getRepositoryId());
    }
    props.put(TransferModel.PROP_FROM_REPOSITORY_ID, header.getRepositoryId());
    
    /**
     * For each property
     */
    List<String> contentProps = new ArrayList<String>();
    for (Serializable value : props.values())
    {
        if ((value != null) && ContentData.class.isAssignableFrom(value.getClass()))
        {
            ContentData srcContent = (ContentData)value;

            if(srcContent.getContentUrl() != null && !srcContent.getContentUrl().isEmpty())
            {
                log.debug("adding part name to from content field");
                contentProps.add(TransferCommons.URLToPartName(srcContent.getContentUrl()));
            }  
        }
    }
    
    props.put(TransferModel.PROP_FROM_CONTENT, (Serializable)contentProps);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:33,代码来源:RepoPrimaryManifestProcessorImpl.java

示例5: getValueInternal

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

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

示例6: testContentUrl_FetchingOrphansNoLimit

import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
public void testContentUrl_FetchingOrphansNoLimit() throws Exception
{
    ContentData contentData = getContentData();
    Pair<Long, ContentData> resultPair = create(contentData);
    getAndCheck(resultPair.getFirst(), contentData);
    delete(resultPair.getFirst());
    // The content URL is orphaned
    final String contentUrlOrphaned = contentData.getContentUrl();
    final boolean[] found = new boolean[] {false}; 
    
    // Iterate over all orphaned content URLs and ensure that we hit the one we just orphaned
    ContentUrlHandler handler = new ContentUrlHandler()
    {
        public void handle(Long id, String contentUrl, Long orphanTime)
        {
            // Check
            if (id == null || contentUrl == null || orphanTime == null)
            {
                fail("Invalid orphan data returned to handler: " + id + "-" + contentUrl + "-" + orphanTime);
            }
            // Did we get the one we wanted?
            if (contentUrl.equals(contentUrlOrphaned))
            {
                found[0] = true;
            }
        }
    };
    contentDataDAO.getContentUrlsOrphaned(handler, Long.MAX_VALUE, Integer.MAX_VALUE);
    assertTrue("Newly-orphaned content URL not found", found[0]);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:31,代码来源:ContentDataDAOTest.java

示例7: processNode

import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
protected void processNode(TransferManifestNormalNode node)
{

    //Skip over any nodes that are not parented with a cm:contains association or 
    //are not content nodes (we don't need their content)
    if (!ContentModel.ASSOC_CONTAINS.equals(node.getPrimaryParentAssoc().getTypeQName()) ||
            !ContentModel.TYPE_CONTENT.equals(node.getAncestorType()))
    {
        return;
    }

    Serializable value = node.getProperties().get(ContentModel.PROP_CONTENT);
    if ((value != null) && ContentData.class.isAssignableFrom(value.getClass()))
    {
        ContentData srcContent = (ContentData) value;
        if (srcContent.getContentUrl() != null && !srcContent.getContentUrl().isEmpty())
        {
            // Only ask for content if content is new or if contentUrl is modified
            boolean contentisMissing = fileTransferReceiver.isContentNewOrModified(
                    node.getNodeRef().toString(), srcContent.getContentUrl());
            if (contentisMissing)
            {
                if (log.isDebugEnabled())
                {
                    log.debug("No node on destination, content is required: " + srcContent.getContentUrl());
                }
                out.missingContent(node.getNodeRef(), ContentModel.PROP_CONTENT, 
                        TransferCommons.URLToPartName(srcContent.getContentUrl()));
            }
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-file-transfer-receiver,代码行数:33,代码来源:FileTransferReceiverRequisiteManifestProcessor.java

示例8: buildNodeContext

import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
public static NodeContext buildNodeContext(TransferManifestNormalNode node, FileTransferInfoEntity nodeEntity, 
        FileTransferInfoEntity parentEntity)
{
    NodeContext result = new NodeContext();
    //Pull some useful information out of the supplied node object
    result.newName = (String) node.getProperties().get(ContentModel.PROP_NAME);
    result.nodeId = node.getNodeRef().toString();
    result.isFolder = ContentModel.TYPE_FOLDER.equals(node.getAncestorType());
    result.newParentId = node.getPrimaryParentAssoc().getParentRef().toString();
    
    //Look up the node id in our database and extract some info from what we find
    result.isNew = (nodeEntity == null);
    result.isRenamed = (!result.isNew && !result.newName.equals(nodeEntity.getContentName()));
    result.parentHasChanged = (!result.isNew && !result.newParentId.equals(nodeEntity.getParent()));
    result.hasMoved = result.parentHasChanged || result.isRenamed;
    result.currentParentPath = result.isNew ? null : nodeEntity.getPath();
    result.currentParentId = result.isNew ? null : nodeEntity.getParent();
    result.currentContentUrl = result.isNew ? null : nodeEntity.getContentUrl();
    result.currentName = result.isNew ? null : nodeEntity.getContentName();
    
    //Look up the target parent node id in our database and extract some info from what we find
    result.parentAlreadyExists = (parentEntity != null);
    result.newParentPath = result.parentAlreadyExists ? (parentEntity.getPath() + parentEntity.getContentName() + "/") : null;
    result.tempName = getNextTempName();
    
    ContentData contentData = (ContentData) node.getProperties().get(ContentModel.PROP_CONTENT);
    result.newContentUrl = "";
    if (contentData != null)
    {
        result.newContentUrl = contentData.getContentUrl();
    }

    return result;
}
 
开发者ID:Alfresco,项目名称:alfresco-file-transfer-receiver,代码行数:35,代码来源:ManifestProcessorImpl.java

示例9: importContent

import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
/**
 * Import Node Content.
 * <p>
 * The content URL, if present, will be a local URL.  This import copies the content
 * from the local URL to a server-assigned location.
 *
 * @param nodeRef containing node
 * @param propertyName the name of the content-type property
 * @param importContentData the identifier of the content to import
 */
private void importContent(NodeRef nodeRef, QName propertyName, String importContentData)
{
    ImporterContentCache contentCache = (binding == null) ? null : binding.getImportConentCache();
    
    // bind import content data description
    importContentData = bindPlaceHolder(importContentData, binding);
    if (importContentData != null && importContentData.length() > 0)
    {
        DataTypeDefinition dataTypeDef = dictionaryService.getDataType(DataTypeDefinition.CONTENT);
        ContentData contentData = (ContentData)DefaultTypeConverter.INSTANCE.convert(dataTypeDef, importContentData);
        String contentUrl = contentData.getContentUrl();
        if (contentUrl != null && contentUrl.length() > 0)
        {
            Map<QName, Serializable> propsBefore = null;
            if (contentUsageImpl != null && contentUsageImpl.getEnabled())
            {
                propsBefore = nodeService.getProperties(nodeRef);
            }

            if (contentCache != null)
            {
                // import content from source
                ContentData cachedContentData = contentCache.getContent(streamHandler, contentData);
                nodeService.setProperty(nodeRef, propertyName, cachedContentData);
            }
            else
            {
                // import the content from the import source file
                InputStream contentStream = streamHandler.importStream(contentUrl);
                ContentWriter writer = contentService.getWriter(nodeRef, propertyName, true);
                writer.setEncoding(contentData.getEncoding());
                writer.setMimetype(contentData.getMimetype());
                writer.putContent(contentStream);
            }
                                
            if (contentUsageImpl != null && contentUsageImpl.getEnabled())
            {
                // Since behaviours for content nodes have all been disabled,
                // it is necessary to update the user's usage stats.
                Map<QName, Serializable> propsAfter = nodeService.getProperties(nodeRef);
                contentUsageImpl.onUpdateProperties(nodeRef, propsBefore, propsAfter);
            }
            
            reportContentCreated(nodeRef, contentUrl);
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:58,代码来源:ImporterComponent.java

示例10: getContent

import org.alfresco.service.cmr.repository.ContentData; //导入方法依赖的package包/类
@Override
public ContentData getContent(final ImportPackageHandler handler, final ContentData sourceContentData)
{
    ContentData cachedContentData = null;
    final String sourceContentUrl = sourceContentData.getContentUrl();

    contentUrlsLock.readLock().lock();
    
    try
    {
        cachedContentData = contentUrls.get(sourceContentUrl);
        if (cachedContentData == null)
        {
            contentUrlsLock.readLock().unlock();
            contentUrlsLock.writeLock().lock();
            
            try
            {
                cachedContentData = contentUrls.get(sourceContentUrl);
                if (cachedContentData == null)
                {
                    cachedContentData = TenantUtil.runAsTenant(new TenantRunAsWork<ContentData>()
                    {
                        @Override
                        public ContentData doWork() throws Exception
                        {
                            InputStream contentStream = handler.importStream(sourceContentUrl);
                            ContentWriter writer = contentService.getWriter(null, null, false);
                            writer.setEncoding(sourceContentData.getEncoding());
                            writer.setMimetype(sourceContentData.getMimetype());
                            writer.putContent(contentStream);
                            return writer.getContentData();
                        }
                    }, TenantService.DEFAULT_DOMAIN);
                    
                    contentUrls.put(sourceContentUrl, cachedContentData);
                }
            }
            finally
            {
                contentUrlsLock.readLock().lock();
                contentUrlsLock.writeLock().unlock();
            }
        }
    }
    finally
    {
        contentUrlsLock.readLock().unlock();
    }
    
    if (logger.isDebugEnabled())
        logger.debug("Mapped contentUrl " + sourceContentUrl + " to " + cachedContentData);
        
    return cachedContentData;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:56,代码来源:DefaultImporterContentCache.java

示例11: 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

示例12: 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.getContentUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。