@Override public boolean next() throws MetadataStoreException { try { return rs.next(); } catch ( SQLException e ) { throw new MetadataStoreException( e.getMessage(), e ); } }
protected MetadataResultSet<?> getRecordById( GetRecordById getRecBI, MetadataStore<?> store, List<String> requestedIdList ) throws OWSException { if ( store != null ) { try { return store.getRecordById( requestedIdList, getRecBI.getTypeNames() ); } catch ( MetadataStoreException e ) { throw new OWSException( e.getMessage(), OWSException.NO_APPLICABLE_CODE ); } } return null; }
/** * Preprocessing for the export of a {@link DescribeRecord} request to determine which recordstore is requested. * * @param descRec * the parsed describeRecord request * @param response * for the servlet request to the client * @throws XMLStreamException * @throws IOException * @throws OWSException */ public void doDescribeRecord( DescribeRecord descRec, HttpResponseBuffer response, ServiceProfile profile ) throws XMLStreamException, IOException, OWSException { this.profile = profile; QName[] typeNames = descRec.getTypeNames(); Version version = descRec.getVersion(); response.setContentType( descRec.getOutputFormat() ); XMLStreamWriter xmlWriter = dcHelper.getXMLResponseWriter( response, null ); try { export( xmlWriter, typeNames, version ); } catch ( MetadataStoreException e ) { LOG.debug( e.getMessage() ); throw new OWSException( e.getMessage(), NO_APPLICABLE_CODE ); } xmlWriter.flush(); }
@Override public void skip( int rows ) throws MetadataStoreException { try { for ( int i = 0; i < rows; i++ ) { rs.next(); } } catch ( SQLException e ) { throw new MetadataStoreException( e.getMessage(), e ); } }
/** * Preprocessing for the export of a {@link GetRecords} request * * @param getRec * @param response * @throws XMLStreamException * @throws IOException * @throws SQLException * @throws OWSException */ public void doGetRecords( GetRecords getRec, HttpResponseBuffer response, MetadataStore<?> store ) throws XMLStreamException, IOException, OWSException { LOG.debug( "doGetRecords: " + getRec ); Version version = getRec.getVersion(); String outputFormat = getRec.getOutputFormat(); response.setContentType( outputFormat ); XMLStreamWriter xmlWriter = getXmlorJsonStreamWriter( outputFormat, response ); try { export( xmlWriter, getRec, version, store ); } catch ( OWSException e ) { LOG.debug( e.getMessage() ); throw new InvalidParameterValueException( e.getMessage() ); } catch ( MetadataStoreException e ) { LOG.debug( e.getMessage() ); throw new OWSException( e.getMessage(), NO_APPLICABLE_CODE ); } xmlWriter.flush(); }
private void deleteFile( TransactionStatus status, File file ) throws MetadataStoreException { boolean deleted = file.delete(); LOG.debug( "File {} was " + ( deleted ? "successful" : "not" ) + " deleted", file ); if ( !deleted ) throw new MetadataStoreException( "Commit failed: could not " + status + " record at " + file ); }
/** * * Preprocessing for the export of a {@link Transaction} request * * @param trans * @param response * @throws XMLStreamException * @throws OWSException * @throws IOException */ public void doTransaction( Transaction trans, HttpResponseBuffer response, MetadataStore<?> store ) throws XMLStreamException, OWSException, IOException { LOG.debug( "doTransaction: " + trans ); Version version = trans.getVersion(); response.setContentType( "application/xml; charset=UTF-8" ); // to be sure of a valid response String schemaLocation = ""; if ( version.equals( VERSION_202 ) ) { schemaLocation = CSW_202_NS + " " + CSW_202_PUBLICATION_SCHEMA; } XMLStreamWriter xmlWriter = getXMLResponseWriter( response, schemaLocation ); try { doTransaction( xmlWriter, trans, version, store ); } catch ( MetadataStoreException e ) { throw new OWSException( e.getMessage(), OWSException.NO_APPLICABLE_CODE ); } xmlWriter.flush(); }
@Override public int getRemaining() throws MetadataStoreException { int i = 0; try { while ( rs.next() ) { i++; } } catch ( SQLException e ) { throw new MetadataStoreException( e.getMessage(), e ); } return i; }
trans = acquireTransaction(); } catch ( MetadataStoreException e ) { String msg = "Could not aquireTranacation to update the profile: " + e.getMessage(); LOG.debug( msg ); throw new ResourceInitException( msg, e ); String msg = "Could not update the profile: " + e.getMessage(); LOG.debug( msg ); try {
@Override public MetadataResultSet<ISORecord> getRecords( MetadataQuery query ) throws MetadataStoreException { try { return storedIsoRecords.getRecords( query ); } catch ( FilterEvaluationException e ) { throw new MetadataStoreException( e ); } }
@Override public void doGetRecordById( GetRecordById getRecBI, HttpResponseBuffer response, MetadataStore<?> store, ServiceProfile profile ) throws XMLStreamException, IOException, InvalidParameterValueException, OWSException { this.profile = profile; LOG.debug( "doGetRecordById: " + getRecBI ); Version version = getRecBI.getVersion(); String outputFormat = getRecBI.getOutputFormat(); response.setContentType( outputFormat ); // to be sure of a valid response String schemaLocation = profile.getGetRecordByIdSchemaLocation( getRecBI.getVersion() ); XMLStreamWriter xmlWriter = getXmlorJsonStreamWriter( outputFormat, response, schemaLocation ); try { export( xmlWriter, getRecBI, version, store ); } catch ( OWSException e ) { LOG.debug( e.getMessage() ); throw new InvalidParameterValueException( e.getMessage() ); } catch ( MetadataStoreException e ) { throw new OWSException( e.getMessage(), NO_APPLICABLE_CODE ); } xmlWriter.flush(); }
public static URI determineOutputSchema( OutputSchema outputSchema ) throws MetadataStoreException { URI schema = null; try { switch ( outputSchema ) { case DC: schema = new URI( CSWConstants.CSW_202_NS ); break; case ISO_19115: schema = new URI( CSWConstants.GMD_NS ); break; } } catch ( URISyntaxException e ) { throw new MetadataStoreException( e.getMessage() ); } return schema; }
useLegacyPredicates = JDBCUtils.useLegayPostGISPredicates( conn, LOG ); } catch ( MetadataStoreException e ) { throw new ResourceInitException( e.getMessage(), e ); } finally { JDBCUtils.close( conn ); String msg = "Could not insert profile: " + e.getMessage(); LOG.debug( msg ); throw new ResourceInitException( msg, e );
@Override public T getRecord() throws MetadataStoreException { try { BufferedInputStream bais = new BufferedInputStream( rs.getBinaryStream( 1 ) ); XMLStreamReader xmlReader = XMLInputFactory.newInstance().createXMLStreamReader( bais ); return getRecord( xmlReader ); } catch ( Exception e ) { throw new MetadataStoreException( "Error re-creating MetadataRecord from result set: " + e.getMessage() ); } }
LOG.debug( e.getMessage(), e ); throw new OWSException( e.getMessage(), OWSException.INVALID_PARAMETER_VALUE );
private ServiceManagerProvider() throws MetadataStoreException { Iterator<ServiceManager> iter = ServiceLoader.load( ServiceManager.class ).iterator(); while ( iter.hasNext() ) { if ( serviceManager != null ) { String msg = "It is not allowed to specify more than one service manager. Please check " + ServiceManager.class.getName(); throw new MetadataStoreException( msg ); } serviceManager = iter.next(); } if ( serviceManager == null ) { serviceManager = new DefaultServiceManager(); } }
@Override public void commit() throws MetadataStoreException { LOG.debug( "Performing commit of transaction." ); try { conn.commit(); } catch ( SQLException e ) { String msg = "Commit failed: " + e.getMessage(); LOG.debug( msg ); throw new MetadataStoreException( msg ); } finally { JDBCUtils.close( conn ); } }
@Override public void rollback() throws MetadataStoreException { LOG.debug( "Performing rollback of transaction." ); try { conn.rollback(); } catch ( SQLException e ) { String msg = "Rollback failed: " + e.getMessage(); LOG.debug( msg ); throw new MetadataStoreException( msg ); } finally { JDBCUtils.close( conn ); } }
private void writeSchemaReference( XMLStreamWriter writer, QName typeName, URL url ) throws MetadataStoreException { if ( url == null ) { LOG.info( "Could not find schema reference snippet for type name " + typeName ); return; } try { InputStreamReader isr = new InputStreamReader( url.openStream(), "UTF-8" ); dcHelper.exportSchemaComponent( writer, typeName, isr ); } catch ( UnsupportedEncodingException e ) { String msg = "Could not export " + typeName; LOG.debug( msg, e ); throw new MetadataStoreException( msg ); } catch ( IOException e ) { String msg = "Could not export " + typeName; LOG.debug( msg, e ); throw new MetadataStoreException( msg ); } catch ( XMLStreamException e ) { String msg = "Could not export " + typeName; LOG.debug( msg, e ); throw new MetadataStoreException( msg ); } }
private void deleteExistingRows( Connection connection, int operatesOnId, String databaseTable ) throws MetadataStoreException { PreparedStatement stmt = null; StringWriter sqlStatement = new StringWriter(); try { sqlStatement.append( "DELETE FROM " + databaseTable + " WHERE " + fk_main + " = ?" ); stmt = connection.prepareStatement( sqlStatement.toString() ); stmt.setInt( 1, operatesOnId ); LOG.debug( stmt.toString() ); stmt.executeUpdate(); } catch ( SQLException e ) { String msg = Messages.getMessage( "ERROR_SQL", sqlStatement.toString(), e.getMessage() ); LOG.debug( msg ); throw new MetadataStoreException( msg ); } finally { close( null, stmt, null, LOG ); } }