Java Code Examples for javax.xml.bind.JAXBException#toString()

The following examples show how to use javax.xml.bind.JAXBException#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ViolationHelper.java    From SeaCloudsPlatform with Apache License 2.0 6 votes vote down vote up
private String getViolationsByAgreementId(String agreementId,
        String termName, Date begin, Date end, String resultType)
        throws HelperException{
    logger.debug("StartOf getViolationsByAgreementId agreementId:"+agreementId +" termName "+termName+" begin "+begin+" end "+end+" resultType "+resultType);;
    try{
        List<IViolation> violations = new ArrayList<IViolation>();
        String serialized = null;
        violations = this.violationDAO.getByAgreementIdInARangeOfDates(agreementId, termName, begin, end);
        serialized = serialize(violations, resultType);
        logger.debug("EndOf getViolationsByAgreementId");
        return serialized;
    } catch (JAXBException e) {
        logger.error("Error in getViolationsByAgreementId " , e);
        throw new HelperException(Code.PARSER,  "Error parsing violations"+ e.toString() );
}
}
 
Example 2
Source File: PluginChecker.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initializes the processor by loading the device configuration.
 *
 * {@inheritDoc}
 */
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    try {
        String deviceOption = processingEnv.getOptions().get(DEVICE_OPTION);
        device = (Device) JAXBContext.newInstance(Device.class)
                .createUnmarshaller().unmarshal(new File(deviceOption));
    } catch (JAXBException e) {
        throw new RuntimeException(
                "Please specify device by -Adevice=device.xml\n"
                + e.toString(), e);
    }
}
 
Example 3
Source File: ConfigParser.java    From openhab1-addons with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * This method loads a List of Request objects from xml file
 *
 * @param importFile
 *            file object to load the object from
 * @return List of Requests
 */
public List<Request> unmarshal(File importFile) throws StiebelHeatPumpException {
    Requests requests = new Requests();

    JAXBContext context;
    try {
        context = JAXBContext.newInstance(Requests.class);
        Unmarshaller um = context.createUnmarshaller();
        requests = (Requests) um.unmarshal(importFile);
    } catch (JAXBException e) {
        throw new StiebelHeatPumpException(e.toString(), e);
    }

    return requests.getRequests();
}
 
Example 4
Source File: ViolationHelper.java    From SeaCloudsPlatform with Apache License 2.0 5 votes vote down vote up
public String getViolationByUUID(UUID uuid) throws HelperException {
    logger.debug("StartOf getViolationByUUID uuid:"+uuid);
    try{
        IViolation violation = violationDAO.getViolationByUUID(uuid.toString());
        
        String serialized = null;
        if (violation != null) 
            serialized = serialize(violation, MediaType.APPLICATION_XML);
        logger.debug("EndOf getViolationByUUID");
        return serialized;
    } catch (JAXBException e) {
        logger.error("Error in getViolationByUUID " , e);
        throw new HelperException(Code.PARSER,  "Error parsing violations"+ e.toString() );
    }
}
 
Example 5
Source File: MonitorServer.java    From jdk9-jigsaw with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
private static String toXml(Statistics stats) {
	try {
		JAXBContext context = JAXBContext.newInstance(StatisticsEntity.class);
		Marshaller marshaller = context.createMarshaller();
		marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
		StringWriter writer = new StringWriter();
		marshaller.marshal(StatisticsEntity.from(stats), writer);
		return writer.toString();
	} catch (JAXBException ex) {
		// don't do this in real live
		return ex.toString();
	}
}
 
Example 6
Source File: MonitorServer.java    From jdk9-jigsaw with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
private static String toXml(Statistics stats) {
	try {
		JAXBContext context = JAXBContext.newInstance(StatisticsEntity.class);
		Marshaller marshaller = context.createMarshaller();
		marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
		StringWriter writer = new StringWriter();
		marshaller.marshal(StatisticsEntity.from(stats), writer);
		return writer.toString();
	} catch (JAXBException ex) {
		// don't do this in real live
		return ex.toString();
	}
}
 
