Get Configuration fixes
This commit is contained in:
parent
93abb135d5
commit
c8ad2a1004
|
@ -17,6 +17,7 @@ import org.gcube.application.cms.serialization.Serialization;
|
||||||
import org.gcube.application.cms.custom.gna.concessioni.model.ProfiledConcessione;
|
import org.gcube.application.cms.custom.gna.concessioni.model.ProfiledConcessione;
|
||||||
import org.gcube.application.cms.plugins.LifecycleManager;
|
import org.gcube.application.cms.plugins.LifecycleManager;
|
||||||
import org.gcube.application.cms.plugins.model.PluginDescriptor;
|
import org.gcube.application.cms.plugins.model.PluginDescriptor;
|
||||||
|
import org.gcube.application.geoportal.common.model.configuration.Index;
|
||||||
import org.gcube.application.geoportal.common.model.document.*;
|
import org.gcube.application.geoportal.common.model.document.*;
|
||||||
import org.gcube.application.geoportal.common.model.document.access.Access;
|
import org.gcube.application.geoportal.common.model.document.access.Access;
|
||||||
import org.gcube.application.geoportal.common.model.document.access.AccessPolicy;
|
import org.gcube.application.geoportal.common.model.document.access.AccessPolicy;
|
||||||
|
@ -259,13 +260,25 @@ public class ConcessioniLifeCycleManager implements LifecycleManager {
|
||||||
BaseRequest indexRequest = new BaseRequest(req.getUseCaseDescriptor(),req.getCaller(),req.getContext());
|
BaseRequest indexRequest = new BaseRequest(req.getUseCaseDescriptor(),req.getCaller(),req.getContext());
|
||||||
|
|
||||||
// Info on Public index
|
// Info on Public index
|
||||||
|
try {
|
||||||
indexRequest.setCallParameters(getPublicIndexParams(req));
|
indexRequest.setCallParameters(getPublicIndexParams(req));
|
||||||
toReturn.getIndexes().add(indexerPlugin.getIndex(indexRequest));
|
Index publicIndex = indexerPlugin.getIndex(indexRequest);
|
||||||
|
publicIndex.put("flag", "public");
|
||||||
|
toReturn.getIndexes().add(publicIndex);
|
||||||
|
}catch(ConfigurationException e){
|
||||||
|
toReturn.addErrorMessage("Unable to gather information on public GIS Centroids Index : "+e.getMessage());
|
||||||
|
log.error("Unable to gather information on public GIS Centroids Index",e);
|
||||||
|
}
|
||||||
// Info on internal_index
|
// Info on internal_index
|
||||||
|
try {
|
||||||
indexRequest.setCallParameters(getInternalIndexParams(req));
|
indexRequest.setCallParameters(getInternalIndexParams(req));
|
||||||
toReturn.getIndexes().add(indexerPlugin.getIndex(indexRequest));
|
Index internalIndex = indexerPlugin.getIndex(indexRequest);
|
||||||
|
internalIndex.put("flag", "internal");
|
||||||
|
toReturn.getIndexes().add(internalIndex);
|
||||||
|
}catch(ConfigurationException e){
|
||||||
|
toReturn.addErrorMessage("Unable to gather information on internal GIS Centroids Index : "+e.getMessage());
|
||||||
|
log.error("Unable to gather information on internal GIS Centroids Index",e);
|
||||||
|
}
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
package org.gcube.application.geoportal.common.model.configuration;
|
package org.gcube.application.geoportal.common.model.configuration;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import jdk.nashorn.internal.runtime.regexp.joni.Config;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@XmlRootElement
|
@XmlRootElement
|
||||||
|
@ -19,9 +23,19 @@ public class Configuration{
|
||||||
public static final String CONTEXT = "context";
|
public static final String CONTEXT = "context";
|
||||||
public static final String LAST_UPDATED_TIME = "last_updated_time";
|
public static final String LAST_UPDATED_TIME = "last_updated_time";
|
||||||
|
|
||||||
|
public static final String ERROR_MESSAGES="errorMessages";
|
||||||
|
public static final String WARNING_MESSAGES="warningMessages";
|
||||||
|
public static final String STATUS="status";
|
||||||
|
|
||||||
|
|
||||||
public static final String INDEXES = "indexes";
|
public static final String INDEXES = "indexes";
|
||||||
public static final String ARCHIVES = "archives";
|
public static final String ARCHIVES = "archives";
|
||||||
|
|
||||||
|
public static enum Status{
|
||||||
|
OK,ERROR,WARNING
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@JsonProperty(PROFILE_ID)
|
@JsonProperty(PROFILE_ID)
|
||||||
private String profileId;
|
private String profileId;
|
||||||
@JsonProperty(CONTEXT)
|
@JsonProperty(CONTEXT)
|
||||||
|
@ -34,4 +48,30 @@ public class Configuration{
|
||||||
@JsonProperty(ARCHIVES)
|
@JsonProperty(ARCHIVES)
|
||||||
private List<Archive> archives;
|
private List<Archive> archives;
|
||||||
|
|
||||||
|
@JsonProperty(ERROR_MESSAGES)
|
||||||
|
private List<String> errorMessages;
|
||||||
|
@JsonProperty(WARNING_MESSAGES)
|
||||||
|
private List<String> warningMessages;
|
||||||
|
|
||||||
|
@JsonProperty(STATUS)
|
||||||
|
private Status status=Status.OK;
|
||||||
|
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
public Configuration addErrorMessage(String msg){
|
||||||
|
status = Status.ERROR;
|
||||||
|
if(errorMessages==null)
|
||||||
|
errorMessages=new ArrayList<>();
|
||||||
|
errorMessages.add(msg);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
@JsonIgnore
|
||||||
|
public Configuration addWarningMessage(String msg){
|
||||||
|
if(status == null || status.equals(Status.OK))
|
||||||
|
status = Status.WARNING;
|
||||||
|
if(warningMessages==null)
|
||||||
|
warningMessages=new ArrayList<>();
|
||||||
|
warningMessages.add(msg);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ public class GCubeTest {
|
||||||
|
|
||||||
|
|
||||||
//testContext = "/pred4s/preprod/preVRE";
|
//testContext = "/pred4s/preprod/preVRE";
|
||||||
// testContext = "/gcube/devsec/devVRE";
|
testContext = "/gcube/devsec/devVRE";
|
||||||
|
|
||||||
|
|
||||||
System.out.println("TEST CONTEXT = "+testContext);
|
System.out.println("TEST CONTEXT = "+testContext);
|
||||||
|
|
|
@ -387,18 +387,18 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Configuration getConfiguration() throws ConfigurationException {
|
public Configuration getConfiguration() throws ConfigurationException{
|
||||||
log.debug("Asking configuration for {} in {} ", useCaseDescriptor.getId(), UserUtils.getCurrent().getContext());
|
log.debug("Asking configuration for {} in {} ", useCaseDescriptor.getId(), UserUtils.getCurrent().getContext());
|
||||||
Configuration toReturn= new Configuration();
|
Configuration toReturn= new Configuration();
|
||||||
List<Archive> archives = new ArrayList<>();
|
List<Archive> archives = new ArrayList<>();
|
||||||
List<Index> indexes=new ArrayList<>();
|
|
||||||
// Set Basic Info
|
|
||||||
toReturn.setArchives(archives);
|
toReturn.setArchives(archives);
|
||||||
|
List<Index> indexes=new ArrayList<>();
|
||||||
|
toReturn.setIndexes(indexes);
|
||||||
|
// Set Basic Info
|
||||||
toReturn.setProfileId(this.getUseCaseDescriptor().getId());
|
toReturn.setProfileId(this.getUseCaseDescriptor().getId());
|
||||||
toReturn.setContext(ContextUtils.getCurrentScope());
|
toReturn.setContext(ContextUtils.getCurrentScope());
|
||||||
toReturn.setLastUpdatedTime(LocalDateTime.now());
|
toReturn.setLastUpdatedTime(LocalDateTime.now());
|
||||||
|
|
||||||
|
|
||||||
// Add Mongo Info
|
// Add Mongo Info
|
||||||
Archive mongoArchive = new Archive("DOCUMENT-STORE-COLLECTION");
|
Archive mongoArchive = new Archive("DOCUMENT-STORE-COLLECTION");
|
||||||
MongoCollection coll=getCollection();
|
MongoCollection coll=getCollection();
|
||||||
|
@ -411,19 +411,26 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
||||||
// Set WS Info
|
// Set WS Info
|
||||||
try {
|
try {
|
||||||
archives.add(new WorkspaceManager().getConfiguration());
|
archives.add(new WorkspaceManager().getConfiguration());
|
||||||
}catch (StorageHubException e) {
|
}catch (Exception e) {
|
||||||
throw new ConfigurationException("Unable to get WS Configuration",e);
|
toReturn.addErrorMessage("Unable to get WS info "+e.getMessage());
|
||||||
|
log.error("Unable to get WS Configuration",e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ADD LC Infos
|
// ADD LC Infos
|
||||||
|
|
||||||
AccountingInfo user = UserUtils.getCurrent().asInfo();
|
AccountingInfo user = UserUtils.getCurrent().asInfo();
|
||||||
|
try{
|
||||||
Configuration lcConfig = getLCManager().getCurrentConfiguration(new BaseRequest(useCaseDescriptor,user.getUser(),user.getContext()));
|
Configuration lcConfig = getLCManager().getCurrentConfiguration(new BaseRequest(useCaseDescriptor,user.getUser(),user.getContext()));
|
||||||
|
log.info("Configuration is {} ",lcConfig);
|
||||||
if(lcConfig.getArchives()!=null)
|
if(lcConfig.getArchives()!=null)
|
||||||
archives.addAll(lcConfig.getArchives());
|
archives.addAll(lcConfig.getArchives());
|
||||||
|
|
||||||
if(lcConfig.getIndexes()!=null)
|
if(lcConfig.getIndexes()!=null)
|
||||||
indexes.addAll(lcConfig.getIndexes());
|
indexes.addAll(lcConfig.getIndexes());
|
||||||
|
}catch(ConfigurationException e){
|
||||||
|
toReturn.addErrorMessage("Unable to get Lifecycle info "+e.getMessage());
|
||||||
|
log.error("Unable to get Lifecycle info ",e);
|
||||||
|
}
|
||||||
|
|
||||||
log.debug("Returning current configuration {}",toReturn);
|
log.debug("Returning current configuration {}",toReturn);
|
||||||
return toReturn;
|
return toReturn;
|
||||||
|
|
|
@ -13,6 +13,8 @@ import org.gcube.application.geoportal.service.engine.mongo.ProfiledMongoManager
|
||||||
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
|
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
|
||||||
import org.gcube.application.cms.serialization.Serialization;
|
import org.gcube.application.cms.serialization.Serialization;
|
||||||
import org.gcube.application.geoportal.service.engine.providers.ConfigurationCache;
|
import org.gcube.application.geoportal.service.engine.providers.ConfigurationCache;
|
||||||
|
import org.gcube.application.geoportal.service.engine.providers.UCDManager;
|
||||||
|
import org.gcube.application.geoportal.service.model.internal.faults.RegistrationException;
|
||||||
|
|
||||||
import javax.ws.rs.*;
|
import javax.ws.rs.*;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class PostgisIndexer {
|
||||||
dbManager.create(table);
|
dbManager.create(table);
|
||||||
|
|
||||||
log.debug("Checking/ registering index layer in GS ");
|
log.debug("Checking/ registering index layer in GS ");
|
||||||
indexName = indexName;
|
this.indexName = indexName;
|
||||||
indexLayer = manager.configureCentroidLayer(indexName,workspace,storeName,table,connectionParameters);
|
indexLayer = manager.configureCentroidLayer(indexName,workspace,storeName,table,connectionParameters);
|
||||||
|
|
||||||
// TODO Additional layers
|
// TODO Additional layers
|
||||||
|
|
|
@ -4,13 +4,11 @@ import freemarker.core.PlainTextOutputFormat;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
import org.gcube.application.geoportal.common.model.document.filesets.GCubeSDILayer;
|
import org.gcube.application.geoportal.common.model.document.filesets.GCubeSDILayer;
|
||||||
|
import org.gcube.application.geoportal.common.model.document.filesets.Materialization;
|
||||||
import sun.misc.GC;
|
import sun.misc.GC;
|
||||||
|
|
||||||
import javax.print.Doc;
|
import javax.print.Doc;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class GCubeSDILayerBuilder {
|
public class GCubeSDILayerBuilder {
|
||||||
|
|
||||||
|
@ -32,7 +30,7 @@ public class GCubeSDILayerBuilder {
|
||||||
GCubeSDILayer theObject = new GCubeSDILayer();
|
GCubeSDILayer theObject = new GCubeSDILayer();
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
Document platformInfo= new Document(GCubeSDILayer.PLATFORM_INFO,GS_PLATFORM);
|
Document platformInfo= new Document(Materialization.TYPE,GS_PLATFORM);
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
GCubeSDILayer.BBOX bbox = GCubeSDILayer.BBOX.WORLD;
|
GCubeSDILayer.BBOX bbox = GCubeSDILayer.BBOX.WORLD;
|
||||||
|
@ -41,12 +39,11 @@ public class GCubeSDILayerBuilder {
|
||||||
Map<OGC_TYPE,Document> ogcLinks = new HashMap<>();
|
Map<OGC_TYPE,Document> ogcLinks = new HashMap<>();
|
||||||
|
|
||||||
public GCubeSDILayerBuilder(){
|
public GCubeSDILayerBuilder(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public GCubeSDILayer getLayer(){
|
public GCubeSDILayer getLayer(){
|
||||||
theObject.put(GCubeSDILayer.PLATFORM_INFO,platformInfo);
|
theObject.put(GCubeSDILayer.PLATFORM_INFO, Collections.singleton(platformInfo));
|
||||||
theObject.put(GCubeSDILayer.B_BOX,bbox);
|
theObject.put(GCubeSDILayer.B_BOX,bbox);
|
||||||
|
|
||||||
prepareOGCLinks();
|
prepareOGCLinks();
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.gcube.application.cms.plugins.reports.Report;
|
||||||
import org.gcube.application.cms.plugins.requests.BaseRequest;
|
import org.gcube.application.cms.plugins.requests.BaseRequest;
|
||||||
import org.gcube.application.cms.plugins.requests.IndexDocumentRequest;
|
import org.gcube.application.cms.plugins.requests.IndexDocumentRequest;
|
||||||
import org.gcube.application.cms.sdi.engine.PostgisIndexer;
|
import org.gcube.application.cms.sdi.engine.PostgisIndexer;
|
||||||
|
import org.gcube.application.cms.sdi.model.GCubeSDILayerBuilder;
|
||||||
import org.gcube.application.cms.sdi.plugins.SDIIndexerPlugin;
|
import org.gcube.application.cms.sdi.plugins.SDIIndexerPlugin;
|
||||||
import org.gcube.application.cms.serialization.Serialization;
|
import org.gcube.application.cms.serialization.Serialization;
|
||||||
import org.gcube.application.cms.tests.BasicPluginTest;
|
import org.gcube.application.cms.tests.BasicPluginTest;
|
||||||
|
@ -18,6 +19,8 @@ import org.gcube.application.geoportal.common.model.configuration.Index;
|
||||||
import org.gcube.application.geoportal.common.model.document.Project;
|
import org.gcube.application.geoportal.common.model.document.Project;
|
||||||
import org.gcube.application.geoportal.common.model.document.accounting.Context;
|
import org.gcube.application.geoportal.common.model.document.accounting.Context;
|
||||||
import org.gcube.application.geoportal.common.model.document.accounting.User;
|
import org.gcube.application.geoportal.common.model.document.accounting.User;
|
||||||
|
import org.gcube.application.geoportal.common.model.document.filesets.GCubeSDILayer;
|
||||||
|
import org.gcube.application.geoportal.common.model.document.filesets.Materialization;
|
||||||
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
|
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
|
||||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||||
import org.gcube.application.geoportal.common.utils.Files;
|
import org.gcube.application.geoportal.common.utils.Files;
|
||||||
|
@ -26,8 +29,7 @@ import org.gcube.spatial.data.geonetwork.utils.UserUtils;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import ucar.units.Base;
|
import ucar.units.Base;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static junit.framework.TestCase.*;
|
||||||
import static junit.framework.TestCase.assertTrue;
|
|
||||||
import static org.junit.Assume.assumeTrue;
|
import static org.junit.Assume.assumeTrue;
|
||||||
|
|
||||||
public class IndexerTest extends BasicPluginTest {
|
public class IndexerTest extends BasicPluginTest {
|
||||||
|
@ -58,7 +60,7 @@ public class IndexerTest extends BasicPluginTest {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getIndex() throws ConfigurationException {
|
public void getIndex() throws ConfigurationException, JsonProcessingException {
|
||||||
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
||||||
IndexerPluginInterface plugin = (IndexerPluginInterface) plugins.get(SDIIndexerPlugin.DESCRIPTOR.getId());
|
IndexerPluginInterface plugin = (IndexerPluginInterface) plugins.get(SDIIndexerPlugin.DESCRIPTOR.getId());
|
||||||
UseCaseDescriptor descriptor=TestProfiles.profiles.get("profiledConcessioni");
|
UseCaseDescriptor descriptor=TestProfiles.profiles.get("profiledConcessioni");
|
||||||
|
@ -68,6 +70,17 @@ public class IndexerTest extends BasicPluginTest {
|
||||||
.setParameter("indexName",Files.fixFilename(GCubeTest.getContext()+"test_index")));
|
.setParameter("indexName",Files.fixFilename(GCubeTest.getContext()+"test_index")));
|
||||||
System.out.println("Test Index Is "+index);
|
System.out.println("Test Index Is "+index);
|
||||||
assertEquals(index.getType(), PostgisIndexer.INDEX_TYPE);
|
assertEquals(index.getType(), PostgisIndexer.INDEX_TYPE);
|
||||||
|
assertNotNull(index.get("layer"));
|
||||||
|
assertNotNull(index.get("indexName"));
|
||||||
|
GCubeSDILayer layer = Serialization.convert(index.get("layer"),GCubeSDILayer.class);
|
||||||
|
assertEquals(GCubeSDILayer.GCUBE_SDY_LAYER_TYPE,layer.getType());
|
||||||
|
|
||||||
|
for (Object pIObj : layer.getPlatformInfo()){
|
||||||
|
Document platformDoc = Serialization.asDocument(pIObj);
|
||||||
|
assertEquals(GCubeSDILayerBuilder.GS_PLATFORM,platformDoc.get(Materialization.TYPE));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue