Example usage for java.io FileWriter flush

List of usage examples for java.io FileWriter flush

Introduction

In this page you can find the example usage for java.io FileWriter flush.

Prototype

public void flush() throws IOException 

Source Link

Document

Flushes the stream.

Usage

From source file:test.gov.nih.nci.cacoresdk.domain.inheritance.parentwithassociation.sametable.SoftTopResourceTest.java

public void testSearch() throws Exception {

    try {//from   ww w .  j a  v a 2s  .  c  om

        String url = baseURL + "/rest/SoftTop/search;id=*";
        WebClient client = WebClient.create(url);
        client.type("application/xml").accept("application/xml");
        Response response = client.get();

        if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() != 200) {
            throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
        }

        File myFile = new File("SoftTop_Search" + "XML.xml");
        System.out.println("writing data to file " + myFile.getAbsolutePath());
        FileWriter myWriter = new FileWriter(myFile);

        BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity())));

        String output;
        System.out.println("Output from Server .... \n");
        while ((output = br.readLine()) != null) {
            myWriter.write(output);
            System.out.println(output);
        }

        myWriter.flush();
        myWriter.close();

    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:test.gov.nih.nci.cacoresdk.domain.inheritance.parentwithassociation.TenuredProfessorResourceTest.java

public void testSearch() throws Exception {

    try {//from   ww  w.j  a  v a 2 s  .c  om

        String url = baseURL + "/rest/TenuredProfessor/search;id=*";
        WebClient client = WebClient.create(url);
        client.type("application/xml").accept("application/xml");
        Response response = client.get();

        if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() != 200) {
            throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
        }

        File myFile = new File("TenuredProfessor_Search" + "XML.xml");
        System.out.println("writing data to file " + myFile.getAbsolutePath());
        FileWriter myWriter = new FileWriter(myFile);

        BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity())));

        String output;
        System.out.println("Output from Server .... \n");
        while ((output = br.readLine()) != null) {
            myWriter.write(output);
            System.out.println(output);
        }

        myWriter.flush();
        myWriter.close();

    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:au.org.ala.layers.grid.GridClassBuilder.java

private static void writeProjectionFile(String filename) {
    FileWriter spWriter = null;
    try {//from  w ww . jav  a 2  s. c  o m
        spWriter = new FileWriter(filename);

        StringBuffer sbProjection = new StringBuffer();
        sbProjection.append("GEOGCS[\"WGS 84\", ").append("\n");
        sbProjection.append("    DATUM[\"WGS_1984\", ").append("\n");
        sbProjection.append("        SPHEROID[\"WGS 84\",6378137,298.257223563, ").append("\n");
        sbProjection.append("            AUTHORITY[\"EPSG\",\"7030\"]], ").append("\n");
        sbProjection.append("        AUTHORITY[\"EPSG\",\"6326\"]], ").append("\n");
        sbProjection.append("    PRIMEM[\"Greenwich\",0, ").append("\n");
        sbProjection.append("        AUTHORITY[\"EPSG\",\"8901\"]], ").append("\n");
        sbProjection.append("    UNIT[\"degree\",0.01745329251994328, ").append("\n");
        sbProjection.append("        AUTHORITY[\"EPSG\",\"9122\"]], ").append("\n");
        sbProjection.append("    AUTHORITY[\"EPSG\",\"4326\"]] ").append("\n");

        //spWriter.write("spname, longitude, latitude \n");
        spWriter.append(sbProjection.toString());
        spWriter.flush();

    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    } finally {
        if (spWriter != null) {
            try {
                spWriter.close();
            } catch (Exception e) {
                logger.error(e.getMessage(), e);
            }
        }
    }
}

From source file:cachedataanalysis.FlowCache.java

