/** * @param allowAll * @param mustExist * @return */ protected Object lookupBackupExecutionsContext(String i, boolean allowAll, boolean mustExist) { if (i != null) { BackupExecutionAdapter backupExecution = null; try { backupExecution = getBackupFacade().getBackupExecutions().get(Long.parseLong(i)); } catch (NumberFormatException e) { } if (backupExecution == null && mustExist) { throw new ResourceNotFoundException("No such backup execution: " + i); } return backupExecution; } else { if (allowAll) { return new ArrayList<BackupExecutionAdapter>( getBackupFacade().getBackupExecutions().values()); } throw new ResourceNotFoundException("No backup execution specified"); } }
/** * @param allowAll * @param mustExist * @return */ protected Object lookupRestoreExecutionsContext(String i, boolean allowAll, boolean mustExist) { if (i != null) { RestoreExecutionAdapter restoreExecution = null; try { restoreExecution = getBackupFacade().getRestoreExecutions().get(Long.parseLong(i)); } catch (NumberFormatException e) { } if (restoreExecution == null && mustExist) { throw new ResourceNotFoundException("No such restore execution: " + i); } return restoreExecution; } else { if (allowAll) { return new ArrayList<RestoreExecutionAdapter>( getBackupFacade().getRestoreExecutions().values()); } throw new ResourceNotFoundException("No backup execution specified"); } }
@DeleteMapping( path = "backup/{backupId:.+}", produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.TEXT_XML_VALUE, MediaType.APPLICATION_XML_VALUE } ) public Object backupDelete( @RequestParam(name = "format", required = false) String format, @PathVariable String backupId) throws IOException { final String executionId = getExecutionIdFilter(backupId); Object lookup = lookupBackupExecutionsContext(executionId, true, false); if (lookup != null) { if (lookup instanceof BackupExecutionAdapter) { try { getBackupFacade().abandonExecution(Long.valueOf(executionId)); } catch (Exception e) { throw new IOException(e); } return wrapObject((BackupExecutionAdapter) lookup, BackupExecutionAdapter.class); } else { return wrapList( (List<BackupExecutionAdapter>) lookup, BackupExecutionAdapter.class); } } return null; }
/** @throws InterruptedException */ protected void ensureCleanedQueues() throws InterruptedException { int cnt = 0; while (!(backupFacade.getRestoreRunningExecutions().isEmpty() && backupFacade.getBackupRunningExecutions().isEmpty())) { if (cnt > 30) { LOGGER.log(Level.SEVERE, "Could not cleanup Running Executions Queues!"); break; } // Wait a bit Thread.sleep(10); cnt++; } } }
backupFacade.runRestoreAsync( file("geoserver-full-backup.zip"), null, null, null, hints); assertNotNull(backupFacade.getRestoreExecutions()); assertTrue(!backupFacade.getRestoreExecutions().isEmpty()); backupFacade.stopExecution(restoreExecution.getId());
backupFacade.runBackupAsync( Files.asResource(backupFile), true, null, null, null, params); assertNotNull(backupFacade.getBackupExecutions()); assertTrue(!backupFacade.getBackupExecutions().isEmpty()); assertNotNull(backupExecution); backupFacade.stopExecution(backupExecution.getId());
Backup.PARAM_BEST_EFFORT_MODE)); backupFacade.runBackupAsync( Files.asResource(File.createTempFile("testRunSpringBatchBackupJob", ".zip")), true, hints); try { backupFacade.runBackupAsync( Files.asResource(File.createTempFile("testRunSpringBatchBackupJob", ".zip")), true, assertNotNull(backupFacade.getBackupExecutions()); assertTrue(!backupFacade.getBackupExecutions().isEmpty()); assertEquals(backupFacade.getBackupRunningExecutions().size(), 1); backupFacade.getBackupExecutions().values().iterator(); while (iterator.hasNext()) { backupExecution = iterator.next();
backupFacade.runBackupAsync( Files.asResource( File.createTempFile("testRunSpringBatchBackupJob", ".zip")), assertNotNull(backupFacade.getBackupExecutions()); assertTrue(!backupFacade.getBackupExecutions().isEmpty()); assertNotNull(backupExecution);
backupFacade.runRestoreAsync( file("geoserver-full-backup.zip"), filter, null, null, hints); assertNotNull(backupFacade.getRestoreExecutions()); assertTrue(!backupFacade.getRestoreExecutions().isEmpty());
getBackupFacade().restartExecution(restore.getId()); .runRestoreAsync( restore.getArchiveFile(), restore.getWsFilter(),
getBackupFacade().restartExecution(backup.getId()); .runBackupAsync( backup.getArchiveFile(), backup.isOverwrite(),
backupFacade.runBackupAsync( Files.asResource( File.createTempFile("testRunSpringBatchBackupJob", ".zip")), backupFacade.stopExecution(backupExecution.getId());
@Test public void testStyleInfoAdditionalResourceWriter() throws IOException { GeoServerDataDirectory dd = backupFacade.getGeoServerDataDirectory(); GeoServerDataDirectory td = new GeoServerDataDirectory(root); StyleInfo style = catalog.getStyleByName(StyleInfo.DEFAULT_POINT); StyleInfoAdditionalResourceWriter siarw = new StyleInfoAdditionalResourceWriter(); siarw.writeAdditionalResources(backupFacade, td.get(Paths.BASE), style); Resource srcStylesDir = BackupUtils.dir(dd.get(Paths.BASE), "styles"); Resource trgStylesDir = BackupUtils.dir(td.get(Paths.BASE), "styles"); assertTrue(Resources.exists(srcStylesDir)); assertTrue(Resources.exists(trgStylesDir)); assertTrue( Resources.exists( Files.asResource(new File(trgStylesDir.dir(), style.getFilename())))); }
backupFacade.getCatalog().getResourcePool().clone((CoverageStoreInfo) item, true); final String mosaicName = mosaicCoverageStore.getName(); final String mosaicUrlBase = mosaicCoverageStore.getURL();
/** @return the backupFacade */ public Backup getBackupFacade() { backupFacade.authenticate(); return backupFacade; }
backupFacade.runRestoreAsync( file("settings-modified-restore.zip"), null, null, null, params); assertNotNull(backupFacade.getRestoreExecutions()); assertTrue(!backupFacade.getRestoreExecutions().isEmpty()); backupFacade.stopExecution(restoreExecution.getId());
backupFacade.runBackupAsync( Files.asResource(parameterizedBackup), true, null, null, null, hints); assertNotNull(backupFacade.getBackupExecutions()); assertTrue(!backupFacade.getBackupExecutions().isEmpty()); assertNotNull(backupExecution); backupFacade.stopExecution(backupExecution.getId());
Catalog cat = getCatalog(); GeoServerDataDirectory dd = backupFacade.getGeoServerDataDirectory(); GeoServerDataDirectory td = new GeoServerDataDirectory(root);
backupFacade.getCatalog().getResourcePool().clone((CoverageStoreInfo) item, true); final String mosaicName = mosaicCoverageStore.getName(); final String mosaicUrlBase = mosaicCoverageStore.getURL();
backupFacade.runRestoreAsync( file("parameterized-restore.zip"), null, null, null, hints); assertNotNull(backupFacade.getRestoreExecutions()); assertTrue(!backupFacade.getRestoreExecutions().isEmpty()); backupFacade.stopExecution(restoreExecution.getId());