public static XMLStreamReader createSafeReader(InputStream inputStream) throws XMLStreamException { if (inputStream == null) { throw new IllegalArgumentException("The provided input stream cannot be null"); } return createSafeReader(new StreamSource(inputStream)); }
public static TemplateDTO deserialize(final StreamSource source) { try { final XMLStreamReader xsr = XmlUtils.createSafeReader(source); final Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); final JAXBElement<TemplateDTO> templateElement = unmarshaller.unmarshal(xsr, TemplateDTO.class); return templateElement.getValue(); } catch (final JAXBException | XMLStreamException e) { throw new FlowSerializationException(e); } } }
private Tenants unmarshallTenants() throws JAXBException { final Unmarshaller unmarshaller = JAXB_TENANTS_CONTEXT.createUnmarshaller(); unmarshaller.setSchema(tenantsSchema); try { final XMLStreamReader xsr = XmlUtils.createSafeReader(new StreamSource(tenantsFile)); final JAXBElement<Tenants> element = unmarshaller.unmarshal(xsr, Tenants.class); return element.getValue(); } catch (XMLStreamException e) { throw new JAXBException("Error unmarshalling tenants", e); } }
public static ClusterNodeInformation unmarshal(final InputStream is) throws JAXBException { try { final Unmarshaller unmarshaller = JAXB_CONTEXT.createUnmarshaller(); final XMLStreamReader xsr = XmlUtils.createSafeReader(is); return (ClusterNodeInformation) unmarshaller.unmarshal(xsr); } catch (XMLStreamException e) { throw new JAXBException("Error unmarshalling the cluster node information", e); } } }
public static BulletinsPayload unmarshal(final InputStream is) throws ProtocolException { try { final Unmarshaller unmarshaller = JAXB_CONTEXT.createUnmarshaller(); final XMLStreamReader xsr = XmlUtils.createSafeReader(is); return (BulletinsPayload) unmarshaller.unmarshal(xsr); } catch (final JAXBException | XMLStreamException e) { throw new ProtocolException(e); } }
private Authorizations unmarshallAuthorizations() throws JAXBException { try { final XMLStreamReader xsr = XmlUtils.createSafeReader(new StreamSource(authorizationsFile)); final Unmarshaller unmarshaller = JAXB_AUTHORIZATIONS_CONTEXT.createUnmarshaller(); unmarshaller.setSchema(authorizationsSchema); final JAXBElement<Authorizations> element = unmarshaller.unmarshal(xsr, Authorizations.class); return element.getValue(); } catch (XMLStreamException e) { logger.error("Encountered an error reading authorizations file: ", e); throw new JAXBException("Error reading authorizations file", e); } }
public static HeartbeatPayload unmarshal(final InputStream is) throws ProtocolException { try { final Unmarshaller unmarshaller = JAXB_CONTEXT.createUnmarshaller(); final XMLStreamReader xsr = XmlUtils.createSafeReader(is); return (HeartbeatPayload) unmarshaller.unmarshal(xsr); } catch (final JAXBException | XMLStreamException e) { throw new ProtocolException(e); } }
public static StandardSnippet deserialize(final InputStream inStream) { try { JAXBContext context = JAXBContext.newInstance(StandardSnippet.class); Unmarshaller unmarshaller = context.createUnmarshaller(); XMLStreamReader xsr = XmlUtils.createSafeReader(inStream); JAXBElement<StandardSnippet> snippetElement = unmarshaller.unmarshal(xsr, StandardSnippet.class); return snippetElement.getValue(); } catch (final JAXBException | XMLStreamException e) { throw new FlowSerializationException(e); } } }
private LoginIdentityProviders loadLoginIdentityProvidersConfiguration() throws Exception { final File loginIdentityProvidersConfigurationFile = properties.getLoginIdentityProviderConfigurationFile(); // load the users from the specified file if (loginIdentityProvidersConfigurationFile.exists()) { try { // find the schema final SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); final Schema schema = schemaFactory.newSchema(LoginIdentityProviders.class.getResource(LOGIN_IDENTITY_PROVIDERS_XSD)); // attempt to unmarshal XMLStreamReader xsr = XmlUtils.createSafeReader(new StreamSource(loginIdentityProvidersConfigurationFile)); final Unmarshaller unmarshaller = JAXB_CONTEXT.createUnmarshaller(); unmarshaller.setSchema(schema); final JAXBElement<LoginIdentityProviders> element = unmarshaller.unmarshal(xsr, LoginIdentityProviders.class); return element.getValue(); } catch (SAXException | JAXBException e) { throw new Exception("Unable to load the login identity provider configuration file at: " + loginIdentityProvidersConfigurationFile.getAbsolutePath()); } } else { throw new Exception("Unable to find the login identity provider configuration file at " + loginIdentityProvidersConfigurationFile.getAbsolutePath()); } }
private Authorizers loadAuthorizersConfiguration() throws Exception { final File authorizersConfigurationFile = properties.getAuthorizerConfigurationFile(); // load the authorizers from the specified file if (authorizersConfigurationFile.exists()) { try { // find the schema final SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); final Schema schema = schemaFactory.newSchema(Authorizers.class.getResource(AUTHORIZERS_XSD)); // attempt to unmarshal final XMLStreamReader xsr = XmlUtils.createSafeReader(new StreamSource(authorizersConfigurationFile)); final Unmarshaller unmarshaller = JAXB_CONTEXT.createUnmarshaller(); unmarshaller.setSchema(schema); final JAXBElement<Authorizers> element = unmarshaller.unmarshal(xsr, Authorizers.class); return element.getValue(); } catch (XMLStreamException | SAXException | JAXBException e) { throw new Exception("Unable to load the authorizer configuration file at: " + authorizersConfigurationFile.getAbsolutePath(), e); } } else { throw new Exception("Unable to find the authorizer configuration file at " + authorizersConfigurationFile.getAbsolutePath()); } }
final byte[] msg = new byte[totalBytesRead]; buffer.get(msg); final XMLStreamReader xsr = XmlUtils.createSafeReader(new ByteArrayInputStream(msg)); return (T) unmarshaller.unmarshal(xsr);
/** * Deserializes the specified criteria. * * @param string the string representation of the criteria * @return the criteria object */ public static Criteria deserialize(final String string) { Criteria criteria = null; if (string != null && !string.trim().equals("")) { try { // deserialize the binding final Unmarshaller unmarshaller = JAXB_CONTEXT.createUnmarshaller(); XMLStreamReader xsr = XmlUtils.createSafeReader(new ByteArrayInputStream(string.getBytes(StandardCharsets.UTF_8))); final JAXBElement<CriteriaBinding> element = unmarshaller.unmarshal(xsr, CriteriaBinding.class); // create the criteria from the binding final CriteriaBinding binding = element.getValue(); criteria = new Criteria(binding.getFlowFilePolicy(), binding.getRules()); } catch (final JAXBException | XMLStreamException e) { throw new IllegalArgumentException(e); } } return criteria; } }
JAXBContext context = JAXBContext.newInstance(TemplateDTO.class); Unmarshaller unmarshaller = context.createUnmarshaller(); XMLStreamReader xsr = XmlUtils.createSafeReader(in); JAXBElement<TemplateDTO> templateElement = unmarshaller.unmarshal(xsr, TemplateDTO.class); template = templateElement.getValue();
xsr = XmlUtils.createSafeReader(new StreamSource(authorizedUsersFile)); } catch (XMLStreamException e) { throw new AuthorizerCreationException("Error converting the legacy authorizers file", e);
xsr = XmlUtils.createSafeReader(new StreamSource(authorizedUsersFile)); } catch (XMLStreamException e) { logger.error("Encountered an error reading authorized users file: ", e);
public static XMLStreamReader createSafeReader(InputStream inputStream) throws XMLStreamException { if (inputStream == null) { throw new IllegalArgumentException("The provided input stream cannot be null"); } return createSafeReader(new StreamSource(inputStream)); }
public static HeartbeatPayload unmarshal(final InputStream is) throws ProtocolException { try { final Unmarshaller unmarshaller = JAXB_CONTEXT.createUnmarshaller(); final XMLStreamReader xsr = XmlUtils.createSafeReader(is); return (HeartbeatPayload) unmarshaller.unmarshal(xsr); } catch (final JAXBException | XMLStreamException e) { throw new ProtocolException(e); } }
private LoginIdentityProviders loadLoginIdentityProvidersConfiguration() throws Exception { final File loginIdentityProvidersConfigurationFile = properties.getLoginIdentityProviderConfigurationFile(); // load the users from the specified file if (loginIdentityProvidersConfigurationFile.exists()) { try { // find the schema final SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); final Schema schema = schemaFactory.newSchema(LoginIdentityProviders.class.getResource(LOGIN_IDENTITY_PROVIDERS_XSD)); // attempt to unmarshal XMLStreamReader xsr = XmlUtils.createSafeReader(new StreamSource(loginIdentityProvidersConfigurationFile)); final Unmarshaller unmarshaller = JAXB_CONTEXT.createUnmarshaller(); unmarshaller.setSchema(schema); final JAXBElement<LoginIdentityProviders> element = unmarshaller.unmarshal(xsr, LoginIdentityProviders.class); return element.getValue(); } catch (SAXException | JAXBException e) { throw new Exception("Unable to load the login identity provider configuration file at: " + loginIdentityProvidersConfigurationFile.getAbsolutePath()); } } else { throw new Exception("Unable to find the login identity provider configuration file at " + loginIdentityProvidersConfigurationFile.getAbsolutePath()); } }
final byte[] msg = new byte[totalBytesRead]; buffer.get(msg); final XMLStreamReader xsr = XmlUtils.createSafeReader(new ByteArrayInputStream(msg)); return (T) unmarshaller.unmarshal(xsr);