NPE in addRendition()

时间:2014-06-12 12:25:23

标签: cq5 aem

我用来向我的DAM资产申请演绎。以下是我正在使用的代码

Node parent = resource.adaptTo(Node.class);
AssetManager manager = resource.getResourceResolver().adaptTo(AssetManager.class);
LOGGER.info("Parent path ===> "+parent.getPath());  
if(!parent.hasNode(video.getVideoId()))
{   
Node videoNode = JcrUtil.createPath(parent.getPath() + "/" + video.getVideoId(), "dam:Asset", parent.getSession());
Node videoContentNode = JcrUtil.createPath(videoNode.getPath() + "/jcr:content" , "dam:AssetContent", parent.getSession());
Node metadataNode = JcrUtil.createPath(videoContentNode.getPath() + "/metadata" , "nt:unstructured", parent.getSession());
//setting properties of metadata node
parent.getSession().save();
try
{
Resource childResource=resource.getChild(video.getVideoId());
LOGGER.info(childResource.getResourceType());
Asset asset=com.day.cq.dam.commons.util.DamUtil.resolveToAsset(childResource);
URL url=new URL(video.getThumbnail());
InputStream stream=url.openStream();
LOGGER.info("stream ::: "+stream.available()); //return 1059
asset.addRendition("vedio", stream , "jpeg");
LOGGER.info("asset.getName() :: "+asset);
}
catch(Exception e)
{
    LOGGER.error("Error ::: "+e);
}

error.log中

13.06.2014 12:59:35.837 *ERROR* [pool-6-thread-4] com.adobe.training.core.YouTubeChannelImporter RepositoryException java.lang.NullPointerException
    at com.adobe.granite.asset.core.impl.AssetImpl.setRenditionResource(AssetImpl.java:301)
    at com.adobe.granite.asset.core.impl.AssetImpl.setRendition(AssetImpl.java:118)
    at com.day.cq.dam.core.impl.AssetImpl.addRendition(AssetImpl.java:502)
    at com.day.cq.dam.core.impl.AssetImpl.addRendition(AssetImpl.java:496)
    at com.adobe.training.core.YouTubeChannelImporter.WriteNode(YouTubeChannelImporter.java:126)
    at com.adobe.training.core.YouTubeChannelImporter.importData(YouTubeChannelImporter.java:71)
    at com.day.cq.polling.importer.impl.PollingImporterImpl.importData(PollingImporterImpl.java:337)
    at com.day.cq.polling.importer.impl.PollingImporterImpl.access$000(PollingImporterImpl.java:59)
    at com.day.cq.polling.importer.impl.PollingImporterImpl$1.run(PollingImporterImpl.java:258)
    at org.apache.sling.commons.scheduler.impl.QuartzJobExecutor.execute(QuartzJobExecutor.java:56)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)

这给了我NPE,我正在使用jcrUtils创建DAM节点。因此,如果遗失了某些财产,请提供建议。

0 个答案:

没有答案