Skip to content

Commit

Permalink
fixed error while shutting down lucene indexing
Browse files Browse the repository at this point in the history
fixed search for old search portal
  • Loading branch information
Jesse Eichar committed Nov 1, 2012
1 parent 4c035f2 commit 40a2247
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,19 @@ protected void customizeContext(ServletContext servletContext,

private void processBeanFactoryPostProcessorParam(
ConfigurableWebApplicationContext applicationContext, String param) {
if (param != null) {
for (String className: param.split(",")) {
try {
Class<?> class1 = Class.forName(className.trim());
BeanFactoryPostProcessor postProcessor = (BeanFactoryPostProcessor) class1.newInstance();
applicationContext.addBeanFactoryPostProcessor(postProcessor);
} catch (Throwable e) {
Log.error(Log.JEEVES, "Unable to create Bean Post processor");
}
}
}
if (param != null) {
for (String className : param.split(",")) {
if (!className.trim().isEmpty()) {
try {
Class<?> class1 = Class.forName(className.trim());
BeanFactoryPostProcessor postProcessor = (BeanFactoryPostProcessor) class1.newInstance();
applicationContext.addBeanFactoryPostProcessor(postProcessor);
} catch (Throwable e) {
Log.error(Log.JEEVES, "Unable to create Bean Post processor");
}
}
}
}
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion web-itest/webspecs
Submodule webspecs updated 108 files
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ public void search(ServiceContext srvContext, Element request, ServiceConfig con
if(Log.isDebugEnabled(Geonet.LUCENE))
Log.debug(Geonet.LUCENE, "LuceneSearcher performing query");
performQuery(getFrom()-1, getTo(), buildSummary);

updateSearchRange(request);

SettingInfo si = new SettingInfo(srvContext);
if (si.isSearchStatsEnabled()) {
if (_sm.getLogAsynch()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,21 @@ protected void updateSearchRange(Element request)
}

protected int readFrom(Element request) {
return loadParam(request, "from");
return loadParam(request, "from", _from);
}

protected int readTo(Element request) {
return loadParam(request, "to");
return loadParam(request, "to", _to);
}

private int loadParam(Element request, String name) {
private int loadParam(Element request, String name, int defaultVal) {
String sFrom = request.getChildText(name);
if (sFrom != null)
{
try { return Integer.parseInt(sFrom); }
catch (NumberFormatException nfe) { throw new IllegalArgumentException("Bad '"+name+"' parameter: " + sFrom); }
}
return _from;
return defaultVal;
}

protected int getFrom() { return _from; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ public synchronized void reset() throws IOException {
public synchronized void close() throws IOException {
List<Throwable> errors = new ArrayList<Throwable>(5);

for (GeonetworkNRTManager manager: searchManagers.values()) {
try {
manager.close();
} catch (Throwable e) {
errors.add(e);
}
}
for (TrackingIndexWriter writer: trackingWriters.values()) {
try {
writer.getIndexWriter().close(true);
Expand All @@ -176,13 +183,13 @@ public synchronized void close() throws IOException {
} catch (Throwable e) {
errors.add(e);
}
}
for (GeonetworkNRTManager manager: searchManagers.values()) {
try {
manager.close();
} catch (Throwable e) {
errors.add(e);
}

if(!errors.isEmpty()) {
for (Throwable throwable : errors) {
Log.error(Geonet.LUCENE, "Failure while closing luceneIndexLanguageTracker", throwable);
}
throw new RuntimeException("There were errors while closing lucene indices");
}
}
public synchronized void optimize() throws CorruptIndexException, IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
<xsl:include href="convert/functions.xsl"/>

<!-- ========================================================================================= -->
<xsl:variable name="isoDocLangId">
<xsl:call-template name="langId19139"/>
</xsl:variable>
<xsl:variable name="isoDocLangId">
<xsl:call-template name="langId19139"/>
</xsl:variable>

<xsl:template match="/">

<Documents>
<xsl:for-each select="/*[name(.)='gmd:MD_Metadata' or @gco:isoType='gmd:MD_Metadata']/gmd:locale/gmd:PT_Locale">
<xsl:call-template name="document">
Expand All @@ -46,44 +47,42 @@
<xsl:template name="document">
<xsl:param name="isoLangId"/>
<xsl:param name="langId"/>

<!--<xsl:variable name="isoLangId" select="java:twoCharLangCode(normalize-space(string(gmd:languageCode/gmd:LanguageCode/@codeListValue)))" />-->
<xsl:variable name="isoLangId" select="normalize-space(string(gmd:languageCode/gmd:LanguageCode/@codeListValue))" />
<Document locale="{$isoLangId}">

<Field name="_locale" string="{$isoLangId}" store="true" index="true"/>
<Field name="_docLocale" string="{$isoDocLangId}" store="true" index="true"/>

<xsl:variable name="poundLangId" select="concat('#',$langId)" />
<xsl:variable name="_defaultTitle">
<xsl:call-template name="defaultTitle">
<xsl:with-param name="isoDocLangId" select="$isoLangId"/>
</xsl:call-template>
</xsl:variable>
<xsl:if test="$isoLangId!=$isoDocLangId">
<!-- not tokenized title for sorting -->
<Field name="_defaultTitle" string="{string($_defaultTitle)}" store="true" index="true" />
</xsl:if>
<xsl:variable name="title"
select="/*[name(.)='gmd:MD_Metadata' or @gco:isoType='gmd:MD_Metadata']/gmd:identificationInfo//gmd:citation//gmd:title//gmd:LocalisedCharacterString[@locale=$poundLangId]"/>


<!--<xsl:variable name="isoLangId" select="java:twoCharLangCode(normalize-space(string(gmd:languageCode/gmd:LanguageCode/@codeListValue)))" />-->
<xsl:variable name="isoLangId" select="normalize-space(string(gmd:languageCode/gmd:LanguageCode/@codeListValue))" />
<Document locale="{$isoLangId}">

<Field name="_locale" string="{$isoLangId}" store="true" index="true"/>
<Field name="_docLocale" string="{$isoDocLangId}" store="true" index="true"/>

<xsl:variable name="poundLangId" select="concat('#',$langId)" />
<xsl:variable name="_defaultTitle">
<xsl:call-template name="defaultTitle">
<xsl:with-param name="isoDocLangId" select="$isoLangId"/>
</xsl:call-template>
</xsl:variable>
<xsl:if test="$isoLangId!=$isoDocLangId">
<!-- not tokenized title for sorting -->
<xsl:choose>
<xsl:when test="normalize-space($title) = ''">
<Field name="_title" string="{string($_defaultTitle)}" store="true" index="true" />
</xsl:when>
<xsl:otherwise>
<Field name="_title" string="{string($title)}" store="true" index="true" />
</xsl:otherwise>
</xsl:choose>

<xsl:apply-templates select="/*[name(.)='gmd:MD_Metadata' or @gco:isoType='gmd:MD_Metadata']" mode="metadata">
<xsl:with-param name="langId" select="$poundLangId"/>
</xsl:apply-templates>

</Document>
</xsl:for-each>
</Documents>
<Field name="_defaultTitle" string="{string($_defaultTitle)}" store="true" index="true" />
</xsl:if>
<xsl:variable name="title"
select="/*[name(.)='gmd:MD_Metadata' or @gco:isoType='gmd:MD_Metadata']/gmd:identificationInfo//gmd:citation//gmd:title//gmd:LocalisedCharacterString[@locale=$poundLangId]"/>

<!-- not tokenized title for sorting -->
<xsl:choose>
<xsl:when test="normalize-space($title) = ''">
<Field name="_title" string="{string($_defaultTitle)}" store="true" index="true" />
</xsl:when>
<xsl:otherwise>
<Field name="_title" string="{string($title)}" store="true" index="true" />
</xsl:otherwise>
</xsl:choose>

<xsl:apply-templates select="/*[name(.)='gmd:MD_Metadata' or @gco:isoType='gmd:MD_Metadata']" mode="metadata">
<xsl:with-param name="langId" select="$poundLangId"/>
</xsl:apply-templates>

</Document>
</xsl:template>

<!-- ========================================================================================= -->
Expand Down

0 comments on commit 40a2247

Please sign in to comment.