|
|
|
@ -137,7 +137,7 @@ public class GenericResourceManager extends AbstractResourceManager {
|
|
|
|
|
resource.profile().description(description.trim());
|
|
|
|
|
}
|
|
|
|
|
if (body != null) {
|
|
|
|
|
resource.profile().newBody(body);
|
|
|
|
|
appendXmlFragment(resource.profile(), body);
|
|
|
|
|
}
|
|
|
|
|
if (subType != null)
|
|
|
|
|
resource.profile().type(subType.trim());
|
|
|
|
@ -186,7 +186,7 @@ public class GenericResourceManager extends AbstractResourceManager {
|
|
|
|
|
resource.profile().description(description.trim());
|
|
|
|
|
}
|
|
|
|
|
if (body != null) {
|
|
|
|
|
resource.profile().newBody(body);
|
|
|
|
|
appendXmlFragment(resource.profile(), body);
|
|
|
|
|
}
|
|
|
|
|
resource.profile().type(subType.trim());
|
|
|
|
|
|
|
|
|
@ -217,4 +217,28 @@ public class GenericResourceManager extends AbstractResourceManager {
|
|
|
|
|
throw new ResourceAccessException("Cannot load the resource " + this.getType(), e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* append a well formed xml string to the body
|
|
|
|
|
* @param parent
|
|
|
|
|
* @param fragment
|
|
|
|
|
* @throws IOException
|
|
|
|
|
* @throws SAXException
|
|
|
|
|
* @throws ParserConfigurationException
|
|
|
|
|
*/
|
|
|
|
|
public static void appendXmlFragment(Profile profile, String fragment) throws IOException, ParserConfigurationException {
|
|
|
|
|
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
|
|
|
|
Element elem = profile.newBody();
|
|
|
|
|
Node fragmentNode;
|
|
|
|
|
try {
|
|
|
|
|
fragmentNode = docBuilder.parse(new InputSource(new StringReader(fragment))).getDocumentElement();
|
|
|
|
|
fragmentNode = elem.getOwnerDocument().importNode(fragmentNode, true);
|
|
|
|
|
elem.appendChild(fragmentNode);
|
|
|
|
|
} catch (SAXException e) {
|
|
|
|
|
//in case no xml is entered, just text
|
|
|
|
|
System.out.println("to append: " + fragment);
|
|
|
|
|
profile.newBody(fragment);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|