/** * Returns given path relative to schema part. * * @param path * path to relativize * @return path relative to schema part * @see #getSchemaPath() */ private Path getRelativeToSchemaPath(Path path) { return path.relativize(pathResolver.getSchemaPath()); }
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (isXmlFile(file)) { try { AlertingDefinition alertingDefinition = transformator.unmarshall(file, pathResolver.getSchemaPath(), ISchemaVersionAware.ConfigurationInterface.SCHEMA_VERSION, pathResolver.getMigrationPath(), AlertingDefinition.class); existingAlertingDefinitions.put(alertingDefinition.getId(), alertingDefinition); } catch (JAXBException | SAXException e) { log.error("Error reading existing alerting definition file. File path: " + file.toString() + ".", e); } } return FileVisitResult.CONTINUE; } });
final Path schemaPath = pathResolver.getSchemaPath();
/** * Returns the {@link ConfigurationInterfaceImportData} from the given import data bytes. * * @param importData * bytes that were exported. * @return {@link ConfigurationInterfaceImportData}. * @throws SAXException * IF {@link SAXException} occurs during unmarshall. * @throws IOException * If {@link IOException} occurs during unmarshall. * @throws JAXBException * If {@link JAXBException} occurs during unmarshall. */ public ConfigurationInterfaceImportData getImportData(byte[] importData) throws JAXBException, IOException, SAXException { return transformator.unmarshall(importData, pathResolver.getSchemaPath(), ISchemaVersionAware.ConfigurationInterface.SCHEMA_VERSION, pathResolver.getMigrationPath(), ConfigurationInterfaceImportData.class); }
/** * Loads the business context definition if it is not already loaded. If successfully loaded * definition will be placed in the {@link #businessContextDefinition} field. */ private void loadBusinessContextDefinition() { log.info("|-Loading the business context definition"); Path path = pathResolver.getBusinessContextFilePath(); BusinessContextDefinition businessContextDefinition = null; if (Files.exists(path)) { try { businessContextDefinition = transformator.unmarshall(path, pathResolver.getSchemaPath(), ISchemaVersionAware.ConfigurationInterface.SCHEMA_VERSION, pathResolver.getMigrationPath(), BusinessContextDefinition.class); } catch (JAXBException | IOException | SAXException e) { log.error("Error loading Configuration interface business context file. File path: " + path.toString() + ".", e); } } if (null == businessContextDefinition) { businessContextDefinition = new BusinessContextDefinition(); try { saveBusinessContext(businessContextDefinition); } catch (JAXBException | IOException e) { log.error("Error saving Configuration interface business context file. File path: " + path.toString() + ".", e); } } businessContextDefinitionReference.set(businessContextDefinition); }
final Path schemaPath = pathResolver.getSchemaPath();
agentMappings = transformator.unmarshall(path, pathResolver.getSchemaPath(), ISchemaVersionAware.ConfigurationInterface.SCHEMA_VERSION, pathResolver.getMigrationPath(), AgentMappings.class); } catch (JAXBException | IOException | SAXException e) { agentMappings = new AgentMappings(Collections.<AgentMapping> emptyList());
when(pathResolver.getEnvironmentPath()).thenReturn(Paths.get(TEST_FOLDER).resolve(EXT_RESOURCES_PATH.relativize(resolverHelper.getEnvironmentPath()))); when(pathResolver.getProfilesPath()).thenReturn(Paths.get(TEST_FOLDER).resolve(EXT_RESOURCES_PATH.relativize(resolverHelper.getProfilesPath()))); when(pathResolver.getSchemaPath()).thenReturn(Paths.get(TEST_FOLDER).resolve(EXT_RESOURCES_PATH.relativize(resolverHelper.getSchemaPath()))); when(pathResolver.getBusinessContextFilePath()).thenReturn(Paths.get(TEST_FOLDER).resolve(EXT_RESOURCES_PATH.relativize(resolverHelper.getBusinessContextFilePath()))); when(pathResolver.getAlertingDefinitionsPath()).thenReturn(Paths.get(TEST_FOLDER).resolve(EXT_RESOURCES_PATH.relativize(resolverHelper.getAlertingDefinitionsPath())));