use of org.apache.cxf.ws.transfer.shared.faults.UnknownResource in project cxf by apache.
the class MemoryResourceManager method get.
@Override
public Representation get(ReferenceParametersType ref) {
String uuid = getUUID(ref);
if (!storage.containsKey(uuid)) {
throw new UnknownResource();
}
String resource = storage.get(uuid);
if (resource.isEmpty()) {
return new Representation();
}
Document doc = null;
try {
doc = StaxUtils.read(new StringReader(storage.get(uuid)));
} catch (XMLStreamException e) {
LOG.severe(e.getLocalizedMessage());
throw new SoapFault("Internal Error", getSoapVersion().getReceiver());
}
Representation representation = new Representation();
representation.setAny(doc.getDocumentElement());
return representation;
}
use of org.apache.cxf.ws.transfer.shared.faults.UnknownResource in project cxf by apache.
the class MemoryResourceManager method put.
@Override
public void put(ReferenceParametersType ref, Representation newRepresentation) {
String uuid = getUUID(ref);
if (!storage.containsKey(uuid)) {
throw new UnknownResource();
}
Element representationEl = (Element) newRepresentation.getAny();
if (representationEl == null) {
storage.put(uuid, "");
} else {
storage.put(uuid, StaxUtils.toString(representationEl));
}
}
use of org.apache.cxf.ws.transfer.shared.faults.UnknownResource in project cxf by apache.
the class MemoryResourceManager method getUUID.
private String getUUID(ReferenceParametersType ref) {
for (Object object : ref.getAny()) {
if (object instanceof JAXBElement) {
JAXBElement<?> element = (JAXBElement<?>) object;
QName qName = element.getName();
if (REF_NAMESPACE.equals(qName.getNamespaceURI()) && REF_LOCAL_NAME.equals(qName.getLocalPart())) {
return (String) element.getValue();
}
} else if (object instanceof Element) {
Element element = (Element) object;
if (REF_NAMESPACE.equals(element.getNamespaceURI()) && REF_LOCAL_NAME.equals(element.getLocalName())) {
return element.getTextContent();
}
}
}
throw new UnknownResource();
}
Aggregations