org.alfresco.service.cmr.repository.ContentData Java Examples

The following examples show how to use org.alfresco.service.cmr.repository.ContentData. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RenditionService2Impl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Returns the hash code of the source node's content url. As transformations may be returned in a different
 * sequences to which they were requested, this is used work out if a rendition should be replaced.
 */
private int getSourceContentHashCode(NodeRef sourceNodeRef)
{
    int hashCode = SOURCE_HAS_NO_CONTENT;
    ContentData contentData = DefaultTypeConverter.INSTANCE.convert(ContentData.class, nodeService.getProperty(sourceNodeRef, PROP_CONTENT));
    if (contentData != null)
    {
        // Originally we used the contentData URL, but that is not enough if the mimetype changes.
        String contentString = contentData.getContentUrl()+contentData.getMimetype();
        if (contentString != null)
        {
            hashCode = contentString.hashCode();
        }
    }
    return hashCode;
}
 
Example #2
Source File: ContentDataDAOTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Category(PerformanceTests.class)
public void testCreateSpeedSingleTxn()
{
    RetryingTransactionCallback<List<Pair<Long, ContentData>>> writeCallback = new RetryingTransactionCallback<List<Pair<Long, ContentData>>>()
    {
        public List<Pair<Long, ContentData>> execute() throws Throwable
        {
            return speedTestWrite(getName(), 10000);
        }
    };
    final List<Pair<Long, ContentData>> pairs = txnHelper.doInTransaction(writeCallback, false, false);
    RetryingTransactionCallback<Void> readCallback = new RetryingTransactionCallback<Void>()
    {
        public Void execute() throws Throwable
        {
            speedTestRead(getName(), pairs);
            return null;
        }
    };
    txnHelper.doInTransaction(readCallback, false, false);
}
 
Example #3
Source File: AbstractProperty.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected ContentData getContentData(CMISNodeInfo nodeInfo)
{
    if (!nodeInfo.isDocument())
    {
        return null;
    }

    if (nodeInfo.containsPropertyValue(CONTENT_PROPERTY))
    {
        return (ContentData) nodeInfo.getPropertyValue(CONTENT_PROPERTY);
    } else
    {
        ContentData contentData = null;

        Serializable value = nodeInfo.getNodeProps().get(ContentModel.PROP_CONTENT);

        if (value != null)
        {
            contentData = DefaultTypeConverter.INSTANCE.convert(ContentData.class, value);
        }

        nodeInfo.putPropertyValue(CONTENT_PROPERTY, contentData);
        return contentData;
    }
}
 
Example #4
Source File: RenditionService2IntegrationTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void changedSourceToNonNull()
{
    NodeRef sourceNodeRef = createSource(ADMIN, "quick.jpg");
    render(ADMIN, sourceNodeRef, DOC_LIB);
    NodeRef rendition1 = waitForRendition(ADMIN, sourceNodeRef, DOC_LIB, true);
    ContentData contentData1 = DefaultTypeConverter.INSTANCE.convert(ContentData.class, nodeService.getProperty(rendition1, PROP_CONTENT));

    updateContent(ADMIN, sourceNodeRef, "quick.png");
    render(ADMIN, sourceNodeRef, DOC_LIB);
    NodeRef rendition2 = waitForRendition(ADMIN, sourceNodeRef, DOC_LIB, true);
    ContentData contentData2 = DefaultTypeConverter.INSTANCE.convert(ContentData.class, nodeService.getProperty(rendition2, PROP_CONTENT));

    assertEquals("The rendition node should not change", rendition1, rendition2);
    assertNotEquals("The content should have change", contentData1.toString(), contentData2.toString());
}
 
