Java Code Examples for com.google.appengine.repackaged.com.google.common.io.Files#copy()

The following examples show how to use com.google.appengine.repackaged.com.google.common.io.Files#copy() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebXmlProcessing.java    From appengine-maven-plugin with Apache License 2.0 5 votes vote down vote up
public void updateWebXml(List<String> services, String webXmlPath)
        throws ParserConfigurationException, SAXException, IOException,
        TransformerFactoryConfigurationError, TransformerException {
  boolean saveRequired;

  String spc = " ";
  String delimiter = "\n";

  DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
  DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
  Document document = docBuilder.parse(webXmlPath);

  Node systemServiceServletNode = findSystemServiceServlet(document);
  if (systemServiceServletNode == null) {
    getLog().info("Not a valid web.xml document");
    return;
  }
  if (isElementAndNamed(systemServiceServletNode, WEB_APP)) {
    systemServiceServletNode = insertSystemServiceServlet(document,
            systemServiceServletNode, spc, delimiter);
    saveRequired = true;
  }

  saveRequired = updateSystemServiceServletParam(document,
          systemServiceServletNode, services);
  String generatedWebInf = outputDirectory + "/WEB-INF";      
  new File(generatedWebInf).mkdirs();
  saveFile(document, generatedWebInf + "/web.xml");
  Files.copy(
          new File(new File(webXmlPath).getParentFile(), "appengine-web.xml"),
          new File(generatedWebInf, "appengine-web.xml"));
}
 
Example 2
Source File: WebXmlProcessing.java    From gcloud-maven-plugin with Apache License 2.0 5 votes vote down vote up
public void updateWebXml(List<String> services, String webXmlPath)
    throws ParserConfigurationException, SAXException, IOException,
    TransformerFactoryConfigurationError, TransformerException {
  boolean saveRequired;

  String spc = " ";
  String delimiter = "\n";

  DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
  DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
  Document document = docBuilder.parse(webXmlPath);

  Node systemServiceServletNode = findSystemServiceServlet(document);
  if (systemServiceServletNode == null) {
    getLog().info("Not a valid web.xml document");
    return;
  }
  if (isElementAndNamed(systemServiceServletNode, WEB_APP)) {
    systemServiceServletNode = insertSystemServiceServlet(document,
        systemServiceServletNode, spc, delimiter);
    saveRequired = true;
  }

  saveRequired = updateSystemServiceServletParam(document,
      systemServiceServletNode, services);
  String generatedWebInf = outputDirectory + "/WEB-INF";
  new File(generatedWebInf).mkdirs();
  saveFile(document, generatedWebInf + "/web.xml");
  Files.copy(
      new File(new File(webXmlPath).getParentFile(), "appengine-web.xml"),
      new File(generatedWebInf, "appengine-web.xml"));
}