2018-04-06 11:40:20 +02:00
|
|
|
package org.gcube.context;
|
|
|
|
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
|
2018-05-18 16:38:19 +02:00
|
|
|
import org.gcube.resourcemanagement.support.server.managers.context.ContextManager;
|
2019-11-15 12:01:39 +01:00
|
|
|
import org.gcube.resourcemanagement.support.shared.types.datamodel.D4SEnvironment;
|
2018-04-06 11:40:20 +02:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Luca Frosini (ISTI - CNR)
|
|
|
|
*/
|
|
|
|
public abstract class ContextElaborator {
|
|
|
|
|
|
|
|
protected Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
|
|
|
|
|
|
public ContextElaborator(){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-05-18 16:38:19 +02:00
|
|
|
public void all() throws Exception{
|
2018-04-06 11:40:20 +02:00
|
|
|
try {
|
2019-11-15 12:01:39 +01:00
|
|
|
LinkedHashMap<String, D4SEnvironment> contexts = ContextManager.readContextsWithUUIDs();
|
|
|
|
for (String context : contexts.keySet()) {
|
|
|
|
D4SEnvironment d4sEnvironment = contexts.get(context);
|
|
|
|
try {
|
2018-04-06 11:40:20 +02:00
|
|
|
logger.debug("Going to elaborate {}", context);
|
2019-11-15 12:01:39 +01:00
|
|
|
elaborateContext(d4sEnvironment);
|
2018-04-06 11:40:20 +02:00
|
|
|
}catch (Exception e) {
|
2019-11-15 12:01:39 +01:00
|
|
|
logger.error("Error while elaborating {}", context, e);
|
2018-04-06 11:40:20 +02:00
|
|
|
throw e;
|
|
|
|
}
|
2019-11-15 12:01:39 +01:00
|
|
|
}
|
2018-04-06 11:40:20 +02:00
|
|
|
} catch (Exception ex) {
|
|
|
|
throw ex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-15 12:01:39 +01:00
|
|
|
protected abstract void elaborateContext(D4SEnvironment d4sEnvironment) throws Exception;
|
2018-04-06 11:40:20 +02:00
|
|
|
}
|