Example #5
Source File: ThumbnailServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private NodeRef createCorruptedContent(NodeRef parentFolder) throws IOException
{
    // The below pdf file has been truncated such that it is identifiable as a PDF but otherwise corrupt.
    File corruptPdfFile = AbstractContentTransformerTest.loadNamedQuickTestFile("quickCorrupt.pdf");
    assertNotNull("Failed to load required test file.", corruptPdfFile);

    Map<QName, Serializable> props = new HashMap<QName, Serializable>();
    props.put(ContentModel.PROP_NAME, "corrupt.pdf");
    NodeRef node = this.secureNodeService.createNode(parentFolder, ContentModel.ASSOC_CONTAINS,
            QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "quickCorrupt.pdf"),
            ContentModel.TYPE_CONTENT, props).getChildRef();

    secureNodeService.setProperty(node, ContentModel.PROP_CONTENT, new ContentData(null,
                MimetypeMap.MIMETYPE_PDF, 0L, null));
    ContentWriter writer = contentService.getWriter(node, ContentModel.PROP_CONTENT, true);
    writer.setMimetype(MimetypeMap.MIMETYPE_PDF);
    writer.setEncoding("UTF-8");
    writer.putContent(corruptPdfFile);
    
    return node;
}
 
Example #6
Source File: ContentDataTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testEquals()
{
    ContentData contentData1 = new ContentData("abc://xxx", MimetypeMap.MIMETYPE_BINARY, 600L, "UTF-8", Locale.ENGLISH);
    ContentData contentData2 = new ContentData("abc://xxx", MimetypeMap.MIMETYPE_BINARY, 600L, "UTF-8", Locale.ENGLISH);
    ContentData contentData3 = new ContentData("abc://XXX", MimetypeMap.MIMETYPE_BINARY, 600L, "UTF-8", Locale.ENGLISH);
    ContentData contentData4 = new ContentData("abc://xxx", MimetypeMap.MIMETYPE_TEXT_PLAIN, 600L, "UTF-8", Locale.ENGLISH);
    ContentData contentData5 = new ContentData("abc://xxx", MimetypeMap.MIMETYPE_BINARY, 500L, "UTF-8", Locale.ENGLISH);
    ContentData contentData6 = new ContentData("abc://xxx", MimetypeMap.MIMETYPE_BINARY, 600L, "UTF-16", Locale.ENGLISH);
    ContentData contentData7 = new ContentData("abc://xxx", MimetypeMap.MIMETYPE_BINARY, 600L, "UTF-8", Locale.CHINESE);
    assertEquals(contentData1, contentData2);
    assertNotSame(contentData1, contentData3);
    assertNotSame(contentData1, contentData4);
    assertNotSame(contentData1, contentData5);
    assertNotSame(contentData1, contentData6);
    assertNotSame(contentData1, contentData7);
}
 
Example #7
Source File: RenditionsImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected NodeRef getRenditionByName(NodeRef nodeRef, String renditionId, Parameters parameters)
{
    if (nodeRef != null)
    {
        if (StringUtils.isEmpty(renditionId))
        {
            throw new InvalidArgumentException("renditionId can't be null or empty.");
        }

        ChildAssociationRef nodeRefRendition = renditionService2.getRenditionByName(nodeRef, renditionId);
        if (nodeRefRendition != null)
        {
            ContentData contentData = getContentData(nodeRefRendition.getChildRef(), false);
            if (contentData != null)
            {
                return tenantService.getName(nodeRef, nodeRefRendition.getChildRef());
            }
        }
    }

    return null;
}
 
Example #8
Source File: CheckOutCheckInServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Test when the aspect is not set when check-in is performed
 */
@Test
public void testVersionAspectNotSetOnCheckIn()
{
    // Create a bag of props
    Map<QName, Serializable> bagOfProps = createTypePropertyBag();
    bagOfProps.put(ContentModel.PROP_CONTENT, new ContentData(null, MimetypeMap.MIMETYPE_TEXT_PLAIN, 0L, "UTF-8"));

    // Create a new node 
    ChildAssociationRef childAssocRef = nodeService.createNode(
            rootNodeRef,
            ContentModel.ASSOC_CHILDREN,
            QName.createQName("test"),
            ContentModel.TYPE_CONTENT,
            bagOfProps);
    NodeRef noVersionNodeRef = childAssocRef.getChildRef();
    
    // Check out and check in
    NodeRef workingCopy = cociService.checkout(noVersionNodeRef);
    cociService.checkin(workingCopy, new HashMap<String, Serializable>());
    
    // Check that the origional node has no version history dispite sending verion props
    assertNull(this.versionService.getVersionHistory(noVersionNodeRef));        
}
 
