use of org.apache.cxf.ws.transfer.shared.faults.InvalidRepresentation in project cxf by apache.
the class FragmentDialect method insertAfter.
private void insertAfter(Document ownerDocument, Node parent, Node refChild, ValueType value) {
for (Object o : value.getContent()) {
if (o instanceof Node) {
Node node = (Node) o;
if (FragmentDialectConstants.FRAGMENT_2011_03_IRI.equals(node.getNamespaceURI()) && FragmentDialectConstants.FRAGMENT_ATTR_NODE_NAME.equals(node.getLocalName())) {
throw new InvalidRepresentation();
}
Node importedNode = ownerDocument.importNode(node, true);
if (parent.getNodeType() == Node.DOCUMENT_NODE) {
parent.appendChild(importedNode);
} else {
Node nextSibling = refChild.getNextSibling();
if (nextSibling == null) {
parent.appendChild(importedNode);
} else {
parent.insertBefore(importedNode, nextSibling);
}
}
} else {
throw new InvalidExpression();
}
}
}
use of org.apache.cxf.ws.transfer.shared.faults.InvalidRepresentation in project cxf by apache.
the class FragmentDialect method insertBefore.
private void insertBefore(Document ownerDocument, Node parent, Node refChild, ValueType value) {
for (Object o : value.getContent()) {
if (o instanceof Node) {
Node node = (Node) o;
if (FragmentDialectConstants.FRAGMENT_2011_03_IRI.equals(node.getNamespaceURI()) && FragmentDialectConstants.FRAGMENT_ATTR_NODE_NAME.equals(node.getLocalName())) {
throw new InvalidRepresentation();
}
Node importedNode = ownerDocument.importNode(node, true);
if (parent.getNodeType() == Node.DOCUMENT_NODE) {
parent.appendChild(importedNode);
} else {
parent.insertBefore(importedNode, refChild);
}
} else {
throw new InvalidExpression();
}
}
}
use of org.apache.cxf.ws.transfer.shared.faults.InvalidRepresentation in project cxf by apache.
the class FragmentDialect method modifyRepresentationModeInsertAfter.
/**
* Process Put requests for InsertAfter mode.
* @param value Value defined in the Value element.
* @return Representation element, which is returned as response.
*/
private Representation modifyRepresentationModeInsertAfter(List<Node> nodeList, ValueType value) {
if (nodeList.isEmpty()) {
throw new InvalidExpression();
}
Node firstNode = nodeList.get(0);
Document ownerDocument = firstNode.getOwnerDocument();
// if firstNode.getOwnerDocument == null the firstNode is ownerDocument
ownerDocument = ownerDocument == null ? (Document) firstNode : ownerDocument;
Node parent = firstNode.getParentNode();
if (parent == null && firstNode.getNodeType() != Node.DOCUMENT_NODE) {
throw new InvalidExpression();
}
if (parent == null) {
parent = firstNode;
if (((Document) parent).getDocumentElement() != null) {
throw new InvalidExpression();
}
}
for (Node node : nodeList) {
if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
throw new InvalidRepresentation();
}
insertAfter(ownerDocument, parent, node, value);
}
Representation representation = new Representation();
representation.setAny(ownerDocument.getDocumentElement());
return representation;
}
use of org.apache.cxf.ws.transfer.shared.faults.InvalidRepresentation in project cxf by apache.
the class FragmentDialect method modifyRepresentationModeInsertBefore.
/**
* Process Put requests for InsertBefore mode.
* @param value Value defined in the Value element.
* @return Representation element, which is returned as response.
*/
private Representation modifyRepresentationModeInsertBefore(List<Node> nodeList, ValueType value) {
if (nodeList.isEmpty()) {
throw new InvalidExpression();
}
Node firstNode = nodeList.get(0);
Document ownerDocument = firstNode.getOwnerDocument();
// if firstNode.getOwnerDocument == null the firstNode is ownerDocument
ownerDocument = ownerDocument == null ? (Document) firstNode : ownerDocument;
Node parent = firstNode.getParentNode();
if (parent == null && firstNode.getNodeType() != Node.DOCUMENT_NODE) {
throw new InvalidExpression();
}
if (parent == null) {
parent = firstNode;
if (((Document) parent).getDocumentElement() != null) {
throw new InvalidExpression();
}
}
for (Node node : nodeList) {
if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
throw new InvalidRepresentation();
}
insertBefore(ownerDocument, parent, node, value);
}
Representation representation = new Representation();
representation.setAny(ownerDocument.getDocumentElement());
return representation;
}
Aggregations