PropertyDefinition def = prop.getDefinition();
// definition can be null if the file is versionned
if (def != null) {
propName = def.getName();
// create the corresponding GWT bean
GWTJahiaNodeProperty nodeProp = new GWTJahiaNodeProperty();
nodeProp.setName(propName);
nodeProp.setMultiple(def.isMultiple());
Value[] values;
if (!def.isMultiple()) {
Value oneValue = prop.getValue();
values = new Value[]{oneValue};
} else {
values = prop.getValues();
}
List<GWTJahiaNodePropertyValue> gwtValues = new ArrayList<GWTJahiaNodePropertyValue>(values.length);
for (Value val : values) {
GWTJahiaNodePropertyValue convertedValue = contentDefinition.convertValue(val, def.getRequiredType());
if (convertedValue != null) {
gwtValues.add(convertedValue);
}
}
nodeProp.setValues(gwtValues);
props.put(nodeProp.getName(), nodeProp);
} else {
logger.debug("The following property has been ignored " + prop.getName() + "," + prop.getPath());
}
}
NodeIterator ni = objectNode.getNodes();
while (ni.hasNext()) {
Node node = ni.nextNode();
if (node.isNodeType(Constants.NT_RESOURCE)) {
NodeDefinition def = node.getDefinition();
propName = def.getName();
// create the corresponding GWT bean
GWTJahiaNodeProperty nodeProp = new GWTJahiaNodeProperty();
nodeProp.setName(propName);
List<GWTJahiaNodePropertyValue> gwtValues = new ArrayList<GWTJahiaNodePropertyValue>();
gwtValues.add(new GWTJahiaNodePropertyValue(node.getProperty(Constants.JCR_MIMETYPE).getString(), GWTJahiaNodePropertyType.ASYNC_UPLOAD));
nodeProp.setValues(gwtValues);
props.put(nodeProp.getName(), nodeProp);
} else if (node.isNodeType(Constants.JAHIANT_PAGE_LINK)) {
// case of link
NodeDefinition def = node.getDefinition();
propName = def.getName();
// create the corresponding GWT bean
GWTJahiaNodeProperty nodeProp = new GWTJahiaNodeProperty();
nodeProp.setName(propName);
List<GWTJahiaNodePropertyValue> gwtValues = new ArrayList<GWTJahiaNodePropertyValue>();
GWTJahiaNode linkNode = navigation.getGWTJahiaNode((JCRNodeWrapper) node);
if (node.isNodeType(Constants.JAHIANT_NODE_LINK)) {
linkNode.set("linkType", "internal");
} else if (node.isNodeType(Constants.JAHIANT_EXTERNAL_PAGE_LINK)) {
linkNode.set("linkType", "external");
}
// url
if (node.hasProperty(Constants.URL)) {
String linkUrl = node.getProperty(Constants.URL).getValue().getString();
linkNode.set(Constants.URL, linkUrl);
}
// title
if (node.hasProperty(Constants.JCR_TITLE)) {
String linkTitle = node.getProperty(Constants.JCR_TITLE).getValue().getString();
linkNode.set(Constants.JCR_TITLE, linkTitle);
}
// alt
if (node.hasProperty(Constants.ALT)) {
String alt = node.getProperty(Constants.ALT).getValue().getString();
linkNode.set(Constants.ALT, alt);
}
if (node.hasProperty(Constants.NODE)) {
JCRValueWrapper weekReference = (JCRValueWrapper) node.getProperty("j:node").getValue();
Node pageNode = weekReference.getNode();
linkNode.set(Constants.NODE, navigation.getGWTJahiaNode((JCRNodeWrapper) pageNode));
linkNode.set(Constants.ALT, pageNode.getName());
linkNode.set(Constants.URL, ((JCRNodeWrapper) pageNode).getUrl());
linkNode.set(Constants.JCR_TITLE, ((JCRNodeWrapper) pageNode).getUrl());
}
GWTJahiaNodePropertyValue proper = new GWTJahiaNodePropertyValue(linkNode, GWTJahiaNodePropertyType.PAGE_LINK);
gwtValues.add(proper);
nodeProp.setValues(gwtValues);
props.put(nodeProp.getName(), nodeProp);
}
}
} catch (RepositoryException e) {
logger.error("Cannot access property " + propName + " of node " + objectNode.getName(), e);
}