Example #9
Source File: AbstractContentDataDAOImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void updateContentData(Long id, ContentData contentData)
{
    if (id == null)
    {
        throw new IllegalArgumentException("Cannot look up ContentData by null ID.");
    }
    if (contentData == null)
    {
        throw new IllegalArgumentException("Cannot update ContentData with a null.");
    }
    contentData = sanitizeMimetype(contentData);
    int updated = contentDataCache.updateValue(id, contentData);
    if (updated < 1)
    {
        throw new ConcurrencyFailureException("ContentData with ID " + id + " not updated");
    }
}
 
Example #10
Source File: OnPropertyUpdateRuleTrigger.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * ALF-17483: It's possible that even for a single-valued contentdata property, its definition may have been changed
 * and the previous persisted value is multi-valued, so let's be careful about converting to ContentData.
 * 
 * @param object
 *            property value to convert
 * @return a ContentData if one can be extracted
 */
private static ContentData toContentData(Object object)
{
    if (object == null)
    {
        return null;
    }
    if (object instanceof ContentData)
    {
        return (ContentData) object;
    }
    if (object instanceof Collection<?> && !((Collection<?>) object).isEmpty())
    {
        return toContentData(((Collection<?>) object).iterator().next());
    }
    return null;
}
 
Example #11
Source File: ContentChunkerImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 
 */
public void addContent(ContentData data) throws TransferException
{
    logger.debug("add content size:" + data.getSize());
    buffer.add(data);
    
    /**
     * work out whether the buffer has filled up and needs to be flushed
     */
    Iterator<ContentData> iter = buffer.iterator();      
    long totalContentSize = 0;
    
    while (iter.hasNext())
    {
        ContentData x = (ContentData)iter.next();
        totalContentSize += x.getSize();
    }
    if(logger.isDebugEnabled())
    {
        logger.debug("elements " + buffer.size() + ", totalContentSize:" + totalContentSize);
    }
    if(totalContentSize >= chunkSize)
    {
        flush();
    }
}
 
Example #12
Source File: ActionServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Before
public void before() throws Exception
{
    super.before();

    this.transactionHelper = (RetryingTransactionHelper)this.applicationContext.getBean("retryingTransactionHelper");

    // Create the node used for tests
    this.nodeRef = this.nodeService.createNode(
            this.rootNodeRef,
            ContentModel.ASSOC_CHILDREN,
            QName.createQName("{test}testnode"),
            ContentModel.TYPE_CONTENT).getChildRef();
    this.nodeService.setProperty(
            this.nodeRef,
            ContentModel.PROP_CONTENT,
            new ContentData(null, MimetypeMap.MIMETYPE_TEXT_PLAIN, 0L, null));
    this.folder = this.nodeService.createNode(
            this.rootNodeRef,
            ContentModel.ASSOC_CHILDREN,
            QName.createQName("{test}testFolder"),
            ContentModel.TYPE_FOLDER).getChildRef();
    
    // Register the test executor, if needed
    SleepActionExecuter.registerIfNeeded(applicationContext);
}
 
Example #13
Source File: UnitTestInProcessTransmitterImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void sendContent(final Transfer transfer, final Set<ContentData> data)
{
    transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
    {
        public Void execute() throws Throwable
        {
            String transferId = transfer.getTransferId();
    
            for(ContentData content : data)
            {
                String contentUrl = content.getContentUrl();
                String fileName = TransferCommons.URLToPartName(contentUrl);

                InputStream contentStream = getContentService().getRawReader(contentUrl).getContentInputStream();
                receiver.saveContent(transferId, fileName, contentStream);
            }
            return null;
        }
    }, false, true);
}
 