public XYSeries exportReportChart() throws IOException {

    File outputHitRate = new File("report/" + name + "_" + policy + "_hitrate.txt");

    FileWriter fw = new FileWriter(outputHitRate);

    XYSeries hitRateCount = new XYSeries(name + "(" + size + " entries)");

    for (int i = 0; i < hitRateRecord.size(); i++) {
        hitRateCount.add(i, hitRateRecord.get(i));
        fw.write(i + "," + hitRateRecord.get(i) + "\n");
        fw.flush();
    }/*w  w  w . j  av a 2  s.c o  m*/
    fw.close();

    XYSeriesCollection HitRateData = new XYSeriesCollection();
    HitRateData.addSeries(hitRateCount);
    JFreeChart hitRateStat = ChartFactory.createXYLineChart(
            "Hit Rate variatoion throughout recording in " + name, "Seconds", "HitRate", HitRateData,
            PlotOrientation.VERTICAL, true, true, false);

    ChartUtilities.saveChartAsJPEG(new File("report/" + name + "_hitRate" + size + ".jpg"), hitRateStat, 1500,
            900);

    //-------------------------------

    if (!fullReport) {
        return hitRateCount;
    }

    DefaultPieDataset hitProtoData = new DefaultPieDataset();
    DefaultPieDataset missProtoData = new DefaultPieDataset();

    CategoryTableXYDataset hitProtoDataRec = new CategoryTableXYDataset();
    for (int i = 0; i < hitProtoRec.size(); i++) {
        if (i % 120 != 0) {
            continue;
        }
        HashMap<String, Integer> _map = hitProtoRec.get(i);
        for (String _str : _map.keySet()) {
            hitProtoDataRec.add(i, _map.get(_str), _str);
        }

    }

    CategoryTableXYDataset missProtoDataRec = new CategoryTableXYDataset();
    for (int i = 0; i < missProtoRec.size(); i++) {
        if (i % 120 != 0) {
            continue;
        }
        HashMap<String, Integer> _map = missProtoRec.get(i);
        for (String _str : _map.keySet()) {
            missProtoDataRec.add(i, _map.get(_str), _str);
        }

    }

    XYSeries hitCountData = new XYSeries("Hit");
    XYSeries allCountData = new XYSeries("All");

    for (int i = 0; i < hitCount.size(); i++) {
        hitCountData.add(i, hitCount.get(i));
        //hitRateCount.add(i,(float)hitCount.get(i)/(hitCount.get(i)+allCount.get(i)));
    }

    for (int i = 0; i < allCount.size(); i++) {
        allCountData.add(i, allCount.get(i));

    }

    XYSeriesCollection CountStatData = new XYSeriesCollection();

    CountStatData.addSeries(hitCountData);
    CountStatData.addSeries(allCountData);

    for (String protocol : hitProto.keySet()) {
        hitProtoData.setValue(protocol, hitProto.get(protocol));
    }

    for (String protocol : missProto.keySet()) {
        missProtoData.setValue(protocol, missProto.get(protocol));
    }

    JFreeChart hitStatRec = ChartFactory.createStackedXYAreaChart(
            "Hit Protocol Fraction throughout record in " + name, "Seconds", "Count", hitProtoDataRec);

    JFreeChart missStatRec = ChartFactory.createStackedXYAreaChart(
            "Miss Protocol Fraction throughout record in " + name, "Seconds", "Count", missProtoDataRec);

    JFreeChart hitStat = ChartFactory.createPieChart3D("Protocal Fraction of Hit Flows in " + name,
            hitProtoData, true, true, false);
    JFreeChart missStat = ChartFactory.createPieChart3D("Protocal Fraction of Miss Flows in " + name,
            missProtoData, true, true, false);
    JFreeChart countStat = ChartFactory.createXYAreaChart("Hit Count to All Packet lookup in " + name,
            "Seconds", "Count", CountStatData, PlotOrientation.VERTICAL, true, true, false);

    ChartUtilities.saveChartAsJPEG(new File("report/" + name + "_hitProto" + size + ".jpg"), hitStat, 1500,
            900);
    ChartUtilities.saveChartAsJPEG(new File("report/" + name + "_missProto" + size + ".jpg"), missStat, 1500,
            900);
    ChartUtilities.saveChartAsJPEG(new File("report/" + name + "_hitCount" + size + ".jpg"), countStat, 1500,
            900);

    ChartUtilities.saveChartAsJPEG(new File("report/" + name + "_hitProtoRecord" + size + ".jpg"), hitStatRec,
            1500, 900);
    ChartUtilities.saveChartAsJPEG(new File("report/" + name + "_missProtoRecord" + size + ".jpg"), missStatRec,
            1500, 900);

    return hitRateCount;
}

