public void addConfigDefinitionsFromBundle(Bundle bundle, List<Bundle> bundlesAdded) { try { checkAndCopyUserDefs(bundle, bundlesAdded); } catch (IOException e) { throw new IllegalArgumentException("Unable to add config definitions from bundle " + bundle.getFile().getAbsolutePath(), e); } }
private static List<ComponentInfo> getComponentsInfo(File appDir) { List<ComponentInfo> components = new ArrayList<>(); for (Bundle bundle : Bundle.getBundles(new File(appDir, ApplicationPackage.COMPONENT_DIR))) { components.add(new ComponentInfo(new File(ApplicationPackage.COMPONENT_DIR, bundle.getFile().getName()).getPath())); } return components; }
public static List<Component> getComponents(File appDir) { List<Component> components = new ArrayList<>(); for (Bundle bundle : Bundle.getBundles(new File(appDir, ApplicationPackage.COMPONENT_DIR))) { components.add(new Component(bundle, new ComponentInfo(new File(ApplicationPackage.COMPONENT_DIR, bundle.getFile().getName()).getPath()))); } return components; }
private void checkUserDefConflict(Bundle bundle, Bundle.DefEntry userDef, List<Bundle> bundlesAdded) { final String defName = userDef.defName; final String defNamespace = userDef.defNamespace; File[] builtinDefsWithSameName = defDir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.matches(defName + ".def") || name.matches(defNamespace + "." + defName + ".def"); } }); if (builtinDefsWithSameName != null && builtinDefsWithSameName.length > 0) { String message = "a built-in config definition (" + getFilePathsCommaSeparated(builtinDefsWithSameName) + ")"; for (Bundle b : bundlesAdded) { for (Bundle.DefEntry defEntry : b.getDefEntries()) { if (defEntry.defName.equals(defName) && defEntry.defNamespace.equals(defNamespace)) { message = "the same config definition in the bundle '" + b.getFile().getName() + "'"; } } } throw new IllegalArgumentException("The config definition with name '" + defNamespace + "." + defName + "' contained in the bundle '" + bundle.getFile().getName() + "' conflicts with " + message + ". Please choose a different name."); } }