Example #14
Source File: AuditDAOTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testAuditModel() throws Exception
{
    final File file = AbstractContentTransformerTest.loadQuickTestFile("pdf");
    assertNotNull(file);
    final URL url = new URL("file:" + file.getAbsolutePath());
    RetryingTransactionCallback<Pair<Long, ContentData>> callback = new RetryingTransactionCallback<Pair<Long, ContentData>>()
    {
        public Pair<Long, ContentData> execute() throws Throwable
        {
            Pair<Long, ContentData> auditModelPair = auditDAO.getOrCreateAuditModel(url);
            return auditModelPair;
        }
    };
    Pair<Long, ContentData> configPair = txnHelper.doInTransaction(callback);
    assertNotNull(configPair);
    // Now repeat.  The results should be exactly the same.
    Pair<Long, ContentData> configPairCheck = txnHelper.doInTransaction(callback);
    assertNotNull(configPairCheck);
    assertEquals(configPair, configPairCheck);
}
 
Example #15
Source File: ContentDataDAOTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testDelete() throws Exception
{
    ContentData contentData = getContentData();
    
    Pair<Long, ContentData> resultPair = create(contentData);
    getAndCheck(resultPair.getFirst(), contentData);
    delete(resultPair.getFirst());
    try
    {
        getAndCheck(resultPair.getFirst(), contentData);
        fail("Entity still exists");
    }
    catch (Throwable e)
    {
        // Expected
    }
}
 
Example #16
Source File: WebDAV.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #17
Source File: RenditionsImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
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;
}
 
Example #18
Source File: SelectorPropertyContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 6 votes vote down vote up
/**
 *
 * {@inheritDoc}
 */
@Override
protected ContentStore selectStoreForContentDataMove(final NodeRef nodeRef, final QName propertyQName, final ContentData contentData,
        final Serializable selectorValue)
{
    ContentStore targetStore;
    if (this.storeBySelectorPropertyValue.containsKey(selectorValue))
    {
        LOGGER.debug("Selecting store for value {} to move {}", selectorValue, contentData);
        targetStore = this.storeBySelectorPropertyValue.get(selectorValue);
    }
    else
    {
        LOGGER.debug("No store registered for value {} - delegating to super.selectStoreForContentDataMove to move {}", selectorValue,
                contentData);
        targetStore = super.selectStoreForContentDataMove(nodeRef, propertyQName, contentData, selectorValue);
    }
    return targetStore;
}
 
Example #19
Source File: ContentDataAttributesInitializer.java    From alfresco-simple-content-stores with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void initialize(final ContentContext context)
{
    final Object contentDataAttribute = ContentStoreContext.getContextAttribute(ContentStoreContext.DEFAULT_ATTRIBUTE_CONTENT_DATA);
    if (contentDataAttribute == null && context instanceof NodeContentContext)
    {
        final NodeRef nodeRef = ((NodeContentContext) context).getNodeRef();
        final QName propertyQName = ((NodeContentContext) context).getPropertyQName();

        final Serializable currentValue = AuthenticationUtil.runAsSystem(() -> this.nodeService.getProperty(nodeRef, propertyQName));

        if (currentValue instanceof ContentData)
        {
            ContentStoreContext.setContextAttribute(ContentStoreContext.DEFAULT_ATTRIBUTE_CONTENT_DATA, currentValue);
        }
    }
}
 
Example #20
Source File: ContentDataDAOTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Ensure that upper and lowercase URLs don't clash
 * @throws Exception
 */
