@Override public String getProjectSettingsLocation() { return pathResolver.getFocusedIdentifier(PROJECT_CONFIG_FOLDER_LOCATION, getProjectSettingsFileName()); }
if (entry.getName().equals(expectedEntryName)) { final MutableFile target = fileManager.createFile(pathResolver.getFocusedIdentifier(Path.SRC_MAIN_RESOURCES, packagePath + "/" + countryCode + ".png")); OutputStream outputStream = null;
private void setUpLog4jConfiguration() { final String log4jConfigFile = getPathResolver().getFocusedIdentifier(Path.SRC_MAIN_RESOURCES, "log4j.properties"); final InputStream templateInputStream = FileUtils.getInputStream(getClass(), "log4j.properties-template"); OutputStream outputStream = null; try { outputStream = getFileManager().createFile(log4jConfigFile).getOutputStream(); IOUtils.copy(templateInputStream, outputStream); } catch (final IOException e) { LOGGER.warning("Unable to install log4j logging configuration"); } finally { IOUtils.closeQuietly(templateInputStream); IOUtils.closeQuietly(outputStream); } }
/** * Creates topLevelPackage folder structure inside the focused module. If * folder is not null, adds this new folder inside topLevelPackage folders * * @param topLevelPackage * folder structure represented as a package (required) * @param folder * the folder to add inside topLevelPackage (can be null) */ private void createFolder(JavaPackage topLevelPackage, String folder) { Validate.notNull(topLevelPackage, "Cannot create topLevelPackage folders"); String filename = topLevelPackage.getFullyQualifiedPackageName().replace('.', File.separatorChar); if (StringUtils.isNotBlank(folder)) { filename += File.separatorChar + folder; } final String physicalPath = getPathResolver().getFocusedIdentifier(Path.SRC_MAIN_JAVA, filename); getFileManager().createDirectory(physicalPath); }
public String backup() { Validate.isTrue(isBackupPossible(), "Project metadata unavailable"); // For Windows, make a date format that can legally form part of a // filename (ROO-277) final String pattern = File.separatorChar == '\\' ? "yyyy-MM-dd_HH.mm.ss" : "yyyy-MM-dd_HH:mm:ss"; final DateFormat df = new SimpleDateFormat(pattern); final long start = System.nanoTime(); ZipOutputStream zos = null; try { final File projectDirectory = new File(getProjectOperations().getPathResolver().getFocusedIdentifier(Path.ROOT, ".")); final MutableFile file = getFileManager().createFile( FileUtils.getCanonicalPath(new File(projectDirectory, getProjectOperations() .getFocusedProjectName() + "_" + df.format(new Date()) + ".zip"))); zos = new ZipOutputStream(file.getOutputStream()); zip(projectDirectory, projectDirectory, zos); } catch (final FileNotFoundException e) { LOGGER.fine("Could not determine project directory"); } catch (final IOException e) { LOGGER.fine("Could not create backup archive"); } finally { IOUtils.closeQuietly(zos); } final long milliseconds = (System.nanoTime() - start) / 1000000; return "Backup completed in " + milliseconds + " ms"; }
outputStream = fileManager.createFile( pathResolver.getFocusedIdentifier(Path.SRC_MAIN_RESOURCES, packagePath + separatorChar + messageBundle.getName())).getOutputStream(); org.apache.commons.io.FileUtils.copyFile(messageBundle, outputStream); outputStream = fileManager.createFile( pathResolver.getFocusedIdentifier(Path.SRC_MAIN_RESOURCES, packagePath + separatorChar + flagGraphic.getName())).getOutputStream(); org.apache.commons.io.FileUtils.copyFile(flagGraphic, outputStream); pathResolver.getFocusedIdentifier(Path.SRC_MAIN_JAVA, packagePath + separatorChar + languageName + "Language.java");
/** * This method copies images resources to gvNIX application */ public void restoreImageResources() { List<String> imageFolderFiles = new ArrayList<String>(); Collections.addAll(imageFolderFiles, "logo_gvnix.png", "favicon.ico"); Iterator<String> imageFolderIterator = imageFolderFiles.iterator(); while (imageFolderIterator.hasNext()) { String fileName = imageFolderIterator.next(); final String imageFile = getPathResolver().getFocusedIdentifier( Path.SRC_MAIN_WEBAPP, "images/".concat(fileName)); BootstrapUtils.createFilesInLocationIfNotExistsUpdateIfExists( getFileManager(), getClass(), imageFile, fileName, "images/"); } }
/** * This method copies images resources to gvNIX application */ public void addImageResources() { List<String> imageFolderFiles = new ArrayList<String>(); Collections.addAll(imageFolderFiles, "logo_gvnix.png", "favicon.ico"); Iterator<String> imageFolderIterator = imageFolderFiles.iterator(); while (imageFolderIterator.hasNext()) { String fileName = imageFolderIterator.next(); final String imageFile = getPathResolver().getFocusedIdentifier( Path.SRC_MAIN_WEBAPP, "images/".concat(fileName)); BootstrapUtils.createFilesInLocationIfNotExistsUpdateIfExists( getFileManager(), getClass(), imageFile, fileName, "images/"); } }
/** * This method adds the bootstrap libraries to the gvNIX project */ public void addBootstrapScriptsLibraries() { List<String> scriptsFolderFiles = new ArrayList<String>(); Collections.addAll(scriptsFolderFiles, "bootstrap.min.js", "offcanvas.js", "README.txt", "assets/html5shiv.js", "assets/respond.min.js"); Iterator<String> scriptsFolderIterator = scriptsFolderFiles.iterator(); while (scriptsFolderIterator.hasNext()) { String fileName = scriptsFolderIterator.next(); final String scriptFile = getPathResolver() .getFocusedIdentifier(Path.SRC_MAIN_WEBAPP, "scripts/bootstrap/".concat(fileName)); BootstrapUtils.createFilesInLocationIfNotExists(getFileManager(), getClass(), scriptFile, fileName, "scripts/bootstrap/"); } }
/** * This method updates HTML structure in default gvNIX layouts to use * bootsrap */ public void updateGvNIXLayouts() { List<String> layoutsFolderFiles = new ArrayList<String>(); Collections.addAll(layoutsFolderFiles, "default-menu-cols.jspx", "default.jspx"); Iterator<String> layoutsFolderIterator = layoutsFolderFiles.iterator(); while (layoutsFolderIterator.hasNext()) { String fileName = layoutsFolderIterator.next(); final String layoutFile = getPathResolver().getFocusedIdentifier( Path.SRC_MAIN_WEBAPP, "WEB-INF/layouts/".concat(fileName)); BootstrapUtils.createFilesInLocationIfNotExistsUpdateIfExists( getFileManager(), getClass(), layoutFile, fileName, "layouts/"); } }
public boolean isControllerAvailable() { return fileManager.exists(pathResolver.getFocusedIdentifier( Path.SRC_MAIN_WEBAPP, "WEB-INF/views")) && !projectOperations .isFeatureInstalledInFocusedModule(FeatureNames.JSF); }
/** * This method updates HTML structure in default gvNIX views to use * bootstrap */ public void updateViews() { List<String> viewsFolderFiles = new ArrayList<String>(); Collections.addAll(viewsFolderFiles, "footer.jspx", "header.jspx", "index.jspx", "uncaughtException.jspx"); Iterator<String> viewsFolderIterator = viewsFolderFiles.iterator(); while (viewsFolderIterator.hasNext()) { String fileName = viewsFolderIterator.next(); final String viewFile = getPathResolver().getFocusedIdentifier( Path.SRC_MAIN_WEBAPP, "WEB-INF/views/".concat(fileName)); BootstrapUtils.updateFilesInLocationIfExists(getFileManager(), getClass(), viewFile, fileName, VIEWS); } }
public boolean isInstallLanguageCommandAvailable() { return isProjectAvailable() && fileManager.exists(pathResolver.getFocusedIdentifier( Path.SRC_MAIN_WEBAPP, "WEB-INF/views/footer.jspx")); }
/** * This method restore the bootstrap libraries to the gvNIX project */ public void restoreBootstrapScriptsLibraries() { List<String> scriptsFolderFiles = new ArrayList<String>(); Collections.addAll(scriptsFolderFiles, "bootstrap.min.js", "offcanvas.js", "README.txt", "assets/html5shiv.js", "assets/respond.min.js"); Iterator<String> scriptsFolderIterator = scriptsFolderFiles.iterator(); while (scriptsFolderIterator.hasNext()) { String fileName = scriptsFolderIterator.next(); final String scriptFile = getPathResolver() .getFocusedIdentifier(Path.SRC_MAIN_WEBAPP, "scripts/bootstrap/".concat(fileName)); BootstrapUtils.createFilesInLocationIfNotExistsUpdateIfExists( getFileManager(), getClass(), scriptFile, fileName, "scripts/bootstrap/"); } }
/** * This method replaces the old standard.css with a new one adapted to * Bootstrap3 */ public void replaceOldStyles() { final String styleFile = getPathResolver().getFocusedIdentifier( Path.SRC_MAIN_WEBAPP, "styles/standard.css"); BootstrapUtils.createFilesInLocationIfNotExistsUpdateIfExists( getFileManager(), getClass(), styleFile, "standard.css", "styles/"); }
/** * This method update security views to use bootstrap */ public void updateSecurityAddonToBootstrap() { final String viewFile = getPathResolver().getFocusedIdentifier( Path.SRC_MAIN_WEBAPP, "WEB-INF/views/login.jspx"); BootstrapUtils.createFilesInLocationIfNotExistsUpdateIfExists( getFileManager(), getClass(), viewFile, "login.jspx", VIEWS); }
/** * This method copies load-scripts-bootstrap-no-datatables.tagx to the * project */ public void addLoadScriptsNoDatatables() { final String tagFile = getPathResolver().getFocusedIdentifier( Path.SRC_MAIN_WEBAPP, "WEB-INF/tags/bootstrap/util/load-scripts-bootstrap.tagx"); BootstrapUtils.createFilesInLocationIfNotExists(getFileManager(), getClass(), tagFile, "load-scripts-bootstrap-no-datatables.tagx", "tags/bootstrap/util/"); }
private String getJndiDataSourceName() { final String contextPath = projectOperations.getPathResolver() .getFocusedIdentifier(Path.SPRING_CONFIG_ROOT, "applicationContext.xml"); final Document appCtx = XmlUtils.readXml(fileManager .getInputStream(contextPath)); final Element root = appCtx.getDocumentElement(); final Element dataSourceJndi = XmlUtils.findFirstElement( "/beans/jndi-lookup[@id = 'dataSource']", root); return dataSourceJndi != null ? dataSourceJndi .getAttribute("jndi-name") : null; }
private String getDbreXmlPath() { for (final String moduleName : projectOperations.getModuleNames()) { final LogicalPath logicalPath = LogicalPath.getInstance( Path.SRC_MAIN_RESOURCES, moduleName); final String dbreXmlPath = projectOperations.getPathResolver() .getIdentifier(logicalPath, DBRE_XML); if (fileManager.exists(dbreXmlPath)) { return dbreXmlPath; } } return projectOperations.getPathResolver().getFocusedIdentifier( Path.SRC_MAIN_RESOURCES, DBRE_XML); }
private Connection getConnection(final boolean displayAddOns) { final String dbProps = "database.properties"; final String jndiDataSource = getJndiDataSourceName(); if (StringUtils.isNotBlank(jndiDataSource)) { final Map<String, String> props = propFileOperations.getProperties( Path.SPRING_CONFIG_ROOT.getModulePathId(projectOperations .getFocusedModuleName()), "jndi.properties"); return connectionProvider.getConnectionViaJndiDataSource( jndiDataSource, props, displayAddOns); } else if (fileManager.exists(projectOperations.getPathResolver() .getFocusedIdentifier(Path.SPRING_CONFIG_ROOT, dbProps))) { final Map<String, String> props = propFileOperations.getProperties( Path.SPRING_CONFIG_ROOT.getModulePathId(projectOperations .getFocusedModuleName()), dbProps); return connectionProvider.getConnection(props, displayAddOns); } final Properties connectionProperties = getConnectionPropertiesFromDataNucleusConfiguration(); return connectionProvider.getConnection(connectionProperties, displayAddOns); }