public Iterator<ImportContext> getContexts() { return contextStore.allNonCompleteImports(); }
public Iterator<ImportContext> getContextsByUser(String user) { return contextStore.importsByUser(user); }
public Iterator<ImportContext> getAllContexts() { return contextStore.iterator(); }
/** * Create a context with the provided optional id. * The provided id must be higher than the current mark. * @param id optional id to use * @return Created ImportContext * @throws IOException * @throws IllegalArgumentException if the provided id is invalid */ public ImportContext createContext(Long id) throws IOException, IllegalArgumentException { ImportContext context = new ImportContext(); if (id != null) { Long retval = contextStore.advanceId(id); assert retval >= id; context.setId(retval); contextStore.save(context); } else { contextStore.add(context); } return context; }
@Test public void testIDManagement() throws Exception { ImportStore store = new MemoryImportStore(); // verify base - first one is zero ImportContext zero = new ImportContext(); store.add(zero); assertEquals(new Long(0), zero.getId()); // try for zero again (less than current case - client out of sync) Long advanceId = store.advanceId(0L); assertEquals(new Long(1), advanceId); // and again for current (equals current case - normal mode) advanceId = store.advanceId(2L); assertEquals(new Long(2), advanceId); // now jump ahead (client advances case - server out of sync) advanceId = store.advanceId(666L); assertEquals(new Long(666), advanceId); // the next created import should be one higher ImportContext dumby = new ImportContext(); store.add(dumby); assertEquals(new Long(667), dumby.getId()); } }
public ImportContext createContext(ImportData data, WorkspaceInfo targetWorkspace, StoreInfo targetStore, ProgressMonitor monitor) throws IOException { ImportContext context = new ImportContext(); context.setProgress(monitor); context.setData(data); if (targetWorkspace == null && targetStore != null) { targetWorkspace = targetStore.getWorkspace(); } if (targetWorkspace == null) { targetWorkspace = catalog.getDefaultWorkspace(); } context.setTargetWorkspace(targetWorkspace); context.setTargetStore(targetStore); init(context); if (!context.progress().isCanceled()) { contextStore.add(context); } //JD: don't think we really need to maintain these, and they aren't persisted //else { // context.setState(ImportContext.State.CANCELLED); //} return context; }
public void delete(ImportContext importContext, boolean purge) throws IOException { if (purge) { importContext.delete(); } contextStore.remove(importContext); }
@Override public void onApplicationEvent(ApplicationEvent event) { // load the context store here to avoid circular dependency on creation of the importer if (event instanceof ContextLoadedEvent) { contextStore = createContextStore(); contextStore.init(); } }
public ImportContext getContext(long id) { ImportContext context = contextStore.get(id); return context != null ? reattach(context) : null; }
public void destroy() throws Exception { jobs.shutdown(); contextStore.destroy(); }
ImportStore createContextStore() { // check the spring context for an import store ImportStore store = null; String name = GeoServerExtensions.getProperty("org.geoserver.importer.store"); if (name == null) { // backward compatability check name = GeoServerExtensions.getProperty("org.opengeo.importer.store"); } if (name != null) { for (ImportStore bean : GeoServerExtensions.extensions(ImportStore.class)) { if (name.equals(bean.getName())) { store = bean; break; } } if (store == null) { LOGGER.warning("Invalid value for import store, no such store " + name); } } if (store == null) { store = new MemoryImportStore(); } LOGGER.info("Enabling import store: " + store.getName()); return store; }
/** * Create a context with the provided optional id. The provided id must be higher than the * current mark. * * @param id optional id to use * @return Created ImportContext * @throws IOException * @throws IllegalArgumentException if the provided id is invalid */ public ImportContext createContext(Long id) throws IOException, IllegalArgumentException { ImportContext context = new ImportContext(); if (id != null) { Long retval = contextStore.advanceId(id); assert retval >= id; context.setId(retval); contextStore.save(context); } else { contextStore.add(context); } return context; }
public ImportContext createContext( ImportData data, WorkspaceInfo targetWorkspace, StoreInfo targetStore, ProgressMonitor monitor) throws IOException { ImportContext context = new ImportContext(); context.setProgress(monitor); context.setData(data); if (targetWorkspace == null && targetStore != null) { targetWorkspace = targetStore.getWorkspace(); } if (targetWorkspace == null) { targetWorkspace = catalog.getDefaultWorkspace(); } context.setTargetWorkspace(targetWorkspace); context.setTargetStore(targetStore); init(context); if (!context.progress().isCanceled()) { contextStore.add(context); } // JD: don't think we really need to maintain these, and they aren't persisted // else { // context.setState(ImportContext.State.CANCELLED); // } return context; }
public void delete(ImportContext importContext, boolean purge) throws IOException { if (purge) { importContext.delete(); } contextStore.remove(importContext); }
@Override public void onApplicationEvent(ApplicationEvent event) { // load the context store here to avoid circular dependency on creation of the importer if (event instanceof ContextLoadedEvent) { contextStore = createContextStore(); contextStore.init(); } }
public ImportContext getContext(long id) { ImportContext context = contextStore.get(id); return context != null ? reattach(context) : null; }
public void destroy() throws Exception { jobs.shutdown(); contextStore.destroy(); }
ImportStore createContextStore() { // check the spring context for an import store ImportStore store = null; String name = GeoServerExtensions.getProperty("org.geoserver.importer.store"); if (name == null) { //backward compatability check name = GeoServerExtensions.getProperty("org.opengeo.importer.store"); } if (name != null) { for (ImportStore bean : GeoServerExtensions.extensions(ImportStore.class)) { if (name.equals(bean.getName())) { store = bean; break; } } if (store == null) { LOGGER.warning("Invalid value for import store, no such store " + name); } } if (store == null) { store = new MemoryImportStore(); } LOGGER.info("Enabling import store: " + store.getName()); return store; }
public Iterator<ImportContext> getAllContexts() { return contextStore.iterator(); }
public Iterator<ImportContext> getContexts() { return contextStore.allNonCompleteImports(); }