} catch ( Throwable t ) { JDBCUtils.close( rs, stmt, conn, LOG ); String msg = Messages.getMessage( "ERROR_REQUEST_TYPE", ResultType.results.name(), t.getMessage() ); LOG.debug( msg ); throw new MetadataStoreException( msg );
/** * Writes a {@link GetRecords} request as XML, valid to http://schemas.opengis.net/csw/2.0.2/CSW-discovery.xsd. * * @param getRecords * never <code>null</code> * @param writer * never <code>null</code> * @throws XMLStreamException * @throws UnknownCRSException * @throws TransformationException */ public static void export( GetRecords getRecords, XMLStreamWriter writer ) throws XMLStreamException, UnknownCRSException, TransformationException { writer.writeStartDocument(); writer.writeStartElement( CSW_202_PREFIX, "GetRecords", CSW_202_NS ); writeNamespacesAndNamespaceDeclaration( getRecords, writer ); writer.writeAttribute( "service", "CSW" ); writer.writeAttribute( "version", VERSION_202_STRING ); writer.writeAttribute( "outputSchema", getRecords.getOutputSchema() ); writer.writeAttribute( "outputFormat", getRecords.getOutputFormat() ); writer.writeAttribute( "resultType", getRecords.getResultType().toString() ); writer.writeAttribute( "startPosition", Integer.toString( getRecords.getStartPosition() ) ); writer.writeAttribute( "maxRecords", Integer.toString( getRecords.getMaxRecords() ) ); writeDistributedSearch( getRecords, writer ); writeQueryElementWithFilter( getRecords, writer ); }
} catch ( Throwable t ) { JDBCUtils.close( rs, preparedStatement, conn, LOG ); String msg = Messages.getMessage( "ERROR_REQUEST_TYPE", ResultType.results.name(), t.getMessage() ); LOG.debug( msg ); throw new MetadataStoreException( msg );
String resultTypeStr = KVPUtils.getDefault( normalizedKVPParams, "RESULTTYPE", ResultType.hits.name() ); ResultType resultType = ResultType.determineResultType( resultTypeStr );
String msg = Messages.getMessage( "ERROR_REQUEST_TYPE", ResultType.results.name(), e.getMessage() ); throw new MetadataStoreException( msg );
/** * Parses the {@link GetRecords} request on basis of CSW version 2.0.2 * * @param version * that is requested, 2.0.2 * @return {@link GetRecords} */ private GetRecords parse202( String defaultOutputFormat, String defaultOutputSchema ) { LOG.debug( rootElement.toString() ); String resultTypeStr = getNodeAsString( rootElement, new XPath( "@resultType", nsContext ), ResultType.hits.name() ); OMElement holeRequest = getElement( rootElement, new XPath( ".", nsContext ) ); ResultType resultType = ResultType.determineResultType( resultTypeStr ); int maxRecords = getNodeAsInt( rootElement, new XPath( "@maxRecords", nsContext ), 10 ); int startPosition = getNodeAsInt( rootElement, new XPath( "@startPosition", nsContext ), 1 ); String outputFormat = getNodeAsString( rootElement, new XPath( "@outputFormat", nsContext ), defaultOutputFormat ); String requestId = getNodeAsString( rootElement, new XPath( "@requestId", nsContext ), null ); String outputSchemaString = getNodeAsString( rootElement, new XPath( "@outputSchema", nsContext ), defaultOutputSchema ); URI outputSchema = URI.create( outputSchemaString ); List<OMElement> getRecordsChildElements = getRequiredElements( rootElement, new XPath( "*", nsContext ) ); return parseSubElements( holeRequest, resultType, maxRecords, startPosition, outputFormat, requestId, outputSchema, getRecordsChildElements ); }
/** * The mandatory "resultType" attribute in the GetRecords operation is set to "hits". * * @throws MetadataStoreException */ public int getRecordCount( final MetadataQuery query ) throws MetadataStoreException { final String resultTypeName = "hits"; LOG.debug( Messages.getMessage( "INFO_EXEC", "do " + resultTypeName + " on getRecords" ) ); try { QueryService queryService = getReadOnlySqlService(); return queryService.executeCounting( query, getConnection() ); } catch ( Throwable t ) { LOG.debug( t.getMessage(), t ); String msg = Messages.getMessage( "ERROR_REQUEST_TYPE", ResultType.results.name(), t.getMessage() ); LOG.debug( msg ); throw new MetadataStoreException( msg ); } finally { // Don't close the ResultSet or PreparedStatement if no error occurs, the ResultSet is needed in the // ISOMetadataResultSet and both will be closed by // org.deegree.metadata.persistence.XMLMetadataResultSet#close(). } }
public static ResultType determineResultType( String typeString ) { ResultType resultType = null; typeString = typeString.toLowerCase(); if ( typeString.equalsIgnoreCase( ResultType.hits.name() ) ) { resultType = ResultType.hits; } else if ( typeString.equalsIgnoreCase( ResultType.results.name() ) ) { resultType = ResultType.results; } else if ( typeString.equalsIgnoreCase( ResultType.validate.name() ) ) { resultType = ResultType.validate; } return resultType; }