From 7e50bec2945176bdab46da568f1eda4ae243f62a Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Fri, 13 Sep 2013 13:38:01 +0000 Subject: [PATCH] updated to #2182 git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/admin/rmp-common-library@81419 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../resources/GenericResourceManager.java | 31 +++---------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/src/main/java/org/gcube/resourcemanagement/support/server/managers/resources/GenericResourceManager.java b/src/main/java/org/gcube/resourcemanagement/support/server/managers/resources/GenericResourceManager.java index 10f8d89..1b759f0 100644 --- a/src/main/java/org/gcube/resourcemanagement/support/server/managers/resources/GenericResourceManager.java +++ b/src/main/java/org/gcube/resourcemanagement/support/server/managers/resources/GenericResourceManager.java @@ -30,6 +30,7 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.gcube.common.resources.gcore.GenericResource; +import org.gcube.common.resources.gcore.GenericResource.Profile; import org.gcube.common.resources.gcore.Resource; import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.impl.ScopeBean; @@ -43,6 +44,7 @@ import org.gcube.resourcemanagement.support.server.utils.ServerConsole; import org.gcube.resources.discovery.client.api.DiscoveryClient; import org.gcube.resources.discovery.client.queries.api.SimpleQuery; import org.w3c.dom.Document; +import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.Text; import org.xml.sax.InputSource; @@ -135,7 +137,7 @@ public class GenericResourceManager extends AbstractResourceManager { resource.profile().description(description.trim()); } if (body != null) { - appendXmlFragment(resource.profile().newBody(), body); + resource.profile().newBody(body); } if (subType != null) resource.profile().type(subType.trim()); @@ -184,7 +186,7 @@ public class GenericResourceManager extends AbstractResourceManager { resource.profile().description(description.trim()); } if (body != null) { - appendXmlFragment(resource.profile().newBody(), body); + resource.profile().newBody(body); } resource.profile().type(subType.trim()); @@ -215,29 +217,4 @@ 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(Node parent, String fragment) throws IOException, ParserConfigurationException { - DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - Document doc = parent.getOwnerDocument(); - Node fragmentNode; - try { - fragmentNode = docBuilder.parse(new InputSource(new StringReader(fragment))).getDocumentElement(); - fragmentNode = doc.importNode(fragmentNode, true); - parent.appendChild(fragmentNode); - } catch (SAXException e) { - //in case no xml is entered, just text - System.out.println("to append: " + fragment); - Text text = doc.createTextNode(fragment); - doc.importNode(text, true); - } - - } - }