From source file:jetbrains.buildServer.vmgr.agent.Utils.java

public String executeAPI(String jSON, String apiUrl, String url, boolean requireAuth, String user,
        String password, String requestMethod, BuildProgressLogger logger, boolean dynamicUserId,
        String buildID, String workPlacePath) throws Exception {

    try {/*  w  w  w.ja v a 2 s  .  com*/

        boolean notInTestMode = true;
        if (logger == null) {
            notInTestMode = false;
        }

        String apiURL = url + "/rest" + apiUrl;

        if (notInTestMode) {
            logger.message("vManager vAPI - Trying to call vAPI '" + "/rest" + apiUrl + "'");
        }
        String input = jSON;
        HttpURLConnection conn = getVAPIConnection(apiURL, requireAuth, user, password, requestMethod,
                dynamicUserId, buildID, workPlacePath, logger);

        if ("PUT".equals(requestMethod) || "POST".equals(requestMethod)) {
            OutputStream os = conn.getOutputStream();
            os.write(input.getBytes());
            os.flush();
        }

        if (conn.getResponseCode() != HttpURLConnection.HTTP_OK
                && conn.getResponseCode() != HttpURLConnection.HTTP_NO_CONTENT
                && conn.getResponseCode() != HttpURLConnection.HTTP_ACCEPTED
                && conn.getResponseCode() != HttpURLConnection.HTTP_CREATED
                && conn.getResponseCode() != HttpURLConnection.HTTP_PARTIAL
                && conn.getResponseCode() != HttpURLConnection.HTTP_RESET) {
            String reason = "";
            if (conn.getResponseCode() == 503)
                reason = "vAPI process failed to connect to remote vManager server.";
            if (conn.getResponseCode() == 401)
                reason = "Authentication Error";
            if (conn.getResponseCode() == 415)
                reason = "The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method.  Check if you selected the right request method (GET/POST/DELETE/PUT).";
            if (conn.getResponseCode() == 405)
                reason = "The method specified in the Request-Line is not allowed for the resource identified by the Request-URI. The response MUST include an Allow header containing a list of valid methods for the requested resource.  Check if you selected the right request method (GET/POST/DELETE/PUT).";
            if (conn.getResponseCode() == 412)
                reason = "vAPI requires vManager 'Integration Server' license.";
            String errorMessage = "Failed : HTTP error code : " + conn.getResponseCode() + " (" + reason + ")";
            if (notInTestMode) {
                logger.message(errorMessage);
                logger.message(conn.getResponseMessage());
            }

            System.out.println(errorMessage);
            return errorMessage;
        }

        BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));

        StringBuilder result = new StringBuilder();
        String output;
        while ((output = br.readLine()) != null) {
            result.append(output);
        }

        conn.disconnect();

        // Flush the output into workspace
        String fileOutput = workPlacePath + File.separator + buildID + File.separator + "vapi.output";

        FileWriter writer = new FileWriter(fileOutput);

        writer.append(result.toString());
        writer.flush();
        writer.close();

        String textOut = "API Call Success: Output was saved into: " + fileOutput;

        if (notInTestMode) {
            logger.message(textOut);
        } else {

            System.out.println(textOut);
        }

        return "success";

    } catch (Exception e) {
        e.printStackTrace();
        logger.error("Failed: Error: " + e.getMessage());
        return e.getMessage();
    }
}

From source file:test.gov.nih.nci.cacoresdk.domain.inheritance.abstrakt.PrivateTeacherResourceTest.java

public void testPrivateTeacher1() {
    try {/* w  ww.  j a  v a  2 s  . c  o m*/

        String url = baseURL + "/rest/PrivateTeacher/search;id=*/pupilCollection";

        WebClient client = WebClient.create(url);
        client.type("application/xml").accept("application/xml");
        Response response = client.get();

        if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() != 200) {
            throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
        }

        File myFile = new File("PrivateTeacher_Search" + "XML.xml");
        System.out.println("writing data to file " + myFile.getAbsolutePath());
        FileWriter myWriter = new FileWriter(myFile);

        BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity())));

        String output;
        System.out.println("Output from Server .... \n");
        while ((output = br.readLine()) != null) {
            myWriter.write(output);
            System.out.println(output);
        }

        myWriter.flush();
        myWriter.close();

    } catch (Exception e) {
        e.printStackTrace();
        ResponseBuilder builder = Response.status(Status.INTERNAL_SERVER_ERROR);
        builder.type("application/xml");
        StringBuffer buffer = new StringBuffer();
        buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        buffer.append("<response>");
        buffer.append("<type>ERROR</type>");
        buffer.append("<code>INTERNAL_ERROR_4</code>");
        buffer.append("<message>Failed to Query due to: " + e.getMessage() + "</message>");
        buffer.append("</response>");
        builder.entity(buffer.toString());
        throw new WebApplicationException(builder.build());
    }

}

From source file:test.gov.nih.nci.cacoresdk.domain.inheritance.childwithassociation.CreditResourceTest.java

public void testCredit1() {
    try {/*from w w  w  . ja  v a 2 s  . co  m*/

        String url = baseURL + "/rest/Credit/search;id=*/issuingBank";

        WebClient client = WebClient.create(url);
        client.type("application/xml").accept("application/xml");
        Response response = client.get();

        if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() != 200) {
            throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
        }

        File myFile = new File("Credit_Search" + "XML.xml");
        System.out.println("writing data to file " + myFile.getAbsolutePath());
        FileWriter myWriter = new FileWriter(myFile);

        BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity())));

        String output;
        System.out.println("Output from Server .... \n");
        while ((output = br.readLine()) != null) {
            myWriter.write(output);
            System.out.println(output);
        }

        myWriter.flush();
        myWriter.close();

    } catch (Exception e) {
        e.printStackTrace();
        ResponseBuilder builder = Response.status(Status.INTERNAL_SERVER_ERROR);
        builder.type("application/xml");
        StringBuffer buffer = new StringBuffer();
        buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        buffer.append("<response>");
        buffer.append("<type>ERROR</type>");
        buffer.append("<code>INTERNAL_ERROR_4</code>");
        buffer.append("<message>Failed to Query due to: " + e.getMessage() + "</message>");
        buffer.append("</response>");
        builder.entity(buffer.toString());
        throw new WebApplicationException(builder.build());
    }

}

From source file:test.gov.nih.nci.cacoresdk.domain.inheritance.implicit.AngelFishResourceTest.java

public void testAngelFish1() {
    try {/*from  w  w  w  .ja  va2 s . co m*/

        String url = baseURL + "/rest/AngelFish/search;id=*/tank";

        WebClient client = WebClient.create(url);
        client.type("application/xml").accept("application/xml");
        Response response = client.get();

        if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() != 200) {
            throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
        }

        File myFile = new File("AngelFish_Search" + "XML.xml");
        System.out.println("writing data to file " + myFile.getAbsolutePath());
        FileWriter myWriter = new FileWriter(myFile);

        BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity())));

        String output;
        System.out.println("Output from Server .... \n");
        while ((output = br.readLine()) != null) {
            myWriter.write(output);
            System.out.println(output);
        }

        myWriter.flush();
        myWriter.close();

    } catch (Exception e) {
        e.printStackTrace();
        ResponseBuilder builder = Response.status(Status.INTERNAL_SERVER_ERROR);
        builder.type("application/xml");
        StringBuffer buffer = new StringBuffer();
        buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        buffer.append("<response>");
        buffer.append("<type>ERROR</type>");
        buffer.append("<code>INTERNAL_ERROR_4</code>");
        buffer.append("<message>Failed to Query due to: " + e.getMessage() + "</message>");
        buffer.append("</response>");
        builder.entity(buffer.toString());
        throw new WebApplicationException(builder.build());
    }

}

