class TempletonUtils {

  public static String addUserHomeDirectoryIfApplicable(String origPathStr, String user)
    throws IOException, URISyntaxException {
    URI uri = new URI(origPathStr);

    if (uri.getPath().isEmpty()) {
      String newPath = "/user/" + user;
      uri = UriBuilder.fromUri(uri).replacePath(newPath).build();
    } else if (!new Path(uri.getPath()).isAbsolute()) {
      String newPath = "/user/" + user + "/" + uri.getPath();
      uri = UriBuilder.fromUri(uri).replacePath(newPath).build();
    } // no work needed for absolute paths

    return uri.toString();
  }

}