Example usage for javax.xml.bind JAXBException printStackTrace

List of usage examples for javax.xml.bind JAXBException printStackTrace

Introduction

In this page you can find the example usage for javax.xml.bind JAXBException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this JAXBException and its stack trace (including the stack trace of the linkedException if it is non-null) to System.err .

Usage

From source file:it.cnr.icar.eric.common.BindingUtility.java

/**
 * Gets the binding object representing the request from specufied XML file.
 */// ww  w. jav  a  2s. com
public Object getRequestObject(File file) throws JAXRException {
    Object req = null;

    try {
        Unmarshaller unmarshaller = getUnmarshaller();
        req = unmarshaller.unmarshal(file);
    } catch (JAXBException e) {
        e.printStackTrace();
        throw new JAXRException(resourceBundle.getString("message.unmarshallRequest"), e);
    }

    return req;
}

From source file:it.cnr.icar.eric.common.BindingUtility.java

public Object getRequestObject(String rootElement, String message) throws JAXRException {
    //TODO: Consider removing String rootElement. Currently not used.
    Object req = null;// www  .ja  va 2 s.c  om

    try {
        StreamSource ss = new StreamSource(new StringReader(message));
        Unmarshaller unmarshaller = getUnmarshaller();
        req = unmarshaller.unmarshal(ss);
    } catch (JAXBException e) {
        e.printStackTrace();
        throw new JAXRException(resourceBundle.getString("message.unmarshallRequest"), e);
    }

    return req;
}

From source file:org.springside.examples.oadata.service.TenderViewService.java

public Result synTenderProccess(TenderView tenderView) {

    boolean result = false;
    //??/* w w w  .j a v  a 2 s  .  c o m*/
    StringWriter writer = new StringWriter();

    BodyXml<TenderView> bodyXml = new BodyXml<TenderView>();
    bodyXml.setProjectInfo(tenderView);
    ;
    SupplierXml supplierXml = new SupplierXml();
    supplierXml.setBody(bodyXml);
    try {
        marshaller.marshal(supplierXml, writer);
    } catch (JAXBException e) {
        logger.error("{}|{}XML?:" + e.getStackTrace(), tenderView.getTenderId(),
                tenderView.getTenderName());
    }
    try {
        HttpPost httpPost = new HttpPost(propertiesLoader.getProperty("syn.synSupplierUrl"));
        // ??/  
        List<NameValuePair> parameters = new ArrayList<NameValuePair>();

        String xmlContent = writer.toString();

        parameters.add(new BasicNameValuePair("xmlContent", xmlContent));
        // UrlEncodedFormEntity  
        UrlEncodedFormEntity formEntiry = new UrlEncodedFormEntity(parameters, "UTF-8");
        httpPost.setEntity(formEntiry);

        // ?connection poolclient
        CloseableHttpResponse closeableHttpResponse = httpClient.execute(httpPost);
        closeableHttpResponse.getEntity().getContent();
        String xmlContentresp = IOUtils.toString(closeableHttpResponse.getEntity().getContent());
        if (xmlContentresp.contains("operTag")) {
            String operTag = StringUtils.substringBetween(xmlContentresp, "<operTag>", "</operTag>");
            String operDesc = StringUtils.substringBetween(xmlContentresp, "<operDesc>", "</operDesc>");
            if ("Y".equals(operTag)) {//?   
                result = true;
            } else {
                logger.error("?{}|{}??{}", tenderView.getTenderId(),
                        tenderView.getTenderName(), operDesc);
            }
        }
        closeableHttpResponse.close();
    } catch (IOException e) {
        e.printStackTrace();
        logger.error("?{}|{}??:" + e.getStackTrace(),
                tenderView.getTenderId(), tenderView.getTenderName());
    }
    return new Result(result, null);
}

From source file:org.springside.examples.quickstart.service.BulletinDataService.java

/**
 * ????//from w  w  w. j  a  v  a 2  s  .c  o  m
 * @param ids
 */
