* @param isReferenced
*/
private boolean parseResourceNode(Node resourceElement, Object parentNode, boolean isReferenced) {
if (containsOnlyAllowedChildren(resourceElement, WadlXml.resourceChildren)) {
if (containsOnlyAllowedAttributes(resourceElement, WadlXml.resourceAttributes)) {
Node hrefNode = resourceElement.getAttributes().getNamedItem(WadlXml.resource_href);
if (hrefNode != null) {
getElementByIdThenParse(applicationElement, hrefNode.getNodeValue(), parentNode);
}
else {
Node pathAttribute = resourceElement.getAttributes().getNamedItem(WadlXml.resource_path);
if (pathAttribute != null) {
ResourceNode resource = null;
if (!isReferenced) {
resource = new ResourceNode(pathAttribute.getNodeValue(), (GenericNode) parentNode, ((GenericNode) parentNode).getApplication());
// resourceChildren = {paramNode, methodNode, resourceNode, docNode}
NodeList childNodes = resourceElement.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
if (childNodes.item(i).getNodeName().equals(WadlXml.paramNode)) {
if (!parseParamNode(childNodes.item(i), resource, false)) {
return false;
}
}
else if (childNodes.item(i).getNodeName().equals(WadlXml.methodNode)) {
if (!parseMethodNode(childNodes.item(i), resource, false)) {
return false;
}
}
else if (childNodes.item(i).getNodeName().equals(WadlXml.resourceNode)) {
if (!parseResourceNode(childNodes.item(i), resource, false)) {
return false;
}
}
else if (childNodes.item(i).getNodeName().equals(WadlXml.docNode)) {
if (!parseDocNode(childNodes.item(i), resource)) {
return false;
}
}
}
Node idNode = resourceElement.getAttributes().getNamedItem(WadlXml.resource_id);
if (idNode != null) {
resource.setId(idNode.getNodeValue());
}
}
else {
Node idNode = resourceElement.getAttributes().getNamedItem(WadlXml.resource_id);
resource = new ResourceNode(idNode.getNodeValue(), true, (GenericNode) parentNode, ((GenericNode) parentNode).getApplication());
}
// attach to parent
if (parentNode instanceof ResourcesNode) {
((ResourcesNode) parentNode).addResource(resource);
}