/** * parses a ContextId object from a Map-representation used in * {@link org.openengsb.core.api.persistence.ConfigPersistenceService} */ public static ContextId fromMetaData(Map<String, String> metaData) { return new ContextId(metaData.get(META_KEY_ID)); }
/** * parses a ContextId object from a Map-representation used in * {@link org.openengsb.core.api.persistence.ConfigPersistenceService} */ public static ContextId fromMetaData(Map<String, String> metaData) { return new ContextId(metaData.get(META_KEY_ID)); }
@Override public void createContext(String contextId) { LOGGER.debug("Creating context %s", contextId); ContextConfiguration contextConfiguration = new ContextConfiguration(new ContextId(contextId).toMetaData(), null); try { getConfigPersistenceService().persist(contextConfiguration); } catch (InvalidConfigurationException e) { LOGGER.error("Error storing context " + contextId + ": Invalid configuration", e); } catch (PersistenceException e) { LOGGER.error("Error storing context " + contextId + ": Persistence error", e); } }
private Context getContextById(String currentContextId) { ContextId contextId = new ContextId(currentContextId); List<ContextConfiguration> contexts = getContextConfigurationsOrEmptyOnError(contextId.toMetaData()); if (contexts.isEmpty()) { return null; } return contexts.get(0).toContext(); }
@Override public void deleteContext(String contextId) { LOGGER.debug("deleting context {}", contextId); try { getConfigPersistenceService().remove(new ContextId(contextId).toMetaData()); } catch (PersistenceException e) { throw new RuntimeException(e); } }