Skip to content

Commit

Permalink
Compilable by Java 1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
pandzel committed Apr 12, 2016
1 parent ec68820 commit 2f67fd1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void onMetadata(ExecutionUnit unit, Publishable record) throws IOExceptio
File f = generateFileName(record.getSourceUri());
f.getParentFile().mkdirs();
if (!f.getName().contains(".")) {
f = f.getParentFile().toPath().resolve(f.getName()+".xml").toFile();
f = new File(f.getParentFile(),f.getName()+".xml");
}
FileOutputStream output = null;
ByteArrayInputStream input = null;
Expand All @@ -120,7 +120,7 @@ public void onMetadata(ExecutionUnit unit, Publishable record) throws IOExceptio
public void onStart(ExecutionUnit unit) {
try {
URL hostUrl = new URL(unit.getRepository().getHostUrl());
destinationFolder = rootFolder!=null? rootFolder.toPath().resolve(hostUrl.getHost()).toFile(): null;
destinationFolder = rootFolder!=null? new File(rootFolder,hostUrl.getHost()): null;
subFolder = splitPath(hostUrl.getPath());
} catch (MalformedURLException ex) {
LOG.log(Level.SEVERE, "Error starting harvesting", ex);
Expand Down Expand Up @@ -150,17 +150,17 @@ private File generateFileName(SourceUri uri) {
}

for (String t: stock) {
fileName = fileName.toPath().resolve(t).toFile();
fileName = new File(fileName,t);
}
return fileName;
} catch (MalformedURLException ex) {
if (UuidUtil.isUuid(sUri)) {
fileName = fileName.toPath().resolve(sanitizeFileName(sUri)+".xml").toFile();
fileName = new File(fileName,sanitizeFileName(sUri)+".xml");
return fileName;
} else {
File f = new File(sanitizeFileName(sUri)+".xml");
for (String t: StringListUtil.merge(subFolder,splitPath(f))) {
fileName = fileName.toPath().resolve(t).toFile();
fileName = new File(fileName,t);
}
return fileName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@

import java.io.File;
import java.net.URL;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

/**
Expand Down Expand Up @@ -57,10 +56,11 @@ public static List<String> splitPath(URL u) {
* @return list of elements
*/
public static List<String> splitPath(File f) {
ArrayList<String> path = new ArrayList<String>();
Iterator<Path> i = f.toPath().iterator();
while (i.hasNext()) {
path.add(sanitizeFileName(i.next().toString()));
LinkedList<String> path = new LinkedList<String>();
while (f!=null) {
String name = f.getParentFile()!=null? f.getName(): f.getPath();
path.push(name);
f = f.getParentFile();
}
return path;
}
Expand Down

0 comments on commit 2f67fd1

Please sign in to comment.