@ -117,6 +117,30 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
public static enum COMMON_IMAGES_FORMAT {
gif , png , jpeg , jpg , bmp , tif , tiff , svg , avif , webp
}
public static enum CENTROID_LAYER_INDEX_FLAG {
PUBLIC ( "public" ) , PRIVATE ( "internal" ) ;
String id ;
CENTROID_LAYER_INDEX_FLAG ( String id ) {
this . id = id ;
}
public String getId ( ) {
return id ;
}
@Override
public String toString ( ) {
StringBuilder builder = new StringBuilder ( ) ;
builder . append ( "CENTROID_LAYER_INDEX_FLAG [id=" ) ;
builder . append ( id ) ;
builder . append ( "]" ) ;
return builder . toString ( ) ;
}
}
/ * *
* The Class ImageDetector .
@ -452,40 +476,38 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
// TODO TO Check index flag should be in configuration or evaluated according to
// user credentials
String indexFlag = "public" ; // default
CENTROID_LAYER_INDEX_FLAG setIndexFlag = null ;
GeoportalServiceIdentityProxy gsp = getGeoportalServiceProxy ( ) ;
if ( gsp . isUser ( ) ) {
indexFlag = "internal" ;
LOG . info ( "user logged - using indexFlag: " + i ndexFlag) ;
setIndexFlag = CENTROID_LAYER_INDEX_FLAG . PRIVATE ;
LOG . info ( "user logged - using indexFlag: " + setI ndexFlag) ;
} else if ( gsp . isIAMClient ( ) ) {
indexFlag = "public" ;
LOG . info ( "user not logged - using indexFlag: " + i ndexFlag) ;
setIndexFlag = CENTROID_LAYER_INDEX_FLAG . PUBLIC ;
LOG . info ( "user not logged - using indexFlag: " + setI ndexFlag) ;
}
// TODO constant
coll . setIndexes ( new ArrayList ( ) ) ;
LOG . debug (
"Checking if " + u . getId ( ) + " is GIS Indexed. Index flag needed is " + indexFlag ) ;
LOG . debug ( "Checking if " + u . getId ( ) + " is GIS Indexed. Index flag needed is '" + setIndexFlag + "'" ) ;
IndexLayerDV toAdd = getLayerIndex ( ucdConfig , setIndexFlag ) ;
if ( toAdd ! = null ) {
coll . getIndexes ( ) . add ( toAdd ) ;
}
for ( Index index : ucdConfig . getIndexes ( ) ) {
try {
IndexLayerDV toAdd = ConvertToDataValueObjectModel . convert ( index ) ;
if ( toAdd . getFlag ( ) . equals ( indexFlag ) ) {
coll . getIndexes ( ) . add ( toAdd ) ;
}
} catch ( Exception e ) {
LOG . debug ( "Skipping invalid index " , e ) ;
} catch ( Throwable t ) {
LOG . error ( "Unable to check index " , t ) ;
// Using the public centroid layer as default
if ( coll . getIndexes ( ) . isEmpty ( ) ) {
LOG . info ( "No available GIS Index for collection " + coll . getUcd ( ) . getName ( ) + " with flag " + setIndexFlag . getId ( ) ) ;
setIndexFlag = CENTROID_LAYER_INDEX_FLAG . PUBLIC ;
LOG . info ( "Prevent fallback - getting the GIS index with flag '" + setIndexFlag . getId ( ) + "' available" ) ;
toAdd = getLayerIndex ( ucdConfig , setIndexFlag ) ;
if ( toAdd ! = null ) {
coll . getIndexes ( ) . add ( toAdd ) ;
}
}
// Return only if gis indexed
if ( coll . getIndexes ( ) . isEmpty ( ) )
LOG . info ( "No available GIS Index for collection " + coll . getUcd ( ) . getName ( ) ) ;
else
if ( ! coll . getIndexes ( ) . isEmpty ( ) )
config . getAvailableCollections ( ) . put ( coll . getUcd ( ) . getId ( ) , coll ) ;
} catch ( Throwable t ) {
@ -504,6 +526,27 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
} . execute ( ) . getResult ( ) ;
}
private IndexLayerDV getLayerIndex ( Configuration ucdConfig , CENTROID_LAYER_INDEX_FLAG flag ) {
for ( Index index : ucdConfig . getIndexes ( ) ) {
try {
IndexLayerDV toAdd = ConvertToDataValueObjectModel . convert ( index ) ;
LOG . trace ( "Discovered index: " + toAdd ) ;
if ( toAdd . getFlag ( ) . compareToIgnoreCase ( flag . getId ( ) ) = = 0 ) {
LOG . debug ( "Layer index found for flag: " + flag + ", returning" ) ;
return toAdd ;
}
} catch ( Exception e ) {
LOG . debug ( "Skipping invalid index " , e ) ;
} catch ( Throwable t ) {
LOG . error ( "Unable to check index " , t ) ;
}
}
return null ;
}
/ * *
* Gets the config list of fields for searching .
@ -657,7 +700,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
filter . setProjection ( projectionForIDs ) ;
ResultSetPaginatedDataIDs searchedDataIDs = new ResultSetPaginatedDataIDs ( ) ;
Integer totalProjectForProfile = SessionUtil . getTotalDocumentForProfileID ( getThreadLocalRequest ( ) ,
theProfileID ) ;