@ -90,8 +90,8 @@ import org.apache.solr.schema.IndexSchema;
public final class Fulltext {
public final class Fulltext {
private static final String SOLR_PATH = "solr_ 6_6 "; // the number should be identical to the number in the property luceneMatchVersion in solrconfig.xml
private static final String SOLR_PATH = "solr_ 8_8_1 "; // the number should be identical to the number in the property luceneMatchVersion in solrconfig.xml
private static final String SOLR_OLD_PATH [ ] = new String [ ] { "solr_36" , "solr_40" , "solr_44" , "solr_45" , "solr_46" , "solr_47" , "solr_4_9" , "solr_4_10" , "solr_5_2" , "solr_5_5" };
private static final String SOLR_OLD_PATH [ ] = new String [ ] { "solr_36" , "solr_40" , "solr_44" , "solr_45" , "solr_46" , "solr_47" , "solr_4_9" , "solr_4_10" , "solr_5_2" , "solr_5_5" , "solr_6_6" };
// class objects
// class objects
private final File segmentPath ;
private final File segmentPath ;
@ -140,24 +140,28 @@ public final class Fulltext {
public void connectLocalSolr ( ) throws IOException {
public void connectLocalSolr ( ) throws IOException {
File solrLocation = new File ( this . segmentPath , SOLR_PATH ) ;
File solrLocation = new File ( this . segmentPath , SOLR_PATH ) ;
// migrate old solr to new
// migrate old solr to new
/ *
for ( String oldVersion : SOLR_OLD_PATH ) {
for ( String oldVersion : SOLR_OLD_PATH ) {
File oldLocation = new File ( this . segmentPath , oldVersion ) ;
File oldLocation = new File ( this . segmentPath , oldVersion ) ;
if ( oldLocation . exists ( ) ) {
if ( oldLocation . exists ( ) ) {
if ( ! oldLocation . renameTo ( solrLocation ) ) {
if ( ! oldLocation . renameTo ( solrLocation ) ) {
ConcurrentLog . severe ( "Fulltext" , "Failed renaming old Solr location ("
ConcurrentLog . severe ( "Fulltext" , "Failed renaming old Solr location ("
+ oldLocation . getAbsolutePath ( ) + ") to new location : " + solrLocation . getAbsolutePath ( ) ) ;
+ oldLocation . getAbsolutePath ( ) + ") to new location : " + solrLocation . getAbsolutePath ( ) ) ;
}
}
}
}
}
}
* /
EmbeddedInstance localCollectionInstance = new EmbeddedInstance ( new File ( new File ( Switchboard . getSwitchboard ( ) . appPath , "defaults" ) , "solr" ) , solrLocation , CollectionSchema . CORE_NAME , new String [ ] { CollectionSchema . CORE_NAME , WebgraphSchema . CORE_NAME } ) ;
EmbeddedInstance localCollectionInstance = new EmbeddedInstance ( new File ( new File ( Switchboard . getSwitchboard ( ) . appPath , "defaults" ) , "solr" ) , solrLocation , CollectionSchema . CORE_NAME , new String [ ] { CollectionSchema . CORE_NAME , WebgraphSchema . CORE_NAME } ) ;
SolrConfig config = localCollectionInstance . getDefaultCore ( ) . getSolrConfig ( ) ;
SolrConfig config = localCollectionInstance . getDefaultCore ( ) . getSolrConfig ( ) ;
String versionValue = config . getVal ( IndexSchema . LUCENE_MATCH_VERSION_PARAM , true ) ;
String versionValue = config . getVal ( IndexSchema . LUCENE_MATCH_VERSION_PARAM , true ) ;
Version luceneVersion = SolrConfig . parseLuceneVersionString ( versionValue ) ;
Version luceneVersion = SolrConfig . parseLuceneVersionString ( versionValue ) ;
String lvn = luceneVersion . major + "_" + luceneVersion . minor ;
String lvn = luceneVersion . major + "_" + luceneVersion . minor + "_" + luceneVersion . bugfix ;
ConcurrentLog . info ( "Fulltext" , "using lucene version " + lvn ) ;
assert SOLR_PATH . endsWith ( lvn ) : "luceneVersion = " + lvn + ", solrPath = " + SOLR_PATH + ", check defaults/solr/solrconfig.xml" ;
assert SOLR_PATH . endsWith ( lvn ) : "luceneVersion = " + lvn + ", solrPath = " + SOLR_PATH + ", check defaults/solr/solrconfig.xml" ;
ConcurrentLog . info ( "Fulltext" , "using lucene version " + lvn ) ;
ConcurrentLog . info ( "Fulltext" , "connected solr in " + solrLocation . toString ( ) + ", lucene version " + lvn ) ;
ConcurrentLog . info ( "Fulltext" , "connected solr in " + solrLocation . toString ( ) + ", lucene version " + lvn ) ;
this . solrInstances . connectEmbedded ( localCollectionInstance ) ;
this . solrInstances . connectEmbedded ( localCollectionInstance ) ;
}
}
@ -194,12 +198,12 @@ public final class Fulltext {
public RemoteSolrConnector getDefaultRemoteSolrConnector ( ) {
public RemoteSolrConnector getDefaultRemoteSolrConnector ( ) {
try {
try {
boolean useBinaryResponseWriter = SwitchboardConstants . REMOTE_SOLR_BINARY_RESPONSE_ENABLED_DEFAULT ;
boolean useBinaryResponseWriter = SwitchboardConstants . REMOTE_SOLR_BINARY_RESPONSE_ENABLED_DEFAULT ;
if ( Switchboard . getSwitchboard ( ) ! = null ) {
if ( Switchboard . getSwitchboard ( ) ! = null ) {
useBinaryResponseWriter = Switchboard . getSwitchboard ( ) . getConfigBool (
useBinaryResponseWriter = Switchboard . getSwitchboard ( ) . getConfigBool (
SwitchboardConstants . REMOTE_SOLR_BINARY_RESPONSE_ENABLED ,
SwitchboardConstants . REMOTE_SOLR_BINARY_RESPONSE_ENABLED ,
SwitchboardConstants . REMOTE_SOLR_BINARY_RESPONSE_ENABLED_DEFAULT ) ;
SwitchboardConstants . REMOTE_SOLR_BINARY_RESPONSE_ENABLED_DEFAULT ) ;
}
}
return this . solrInstances . getDefaultRemoteConnector ( useBinaryResponseWriter ) ;
return this . solrInstances . getDefaultRemoteConnector ( useBinaryResponseWriter ) ;
} catch ( IOException e ) {
} catch ( IOException e ) {
return null ;
return null ;
@ -207,35 +211,35 @@ public final class Fulltext {
}
}
public EmbeddedInstance getEmbeddedInstance ( ) {
public EmbeddedInstance getEmbeddedInstance ( ) {
this . solrInstancesLock . lock ( ) ;
this . solrInstancesLock . lock ( ) ;
try {
try {
if ( this . solrInstances . isConnectedEmbedded ( ) ) {
if ( this . solrInstances . isConnectedEmbedded ( ) ) {
return this . solrInstances . getEmbedded ( ) ;
return this . solrInstances . getEmbedded ( ) ;
}
}
return null ;
return null ;
} finally {
} finally {
this . solrInstancesLock . unlock ( ) ;
this . solrInstancesLock . unlock ( ) ;
}
}
}
}
public SolrConnector getDefaultConnector ( ) {
public SolrConnector getDefaultConnector ( ) {
this . solrInstancesLock . lock ( ) ;
this . solrInstancesLock . lock ( ) ;
try {
try {
return this . solrInstances . getDefaultMirrorConnector ( ) ;
return this . solrInstances . getDefaultMirrorConnector ( ) ;
} finally {
} finally {
this . solrInstancesLock . unlock ( ) ;
this . solrInstancesLock . unlock ( ) ;
}
}
}
}
public SolrConnector getWebgraphConnector ( ) {
public SolrConnector getWebgraphConnector ( ) {
if ( ! this . writeWebgraph ) {
if ( ! this . writeWebgraph ) {
return null ;
return null ;
}
}
this . solrInstancesLock . lock ( ) ;
this . solrInstancesLock . lock ( ) ;
try {
try {
return this . solrInstances . getGenericMirrorConnector ( WebgraphSchema . CORE_NAME ) ;
return this . solrInstances . getGenericMirrorConnector ( WebgraphSchema . CORE_NAME ) ;
} finally {
} finally {
this . solrInstancesLock . unlock ( ) ;
this . solrInstancesLock . unlock ( ) ;
}
}
}
}
@ -249,9 +253,9 @@ public final class Fulltext {
public void clearLocalSolr ( ) throws IOException {
public void clearLocalSolr ( ) throws IOException {
if ( this . exportthread ! = null ) {
if ( this . exportthread ! = null ) {
this . exportthread . interrupt ( ) ;
this . exportthread . interrupt ( ) ;
}
}
this . solrInstancesLock . lock ( ) ;
this . solrInstancesLock . lock ( ) ;
try {
try {
EmbeddedInstance instance = this . solrInstances . getEmbedded ( ) ;
EmbeddedInstance instance = this . solrInstances . getEmbedded ( ) ;
if ( instance ! = null ) {
if ( instance ! = null ) {
@ -262,12 +266,12 @@ public final class Fulltext {
}
}
this . solrInstances . clearCaches ( ) ;
this . solrInstances . clearCaches ( ) ;
} finally {
} finally {
this . solrInstancesLock . unlock ( ) ;
this . solrInstancesLock . unlock ( ) ;
}
}
}
}
public void clearRemoteSolr ( ) throws IOException {
public void clearRemoteSolr ( ) throws IOException {
this . solrInstancesLock . lock ( ) ;
this . solrInstancesLock . lock ( ) ;
try {
try {
ShardInstance instance = this . solrInstances . getRemote ( ) ;
ShardInstance instance = this . solrInstances . getRemote ( ) ;
if ( instance ! = null ) {
if ( instance ! = null ) {
@ -277,7 +281,7 @@ public final class Fulltext {
}
}
this . solrInstances . clearCaches ( ) ;
this . solrInstances . clearCaches ( ) ;
} finally {
} finally {
this . solrInstancesLock . unlock ( ) ;
this . solrInstancesLock . unlock ( ) ;
}
}
}
}
@ -309,7 +313,7 @@ public final class Fulltext {
try {
try {
this . solrInstances . close ( ) ;
this . solrInstances . close ( ) ;
} catch ( Throwable e ) {
} catch ( Throwable e ) {
ConcurrentLog . logException ( e ) ;
ConcurrentLog . logException ( e ) ;
}
}
}
}
@ -354,7 +358,7 @@ public final class Fulltext {
try {
try {
SolrDocument doc = this . getDefaultConnector ( ) . getDocumentById ( u ) ;
SolrDocument doc = this . getDefaultConnector ( ) . getDocumentById ( u ) ;
if ( doc ! = null ) {
if ( doc ! = null ) {
return new URIMetadataNode ( doc , wre , score ) ;
return new URIMetadataNode ( doc , wre , score ) ;
}
}
} catch ( final IOException e ) {
} catch ( final IOException e ) {
ConcurrentLog . logException ( e ) ;
ConcurrentLog . logException ( e ) ;
@ -493,7 +497,6 @@ public final class Fulltext {
}
}
}
}
/ * *
/ * *
* remove a full subpath from the index
* remove a full subpath from the index
* @param basepath the left path of the url ; at least until the end of the host
* @param basepath the left path of the url ; at least until the end of the host
@ -533,7 +536,7 @@ public final class Fulltext {
this . getDefaultConnector ( ) . deleteByIds ( deleteIDs ) ;
this . getDefaultConnector ( ) . deleteByIds ( deleteIDs ) ;
if ( this . writeWebgraph ) { // Webgraph.id is combination of sourceHash+targetHash+hexCounter, to be successful use source_id_s and/or target_id_s
if ( this . writeWebgraph ) { // Webgraph.id is combination of sourceHash+targetHash+hexCounter, to be successful use source_id_s and/or target_id_s
for ( String id : deleteIDs ) {
for ( String id : deleteIDs ) {
/* Add quotes around the url hash to prevent Solr logging a ParseException stack trace when the hash start with a '-' character */
/* Add quotes around the url hash to prevent Solr logging a ParseException stack trace when the hash start with a '-' character */
this . getWebgraphConnector ( ) . deleteByQuery ( WebgraphSchema . source_id_s . name ( ) + ":\"" + id + "\"" ) ;
this . getWebgraphConnector ( ) . deleteByQuery ( WebgraphSchema . source_id_s . name ( ) + ":\"" + id + "\"" ) ;
}
}
}
}
@ -554,7 +557,7 @@ public final class Fulltext {
String id = ASCII . String ( urlHash ) ;
String id = ASCII . String ( urlHash ) ;
this . getDefaultConnector ( ) . deleteById ( id ) ;
this . getDefaultConnector ( ) . deleteById ( id ) ;
if ( this . writeWebgraph ) { // Webgraph.id is combination of sourceHash+targetHash+hexCounter, to be successful use source_id_s and/or target_id_s
if ( this . writeWebgraph ) { // Webgraph.id is combination of sourceHash+targetHash+hexCounter, to be successful use source_id_s and/or target_id_s
/* Add quotes around the url hash to prevent Solr logging a ParseException stack trace when the hash start with a '-' character */
/* Add quotes around the url hash to prevent Solr logging a ParseException stack trace when the hash start with a '-' character */
this . getWebgraphConnector ( ) . deleteByQuery ( WebgraphSchema . source_id_s + ":\"" + id + "\"" ) ;
this . getWebgraphConnector ( ) . deleteByQuery ( WebgraphSchema . source_id_s + ":\"" + id + "\"" ) ;
}
}
} catch ( final Throwable e ) {
} catch ( final Throwable e ) {
@ -613,11 +616,11 @@ public final class Fulltext {
public File dumpEmbeddedSolr ( ) throws SolrException {
public File dumpEmbeddedSolr ( ) throws SolrException {
final EmbeddedInstance esc = this . solrInstances . getEmbedded ( ) ;
final EmbeddedInstance esc = this . solrInstances . getEmbedded ( ) ;
if ( esc = = null ) {
if ( esc = = null ) {
throw new SolrException ( ErrorCode . SERVICE_UNAVAILABLE , "No embedded Solr available." ) ;
throw new SolrException ( ErrorCode . SERVICE_UNAVAILABLE , "No embedded Solr available." ) ;
}
}
final File storagePath = esc . getContainerPath ( ) ;
final File storagePath = esc . getContainerPath ( ) ;
final File zipOut = new File ( this . archivePath , storagePath . getName ( ) + "_" + GenericFormatter . SHORT_DAY_FORMATTER . format ( ) + ".zip" ) ;
final File zipOut = new File ( this . archivePath , storagePath . getName ( ) + "_" + GenericFormatter . SHORT_DAY_FORMATTER . format ( ) + ".zip" ) ;
this . solrInstancesLock . lock ( ) ;
this . solrInstancesLock . lock ( ) ;
try {
try {
this . disconnectLocalSolr ( ) ;
this . disconnectLocalSolr ( ) ;
try {
try {
@ -632,7 +635,7 @@ public final class Fulltext {
}
}
}
}
} finally {
} finally {
this . solrInstancesLock . unlock ( ) ;
this . solrInstancesLock . unlock ( ) ;
}
}
return zipOut ;
return zipOut ;
}
}
@ -645,10 +648,10 @@ public final class Fulltext {
public void restoreEmbeddedSolr ( final File solrDumpZipFile ) {
public void restoreEmbeddedSolr ( final File solrDumpZipFile ) {
final EmbeddedInstance esc = this . solrInstances . getEmbedded ( ) ;
final EmbeddedInstance esc = this . solrInstances . getEmbedded ( ) ;
if ( esc = = null ) {
if ( esc = = null ) {
throw new SolrException ( ErrorCode . SERVICE_UNAVAILABLE , "No embedded Solr available." ) ;
throw new SolrException ( ErrorCode . SERVICE_UNAVAILABLE , "No embedded Solr available." ) ;
}
}
final File storagePath = esc . getContainerPath ( ) ;
final File storagePath = esc . getContainerPath ( ) ;
this . solrInstancesLock . lock ( ) ;
this . solrInstancesLock . lock ( ) ;
try {
try {
// this.disconnectLocalSolr(); // moved to (InstanceMirror) sorlInstances.close()
// this.disconnectLocalSolr(); // moved to (InstanceMirror) sorlInstances.close()
this . solrInstances . close ( ) ;
this . solrInstances . close ( ) ;
@ -665,7 +668,7 @@ public final class Fulltext {
}
}
}
}
} finally {
} finally {
this . solrInstancesLock . unlock ( ) ;
this . solrInstancesLock . unlock ( ) ;
}
}
}
}
@ -684,7 +687,7 @@ public final class Fulltext {
* Please check before that the local embedded Solr is enabled and no external remote Solr is attached .
* Please check before that the local embedded Solr is enabled and no external remote Solr is attached .
* /
* /
public void rebootEmbeddedLocalSolr ( ) {
public void rebootEmbeddedLocalSolr ( ) {
this . solrInstancesLock . lock ( ) ;
this . solrInstancesLock . lock ( ) ;
try {
try {
this . disconnectLocalSolr ( ) ;
this . disconnectLocalSolr ( ) ;
// this.solrInstances.close(); // moved to (InstanceMirror) sorlInstances.close()
// this.solrInstances.close(); // moved to (InstanceMirror) sorlInstances.close()
@ -695,7 +698,7 @@ public final class Fulltext {
ConcurrentLog . logException ( e ) ;
ConcurrentLog . logException ( e ) ;
}
}
} finally {
} finally {
this . solrInstancesLock . unlock ( ) ;
this . solrInstancesLock . unlock ( ) ;
}
}
}
}
@ -732,47 +735,46 @@ public final class Fulltext {
final long doccount ;
final long doccount ;
final Date firstdate , lastdate ;
final Date firstdate , lastdate ;
if ( firstdoclist . size ( ) = = 0 | | lastdoclist . size ( ) = = 0 ) {
if ( firstdoclist . size ( ) = = 0 | | lastdoclist . size ( ) = = 0 ) {
/ * Now check again the number of documents without sorting , for compatibility with old fields indexed without DocValues fields ( prior to YaCy 1.90 )
/ * Now check again the number of documents without sorting , for compatibility with old fields indexed without DocValues fields ( prior to YaCy 1.90 )
* When the local Solr index contains such old documents , requests with sort query return nothing and trace in logs
* When the local Solr index contains such old documents , requests with sort query return nothing and trace in logs
* "java.lang.IllegalStateException: unexpected docvalues type NONE for field..." * /
* "java.lang.IllegalStateException: unexpected docvalues type NONE for field..." * /
doccount = this . getDefaultConnector ( ) . getCountByQuery ( query ) ;
doccount = this . getDefaultConnector ( ) . getCountByQuery ( query ) ;
if ( doccount = = 0 ) {
if ( doccount = = 0 ) {
/* Finally no document to export was found */
/* Finally no document to export was found */
throw new IOException ( "number of exported documents == 0" ) ;
throw new IOException ( "number of exported documents == 0" ) ;
}
}
/* we use default date values just to generate a proper dump file path */
/* we use default date values just to generate a proper dump file path */
firstdate = new Date ( 0 ) ;
firstdate = new Date ( 0 ) ;
lastdate = new Date ( 0 ) ;
lastdate = new Date ( 0 ) ;
} else {
} else {
doccount = firstdoclist . getNumFound ( ) ;
doccount = firstdoclist . getNumFound ( ) ;
// create the export name
// create the export name
SolrDocument firstdoc = firstdoclist . get ( 0 ) ;
SolrDocument firstdoc = firstdoclist . get ( 0 ) ;
SolrDocument lastdoc = lastdoclist . get ( 0 ) ;
SolrDocument lastdoc = lastdoclist . get ( 0 ) ;
firstdateobject = firstdoc . getFieldValue ( CollectionSchema . load_date_dt . getSolrFieldName ( ) ) ;
firstdateobject = firstdoc . getFieldValue ( CollectionSchema . load_date_dt . getSolrFieldName ( ) ) ;
lastdateobject = lastdoc . getFieldValue ( CollectionSchema . load_date_dt . getSolrFieldName ( ) ) ;
lastdateobject = lastdoc . getFieldValue ( CollectionSchema . load_date_dt . getSolrFieldName ( ) ) ;
/ * When firstdate or lastdate is null , we use a default one just to generate a proper dump file path
/ * When firstdate or lastdate is null , we use a default one just to generate a proper dump file path
* This should not happen because load_date_dt field is mandatory in the main Solr schema ,
* This should not happen because load_date_dt field is mandatory in the main Solr schema ,
* but for some reason some documents might end up here with an empty load_date_dt field value * /
* but for some reason some documents might end up here with an empty load_date_dt field value * /
if ( firstdateobject instanceof Date ) {
if ( firstdateobject instanceof Date ) {
firstdate = ( Date ) firstdateobject ;
firstdate = ( Date ) firstdateobject ;
} else {
} else {
ConcurrentLog . warn ( "Fulltext" , "The required field " + CollectionSchema . load_date_dt . getSolrFieldName ( ) + " is empty on document with id : "
ConcurrentLog . warn ( "Fulltext" , "The required field " + CollectionSchema . load_date_dt . getSolrFieldName ( ) + " is empty on document with id : "
+ firstdoc . getFieldValue ( CollectionSchema . id . getSolrFieldName ( ) ) ) ;
+ firstdoc . getFieldValue ( CollectionSchema . id . getSolrFieldName ( ) ) ) ;
firstdate = new Date ( 0 ) ;
firstdate = new Date ( 0 ) ;
}
}
if ( lastdateobject instanceof Date ) {
if ( lastdateobject instanceof Date ) {
lastdate = ( Date ) lastdateobject ;
lastdate = ( Date ) lastdateobject ;
} else {
} else {
ConcurrentLog . warn ( "Fulltext" , "The required field " + CollectionSchema . load_date_dt . getSolrFieldName ( ) + " is empty on document with id : "
ConcurrentLog . warn ( "Fulltext" , "The required field " + CollectionSchema . load_date_dt . getSolrFieldName ( ) + " is empty on document with id : "
+ lastdoc . getFieldValue ( CollectionSchema . id . getSolrFieldName ( ) ) ) ;
+ lastdoc . getFieldValue ( CollectionSchema . id . getSolrFieldName ( ) ) ) ;
lastdate = new Date ( 0 ) ;
lastdate = new Date ( 0 ) ;
}
}
}
}
String s = new File ( path , yacy_dump_prefix +
String s = new File ( path , yacy_dump_prefix +
"f" + GenericFormatter . SHORT_MINUTE_FORMATTER . format ( firstdate ) + "_" +
"f" + GenericFormatter . SHORT_MINUTE_FORMATTER . format ( firstdate ) + "_" +
"l" + GenericFormatter . SHORT_MINUTE_FORMATTER . format ( lastdate ) + "_" +
"l" + GenericFormatter . SHORT_MINUTE_FORMATTER . format ( lastdate ) + "_" +
@ -799,8 +801,8 @@ public final class Fulltext {
}
}
public static void main ( String args [ ] ) {
public static void main ( String args [ ] ) {
Date firstdate = null ;
Date firstdate = null ;
System . out . println ( GenericFormatter . SHORT_MINUTE_FORMATTER . format ( firstdate ) ) ;
System . out . println ( GenericFormatter . SHORT_MINUTE_FORMATTER . format ( firstdate ) ) ;
}
}
public Export export ( ) {
public Export export ( ) {
@ -816,7 +818,7 @@ public final class Fulltext {
private final boolean dom , text ;
private final boolean dom , text ;
private Export ( final File f , final String filter , final String query , final ExportFormat format , final boolean dom , final boolean text ) {
private Export ( final File f , final String filter , final String query , final ExportFormat format , final boolean dom , final boolean text ) {
super ( "Fulltext.Export" ) ;
super ( "Fulltext.Export" ) ;
// format: 0=text, 1=html, 2=rss/xml
// format: 0=text, 1=html, 2=rss/xml
this . f = f ;
this . f = f ;
this . pattern = filter = = null ? null : Pattern . compile ( filter ) ;
this . pattern = filter = = null ? null : Pattern . compile ( filter ) ;
@ -831,20 +833,20 @@ public final class Fulltext {
@Override
@Override
public void run ( ) {
public void run ( ) {
try {
try {
final File parentf = this . f . getParentFile ( ) ;
final File parentf = this . f . getParentFile ( ) ;
if ( parentf ! = null ) {
if ( parentf ! = null ) {
parentf . mkdirs ( ) ;
parentf . mkdirs ( ) ;
}
}
} catch ( Exception e ) {
} catch ( Exception e ) {
ConcurrentLog . logException ( e ) ;
ConcurrentLog . logException ( e ) ;
this . failure = e . getMessage ( ) ;
this . failure = e . getMessage ( ) ;
return ;
return ;
}
}
try ( /* Resources automatically closed by this try-with-resources statement */
try ( /* Resources automatically closed by this try-with-resources statement */
final OutputStream os = new FileOutputStream ( this . format = = ExportFormat . solr ? new File ( this . f . getAbsolutePath ( ) + ".gz" ) : this . f ) ;
final OutputStream os = new FileOutputStream ( this . format = = ExportFormat . solr ? new File ( this . f . getAbsolutePath ( ) + ".gz" ) : this . f ) ;
final OutputStream wrappedStream = ( ( this . format = = ExportFormat . solr ) ) ? new GZIPOutputStream ( os , 65536 ) { { def . setLevel ( Deflater . BEST_COMPRESSION ) ; } } : os ;
final OutputStream wrappedStream = ( ( this . format = = ExportFormat . solr ) ) ? new GZIPOutputStream ( os , 65536 ) { { def . setLevel ( Deflater . BEST_COMPRESSION ) ; } } : os ;
final PrintWriter pw = new PrintWriter ( new BufferedOutputStream ( wrappedStream ) ) ;
final PrintWriter pw = new PrintWriter ( new BufferedOutputStream ( wrappedStream ) ) ;
) {
) {
if ( this . format = = ExportFormat . html ) {
if ( this . format = = ExportFormat . html ) {
@ -946,7 +948,7 @@ public final class Fulltext {
pw . println ( "</response>" ) ;
pw . println ( "</response>" ) ;
}
}
} catch ( final Exception e ) {
} catch ( final Exception e ) {
/* Catch but log any IO exception that can occur on copy, automatic closing or streams creation */
/* Catch but log any IO exception that can occur on copy, automatic closing or streams creation */
ConcurrentLog . logException ( e ) ;
ConcurrentLog . logException ( e ) ;
this . failure = e . getMessage ( ) ;
this . failure = e . getMessage ( ) ;
}
}
@ -966,10 +968,10 @@ public final class Fulltext {
}
}
@SuppressWarnings ( "unchecked" )
@SuppressWarnings ( "unchecked" )
private String getStringFrom ( final Object o ) {
private String getStringFrom ( final Object o ) {
if ( o = = null ) return "" ;
if ( o = = null ) return "" ;
if ( o instanceof ArrayList ) return ( ( ArrayList < String > ) o ) . get ( 0 ) ;
if ( o instanceof ArrayList ) return ( ( ArrayList < String > ) o ) . get ( 0 ) ;
return ( String ) o ;
return ( String ) o ;
}
}
}
}