public void testEnsureCaseSensitiveStorage() throws Exception
{
    ContentData contentData = getContentData();
    String contentUrlUpper = contentData.getContentUrl().toUpperCase();
    ContentData contentDataUpper = new ContentData(
            contentUrlUpper, MimetypeMap.MIMETYPE_TEXT_PLAIN, 0L, "UTF-8", new Locale("FR"));
    String contentUrlLower = contentData.getContentUrl().toLowerCase();
    ContentData contentDataLower = new ContentData(
            contentUrlLower, MimetypeMap.MIMETYPE_TEXT_PLAIN, 0L, "utf-8", new Locale("fr"));
    
    Pair<Long, ContentData> resultPairUpper = create(contentDataUpper);
    getAndCheck(resultPairUpper.getFirst(), contentDataUpper);
    
    Pair<Long, ContentData> resultPairLower = create(contentDataLower);
    getAndCheck(resultPairLower.getFirst(), contentDataLower);
}
 
Example #21
Source File: ContentDataDAOTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private Pair<Long, ContentData> create(final ContentData contentData)
{
    RetryingTransactionCallback<Pair<Long, ContentData>> callback = new RetryingTransactionCallback<Pair<Long, ContentData>>()
    {
        public Pair<Long, ContentData> execute() throws Throwable
        {
            Pair<Long, ContentData> contentDataPair = contentDataDAO.createContentData(contentData);
            return contentDataPair;
        }
    };
    return txnHelper.doInTransaction(callback, false, false);
}
 
Example #22
Source File: ContentStreamLengthProperty.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Serializable getValueInternal(CMISNodeInfo nodeInfo)
{
    ContentData contentData = getContentData(nodeInfo);

    if (contentData != null)
    {
        return contentData.getSize();
    }
    return null;
}
 
Example #23
Source File: ContentDataDAOTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void speedTestRead(String name, List<Pair<Long, ContentData>> pairs)
{
    System.out.println("Starting read speed test: " + name);
    long start = System.nanoTime();
    // Loop and check for performance degradation
    int num = 1;
    for (Pair<Long, ContentData> pair : pairs)
    {
        Long id = pair.getFirst();
        ContentData contentData = pair.getSecond();
        // Retrieve it
        getAndCheck(id, contentData);
        // Report
        if (num % 1000 == 0)
        {
            long now = System.nanoTime();
            double diffMs = (double) (now - start) / 1E6;
            double aveMs = diffMs / (double) num;
            String msg = String.format(
                    "   Read %7d rows; average is %5.2f ms per row or %5.2f rows per second",
                    num,
                    aveMs,
                    1000.0 / aveMs);
            System.out.println(msg);
        }
        num++;
    }
    // Done
}
 
Example #24
Source File: ContentAwareScriptableQNameMap.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Object get(Object name)
{
    Object value = super.get(name);
    
    if (value == null)
    {
       // convert the key to a qname and look up the data-type for the property
       QName qname = QName.resolveToQName(getResolver(), name.toString());
       PropertyDefinition propDef = this.services.getDictionaryService().getProperty(qname);
       if (propDef != null && DataTypeDefinition.CONTENT.equals(propDef.getDataType().getName()))
       {
           // found a valid cm:content property that is not initialised
           String mimetype = null;
           if (qname.equals(ContentModel.PROP_CONTENT)) 
           {
               String fileName = (String)get("cm:name");
               if (fileName != null)
               {
                   // We don't have any content, so just use the filename when
                   //  trying to guess the mimetype for this
                   mimetype = this.services.getMimetypeService().guessMimetype(fileName);
               }
           }
           ContentData cdata = new ContentData(null, mimetype, 0L, "UTF-8");
           // create the JavaScript API object we need
           value = factory.new ScriptContentData(cdata, qname);
           // and store it so it is available to the API user
           put(name, value);
       }
    }
    
    return value;
}
 
Example #25
Source File: ContentDataDAOTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Check that orphaned content can be re-instated.
 */
public void testReinstate_ALF3867()
{
    ContentData contentData = getContentData();
    Pair<Long, ContentData> resultPair = create(contentData);
    getAndCheck(resultPair.getFirst(), contentData);
    delete(resultPair.getFirst());
    // Now create a ContentData with the same URL
    create(contentData);
}
 