From source file:test.gov.nih.nci.cacoresdk.domain.inheritance.implicit.DiscusFishResourceTest.java

public void testDiscusFish1() {
    try {//from   w  ww . j  ava2s . co m

        String url = baseURL + "/rest/DiscusFish/search;id=*/tank";

        WebClient client = WebClient.create(url);
        client.type("application/xml").accept("application/xml");
        Response response = client.get();

        if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() != 200) {
            throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
        }

        File myFile = new File("DiscusFish_Search" + "XML.xml");
        System.out.println("writing data to file " + myFile.getAbsolutePath());
        FileWriter myWriter = new FileWriter(myFile);

        BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity())));

        String output;
        System.out.println("Output from Server .... \n");
        while ((output = br.readLine()) != null) {
            myWriter.write(output);
            System.out.println(output);
        }

        myWriter.flush();
        myWriter.close();

    } catch (Exception e) {
        e.printStackTrace();
        ResponseBuilder builder = Response.status(Status.INTERNAL_SERVER_ERROR);
        builder.type("application/xml");
        StringBuffer buffer = new StringBuffer();
        buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        buffer.append("<response>");
        buffer.append("<type>ERROR</type>");
        buffer.append("<code>INTERNAL_ERROR_4</code>");
        buffer.append("<message>Failed to Query due to: " + e.getMessage() + "</message>");
        buffer.append("</response>");
        builder.entity(buffer.toString());
        throw new WebApplicationException(builder.build());
    }

}

From source file:test.gov.nih.nci.cacoresdk.domain.inheritance.implicit.FishResourceTest.java

public void testFish1() {
    try {//from  ww w  . j a  v  a2 s . co m

        String url = baseURL + "/rest/Fish/search;id=*/tank";

        WebClient client = WebClient.create(url);
        client.type("application/xml").accept("application/xml");
        Response response = client.get();

        if (response.getStatus() == Status.NOT_ACCEPTABLE.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) {
            InputStream is = (InputStream) response.getEntity();
            org.jdom.input.SAXBuilder builder = new org.jdom.input.SAXBuilder(false);
            org.jdom.Document jDoc = builder.build(is);
            assertEquals(jDoc.getRootElement().getName(), "response");
        } else if (response.getStatus() != 200) {
            throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
        }

        File myFile = new File("Fish_Search" + "XML.xml");
        System.out.println("writing data to file " + myFile.getAbsolutePath());
        FileWriter myWriter = new FileWriter(myFile);

        BufferedReader br = new BufferedReader(new InputStreamReader(((InputStream) response.getEntity())));

        String output;
        System.out.println("Output from Server .... \n");
        while ((output = br.readLine()) != null) {
            myWriter.write(output);
            System.out.println(output);
        }

        myWriter.flush();
        myWriter.close();

    } catch (Exception e) {
        e.printStackTrace();
        ResponseBuilder builder = Response.status(Status.INTERNAL_SERVER_ERROR);
        builder.type("application/xml");
        StringBuffer buffer = new StringBuffer();
        buffer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        buffer.append("<response>");
        buffer.append("<type>ERROR</type>");
        buffer.append("<code>INTERNAL_ERROR_4</code>");
        buffer.append("<message>Failed to Query due to: " + e.getMessage() + "</message>");
        buffer.append("</response>");
        builder.entity(buffer.toString());
        throw new WebApplicationException(builder.build());
    }

}