public boolean synBulletin(Long[] ids) {
    //
    boolean result = false;
    List<Long> idls = new ArrayList<Long>();
    CollectionUtils.addAll(idls, ids);
    Iterable<BulletinData> bulletinDatas = bulletinDataDao.findAll(idls);
    for (BulletinData bulletinData : bulletinDatas) {

        //bulletinData
        //         bulletinData.setBulletinUrl("http://gxoa.cc/attachmentDownload.do?filePath="+bulletinData.getAttachmentPath()+"&amp;fileName="+bulletinData.getAttachmentId());

        //??
        StringWriter writer = new StringWriter();

        BodyXml<BulletinData> bodyXml = new BodyXml<BulletinData>();
        bodyXml.setProjectInfo(bulletinData);
        BulletinXml bulletinXml = new BulletinXml();
        bulletinXml.setBody(bodyXml);

        try {
            marshaller.marshal(bulletinXml, writer);
        } catch (JAXBException e) {
            logger.error("{}|{}XML?:" + e.getStackTrace(), bulletinData.getId(),
                    bulletinData.getAnnouncementDate());
        }
        try {

            HttpPost httpPost = new HttpPost(propertiesLoader.getProperty("syn.synBulletinUrl"));
            // ??/  
            List<NameValuePair> parameters = new ArrayList<NameValuePair>();

            parameters.add(new BasicNameValuePair("xmlContent", writer.toString()));
            // UrlEncodedFormEntity  
            UrlEncodedFormEntity formEntiry = new UrlEncodedFormEntity(parameters, "UTF-8");
            httpPost.setEntity(formEntiry);

            // ?connection poolclient
            CloseableHttpResponse closeableHttpResponse = httpClient.execute(httpPost);
            closeableHttpResponse.getEntity().getContent();
            String xmlContentresp = IOUtils.toString(closeableHttpResponse.getEntity().getContent());
            if (xmlContentresp.contains("operTag")) {
                String operTag = StringUtils.substringBetween(xmlContentresp, "<operTag>", "</operTag>");
                if ("Y".equals(operTag)) {//?   
                    //?? 
                    bulletinData.setSynStatus(BuyerData.SYNSTATUS_SUCCESS);
                    bulletinDataDao.save(bulletinData);
                    result = true;
                } else {

                    logger.error("?{}|{}??", bulletinData.getId(),
                            bulletinData.getAnnouncementDate());
                }
            }
            //httpClient.close();
        } catch (IOException e) {
            e.printStackTrace();
            logger.error("?{}|{}??:" + e.getStackTrace(),
                    bulletinData.getId(), bulletinData.getAnnouncementDate());
        }
    }
    return result;
}

From source file:de.tu_dortmund.ub.api.paaa.PaaaEndpoint.java

private void sendRequestError(HttpServletResponse httpServletResponse, RequestError requestError,
        String format) {/*from   w  w w.j a v a2 s. com*/

    ObjectMapper mapper = new ObjectMapper();

    httpServletResponse.setHeader("WWW-Authentificate", "Bearer");
    httpServletResponse.setHeader("WWW-Authentificate", "Bearer realm=\"PAAA\"");
    httpServletResponse.setContentType("application/json");

    try {

        // XML-Ausgabe mit JAXB
        if (format.equals("xml")) {

            try {

                JAXBContext context = JAXBContext.newInstance(RequestError.class);
                Marshaller m = context.createMarshaller();
                m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);

                // Write to HttpResponse
                httpServletResponse.setContentType("application/xml;charset=UTF-8");
                m.marshal(requestError, httpServletResponse.getWriter());
            } catch (JAXBException e) {
                this.logger.error(e.getMessage(), e.getCause());
                httpServletResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                        "Internal Server Error: Error while rendering the results.");
            }
        }

        // JSON-Ausgabe mit Jackson
        if (format.equals("json")) {

            httpServletResponse.setContentType("application/json;charset=UTF-8");
            mapper.writeValue(httpServletResponse.getWriter(), requestError);
        }
    } catch (Exception e) {

        e.printStackTrace();
    }
}

From source file:org.springside.examples.quickstart.service.BulletinDataService.java