Example #26
Source File: ContentStoreCleanerScalabilityRunner.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void loadData(final int maxCount)
{
    final MutableInt doneCount = new MutableInt(0);
    // Batches of 1000 objects
    RetryingTransactionCallback<Integer> makeNodesCallback = new RetryingTransactionCallback<Integer>()
    {
        public Integer execute() throws Throwable
        {
            for (int i = 0; i < 1000; i++)
            {
                // We don't need to write anything
                String contentUrl = FileContentStore.createNewFileStoreUrl();
                ContentData contentData = new ContentData(contentUrl, MimetypeMap.MIMETYPE_TEXT_PLAIN, 10, "UTF-8");
                nodeHelper.makeNode(contentData);
                
                int count = doneCount.intValue();
                count++;
                doneCount.setValue(count);
                
                // Do some reporting
                if (count % 1000 == 0)
                {
                    System.out.println(String.format("   " + (new Date()) + "Total created: %6d", count));
                }
                
                // Double check for shutdown
                if (vmShutdownListener.isVmShuttingDown())
                {
                    break;
                }
            }
            return maxCount;
        }
    };
    int repetitions = (int) Math.floor((double)maxCount / 1000.0);
    for (int i = 0; i < repetitions; i++)
    {
        transactionService.getRetryingTransactionHelper().doInTransaction(makeNodesCallback);
    }
}
 
Example #27
Source File: ContentAccessorFacade.java    From alfresco-simple-content-stores with Apache License 2.0 5 votes vote down vote up
/**
 *
 * {@inheritDoc}
 */
@Override
public ContentData getContentData()
{
    this.ensureDelegate();
    // re-construct a ContentData object from the various getters
    // this will account for any potential override to handle transformations without requiring override of getContentData()
    final ContentData property = new ContentData(this.getContentUrl(), this.getMimetype(), this.getSize(), this.getEncoding(),
            this.getLocale());
    return property;
}
 
Example #28
Source File: WorkflowRestImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected Item createItemForNodeRef(NodeRef nodeRef) {
    Map<QName, Serializable> properties = nodeService.getProperties(nodeRef);
    Item item = new Item();
    String name = (String) properties.get(ContentModel.PROP_NAME);
    String title = (String) properties.get(ContentModel.PROP_TITLE);
    String description = (String) properties.get(ContentModel.PROP_DESCRIPTION);
    Date createdAt = (Date) properties.get(ContentModel.PROP_CREATED);
    String createdBy = (String) properties.get(ContentModel.PROP_CREATOR);
    Date modifiedAt = (Date) properties.get(ContentModel.PROP_MODIFIED);
    String modifiedBy = (String) properties.get(ContentModel.PROP_MODIFIER);
    
    ContentData contentData = (ContentData) nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT);
    
    item.setId(nodeRef.getId());
    item.setName(name);
    item.setTitle(title);
    item.setDescription(description);
    item.setCreatedAt(createdAt);
    item.setCreatedBy(createdBy);
    item.setModifiedAt(modifiedAt);
    item.setModifiedBy(modifiedBy);
    if (contentData != null) 
    {
        item.setMimeType(contentData.getMimetype());
        item.setSize(contentData.getSize());
    }
    return item;
}
 
Example #29
Source File: ScriptNode.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void setMimetype(String mimetype)
{
    mimetype = mimetype.toLowerCase();
    this.contentData = ContentData.setMimetype(this.contentData, mimetype);
    services.getNodeService().setProperty(nodeRef, this.property, this.contentData);
    updateContentData(false);
}
 
Example #30
Source File: RenditionsImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
private ContentData getContentData(NodeRef nodeRef, boolean validate)
{
    ContentData contentData = (ContentData) nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT);
    if (validate && !ContentData.hasContent(contentData))
    {
        throw new InvalidArgumentException("Node id '" + nodeRef.getId() + "' has no content.");
    }
    return contentData;
}