updated to #2182 AND TESTED OK
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/admin/rmp-common-library@81423 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7e50bec294
commit
bfcf92aef9
|
@ -137,7 +137,7 @@ public class GenericResourceManager extends AbstractResourceManager {
|
||||||
resource.profile().description(description.trim());
|
resource.profile().description(description.trim());
|
||||||
}
|
}
|
||||||
if (body != null) {
|
if (body != null) {
|
||||||
resource.profile().newBody(body);
|
appendXmlFragment(resource.profile(), body);
|
||||||
}
|
}
|
||||||
if (subType != null)
|
if (subType != null)
|
||||||
resource.profile().type(subType.trim());
|
resource.profile().type(subType.trim());
|
||||||
|
@ -186,7 +186,7 @@ public class GenericResourceManager extends AbstractResourceManager {
|
||||||
resource.profile().description(description.trim());
|
resource.profile().description(description.trim());
|
||||||
}
|
}
|
||||||
if (body != null) {
|
if (body != null) {
|
||||||
resource.profile().newBody(body);
|
appendXmlFragment(resource.profile(), body);
|
||||||
}
|
}
|
||||||
resource.profile().type(subType.trim());
|
resource.profile().type(subType.trim());
|
||||||
|
|
||||||
|
@ -217,4 +217,28 @@ public class GenericResourceManager extends AbstractResourceManager {
|
||||||
throw new ResourceAccessException("Cannot load the resource " + this.getType(), e);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue