/** * Gets the class name of the specified Grails resource * * @param resource The Spring Resource * @return The class name or null if the resource is not a Grails class */ public static String getClassName(Resource resource) { try { return getClassName(resource.getFile().getAbsolutePath()); } catch (IOException e) { return null; } }
/** Reads a plugin.xml descriptor for the given plugin name */ public GPathResult readPluginXmlMetadata(String pluginName) throws Exception { Resource pluginResource = pluginSettings.getPluginDirForName(pluginName); if (pluginResource != null) { File pluginDir = pluginResource.getFile(); return new XmlSlurper().parse(new File(pluginDir, "plugin.xml")); } return null; }
/** Reads all installed plugin descriptors returning a list */ public List<GPathResult> readAllPluginXmlMetadata() throws Exception { Resource[] allFiles = pluginSettings.getPluginXmlMetadata(); List<GPathResult> results = new ArrayList<GPathResult>(); for (Resource resource : allFiles) { if (resource.exists()) { results.add(new XmlSlurper().parse(resource.getFile())); } } return results; }
private String getPathForResource(Resource res) { if (res == null) return ""; String path = null; try { File file = res.getFile(); if (file != null) path = file.getAbsolutePath(); } catch (IOException e) { // ignore } if (path != null) { return path; } if (res.getDescription() != null) { return res.getDescription(); } return ""; }