#22461 #1

Merged
fabio.sinibaldi merged 27 commits from #22461 into master 2022-01-14 12:43:19 +01:00
16 changed files with 78 additions and 73 deletions
Showing only changes of commit 5ced0095d6 - Show all commits

View File

@ -4,7 +4,7 @@ import org.gcube.application.cms.plugins.faults.InitializationException;
import org.gcube.application.cms.plugins.faults.ShutDownException;
import org.gcube.application.cms.plugins.reports.InitializationReport;
public interface InitializablePlugin {
public interface InitializablePlugin extends Plugin{
/**
* To be called once per context
* @return

View File

@ -13,6 +13,8 @@ public class PluginDescriptor {
@NonNull
private String ID;
@NonNull
private String type;
private String label;
private String description;
private ComparableVersion version;

View File

@ -41,7 +41,7 @@ public class SerializationTest {
System.out.println("Profile is "+mapper.writeValueAsString(concessione));
Assert.assertTrue(concessione.getFields().size()>0);
//Assert.assertTrue(concessione .getFields().size()>0);
}

View File

@ -1,7 +0,0 @@
package org.gcube.application.geoportal.common.model.profile;
public class DefaultCompiler {
}

View File

@ -1,12 +0,0 @@
package org.gcube.application.geoportal.common.model.profile;
import lombok.Data;
import lombok.Getter;
@Data
public class Field {
}

View File

@ -1,7 +0,0 @@
package org.gcube.application.geoportal.common.model.profile;
public class FieldMapping {
}

View File

@ -0,0 +1,12 @@
package org.gcube.application.geoportal.common.model.profile;
import lombok.Data;
import org.bson.Document;
@Data
public class HandlerDeclaration {
private String id;
private String type;
private Document configuration;
}

View File

@ -1,7 +0,0 @@
package org.gcube.application.geoportal.common.model.profile;
public class IndexDefinition {
}

View File

@ -1,7 +0,0 @@
package org.gcube.application.geoportal.common.model.profile;
public class IsoMapper {
private String className;
}

View File

@ -7,19 +7,23 @@ import javax.xml.bind.annotation.XmlRootElement;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.bson.Document;
import org.gcube.application.geoportal.common.model.document.AccountingInfo;
import org.gcube.application.geoportal.common.model.document.ComparableVersion;
@Data
@NoArgsConstructor
@XmlRootElement
public class Profile{
private String name;
private String id;
private List<Field> fields;
private List<DefaultCompiler> defaultCompilers;
private List<Validator> validators;
private IsoMapper isoMapper;
private List<FieldMapping> centroidsMapping;
private List<IndexDefinition> indexes;
private ComparableVersion version;
private String name;
private String description;
private AccountingInfo creationInfo;
private Document schema;
private List<HandlerDeclaration> handlers;
}

View File

@ -1,5 +0,0 @@
package org.gcube.application.geoportal.common.model.profile;
public class Validator {
}

View File

@ -38,9 +38,9 @@ public class ImplementationProvider {
@Setter
private ISProvider isProvider=new ISProvider();
// @Getter
// @Setter
// private EMFProvider emfProvider=new ScopedEMFProvider();
@Getter
@Setter
private ProfileMapCache profiles=new ProfileMapCache();
@Getter

View File

@ -8,7 +8,9 @@ import org.bson.types.ObjectId;
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
import org.gcube.application.geoportal.common.model.legacy.Concessione;
import org.gcube.application.geoportal.common.model.legacy.report.ValidationReport;
import org.gcube.application.geoportal.common.model.profile.Profile;
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
import org.gcube.application.geoportal.service.engine.ImplementationProvider;
import org.gcube.application.geoportal.service.model.internal.faults.ConfigurationException;
import org.gcube.application.geoportal.service.model.internal.faults.DeletionException;
import org.gcube.application.geoportal.service.utils.Serialization;
@ -17,6 +19,7 @@ import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.security.InvalidParameterException;
import java.util.Map;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.function.Consumer;
@ -26,16 +29,13 @@ import static org.gcube.application.geoportal.service.engine.mongo.ConcessioniMo
public class ProfiledMongoManager extends MongoManager implements MongoManagerI<ProfiledDocument>{
String profileId;
Profile profile;
public ProfiledMongoManager(String profileId) throws ConfigurationException {
if(profileId==null) throw new InvalidParameterException("Profile ID cannot be null");
//check profile existance
//ProfileManager.get(profileId);
// TODO GET FROM PROFILES
if (!profileId.equals("profiled-concessioni")) throw new WebApplicationException("Profile "+profileId+" not registered", Response.Status.NOT_FOUND);
Map<String,Profile> profiles=ImplementationProvider.get().getProfiles().getObject();
if(!profiles.containsKey(profileId))
throw new WebApplicationException("Profile "+profileId+" not registered", Response.Status.NOT_FOUND);
}
private ProfiledDocument onUpdate(ProfiledDocument updatedDocument){

View File

@ -1,12 +1,19 @@
package org.gcube.application.geoportal.service.engine.providers;
import com.fasterxml.jackson.core.JsonProcessingException;
import lombok.extern.slf4j.Slf4j;
import org.gcube.application.geoportal.common.model.profile.Profile;
import org.gcube.application.geoportal.common.utils.Files;
import org.gcube.application.geoportal.service.model.internal.faults.ConfigurationException;
import org.gcube.application.geoportal.service.utils.Serialization;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@Slf4j
public class ProfileMapCache extends AbstractScopedMap<Map<String,Profile>> {
public ProfileMapCache() {
@ -26,16 +33,25 @@ public class ProfileMapCache extends AbstractScopedMap<Map<String,Profile>> {
@Override
protected Map<String, Profile> retrieveObject() throws ConfigurationException {
// TODO Auto-generated method stub
Profile p=new Profile();
p.
return Collections.singletonMap("")
// Load from resources
HashMap<String,Profile> toReturn=new HashMap<>();
try {
Profile p=Serialization.read(Files.
readFileAsString(Files.getFileFromResources("profiles/concessione.json").getAbsolutePath(), Charset.defaultCharset()), Profile.class);
log.debug("Loaded "+p.getName()+" ID "+p.getId());
toReturn.put(p.getId(),p);
return null;
}catch (JsonProcessingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return toReturn;
}
}

View File

@ -0,0 +1,16 @@
{
"id" : "concessione",
"version" : "1.0.0",
"name" : "Concessione",
"description" : "Embedded profile for concessioni [mibac] management",
"creationInfo": {
"user" : {
"username": "fabio.sinibaldi"
}
},
"handlers" : [
{
"id" : "concessioniLifecycle",
"type" : "LifecycleManagement"}
]
}

View File

@ -17,7 +17,7 @@ import static org.junit.Assert.assertEquals;
public class ProjectTests extends BasicServiceTestUnit{
String testProfileId="profiled-concessioni";
String testProfileId="concessione";
@Before
public void setContext(){