Example 7
Source File: PluginChecker.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initializes the processor by loading the device configuration.
 *
 * {@inheritDoc}
 */
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    try {
        String deviceOption = processingEnv.getOptions().get(DEVICE_OPTION);
        device = (Device) JAXBContext.newInstance(Device.class)
                .createUnmarshaller().unmarshal(new File(deviceOption));
    } catch (JAXBException e) {
        throw new RuntimeException(
                "Please specify device by -Adevice=device.xml\n"
                + e.toString(), e);
    }
}
 
Example 8
Source File: PluginChecker.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initializes the processor by loading the device configuration.
 *
 * {@inheritDoc}
 */
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    try {
        String deviceOption = processingEnv.getOptions().get(DEVICE_OPTION);
        device = (Device) JAXBContext.newInstance(Device.class)
                .createUnmarshaller().unmarshal(new File(deviceOption));
    } catch (JAXBException e) {
        throw new RuntimeException(
                "Please specify device by -Adevice=device.xml\n"
                + e.toString(), e);
    }
}
 
Example 9
Source File: PluginChecker.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initializes the processor by loading the device configuration.
 *
 * {@inheritDoc}
 */
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    try {
        String deviceOption = processingEnv.getOptions().get(DEVICE_OPTION);
        device = (Device) JAXBContext.newInstance(Device.class)
                .createUnmarshaller().unmarshal(new File(deviceOption));
    } catch (JAXBException e) {
        throw new RuntimeException(
                "Please specify device by -Adevice=device.xml\n"
                + e.toString(), e);
    }
}
 
Example 10
Source File: PluginChecker.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initializes the processor by loading the device configuration.
 *
 * {@inheritDoc}
 */
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    try {
        String deviceOption = processingEnv.getOptions().get(DEVICE_OPTION);
        device = (Device) JAXBContext.newInstance(Device.class)
                .createUnmarshaller().unmarshal(new File(deviceOption));
    } catch (JAXBException e) {
        throw new RuntimeException(
                "Please specify device by -Adevice=device.xml\n"
                + e.toString(), e);
    }
}
 
Example 11
Source File: PluginChecker.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initializes the processor by loading the device configuration.
 *
 * {@inheritDoc}
 */
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    try {
        String deviceOption = processingEnv.getOptions().get(DEVICE_OPTION);
        device = (Device) JAXBContext.newInstance(Device.class)
                .createUnmarshaller().unmarshal(new File(deviceOption));
    } catch (JAXBException e) {
        throw new RuntimeException(
                "Please specify device by -Adevice=device.xml\n"
                + e.toString(), e);
    }
}
 
Example 12
Source File: PluginChecker.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initializes the processor by loading the device configuration.
 *
 * {@inheritDoc}
 */
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    try {
        String deviceOption = processingEnv.getOptions().get(DEVICE_OPTION);
        device = (Device) JAXBContext.newInstance(Device.class)
                .createUnmarshaller().unmarshal(new File(deviceOption));
    } catch (JAXBException e) {
        throw new RuntimeException(
                "Please specify device by -Adevice=device.xml\n"
                + e.toString(), e);
    }
}
 
Example 13
Source File: PluginChecker.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initializes the processor by loading the device configuration.
 *
 * {@inheritDoc}
 */
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    try {
        String deviceOption = processingEnv.getOptions().get(DEVICE_OPTION);
        device = (Device) JAXBContext.newInstance(Device.class)
                .createUnmarshaller().unmarshal(new File(deviceOption));
    } catch (JAXBException e) {
        throw new RuntimeException(
                "Please specify device by -Adevice=device.xml\n"
                + e.toString(), e);
    }
}
 
Example 14
Source File: MonitorServer.java    From demo-java-9-migration with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
private static String toXml(Statistics stats) {
	try {
		JAXBContext context = JAXBContext.newInstance(StatisticsEntity.class);
		Marshaller marshaller = context.createMarshaller();
		marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
		StringWriter writer = new StringWriter();
		marshaller.marshal(StatisticsEntity.from(stats), writer);
		return writer.toString();
	} catch (JAXBException ex) {
		// don't do this in real live
		return ex.toString();
	}
}
 
Example 15
Source File: JAXBEncoder.java    From feign with Apache License 2.0 5 votes vote down vote up
@Override
public void encode(Object object, Type bodyType, RequestTemplate template) {
  if (!(bodyType instanceof Class)) {
    throw new UnsupportedOperationException(
        "JAXB only supports encoding raw types. Found " + bodyType);
  }
  try {
    Marshaller marshaller = jaxbContextFactory.createMarshaller((Class<?>) bodyType);
    StringWriter stringWriter = new StringWriter();
    marshaller.marshal(object, stringWriter);
    template.body(stringWriter.toString());
  } catch (JAXBException e) {
    throw new EncodeException(e.toString(), e);
  }
}
 
Example 16
Source File: PluginChecker.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initializes the processor by loading the device configuration.
 *
 * {@inheritDoc}
 */
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    try {
        String deviceOption = processingEnv.getOptions().get(DEVICE_OPTION);
        device = (Device) JAXBContext.newInstance(Device.class)
                .createUnmarshaller().unmarshal(new File(deviceOption));
    } catch (JAXBException e) {
        throw new RuntimeException(
                "Please specify device by -Adevice=device.xml\n"
                + e.toString(), e);
    }
}
 
Example 17
Source File: PluginChecker.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initializes the processor by loading the device configuration.
 *
 * {@inheritDoc}
 */
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    try {
        String deviceOption = processingEnv.getOptions().get(DEVICE_OPTION);
        device = (Device) JAXBContext.newInstance(Device.class)
                .createUnmarshaller().unmarshal(new File(deviceOption));
    } catch (JAXBException e) {
        throw new RuntimeException(
                "Please specify device by -Adevice=device.xml\n"
                + e.toString(), e);
    }
}
 
Example 18
Source File: PluginChecker.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initializes the processor by loading the device configuration.
 *
 * {@inheritDoc}
 */
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
    super.init(processingEnv);
    try {
        String deviceOption = processingEnv.getOptions().get(DEVICE_OPTION);
        device = (Device) JAXBContext.newInstance(Device.class)
                .createUnmarshaller().unmarshal(new File(deviceOption));
    } catch (JAXBException e) {
        throw new RuntimeException(
                "Please specify device by -Adevice=device.xml\n"
                + e.toString(), e);
    }
}
 
Example 19
Source File: MSPDIWriter.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override public void write(ProjectFile projectFile, OutputStream stream) throws IOException
{
   try
   {
      if (CONTEXT == null)
      {
         throw CONTEXT_EXCEPTION;
      }

      m_projectFile = projectFile;
      m_projectFile.validateUniqueIDsForMicrosoftProject();
      m_eventManager = m_projectFile.getEventManager();
      DatatypeConverter.setParentFile(m_projectFile);

      Marshaller marshaller = CONTEXT.createMarshaller();
      marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);

      m_extendedAttributesInUse = new HashSet<>();

      m_factory = new ObjectFactory();
      Project project = m_factory.createProject();

      writeProjectProperties(project);
      writeCalendars(project);
      writeResources(project);
      writeTasks(project);
      writeAssignments(project);
      writeOutlineCodes(project);
      writeProjectExtendedAttributes(project);

      marshaller.marshal(project, stream);
   }

   catch (JAXBException ex)
   {
      throw new IOException(ex.toString());
   }

   finally
   {
      m_projectFile = null;
      m_factory = null;
      m_extendedAttributesInUse = null;
   }
}
 
Example 20
Source File: PlannerWriter.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override public void write(ProjectFile projectFile, OutputStream stream) throws IOException
{
   try
   {
      m_projectFile = projectFile;
      m_eventManager = projectFile.getEventManager();

      if (CONTEXT == null)
      {
         throw CONTEXT_EXCEPTION;
      }

      Marshaller marshaller = CONTEXT.createMarshaller();
      marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
      if (m_encoding != null)
      {
         marshaller.setProperty(Marshaller.JAXB_ENCODING, m_encoding);
      }

      //
      // The Planner implementation used  as the basis for this work, 0.14.1
      // does not appear to have a particularly robust parser, and rejects
      // files with the full XML declaration produced by JAXB. The
      // following property suppresses this declaration.
      //
      marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);

      m_factory = new ObjectFactory();
      m_plannerProject = m_factory.createProject();

      writeProjectProperties();
      writeCalendars();
      writeResources();
      writeTasks();
      writeAssignments();

      marshaller.marshal(m_plannerProject, stream);
   }

   catch (JAXBException ex)
   {
      throw new IOException(ex.toString());
   }

   finally
   {
      m_projectFile = null;
      m_factory = null;
      m_plannerProject = null;
   }
}