Package org.jboss.forge.parser.xml

Examples of org.jboss.forge.parser.xml.Node


   protected void setupWebXML()
   {
      ServletFacet servlet = this.project.getFacet(ServletFacet.class);

      Node webXML = removeConflictingErrorPages(servlet);
      servlet.getConfigFile().setContents(XMLParser.toXMLInputStream(webXML));

      WebAppDescriptor servletConfig = servlet.getConfig();
      WebResourceFacet web = this.project.getFacet(WebResourceFacet.class);
View Full Code Here


      servlet.saveConfig(servletConfig);
   }

   protected Node removeConflictingErrorPages(final ServletFacet servlet)
   {
      Node webXML = XMLParser.parse(servlet.getConfigFile().getResourceInputStream());
      Node root = webXML.getRoot();
      List<Node> errorPages = root.get("error-page");

      for (String code : Arrays.asList("404", "500"))
      {
         for (Node errorPage : errorPages)
         {
            if (code.equals(errorPage.getSingle("error-code").getText())
                     && this.prompt.promptBoolean("Your web.xml already contains an error page for " + code
                              + " status codes, replace it?"))
            {
               root.removeChild(errorPage);
            }
         }
      }
      return webXML;
   }
View Full Code Here

         if (log.isLoggable(Level.FINE))
         {
            log.fine("Processing " + pomFile.getAbsolutePath() + " for classpath artifact resolution");
         }

         final Node pom = XMLParser.parse(pomFile);

         String groupId = pom.getTextValueForPatternName("groupId");
         String artifactId = pom.getTextValueForPatternName("artifactId");
         String type = pom.getTextValueForPatternName("packaging");
         String version = pom.getTextValueForPatternName("version");

         if (groupId == null || groupId.isEmpty())
         {
            groupId = pom.getTextValueForPatternName("parent/groupId");
         }
         if (type == null || type.isEmpty())
         {
            type = "jar";
         }
         if (version == null || version.isEmpty())
         {
            version = pom.getTextValueForPatternName("parent/version");
         }

         final Artifact foundArtifact = new DefaultArtifact(groupId, artifactId, type, version);
         foundArtifact.setFile(pomFile);
         return foundArtifact;
View Full Code Here

      Assert.assertSame(config, facet.getConfigurationStrategy());
      Assert.assertEquals("/rest", facet.getApplicationPath());

      XMLResource webConfig = project.getFacet(ServletFacet_3_0.class).getConfigFile().reify(XMLResource.class);
      Assert.assertNotNull(webConfig);
      Node xmlSource = webConfig.getXmlSource();
      Assert.assertNotNull(xmlSource);
      Node servletClass = xmlSource.getSingle("servlet/servlet-name=" + RestWebXmlConfigurationStrategy.JAXRS_SERVLET);
      Node servletMapping = xmlSource.getSingle("servlet-mapping/servlet-name="
               + RestWebXmlConfigurationStrategy.JAXRS_SERVLET);
      Assert.assertNotNull(servletClass);
      Assert.assertNotNull(servletMapping);
      Node urlPatternTag = servletMapping.getParent().getSingle("url-pattern");
      Assert.assertNotNull(urlPatternTag);
      Assert.assertEquals(path, urlPatternTag.getText());
   }
View Full Code Here

   protected void setupWebXML()
   {
      ServletFacet servlet = this.project.getFacet(ServletFacet.class);

      Node webXML = removeConflictingErrorPages(servlet);
      servlet.getConfigFile().setContents(XMLParser.toXMLInputStream(webXML));

      WebAppDescriptor servletConfig = servlet.getConfig();
      WebResourceFacet web = this.project.getFacet(WebResourceFacet.class);
View Full Code Here

      servlet.saveConfig(servletConfig);
   }

   protected Node removeConflictingErrorPages(final ServletFacet servlet)
   {
      Node webXML = XMLParser.parse(servlet.getConfigFile().getResourceInputStream());
      Node root = webXML.getRoot();
      List<Node> errorPages = root.get("error-page");

      for (String code : Arrays.asList("404", "500"))
      {
         for (Node errorPage : errorPages)
         {
            if (code.equals(errorPage.getSingle("error-code").getText())
                     && this.prompt.promptBoolean("Your web.xml already contains an error page for " + code
                              + " status codes, replace it?"))
            {
               root.removeChild(errorPage);
            }
         }
      }
      return webXML;
   }
View Full Code Here

   private XMLSourceFactory factory;

   @Test
   public void testXMLSourceFactoryParse() throws Exception
   {
      Node xmlNode = factory.parse("<test/>");
      Assert.assertEquals("test", xmlNode.getName());
   }
View Full Code Here

   private ResourceFactory factory;

   @Test
   public void testXMLResourceCreation() throws Exception
   {
      Node node = XMLParser.parse("<test/>");
      XMLResource resource = factory.create(XMLResource.class, File.createTempFile("forge", ".xml"));
      resource.createNewFile();
      resource.setContents(node);
      Assert.assertEquals("test", resource.getXmlSource().getName());
   }
View Full Code Here

   }

   @Test
   public void testJavaResourceCreationSpecialized() throws Exception
   {
      Node node = XMLParser.parse("<test/>");
      XMLResource resource = factory.create(XMLResource.class, File.createTempFile("forge", ".xml"));
      resource.createNewFile();
      resource.setContents(node);

      Resource<File> newResource = factory.create(resource.getUnderlyingResourceObject());
View Full Code Here

         if (log.isLoggable(Level.FINE))
         {
            log.fine("Processing " + pomFile.getAbsolutePath() + " for classpath artifact resolution");
         }

         final Node pom = XMLParser.parse(pomFile);

         String groupId = pom.getTextValueForPatternName("groupId");
         String artifactId = pom.getTextValueForPatternName("artifactId");
         String type = pom.getTextValueForPatternName("packaging");
         String version = pom.getTextValueForPatternName("version");

         if (groupId == null || groupId.isEmpty())
         {
            groupId = pom.getTextValueForPatternName("parent/groupId");
         }
         if (type == null || type.isEmpty())
         {
            type = "jar";
         }
         if (version == null || version.isEmpty())
         {
            version = pom.getTextValueForPatternName("parent/version");
         }

         final Artifact foundArtifact = new DefaultArtifact(groupId, artifactId, type, version);
         foundArtifact.setFile(pomFile);
         return foundArtifact;
View Full Code Here

TOP

Related Classes of org.jboss.forge.parser.xml.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.