/** * The audit record is created by the system, so programmatic validation * here is o.k. Normally, validation takes place via XML Schema and * Schematron. * * @param audit * @throws ObjectIntegrityException */ protected static void validateAudit(AuditRecord audit) throws ObjectIntegrityException { if (audit.id == null || audit.id.isEmpty()) { throw new ObjectIntegrityException("Audit record must have id."); } if (audit.date == null) { throw new ObjectIntegrityException("Audit record must have date."); } if (audit.processType == null || audit.processType.isEmpty()) { throw new ObjectIntegrityException("Audit record must have processType."); } if (audit.action == null || audit.action.isEmpty()) { throw new ObjectIntegrityException("Audit record must have action."); } if (audit.componentID == null) { audit.componentID = ""; // for backwards compatibility, no error on null // throw new ObjectIntegrityException("Audit record must have componentID."); } if (audit.responsibility == null || audit.responsibility.isEmpty()) { throw new ObjectIntegrityException("Audit record must have responsibility."); } }
/** * Serialize the object, failing the test if an exception is thrown. */ protected Document doSerializeOrFail(DigitalObject obj, int transContext) { Document result = null; try { result = doSerialize(obj, transContext); } catch (ObjectIntegrityException e) { e.printStackTrace(); fail("Serializer threw ObjectIntegrityException"); } catch (SAXException e) { e.printStackTrace(); fail("Serialized XML was not well-formed"); } return result; }
protected DigitalObject doDeserializeOrFail(DigitalObject obj) { DigitalObject result = null; try { result = doDeserialize(obj); } catch (ObjectIntegrityException e) { e.printStackTrace(); fail("Deserializer threw ObjectIntegrityException"); } catch (StreamIOException e) { e.printStackTrace(); fail("Deserializer threw StreamIOException"); } return result; }
/** * The audit record is created by the system, so programmatic validation * here is o.k. Normally, validation takes place via XML Schema and * Schematron. * * @param audit * @throws ObjectIntegrityException */ protected static void validateAudit(AuditRecord audit) throws ObjectIntegrityException { if (audit.id == null || audit.id.isEmpty()) { throw new ObjectIntegrityException("Audit record must have id."); } if (audit.date == null) { throw new ObjectIntegrityException("Audit record must have date."); } if (audit.processType == null || audit.processType.isEmpty()) { throw new ObjectIntegrityException("Audit record must have processType."); } if (audit.action == null || audit.action.isEmpty()) { throw new ObjectIntegrityException("Audit record must have action."); } if (audit.componentID == null) { audit.componentID = ""; // for backwards compatibility, no error on null // throw new ObjectIntegrityException("Audit record must have componentID."); } if (audit.responsibility == null || audit.responsibility.isEmpty()) { throw new ObjectIntegrityException("Audit record must have responsibility."); } }
public DCFields(InputStream in) throws RepositoryConfigurationException, ObjectIntegrityException, StreamIOException { try { XmlTransformUtility.parseWithoutValidating(in, this); } catch (SAXException saxe) { throw new ObjectIntegrityException("Parse error parsing DC XML Metadata: " + saxe.getMessage()); } catch (IOException ioe) { throw new StreamIOException("Stream error parsing DC XML Metadata: " + ioe.getMessage()); } }
public DCFields(InputStream in) throws RepositoryConfigurationException, ObjectIntegrityException, StreamIOException { try { XmlTransformUtility.parseWithoutValidating(in, this); } catch (SAXException saxe) { throw new ObjectIntegrityException("Parse error parsing DC XML Metadata: " + saxe.getMessage()); } catch (IOException ioe) { throw new StreamIOException("Stream error parsing DC XML Metadata: " + ioe.getMessage()); } }
public ObjectFields(String[] fieldNames, InputStream in) throws UnrecognizedFieldException, RepositoryConfigurationException, ObjectIntegrityException, StreamIOException { this(fieldNames); try { XmlTransformUtility.parseWithoutValidating(in, this); } catch (SAXException saxe) { throw new ObjectIntegrityException("Parse error parsing ObjectFields: " + saxe.getMessage()); } catch (IOException ioe) { throw new StreamIOException("Stream error parsing ObjectFields: " + ioe.getMessage()); } }
public ObjectFields(String[] fieldNames, InputStream in) throws UnrecognizedFieldException, RepositoryConfigurationException, ObjectIntegrityException, StreamIOException { this(fieldNames); try { XmlTransformUtility.parseWithoutValidating(in, this); } catch (SAXException saxe) { throw new ObjectIntegrityException("Parse error parsing ObjectFields: " + saxe.getMessage()); } catch (IOException ioe) { throw new StreamIOException("Stream error parsing ObjectFields: " + ioe.getMessage()); } }
/** * Constructor allows this class to initiate the parsing */ public MmapParser(String parentPID, InputStream in) throws RepositoryConfigurationException, ObjectIntegrityException { XMLReader xmlReader = null; try { SAXParserFactory saxfactory = SAXParserFactory.newInstance(); saxfactory.setValidating(false); SAXParser parser = saxfactory.newSAXParser(); xmlReader = parser.getXMLReader(); xmlReader.setContentHandler(this); xmlReader.setFeature("http://xml.org/sax/features/namespaces", false); xmlReader .setFeature("http://xml.org/sax/features/namespace-prefixes", false); } catch (Exception e) { throw new RepositoryConfigurationException("Internal SAX error while " + "preparing for Method Map datastream parsing: " + e.getMessage()); } try { xmlReader.parse(new InputSource(in)); } catch (Exception e) { throw new ObjectIntegrityException("Error parsing Method Map datastream" + e.getClass().getName() + ": " + e.getMessage()); } }
/** * Constructor allows this class to initiate the parsing */ public WSDLParser(InputStream in) throws RepositoryConfigurationException, ObjectIntegrityException { XMLReader xmlReader = null; try { SAXParserFactory saxfactory = SAXParserFactory.newInstance(); saxfactory.setValidating(false); SAXParser parser = saxfactory.newSAXParser(); xmlReader = parser.getXMLReader(); xmlReader.setContentHandler(this); xmlReader.setFeature("http://xml.org/sax/features/namespaces", false); xmlReader .setFeature("http://xml.org/sax/features/namespace-prefixes", false); } catch (Exception e) { throw new RepositoryConfigurationException("Internal SAX error while " + "preparing for WSDL datastream parsing: " + e.getMessage()); } try { xmlReader.parse(new InputSource(in)); } catch (Exception e) { throw new ObjectIntegrityException("Error parsing WSDL datastream" + e.getClass().getName() + ": " + e.getMessage()); } }
/** * Constructor allows this class to initiate the parsing */ public DSInputSpecParser(String parentPID, InputStream in) throws RepositoryConfigurationException, ObjectIntegrityException { sDepPID = parentPID; XMLReader xmlReader = null; try { SAXParserFactory saxfactory = SAXParserFactory.newInstance(); saxfactory.setValidating(false); SAXParser parser = saxfactory.newSAXParser(); xmlReader = parser.getXMLReader(); xmlReader.setContentHandler(this); xmlReader.setFeature("http://xml.org/sax/features/namespaces", false); xmlReader .setFeature("http://xml.org/sax/features/namespace-prefixes", false); } catch (Exception e) { throw new RepositoryConfigurationException("Internal SAX error while " + "preparing for DSInputSpec datastream deserialization: " + e.getMessage()); } try { xmlReader.parse(new InputSource(in)); } catch (Exception e) { throw new ObjectIntegrityException("Error parsing DSInputSpec datastream" + e.getClass().getName() + ": " + e.getMessage()); } }
/** * Constructor allows this class to initiate the parsing */ public WSDLParser(InputStream in) throws RepositoryConfigurationException, ObjectIntegrityException { XMLReader xmlReader = null; try { SAXParserFactory saxfactory = SAXParserFactory.newInstance(); saxfactory.setValidating(false); SAXParser parser = saxfactory.newSAXParser(); xmlReader = parser.getXMLReader(); xmlReader.setContentHandler(this); xmlReader.setFeature("http://xml.org/sax/features/namespaces", false); xmlReader .setFeature("http://xml.org/sax/features/namespace-prefixes", false); } catch (Exception e) { throw new RepositoryConfigurationException("Internal SAX error while " + "preparing for WSDL datastream parsing: " + e.getMessage()); } try { xmlReader.parse(new InputSource(in)); } catch (Exception e) { throw new ObjectIntegrityException("Error parsing WSDL datastream" + e.getClass().getName() + ": " + e.getMessage()); } }
/** * Constructor allows this class to initiate the parsing */ public MmapParser(String parentPID, InputStream in) throws RepositoryConfigurationException, ObjectIntegrityException { XMLReader xmlReader = null; try { SAXParserFactory saxfactory = SAXParserFactory.newInstance(); saxfactory.setValidating(false); SAXParser parser = saxfactory.newSAXParser(); xmlReader = parser.getXMLReader(); xmlReader.setContentHandler(this); xmlReader.setFeature("http://xml.org/sax/features/namespaces", false); xmlReader .setFeature("http://xml.org/sax/features/namespace-prefixes", false); } catch (Exception e) { throw new RepositoryConfigurationException("Internal SAX error while " + "preparing for Method Map datastream parsing: " + e.getMessage()); } try { xmlReader.parse(new InputSource(in)); } catch (Exception e) { throw new ObjectIntegrityException("Error parsing Method Map datastream" + e.getClass().getName() + ": " + e.getMessage()); } }
private DefaultHandler parse(InputSource xml, DefaultHandler eventHandler) throws ObjectIntegrityException, RepositoryConfigurationException, GeneralException { try { // XMLSchema validation via SAX parser XmlTransformUtility.parseWithoutValidating(xml, eventHandler); return eventHandler; } catch (SAXException e) { String msg = "ServiceMapper returned SAXException. " + "The underlying exception was a " + e.getClass().getName() + ". " + "The message was " + "\"" + e.getMessage() + "\""; throw new ObjectIntegrityException(msg); } catch (Exception e) { String msg = "ServiceMapper returned error. " + "The underlying error was a " + e.getClass().getName() + ". " + "The message was " + "\"" + e.getMessage() + "\""; e.printStackTrace(); throw new GeneralException(msg); } }
/** * Constructor allows this class to initiate the parsing */ public DSInputSpecParser(String parentPID, InputStream in) throws RepositoryConfigurationException, ObjectIntegrityException { sDepPID = parentPID; XMLReader xmlReader = null; try { SAXParserFactory saxfactory = SAXParserFactory.newInstance(); saxfactory.setValidating(false); SAXParser parser = saxfactory.newSAXParser(); xmlReader = parser.getXMLReader(); xmlReader.setContentHandler(this); xmlReader.setFeature("http://xml.org/sax/features/namespaces", false); xmlReader .setFeature("http://xml.org/sax/features/namespace-prefixes", false); } catch (Exception e) { throw new RepositoryConfigurationException("Internal SAX error while " + "preparing for DSInputSpec datastream deserialization: " + e.getMessage()); } try { xmlReader.parse(new InputSource(in)); } catch (Exception e) { throw new ObjectIntegrityException("Error parsing DSInputSpec datastream" + e.getClass().getName() + ": " + e.getMessage()); } }
private DefaultHandler parse(InputSource xml, DefaultHandler eventHandler) throws ObjectIntegrityException, RepositoryConfigurationException, GeneralException { try { // XMLSchema validation via SAX parser XmlTransformUtility.parseWithoutValidating(xml, eventHandler); return eventHandler; } catch (SAXException e) { String msg = "ServiceMapper returned SAXException. " + "The underlying exception was a " + e.getClass().getName() + ". " + "The message was " + "\"" + e.getMessage() + "\""; throw new ObjectIntegrityException(msg); } catch (Exception e) { String msg = "ServiceMapper returned error. " + "The underlying error was a " + e.getClass().getName() + ". " + "The message was " + "\"" + e.getMessage() + "\""; e.printStackTrace(); throw new GeneralException(msg); } }
/** * {@inheritDoc} */ public void deserialize(InputStream in, DigitalObject obj, String encoding, int transContext) throws ObjectIntegrityException, StreamIOException, UnsupportedEncodingException { logger.debug("Deserializing " + m_format.uri + " for transContext: " + transContext); try { XmlTransformUtility.parseWithoutValidating(in, new METSContentHandler(m_format, m_translator, transContext, encoding, obj)); } catch (IOException ioe) { throw new StreamIOException("Low-level stream IO problem occurred " + "while SAX parsing this object."); } catch (SAXException se) { throw new ObjectIntegrityException("METS stream was bad : " + se.getMessage()); } try { m_translator.normalizeDatastreams(obj, transContext, encoding); } catch (UnsupportedEncodingException e) { throw new ObjectIntegrityException(e.getMessage(),e); } }
/** * {@inheritDoc} */ public void deserialize(InputStream in, DigitalObject obj, String encoding, int transContext) throws ObjectIntegrityException, StreamIOException, UnsupportedEncodingException { logger.debug("Deserializing " + m_format.uri + " for transContext: " + transContext); try { XmlTransformUtility.parseWithoutValidating(in, new METSContentHandler(m_format, m_translator, transContext, encoding, obj)); } catch (IOException ioe) { throw new StreamIOException("Low-level stream IO problem occurred " + "while SAX parsing this object."); } catch (SAXException se) { throw new ObjectIntegrityException("METS stream was bad : " + se.getMessage()); } try { m_translator.normalizeDatastreams(obj, transContext, encoding); } catch (UnsupportedEncodingException e) { throw new ObjectIntegrityException(e.getMessage(),e); } }
if (bindings[i].bindKeyName == null || bindings[i].bindKeyName.isEmpty()) { throw new ObjectIntegrityException("Object's disseminator" + " binding map binding must have a binding key name."); throw new ObjectIntegrityException("Object's disseminator" + " binding map binding must point to a datastream.");
if (bindings[i].bindKeyName == null || bindings[i].bindKeyName.isEmpty()) { throw new ObjectIntegrityException("Object's disseminator" + " binding map binding must have a binding key name."); throw new ObjectIntegrityException("Object's disseminator" + " binding map binding must point to a datastream.");