@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (isXmlFile(file)) { try { Profile profile = transformator.unmarshall(file, schemaPath, ISchemaVersionAware.ConfigurationInterface.SCHEMA_VERSION, pathResolver.getMigrationPath(), Profile.class); existingProfiles.put(profile.getId(), profile); } catch (JAXBException | SAXException e) { log.error("Error reading existing Configuration interface profile file. File path: " + file.toString() + ".", e); } } return FileVisitResult.CONTINUE; } });
@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; } });
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { if (isXmlFile(file)) { try { Environment environment = transformator.unmarshall(file, schemaPath, ISchemaVersionAware.ConfigurationInterface.SCHEMA_VERSION, pathResolver.getMigrationPath(), Environment.class); existingEnvironments.put(environment.getId(), environment); // if checking of the profile made a change, save it if (checkProfiles(environment)) { try { saveEnvironment(environment); log.info("Environment '" + environment.getName() + "' was auto-updated as it was referencing the non-existing profile(s)."); } catch (IOException | JAXBException e) { log.error("Error updating existing Configuration interface environment file. File path: " + file.toString() + ".", e); } } } catch (JAXBException | SAXException e) { log.error("Error reading existing Configuration interface environment file. File path: " + file.toString() + ".", e); } } return FileVisitResult.CONTINUE; } });
/** * 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); }
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());