Package thredds.catalog2.xml.parser

Examples of thredds.catalog2.xml.parser.ThreddsXmlParserException


    }
    catch( XMLStreamException e )
    {
      String message = "Problems reading stream [" + source.getSystemId() + "].";
      log.error( "getEventReaderFromSource(): " + message, e );
      throw new ThreddsXmlParserException( message, e );
    }
    return reader;
  }
View Full Code Here


      hrefUri = new URI( href );
    }
    catch ( URISyntaxException e )
    {
      log.error( "parseElement(): Bad catalog base URI [" + href + "]: " + e.getMessage(), e );
      throw new ThreddsXmlParserException( "Bad catalog base URI [" + href + "]: " + e.getMessage(), e );
    }

    // Construct builder.
    if ( this.parentCatalogBuilder != null )
      this.selfBuilder = this.parentCatalogBuilder.addCatalogRef( title, hrefUri );
    else if ( this.parentDatasetNodeBuilder != null )
      this.selfBuilder = this.parentDatasetNodeBuilder.addCatalogRef( title, hrefUri );
    else
      throw new ThreddsXmlParserException( "" );

    this.datasetNodeElementParserHelper = new DatasetNodeElementParserHelper( this.parentDatasetNodeElementParserHelper,
                                                                              this.selfBuilder,
                                                                              this.builderFactory );
View Full Code Here

    else if ( this.timeCovParserFactory.isEventMyStartElement( startElement ) )
      this.delegate = this.timeCovParserFactory.getNewParser( this.reader, this.builderFactory, this.selfBuilder );
    else if ( this.variableGroupParserFactory.isEventMyStartElement( startElement ) )
      this.delegate = this.variableGroupParserFactory.getNewParser( this.reader, this.builderFactory, this.selfBuilder );
    else
      throw new ThreddsXmlParserException( "Not a recognized ThreddsMetadata child element [" + startElement.getName().getLocalPart() + "]." );

    this.delegate.parseStartElement();
  }
View Full Code Here

        {
            String msg = "Unsupported DatePointType [" + typeString + "].";
            ThreddsXmlParserIssue parserIssue = StaxThreddsXmlParserUtils
                    .createIssueForUnexpectedEvent( msg, ThreddsXmlParserIssue.Severity.WARNING, this.reader, startElement );
            log.error( "parseStartElement(): " + parserIssue.getMessage() );
            throw new ThreddsXmlParserException( parserIssue );
        }

    }
View Full Code Here

              ThreddsXmlParserIssue issue = StaxThreddsXmlParserUtils
                      .createIssueForUnexpectedEvent( msg, ThreddsXmlParserIssue.Severity.FATAL,
                                                      this.reader, event );
              log.error( this.getClass().getName() + ".parse(): " + issue.getMessage() );
              // ToDo Gather issues (and "this.reader.next(); continue;") rather than throw exception.
              throw new ThreddsXmlParserException( issue );
            }
          }
        }
        else
        {
          log.debug( this.getClass().getName() + ".parse(): Unhandled event [" + event.getLocation() + "--" + event + "]." );
          this.reader.next();
          continue;
        }
      }

      this.postProcessingAfterEndElement();
      return this.getSelfBuilder();
    }
    catch ( XMLStreamException e )
    {
      log.error( "parse(): Failed to parse " + this.elementName + " element: " + e.getMessage(), e );
      throw new ThreddsXmlParserException( "Failed to parse " + this.elementName + " element: " + e.getMessage(), e );
    }

  }
View Full Code Here

  StartElement getNextEventIfStartElementIsMine()
          throws ThreddsXmlParserException
  {
    if ( ! this.reader.hasNext() )
      throw new ThreddsXmlParserException( "XMLEventReader has no further events." );

    StartElement startElement = null;
    try
    {
      XMLEvent event = this.reader.peek();
      if ( ! event.isStartElement() )
        throw new ThreddsXmlParserException( "Next event must be StartElement." );

      if ( ! event.asStartElement().getName().equals( this.elementName ) )
        throw new ThreddsXmlParserException( "Start element must be an '" + this.elementName.getLocalPart() + "' element." );

      startElement = this.reader.nextEvent().asStartElement();
    }
    catch ( XMLStreamException e )
    {
      throw new ThreddsXmlParserException( "Problem reading from XMLEventReader." );
    }

    return startElement;
  }
View Full Code Here

  StartElement peekAtNextEventIfStartElement()
          throws ThreddsXmlParserException
  {
    if ( ! this.reader.hasNext() )
      throw new ThreddsXmlParserException( "XMLEventReader has no further events." );

    StartElement startElement = null;
    while ( this.reader.hasNext() )
    {
      XMLEvent event = null;
      try
      {
        event = this.reader.peek();
      }
      catch (XMLStreamException e)
      {
        String msg = "Problem reading from XMLEventReader.";
        ThreddsXmlParserIssue issue = StaxThreddsXmlParserUtils
                .createIssueForException( msg, this.reader, e);
        log.error("peekAtNextEventIfStartElement(): " + issue.getMessage());
        // ToDo Gather issues rather than throw exception.
        throw new ThreddsXmlParserException(issue);
      }

      if (event.isStartElement())
      {
        startElement = event.asStartElement();
        break;
      }
      else if( event.isCharacters() && event.asCharacters().isWhiteSpace())
      {
        // Skip any whitespace characters.
        this.reader.next();
      }
      else
      {
        String msg = "Expecting StartElement for next event [" + event.getClass().getName() + "]";
        ThreddsXmlParserIssue issue = StaxThreddsXmlParserUtils
                .createIssueForUnexpectedEvent( msg, ThreddsXmlParserIssue.Severity.FATAL, this.reader,event );
        log.error( "peekAtNextEventIfStartElement(): " + issue.getMessage());
          // ToDo Gather issues rather than throw exception.
        throw new ThreddsXmlParserException( issue );
      }
    }

    return startElement;
  }
View Full Code Here

    else if ( this.datasetNodeBuilder != null )
      this.datasetNodeBuilder.addProperty( name, value );
    else if ( this.serviceBuilder != null )
      this.serviceBuilder.addProperty( name, value );
    else
      throw new ThreddsXmlParserException( "Unknown builder - for addProperty()." );
  }
View Full Code Here

    else if ( this.datasetNodeBuilder != null )
      parentBuilder = this.datasetNodeBuilder;
    else if ( this.serviceBuilder != null )
      parentBuilder = this.serviceBuilder;
    else
      throw new ThreddsXmlParserException( "Unknown parent builder." );

    BuilderIssue issue = new BuilderIssue( BuilderIssue.Severity.WARNING, "Unexpected child element: " + unexpectedChildElementAsString, parentBuilder, null );
    // ToDo Save the results in a ThreddsXmlParserIssue (Warning) and report.
  }
View Full Code Here

    StartElement startElement = this.getNextEventIfStartElementIsMine();
      
    if ( this.parentDatasetBuilder != null )
      this.selfBuilder = this.parentDatasetBuilder.addAccessBuilder();
    else
      throw new ThreddsXmlParserException( "" );

    Attribute serviceNameAtt = startElement.getAttributeByName( AccessElementNames.AccessElement_ServiceName );
    if ( serviceNameAtt != null )
    {
      String serviceName = serviceNameAtt.getValue();
View Full Code Here

TOP

Related Classes of thredds.catalog2.xml.parser.ThreddsXmlParserException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.