/** * Deletes the existing environment. * * @param environment * Environment to delete. * @throws IOException * If {@link IOException} occurs during delete. */ public void deleteEnvironment(Environment environment) throws IOException { String id = environment.getId(); Environment local = existingEnvironments.remove(id); if (null != local) { Files.deleteIfExists(pathResolver.getEnvironmentFilePath(local)); AgentMappings agentMappings = agentMappingsReference.get(); if (checkEnvironments(agentMappings)) { try { saveAgentMappings(agentMappings, false); } catch (Exception e) { log.error("Update of the agent mappings on the environment deletion failed.", e); } } } }
/** * Saves {@link Environment} to the disk. * * @param environment * {@link Environment} to save. * @throws IOException * If {@link IOException} occurs. * @throws JAXBException * If {@link JAXBException} occurs. If saving fails. */ private void saveEnvironment(Environment environment) throws JAXBException, IOException { transformator.marshall(pathResolver.getEnvironmentFilePath(environment), environment, getRelativeToSchemaPath(pathResolver.getEnvironmentPath()).toString(), ISchemaVersionAware.ConfigurationInterface.SCHEMA_VERSION); }
@Override public Path answer(InvocationOnMock invocation) throws Throwable { return Paths.get(TEST_FOLDER).resolve(EXT_RESOURCES_PATH.relativize(resolverHelper.getEnvironmentPath())) .resolve(EXT_RESOURCES_PATH.relativize(resolverHelper.getEnvironmentFilePath((Environment) invocation.getArguments()[0]))); } }).when(pathResolver).getEnvironmentFilePath(Matchers.<Environment> any());
/** * Imports the environment. Note that if environment with the same id already exists it will be * overwritten. * * @param environment * Environment. * @return Returns created/updated environment depending if the overwrite was executed. * @throws BusinessException * If attempt is made to import environment without the id. * @throws IOException * If {@link IOException} occurs during save. * @throws JAXBException * If {@link JAXBException} occurs during save. */ public Environment importEnvironment(Environment environment) throws BusinessException, JAXBException, IOException { if (null == environment.getId()) { throw new BusinessException("Import the environment '" + environment.getName() + "'.", ConfigurationInterfaceErrorCodeEnum.IMPORT_DATA_NOT_VALID); } environment.setImportDate(new Date()); if (existingEnvironments.containsKey(environment.getId())) { Environment old = existingEnvironments.replace(environment.getId(), environment); Files.deleteIfExists(pathResolver.getEnvironmentFilePath(old)); } else { existingEnvironments.put(environment.getId(), environment); } checkProfiles(environment); saveEnvironment(environment); return environment; }
.resolve(EXT_RESOURCES_PATH.relativize(resolverHelper.getEnvironmentFilePath((Environment) invocation.getArguments()[0]))); }).when(pathResolver).getEnvironmentFilePath(Matchers.<Environment> any()); doAnswer(new Answer<Path>() { @Override
Files.deleteIfExists(pathResolver.getEnvironmentFilePath(local));