@Nullable public String getConfigFileErrorMessage(final ConfigFile configFile) { if (configFile.getVirtualFile() == null) { String path = FileUtil.toSystemDependentName(VfsUtil.urlToPath(configFile.getUrl())); return CompilerBundle.message("mesage.text.deployment.descriptor.file.not.exist", path); } PsiFile psiFile = configFile.getPsiFile(); if (psiFile == null || !psiFile.isValid()) { return CompilerBundle.message("message.text.deployment.description.invalid.file"); } if (psiFile instanceof XmlFile) { XmlDocument document = ((XmlFile)psiFile).getDocument(); if (document == null || document.getRootTag() == null) { return CompilerBundle.message("message.text.xml.file.invalid", FileUtil.toSystemDependentName(VfsUtil.urlToPath(configFile.getUrl()))); } } return null; }
@Override public VirtualFile suggestParentDirectoryForAppEngineWebXml( @NotNull Module module, @NotNull ModifiableRootModel rootModel) { final WebFacet webFacet = ContainerUtil.getFirstItem(WebFacet.getInstances(module)); if (webFacet == null) { return null; } ConfigFile configFile = webFacet.getWebXmlDescriptor(); if (configFile == null) { return null; } final VirtualFile webXml = configFile.getVirtualFile(); if (webXml == null) { return null; } return webXml.getParent(); }
@Nullable public <T extends DomElement> T getRoot(@Nullable JavaEEModuleExtension<?> facet, @NotNull Class<T> type) { if(facet != null) { ConfigFile item = facet.getDescriptorsContainer().getConfigFile(meta); if(item != null) { XmlFile xml = item.getXmlFile(); if(xml != null) { DomFileElement<T> element = DomManager.getDomManager(facet.getModule().getProject()).getFileElement(xml, type); if(element != null) { return element.getRootElement(); } } } } return null; }
public void reportDeploymentDescriptorDoesNotExists(ConfigFile descriptor, CompileContext context, Module module) { final String description = ModuleType.get(module).getName() + " '" + module.getName() + '\''; String descriptorPath = VfsUtil.urlToPath(descriptor.getUrl()); final String message = CompilerBundle.message("message.text.compiling.item.deployment.descriptor.could.not.be.found", description, descriptorPath); context.addMessage(CompilerMessageCategory.ERROR, message, null, -1, -1); }
public void checkConfigFile(final ConfigFile descriptor, final CompileContext compileContext, final Module module) { if (new File(VfsUtil.urlToPath(descriptor.getUrl())).exists()) { String message = getConfigFileErrorMessage(descriptor); if (message != null) { final String moduleDescription = ModuleType.get(module).getName() + " '" + module.getName() + '\''; compileContext.addMessage(CompilerMessageCategory.ERROR, CompilerBundle.message("message.text.compiling.module.message", moduleDescription, message), descriptor.getUrl(), -1, -1); } } else { DeploymentUtil.getInstance().reportDeploymentDescriptorDoesNotExists(descriptor, compileContext, module); } }
@Nullable public static XmlFile getPluginXml(Module module) { if (module == null) return null; if (!isOfType(module)) return null; final PluginBuildConfiguration buildConfiguration = PluginBuildConfiguration.getInstance(module); if (buildConfiguration == null) return null; final ConfigFile configFile = buildConfiguration.getPluginXmlConfigFile(); return configFile != null ? configFile.getXmlFile() : null; }
@Nullable public static XmlFile getPluginXml(Module module) { if (module == null) return null; if (!(get(module) instanceof PluginModuleType)) return null; final PluginBuildConfiguration buildConfiguration = PluginBuildConfiguration.getInstance(module); if (buildConfiguration == null) return null; final ConfigFile configFile = buildConfiguration.getPluginXmlConfigFile(); return configFile != null ? configFile.getXmlFile() : null; }
@Nullable public static Element findContextInContextXmlByFacet(TomcatDeploymentModelBase tomcatModel) { Artifact artifact = tomcatModel.getArtifact(); if(artifact != null) { JavaeeDescriptor contextDescriptor = TomcatIntegration.getInstance().getDescriptorsManager().getItem(TomcatContextRoot.class); ConfigFileMetaData metaData = contextDescriptor.getMetaData(); for(JavaEEModuleExtension facet : JavaeeArtifactUtil.getInstance().getFacetsIncludedInArtifact(tomcatModel.getCommonModel().getProject(), artifact, JavaWebModuleExtension.class)) { ConfigFile configFile = facet.getDescriptorsContainer().getConfigFile(metaData); try { if(configFile != null) { VirtualFile contextXmlFile = configFile.getVirtualFile(); if(contextXmlFile != null) { Document contextDocument = loadXMLFile(VfsUtilCore.virtualToIoFile(contextXmlFile)); return contextDocument.getRootElement(); } } } catch(ExecutionException e) { LOG.info(e); } } } return null; }
@Deprecated public abstract void reportDeploymentDescriptorDoesNotExists(ConfigFile descriptor, CompileContext context, Module module);
@Nullable public abstract String getConfigFileErrorMessage(ConfigFile configFile);
@Deprecated public abstract void checkConfigFile(final ConfigFile descriptor, final CompileContext compileContext, final Module module);
public static void addDescriptor(@NotNull final Collection<VirtualFile> result, @Nullable final ConfigFile configFile) { if (configFile != null) { ContainerUtil.addIfNotNull(configFile.getVirtualFile(), result); } }
@Nullable public ConfigFile getPluginXML() { return myPluginXmlContainer.getConfigFile(PluginDescriptorConstants.META_DATA); }
@Nullable public ConfigFile getPluginXmlConfigFile() { return myPluginXmlContainer.getConfigFile(PluginDescriptorConstants.META_DATA); }
@Nullable private String getPluginXmlUrl() { ConfigFile configFile = getPluginXmlConfigFile(); return configFile != null ? configFile.getUrl() : null; }
public abstract void reportDeploymentDescriptorDoesNotExists(ConfigFile descriptor, CompileContext context, Module module);
public abstract void checkConfigFile(final ConfigFile descriptor, final CompileContext compileContext, final Module module);