public boolean sysBulletinProccess(ProjectData projectData) {
    boolean result = false;

    BulletinData bulletinData = projectData.getBulletinDataSelected();

    //bulletinData 
    //bulletinData.setBulletinUrl("http://gxoa.cc/attachmentDownload.do?filePath="+bulletinData.getAttachmentPath()+"&amp;fileName="+bulletinData.getAttachmentName());

    //??//from  w  ww  .  ja v  a 2  s.co  m
    StringWriter writer = new StringWriter();

    BodyXml<BulletinData> bodyXml = new BodyXml<BulletinData>();
    bodyXml.setProjectInfo(bulletinData);
    BulletinXml bulletinXml = new BulletinXml();
    bulletinXml.setBody(bodyXml);

    try {
        marshaller.marshal(bulletinXml, writer);
    } catch (JAXBException e) {
        logger.error("{}|{}XML?:" + e.getStackTrace(), bulletinData.getId(),
                bulletinData.getAnnouncementDate());
    }
    try {

        HttpPost httpPost = new HttpPost(propertiesLoader.getProperty("syn.synBulletinUrl"));
        // ??/  
        List<NameValuePair> parameters = new ArrayList<NameValuePair>();

        parameters.add(new BasicNameValuePair("xmlContent", writer.toString()));
        // UrlEncodedFormEntity  
        UrlEncodedFormEntity formEntiry = new UrlEncodedFormEntity(parameters, "UTF-8");
        httpPost.setEntity(formEntiry);

        // ?connection poolclient
        CloseableHttpResponse closeableHttpResponse = httpClient.execute(httpPost);
        closeableHttpResponse.getEntity().getContent();
        String xmlContentresp = IOUtils.toString(closeableHttpResponse.getEntity().getContent());
        if (xmlContentresp.contains("operTag")) {
            String operTag = StringUtils.substringBetween(xmlContentresp, "<operTag>", "</operTag>");
            if ("Y".equals(operTag)) {//?   
                //?? 
                bulletinData.setSynStatus(BulletinData.SYNSTATUS_SUCCESS);
                bulletinDataDao.save(bulletinData);
                //???
                projectData.setSynStatus(ProjectData.SYNSTATUS_BULLETIN_SUCCESS);
                projectDataDao.save(projectData);
                result = true;
            } else {
                logger.error("?{}|{}??", bulletinData.getId(),
                        bulletinData.getAnnouncementDate());
            }
        }
        closeableHttpResponse.close();
        //httpClient.close();
    } catch (IOException e) {
        e.printStackTrace();
        logger.error("?{}|{}??:" + e.getStackTrace(),
                bulletinData.getId(), bulletinData.getAnnouncementDate());
    }
    return result;
}

From source file:com.photon.phresco.framework.actions.applications.Quality.java

private List<String> getProjectModules() {
    try {/*w  ww .j av a  2 s.  c o  m*/
        StringBuilder builder = new StringBuilder(Utility.getProjectHome());
        builder.append(projectCode);
        builder.append(File.separatorChar);
        builder.append(POM_XML);
        File pomPath = new File(builder.toString());
        PomProcessor processor = new PomProcessor(pomPath);
        Modules pomModule = processor.getPomModule();
        if (pomModule != null) {
            return pomModule.getModule();
        }
    } catch (JAXBException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (PhrescoPomException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:it.cnr.icar.eric.client.xml.registry.LifeCycleManagerImpl.java

public BulkResponse doSubmitObjectsRequest(ClientRequestContext context) throws JAXRException {
    BulkResponseImpl response = null;//from   w  ww.j a v  a  2 s  .c  o  m
    try {
        JAXRUtility.addCreateSessionSlot(context.getCurrentRegistryRequest(), regService.getConnection());
        checkCredentialInfo();

        RegistryResponseType ebResp = serverLCM.submitObjects(context);

        response = new BulkResponseImpl(this, ebResp, null);

    } catch (javax.xml.bind.JAXBException e) {
        e.printStackTrace();
        log.debug(e);
        throw new JAXRException(e);
    }

    return response;
}

From source file:it.cnr.icar.eric.client.xml.registry.LifeCycleManagerImpl.java

private BulkResponse doSubmitObjectsRequestInternal(ClientRequestContext context) throws JAXRException {
    BulkResponseImpl response = null;//from   w  w  w . j a  va  2 s  . co  m

    try {

        SubmitObjectsRequest ebSubmitObjectsRequest = lcmFac.createSubmitObjectsRequest();
        context.pushRegistryRequest(ebSubmitObjectsRequest);
        if (context.getSlotsMap() != null) {
            bu.addSlotsToRequest(ebSubmitObjectsRequest, context.getSlotsMap());
        }

        //RegistryObjectListType ebRegistryObjectListType = bu.getRegistryObjectListType((RegistryObjectType) context.getSubmitObjectsMap().keySet());
        @SuppressWarnings("unchecked")
        RegistryObjectListType ebRegistryObjectListType = bu
                .getRegistryObjectListType(context.getSubmitObjectsMap().keySet());

        ebSubmitObjectsRequest.setRegistryObjectList(ebRegistryObjectListType);

        response = (BulkResponseImpl) doSubmitObjectsRequest(context);

        // Now setCollection with ids of objects saved
        setKeysOnBulkResponse(context, response);

    } catch (javax.xml.bind.JAXBException e) {
        e.printStackTrace();
        log.debug(e);
        throw new JAXRException(e);
    } finally {
        context.popRegistryRequest();
    }

    return response;
}