Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated XMLHelper with new one #987

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,14 @@
import fi.nls.oskari.log.Logger;
import fi.nls.oskari.util.JSONHelper;
import fi.nls.oskari.util.ResponseHelper;
import fi.nls.oskari.util.XmlHelper;

import org.geotools.referencing.CRS;
import org.json.JSONException;
import org.json.JSONObject;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.w3c.dom.Document;
import org.oskari.xml.XmlHelper;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.stream.XMLStreamException;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

@OskariActionRoute("VectorFeatureWriter")
public class VectorFeatureWriterHandler extends AbstractFeatureHandler {
Expand Down Expand Up @@ -163,22 +152,9 @@ private String parseFeatureIdFromInsertResponse(String response)
throw new ActionParamsException("Didn't get the expected response from service " + response);
}

try {
DocumentBuilderFactory factory = XmlHelper.newDocumentBuilderFactory();
DocumentBuilder builder = factory.newDocumentBuilder();

ByteArrayInputStream input = new ByteArrayInputStream(response.getBytes("UTF-8"));
Document doc = builder.parse(input);

NodeList res = doc.getElementsByTagName("ogc:FeatureId");
Element res3 = (Element) res.item(0);
return res3.getAttribute("fid");
} catch (ParserConfigurationException ex) {
throw new ActionException("Parser configuration error", ex);
} catch (IOException ex) {
throw new ActionException("IO error", ex);
} catch (SAXException ex) {
throw new ActionException("SAX processing error", ex);
}
Element doc = XmlHelper.parseXML(response);
NodeList res = doc.getElementsByTagName("ogc:FeatureId");
Element res3 = (Element) res.item(0);
return res3.getAttribute("fid");
}
}
Loading