public String createArtifacts(final JavaPackage topLevelPackage, final String nullableProjectName, final String javaVersion, final GAV parentPom, final String module, final ProjectOperations projectOperations) { // Already created by the creator addon return projectOperations.getPathResolver().getIdentifier( LogicalPath.getInstance(Path.ROOT, ""), "pom.xml"); }
@Override public Map<String, String> getProperties(final LogicalPath propertyFilePath, final String propertyFilename) { Validate.notNull(propertyFilePath, "Property file path required"); Validate.notBlank(propertyFilename, "Property filename required"); final String filePath = getProjectOperations().getPathResolver().getIdentifier(propertyFilePath, propertyFilename); final Properties props = new Properties(); try { if (getFileManager().exists(filePath)) { loadProperties(props, new BufferedInputStream(new FileInputStream(filePath))); } else { throw new IllegalStateException(String.format( "ERROR: '%s' properties file doesn't exists.", filePath)); } } catch (final IOException ioe) { throw new IllegalStateException(ioe); } final Map<String, String> result = new HashMap<String, String>(); for (final Object key : props.keySet()) { result.put(key.toString(), props.getProperty(key.toString())); } return Collections.unmodifiableMap(result); }
getProjectOperations().getPathResolver().getIdentifier(propertyFilePath, propertyFilename); final Properties props = new Properties();
@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); }
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"; }
@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()); }
private void addAddonsDependencies(Document pom, String folder, JavaPackage topLevelPackage) { projectOperations.getPathResolver().getIdentifier(Path.ROOT.getModulePathId(""), folder + "/pom.xml");
getProjectOperations().getPathResolver().getIdentifier(propertyFilePath, propertyFilename); MutableFile mutableFile = null;
for (final LogicalPath sourcePath : projectOperations.getPathResolver().getSourcePaths()) { final String possibleSuperclass = PhysicalTypeIdentifier.createIdentifier(details.getExtendsTypes().get(0), sourcePath);
/** * Utility to get {@link PathResolver}. * * @return PathResolver or null if project isn't available yet */ private PathResolver getPathResolver() { // Use PathResolver to resolve between {@link File}, {@link Path} and // canonical path {@link String}s. // See {@link MavenPathResolver} to know location values PathResolver pathResolver = getProjectOperations().getPathResolver(); return pathResolver; }
/** * Get the path identifier for a java type in the project. * * @param javaType Java type * @return Path identifier in project */ protected String getJavaTypeIdentifier(JavaType javaType) { return projectOperations.getPathResolver().getIdentifier( LogicalPath.getInstance(Path.SRC_MAIN_JAVA, ""), javaType.getFullyQualifiedTypeName() .replace('.', File.separatorChar).concat(".java")); }
/** {@inheritDoc} */ public String getSpringMvcConfigFile() { // resolve path for spring-mvc.xml if it hasn't been resolved yet if (springMvcConfigFile == null) { springMvcConfigFile = projectOperations.getPathResolver() .getIdentifier( LogicalPath.getInstance(Path.SRC_MAIN_WEBAPP, ""), "WEB-INF/spring/webmvc-config.xml"); } return springMvcConfigFile; }
/** * {@inheritDoc} */ public String getGenSourcesDir() { if (genSourcesDir != null) { return genSourcesDir; } genSourcesDir = projectOperations.getPathResolver().getIdentifier( LogicalPath.getInstance(Path.ROOT, ""), GENERATED_CXF_SOURCES_DIR); return genSourcesDir; }
/** {@inheritDoc} */ public String getJasperViewsFile() { // resolve path for jasper-views.xml if it hasn't been resolved yet if (jasperViewsConfigFile == null) { jasperViewsConfigFile = projectOperations.getPathResolver() .getIdentifier( LogicalPath.getInstance(Path.SRC_MAIN_WEBAPP, ""), JASPER_VIEWS_XML); } return jasperViewsConfigFile; }
/** * @return Returns the path to axis client wsdd config file */ private String getAxisClientConfigPath() { return projectOperations.getPathResolver().getIdentifier( LogicalPath.getInstance(Path.SRC_MAIN_RESOURCES, ""), "client-config.wsdd"); }
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; }
public boolean isInstalledInModule(final String moduleName) { final LogicalPath webAppPath = LogicalPath.getInstance( Path.SRC_MAIN_WEBAPP, moduleName); return fileManager.exists(projectOperations.getPathResolver() .getIdentifier(webAppPath, "WEB-INF/spring/webmvc-config.xml")); }
/** * Get web configuration (web.xml) absolute file path. * * @return web configuration (web.xml) absolute file path */ protected String getWebConfigFilePath() { return getProjectOperations().getPathResolver().getIdentifier( LogicalPath.getInstance(Path.SRC_MAIN_WEBAPP, ""), "WEB-INF/web.xml"); }
@Override public String getSecurityPropertiesAbsolutePath( JavaType importedServiceClass) { // Resolve properties absolute path String propertiesPath = projectOperations.getPathResolver() .getIdentifier( LogicalPath.getInstance(Path.SRC_MAIN_RESOURCES, ""), WSServiceSecurityMetadata .getPropertiesPath(importedServiceClass)); return propertiesPath; }