private Properties createFileSourceConfiguration() { String format = null; if (projectConfig.hasProperty(PROJECT_RESOURCES_FILEFORMAT_PROPERTY)) { format = projectConfig.getProperty(PROJECT_RESOURCES_FILEFORMAT_PROPERTY); } return generateFileSourceConfigurationProperties( projectConfig.getProperty(PROJECT_RESOURCES_FILE_PROPERTY), format, true, true); }
/** * Create a {@link NodeSetMerge} based on project configuration, it defaults to merge all node * attributes unless "project.resources.mergeNodeAttributes" is false * * @return a NodeSetMerge */ private NodeSetMerge getNodeSetMerge() { if (projectConfig.hasProperty(PROJECT_RESOURCES_MERGE_NODE_ATTRIBUTES) && "false".equals(projectConfig.getProperty(PROJECT_RESOURCES_MERGE_NODE_ATTRIBUTES))) { return new AdditiveListNodeSet(); } return new MergedAttributesNodeSet(); }
private Properties createURLSourceConfiguration() { final URLResourceModelSource.Configuration build = URLResourceModelSource.Configuration.build(); build.url(projectConfig.getProperty(PROJECT_RESOURCES_URL_PROPERTY)); build.project(projectConfig.getName()); return build.getProperties(); }
private File getResourceModelSourceFileCacheForType(String ident) { String varDir = projectConfig.getProperty("framework.var.dir"); File file = new File( varDir, "resourceModelSourceCache/" + projectConfig.getName() + "/" + ident + ".xml"); if (!file.getParentFile().exists() && !file.getParentFile().mkdirs()) { logger.warn("Failed to create cache dirs for source file cache"); } return file; }
/** * Conditionally update the nodes resources file if a URL source is defined for it and return true * if the update process was invoked and succeeded * * @param nodesResourcesFilePath destination file path * @return true if the update succeeded, false if it was not performed * @throws UpdateUtils.UpdateException if an error occurs while trying to update the resources * file */ @Override public boolean updateNodesResourceFile(final String nodesResourcesFilePath) throws UpdateUtils.UpdateException { if (shouldUpdateNodesResourceFile()) { updateNodesResourceFileFromUrl( projectConfig.getProperty(PROJECT_RESOURCES_URL_PROPERTY), null, null, nodesResourcesFilePath); return true; } return false; }
/** * Return true in these cases: 1. project.properties allows URL and framework.properties allows * URL. 2. project.properties allows URL and no regexes are set in framework.properties 3. * project.properties no regexes are set, and framework.properites allows URL. */ boolean isAllowedProviderURL(final String providerURL) { // whitelist the configured providerURL if (projectConfig.hasProperty(PROJECT_RESOURCES_URL_PROPERTY) && projectConfig.getProperty(PROJECT_RESOURCES_URL_PROPERTY).equals(providerURL)) { return true; } // check regex properties for project props int i = 0; boolean projpass = false; boolean setproj = false; while (projectConfig.hasProperty(PROJECT_RESOURCES_ALLOWED_URL_PREFIX + i)) { setproj = true; final String regex = projectConfig.getProperty(PROJECT_RESOURCES_ALLOWED_URL_PREFIX + i); final Pattern pat = Pattern.compile(regex, Pattern.CASE_INSENSITIVE); final Matcher matcher = pat.matcher(providerURL); if (matcher.matches()) { logger.debug( "ProviderURL allowed by project property \"project.resources.allowedURL." + i + "\": " + regex); projpass = true; break; } i++; } if (!projpass && setproj) { // was checked but failed match return false; } // check framework props i = 0; final boolean setframework = projectConfig.hasProperty(FRAMEWORK_RESOURCES_ALLOWED_URL_PREFIX + i); if (!setframework && projpass) { // unset in framework.props, allowed by project.props return true; } if (!setframework && !setproj) { // unset in both return false; } while (projectConfig.hasProperty(FRAMEWORK_RESOURCES_ALLOWED_URL_PREFIX + i)) { final String regex = projectConfig.getProperty(FRAMEWORK_RESOURCES_ALLOWED_URL_PREFIX + i); final Pattern pat = Pattern.compile(regex, Pattern.CASE_INSENSITIVE); final Matcher matcher = pat.matcher(providerURL); if (matcher.matches()) { logger.debug( "ProviderURL allowed by framework property \"framework.resources.allowedURL." + i + "\": " + regex); // allowed by framework.props, and unset or allowed by project.props, return true; } i++; } if (projpass) { logger.warn( "providerURL was allowed by project.properties, but is not allowed by framework.properties: " + providerURL); } return false; }