@Override public String getProperty(LogicalPath propertyFilePath, String propertyFilename, String prefix, String key) { Validate.notNull(prefix, "Prefix could be blank but not null"); Validate.notNull(propertyFilePath, "Property file path required"); Validate.notBlank(propertyFilename, "Property filename required"); Validate.notBlank(key, "Key required"); final String filePath = getProjectOperations().getPathResolver().getIdentifier(propertyFilePath, propertyFilename); MutableFile mutableFile = null; final Properties props = new Properties(); if (getFileManager().exists(filePath)) { mutableFile = getFileManager().updateFile(filePath); loadProperties(props, mutableFile.getInputStream()); } else { return null; } // Including prefix if needed if (StringUtils.isNotBlank(prefix)) { key = prefix.concat(".").concat(key); } return props.getProperty(key); }
@Override public void removePropertiesByPrefix(LogicalPath propertyFilePath, String propertyFilename, String prefix) { Validate.notBlank(prefix, "Prefix required"); Validate.notNull(propertyFilePath, "Property file path required"); Validate.notBlank(propertyFilename, "Property filename required"); final String filePath = getProjectOperations().getPathResolver().getIdentifier(propertyFilePath, propertyFilename); MutableFile mutableFile = null; final Properties props = new Properties(); if (getFileManager().exists(filePath)) { mutableFile = getFileManager().updateFile(filePath); loadProperties(props, mutableFile.getInputStream()); } else { throw new IllegalStateException(String.format("ERROR: '%s' properties file doesn't exists.", filePath)); } for (Entry property : props.entrySet()) { String key = (String) property.getKey(); if (key != null && key.startsWith(prefix)) { props.remove(key); } } storeProps(props, mutableFile.getOutputStream(), "Updated at " + new Date()); }
@Override public void removeProperty(LogicalPath propertyFilePath, String propertyFilename, String prefix, String key) { Validate.notNull(prefix, "Prefix could be blank but not null"); Validate.notNull(propertyFilePath, "Property file path required"); Validate.notBlank(propertyFilename, "Property filename required"); Validate.notBlank(key, "Key required"); final String filePath = getProjectOperations().getPathResolver().getIdentifier(propertyFilePath, propertyFilename); MutableFile mutableFile = null; final Properties props = new Properties(); if (getFileManager().exists(filePath)) { mutableFile = getFileManager().updateFile(filePath); loadProperties(props, mutableFile.getInputStream()); } else { throw new IllegalStateException(String.format("ERROR: '%s' properties file doesn't exists.", filePath)); } // Including prefix if needed if (StringUtils.isNotBlank(prefix)) { key = prefix.concat(".").concat(key); } if (props.containsKey(key)) { props.remove(key); storeProps(props, mutableFile.getOutputStream(), "Updated at " + new Date()); } }
dependenciesElement.appendChild(dependencyAdvancedElement); XmlUtils.writeXml(fileManager.updateFile(pomRooAddonSuite).getOutputStream(), docXml);
try { if (fileManager.exists(filePath)) { appDevMutableFile = fileManager.updateFile(filePath); inputStream = appDevMutableFile.getInputStream(); props.load(inputStream);
mutableFile = getFileManager().updateFile(filePath); loadProperties(props, mutableFile.getInputStream()); } else {
LogicalPath rootPath = LogicalPath.getInstance(Path.ROOT, ""); XmlUtils.writeXml( fileManager.updateFile( pathResolver.getIdentifier(rootPath, folder + "/" + "src/main/resources/obr.xml")) .getOutputStream(), docXml); LogicalPath rootPath = LogicalPath.getInstance(Path.ROOT, ""); XmlUtils.writeXml( fileManager.updateFile( pathResolver.getIdentifier(rootPath, "src/main/resources/obr.xml")) .getOutputStream(), docXml);
public void writeOut() { if (manifestOK) { try { mf.write(new OutputStreamWriter( fileManager.updateFile(templateMfPath).getOutputStream())); } catch (IOException e) { logger.log(Level.SEVERE, "Unable to write template.mf contents, bundlor command aborted", e); } } }
/** * Load the orm.xml file * * @param create file if not exists * * @return {@link MutableFile} and {@link Document} */ private Pair<MutableFile, Document> loadOrmFile(boolean create) { // Get the orm.xml path (and create it if not exists) String ormXmlPath = getOrmXmlPath(create); if (ormXmlPath == null) { return null; } // Load xml file MutableFile ormXmlMutableFile = null; Document ormXml; try { // Get orm.xml content and parse it ormXmlMutableFile = fileManager.updateFile(ormXmlPath); ormXml = XmlUtils.getDocumentBuilder().parse( ormXmlMutableFile.getInputStream()); } catch (Exception e) { LOGGER.severe("Error loading file '".concat(ormXmlPath).concat("'")); throw new IllegalStateException("Error loading file '".concat( ormXmlPath).concat("'"), e); } return new ImmutablePair<MutableFile, Document>(ormXmlMutableFile, ormXml); }
inputStream = FileUtils.getInputStream(loadingClass, directory.concat(fileName)); outputStream = fileManager.updateFile(filePath) .getOutputStream(); IOUtils.copy(inputStream, outputStream);
public String getHandledExceptionList() { String webXmlPath = pathResolver.getIdentifier( LogicalPath.getInstance(Path.SRC_MAIN_WEBAPP, ""), WEB_MVC_CONFIG); Validate.isTrue(fileManager.exists(webXmlPath), WEB_MVC_CONFIG_NOT_FOUND); MutableFile webXmlMutableFile = null; Document webXml; try { webXmlMutableFile = fileManager.updateFile(webXmlPath); webXml = XmlUtils.getDocumentBuilder().parse( webXmlMutableFile.getInputStream()); } catch (Exception e) { throw new IllegalStateException(e); } Element root = webXml.getDocumentElement(); List<Element> simpleMappingException = null; simpleMappingException = XmlUtils.findElements(RESOLVER_BEAN_MESSAGE + "/property[@name='exceptionMappings']/props/prop", root); Validate.notNull(simpleMappingException, "There aren't Exceptions handled by the application."); StringBuilder exceptionList = new StringBuilder("Handled Exceptions:\n"); for (Element element : simpleMappingException) { exceptionList.append(element.getAttribute("key") + "\n"); } return exceptionList.toString(); }
@Override public String getProperty(LogicalPath propertyFilePath, String propertyFilename, String prefix, String key) { Validate.notNull(prefix, "Prefix could be blank but not null"); Validate.notNull(propertyFilePath, "Property file path required"); Validate.notBlank(propertyFilename, "Property filename required"); Validate.notBlank(key, "Key required"); final String filePath = getProjectOperations().getPathResolver().getIdentifier(propertyFilePath, propertyFilename); MutableFile mutableFile = null; final Properties props = new Properties(); if (getFileManager().exists(filePath)) { mutableFile = getFileManager().updateFile(filePath); loadProperties(props, mutableFile.getInputStream()); } else { return null; } // Including prefix if needed if (StringUtils.isNotBlank(prefix)) { key = prefix.concat(".").concat(key); } return props.getProperty(key); }
@Override public void removeProperty(LogicalPath propertyFilePath, String propertyFilename, String prefix, String key) { Validate.notNull(prefix, "Prefix could be blank but not null"); Validate.notNull(propertyFilePath, "Property file path required"); Validate.notBlank(propertyFilename, "Property filename required"); Validate.notBlank(key, "Key required"); final String filePath = getProjectOperations().getPathResolver().getIdentifier(propertyFilePath, propertyFilename); MutableFile mutableFile = null; final Properties props = new Properties(); if (getFileManager().exists(filePath)) { mutableFile = getFileManager().updateFile(filePath); loadProperties(props, mutableFile.getInputStream()); } else { throw new IllegalStateException(String.format("ERROR: '%s' properties file doesn't exists.", filePath)); } // Including prefix if needed if (StringUtils.isNotBlank(prefix)) { key = prefix.concat(".").concat(key); } if (props.containsKey(key)) { props.remove(key); storeProps(props, mutableFile.getOutputStream(), "Updated at " + new Date()); } }
@Override public void removePropertiesByPrefix(LogicalPath propertyFilePath, String propertyFilename, String prefix) { Validate.notBlank(prefix, "Prefix required"); Validate.notNull(propertyFilePath, "Property file path required"); Validate.notBlank(propertyFilename, "Property filename required"); final String filePath = getProjectOperations().getPathResolver().getIdentifier(propertyFilePath, propertyFilename); MutableFile mutableFile = null; final Properties props = new Properties(); if (getFileManager().exists(filePath)) { mutableFile = getFileManager().updateFile(filePath); loadProperties(props, mutableFile.getInputStream()); } else { throw new IllegalStateException(String.format("ERROR: '%s' properties file doesn't exists.", filePath)); } for (Entry property : props.entrySet()) { String key = (String) property.getKey(); if (key != null && key.startsWith(prefix)) { props.remove(key); } } storeProps(props, mutableFile.getOutputStream(), "Updated at " + new Date()); }
outputStream = fileManager.updateFile(filePath) .getOutputStream();
webXmlMutableFile = fileManager.updateFile(webXmlPath); webXml = XmlUtils.getDocumentBuilder().parse( webXmlMutableFile.getInputStream());
public boolean isMessageMappingAvailable() { String webXmlPath = pathResolver.getIdentifier( LogicalPath.getInstance(Path.SRC_MAIN_WEBAPP, ""), WEB_MVC_CONFIG); if (!fileManager.exists(webXmlPath)) { return false; } MutableFile webXmlMutableFile = null; Document webXml; try { webXmlMutableFile = fileManager.updateFile(webXmlPath); webXml = XmlUtils.getDocumentBuilder().parse( webXmlMutableFile.getInputStream()); } catch (Exception e) { throw new IllegalStateException(e); } Element root = webXml.getDocumentElement(); Element exceptionResolver = XmlUtils.findFirstElement( RESOLVER_BEAN_MESSAGE + "/property[@name='exceptionMappings']/props/prop", root); boolean isExceptionAvailable = (exceptionResolver != null) ? true : false; return isExceptionAvailable; }
public boolean isExceptionMappingAvailable() { String webXmlPath = pathResolver.getIdentifier( LogicalPath.getInstance(Path.SRC_MAIN_WEBAPP, ""), WEB_MVC_CONFIG); if (!fileManager.exists(webXmlPath)) { return false; } MutableFile webXmlMutableFile = null; Document webXml; try { webXmlMutableFile = fileManager.updateFile(webXmlPath); webXml = XmlUtils.getDocumentBuilder().parse( webXmlMutableFile.getInputStream()); } catch (Exception e) { throw new IllegalStateException(e); } Element root = webXml.getDocumentElement(); Element exceptionResolver = XmlUtils .findFirstElement( "/beans/bean[@class='org.springframework.web.servlet.handler.SimpleMappingExceptionResolver']" + "/property[@name='exceptionMappings']/props/prop", root); boolean isExceptionAvailable = (exceptionResolver != null) ? true : false; return isExceptionAvailable; }
docTagxMutableFile = fileManager.updateFile(docTagxPath); docTagx = XmlUtils.getDocumentBuilder().parse( docTagxMutableFile.getInputStream());
if (fileManager.exists(applicationContextSecurity)) { mutableConfigXml = fileManager .updateFile(applicationContextSecurity); webConfigDoc = XmlUtils.getDocumentBuilder().parse( mutableConfigXml.getInputStream());