Skip to content

Commit

Permalink
[MSITE-945] Remove dependency on Commons IO
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Osipov <[email protected]>

This closes #202
  • Loading branch information
FredrikAnderson authored and michael-o committed Jul 29, 2024
1 parent 6fc5d17 commit be35f64
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
7 changes: 0 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -487,13 +487,6 @@ under the License.
<scope>test</scope>
</dependency>

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.16.1</version>
<scope>test</scope>
</dependency>

<!-- test -->
<dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.io.FileUtils;
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
import org.apache.maven.bridge.MavenRepositorySystem;
import org.apache.maven.doxia.tools.SiteTool;
Expand Down Expand Up @@ -220,12 +220,12 @@ public void davDeployThruProxyWitAuthzInProxy() throws Exception {
private void assertContentInFiles() throws Exception {
File htmlFile = new File(siteTargetPath, "site" + File.separator + "index.html");
assertTrue(htmlFile.exists());
String fileContent = FileUtils.readFileToString(htmlFile, StandardCharsets.UTF_8);
assertTrue(fileContent.contains("Welcome to Apache Maven"));
String htmlContent = new String(Files.readAllBytes(htmlFile.toPath()), StandardCharsets.UTF_8);
assertTrue(htmlContent.contains("Welcome to Apache Maven"));

File cssFile = new File(siteTargetPath, "site" + File.separator + "css" + File.separator + "maven-base.css");
assertTrue(cssFile.exists());
String cssContent = FileUtils.readFileToString(cssFile, StandardCharsets.UTF_8);
String cssContent = new String(Files.readAllBytes(cssFile.toPath()), StandardCharsets.UTF_8);
assertTrue(cssContent.contains("background-image: url(../images/collapsed.gif);"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@

import java.io.File;
import java.io.IOException;
import java.util.*;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Enumeration;
import java.util.List;
import java.util.Map;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.eclipse.jetty.proxy.AsyncProxyServlet;

/**
Expand Down Expand Up @@ -121,7 +124,8 @@ public void service(ServletRequest req, ServletResponse res) throws ServletExcep

if (request.getMethod().equalsIgnoreCase("PUT") && targetPath != null) {
File targetFile = new File(siteTargetPath, targetPath);
FileUtils.writeByteArrayToFile(targetFile, IOUtils.toByteArray(request.getInputStream()));
targetFile.getParentFile().mkdirs();
Files.copy(request.getInputStream(), targetFile.toPath());
}

response.setStatus(HttpServletResponse.SC_OK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
Expand Down Expand Up @@ -74,7 +73,8 @@ public void handle(String target, Request r, HttpServletRequest request, HttpSer

if (request.getMethod().equalsIgnoreCase("PUT")) {
File targetFile = new File(siteTargetPath, targetPath);
FileUtils.writeByteArrayToFile(targetFile, IOUtils.toByteArray(request.getInputStream()));
targetFile.getParentFile().mkdirs();
Files.copy(request.getInputStream(), targetFile.toPath());
}

// PrintWriter writer = response.getWriter();
Expand Down

0 comments on commit be35f64

Please sign in to comment.