Hi guys
I have a project running on a recently upgraded 6.4 instance.
There are several components in the solution but just for one specific component the object granite.resource is acting weird.
The first problem I'm experiencing with granite.resource is that the properties object is empty (granite.resource.properties) in fact if I run a JSON.stringify with the whole granite.resource object I get the following.
{
"path":"/content/guidelines/logo/jcr:content/par/guidelines_hero_b",
"properties":{},
"nativeResource":{},
"_promise":{}
}
As you can see the object properties is totally empty, there is no information related to the component there.
The second issue I'm experiencing is related to the granite.resource.resolve. This method is not working as expected and the nodes this method return have the same problem mentioned before, that is, the properties object is empty for each one of the nodes returned.
This is the full script of my component.
use(['/libs/wcm/foundation/components/utils/ResourceUtils.js',
'/libs/wcm/foundation/components/utils/Image.js',
'/libs/sightly/js/3rd-party/q.js',
'/apps/my-app/components/models/utils.js'], function(ResourceUtils, Image, Q, Utils) {
var widget = {};
var componentResourceType = "my-app/components/brand/guidelines-hero-banner";
var image = new Image(granite.resource);
widget.image = image.fileReference() ? image.fileReference() : image.src();
widget.items = [];
// Get parsys soft-links
var parsys = currentPage.getPath() + '/jcr:content/par';
granite.resource.resolve(parsys).then(function (resource) {
resource.getChildren().then(function (paragraphs) {
paragraphs.forEach(function (item) {
var resourceType = item.properties['sling:resourceType'];
var heading = item.properties['jcr:heading'];
// THE VARIABLES resourceType and heading ARE ALWAYS EMPTY
if (heading && resourceType != componentResourceType) {
var fragmentLink = Utils.toFragment(Utils.slugify(heading));
widget.items.push({
name: heading,
link: '#' + fragmentLink
});
}
});
});
});
return widget;
});
So here in line 9 when I instantiate the image object, it doesn't populate correctly the fileReference (used in line 12) as the object passed by parameter (granite.resource) contains an empty properties array.
In line 22 and 23, those two properties are ALWAYS empty. The object item suffers the same as the granite.resource, in which the properties object is empty.
As I mentioned the other components of the site work fine with this granite.resource object, it only affects the component in question.
Any idea what could be happening here? Maybe a Bundle needs to be restarted? Permissions?
I found really weird this is only affecting this component.
Thanks,
-David.