context-enumeration/src/main/java/org/gcube/context/ContextElaborator.java

42 lines
996 B
Java

package org.gcube.context;
import java.util.LinkedHashMap;
import org.gcube.common.scope.impl.ScopeBean;
import org.gcube.resourcemanagement.support.server.managers.context.ContextManager;
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(){
}
public void all() throws Exception{
try {
LinkedHashMap<String,ScopeBean> map = ContextManager.readContexts();
for(String scope : map.keySet()) {
try {
String context = map.get(scope).toString();
logger.debug("Going to elaborate {}", context);
elaborateContext(map.get(scope));
}catch (Exception e) {
logger.error("Error while elaborating {}", scope, e);
throw e;
}
}
} catch (Exception ex) {
throw ex;
}
}
protected abstract void elaborateContext(ScopeBean scopeBean) throws Exception;
}