Skip to content

Commit

Permalink
Merge pull request #6 from genepattern/develop
Browse files Browse the repository at this point in the history
release 1.2.5 fix for '/gp/jobResults'
  • Loading branch information
Peter J Carr authored May 8, 2017
2 parents 7163f29 + 8aa610f commit 82999ff
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 22 deletions.
File renamed without changes.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
## VisualizerLauncher
Launches a GenePattern visualizer from the desktop. Use this as a replacement for the 'Open Visualizer' link embedded in the web page. The application is available for download directly from the [releases](https://github.com/genepattern/VisualizerLauncher/releases/latest) page.

See the [INSTALL page](INSTALL.md) for instructions on building the application.
Launch a GenePattern visualizer from the desktop. Use this as a replacement for the 'Open Visualizer' link on the Job Status page.

See the [home page](https://genepattern.github.io/VisualizerLauncher/) for more usage instructions.
See the [home page](https://genepattern.github.io/VisualizerLauncher/) for usage instructions.

### Developer documentation

See the [BUILD page](BUILD.md) for instructions on building the application from source code.

### Release archive

See the [releases page](https://github.com/genepattern/VisualizerLauncher/releases/latest) for release notes and older versions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>genepattern.org</groupId>
<artifactId>visualizerLauncher</artifactId>
<version>1.2.4</version>
<version>1.2.5</version>
<name>VisualizerLauncher</name>
<url>http://maven.apache.org</url>

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/genepattern/desktop/JobInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class JobInfo
private String jobNumber;
private GPTask gpTask;
private String[] commandLine;
private Map inputURLToFilePathMap;
private Map<String,String> inputURLToFilePathMap;

public String getJobNumber() {
return jobNumber;
Expand Down Expand Up @@ -40,7 +40,7 @@ public Map<String, String> getInputURLToFilePathMap() {
return inputURLToFilePathMap;
}

public void setInputURLToFilePathMap(Map inputURLToFilePathMap) {
public void setInputURLToFilePathMap(Map<String,String> inputURLToFilePathMap) {
this.inputURLToFilePathMap = inputURLToFilePathMap;
}
}
12 changes: 7 additions & 5 deletions src/main/java/org/genepattern/desktop/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,18 @@ protected static String retrieveJobDetails(final String basicAuthHeader, final S
* @param dir, The directory to download the URL to.
* @param filename, The filename to download the URL to.
*/
public static File downloadFile(String authString, URL fromUrl, File toDir, String filename) throws IOException {
public static File downloadFile(final String authString, final URL fromUrl, final File toDir, final String filename) throws IOException {
InputStream is = null;
FileOutputStream fos = null;
File file = null;
File toFile = null;
try {
URLConnection conn = fromUrl.openConnection();
conn.setRequestProperty("Authorization", authString);

is = conn.getInputStream();
toDir.mkdirs();
file = new File(toDir, filename);
fos = new FileOutputStream(file);
toFile = new File(toDir, filename);
fos = new FileOutputStream(toFile);
byte[] buf = new byte[100000];
int j;
while ((j = is.read(buf, 0, buf.length)) != -1) {
Expand All @@ -136,17 +136,19 @@ public static File downloadFile(String authString, URL fromUrl, File toDir, Stri
is.close();
}
catch (IOException e) {
log.error("Unexpected error closing input stream, fromUrl="+fromUrl, e);
}
}
if (fos != null) {
try {
fos.close();
}
catch (IOException e) {
log.error("Unexpected error closing output stream, toFile="+toFile, e);
}
}
}
return file;
return toFile;
}

/** create thread to read from a process output or error stream */
Expand Down
33 changes: 22 additions & 11 deletions src/main/java/org/genepattern/desktop/VisualizerLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class VisualizerLauncher {
this.jobInfo = new JobInfo();
}

private void login() {
private void run() {
JPanel panel = new JPanel(new GridLayout(4, 1));
panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

Expand Down Expand Up @@ -182,10 +182,6 @@ public void actionPerformed(ActionEvent e) {
frame.setVisible(true);
}

public void run() {
login();
}

private void downloadSupportFiles(final GPTask task) throws Exception {
for(final String supportFileURL : task.getSupportFileUrls()) {
final int slashIndex = supportFileURL.lastIndexOf('=');
Expand Down Expand Up @@ -317,6 +313,10 @@ private void prepareCommandLineStep() throws IOException {
final String[] cmdLineList = new String[cmdLineArr.length()];
for(int i=0;i< cmdLineArr.length(); i++) {
String argValue = cmdLineArr.getString(i);
if (argValue.startsWith("/gp/")) {
// e.g. gpServer=http://127.0.0.1:8080/gp
argValue=argValue.replaceFirst("/gp", gpServer);
}
if(inputURLMap.containsKey(argValue)) {
argValue = downloadLocation.getAbsolutePath() + "/" + inputURLMap.get(argValue);
}
Expand Down Expand Up @@ -355,17 +355,28 @@ protected void downloadInputFiles() throws Exception {
final JSONArray inputFiles=inputFilesJsonObj.getJSONArray("inputFiles");
final Map<String, String> map = new HashMap<String, String>();
for(int i=0;i<inputFiles.length();i++) {
String inputFile = inputFiles.getString(i);
if (inputFile.startsWith("<GenePatternURL>")) {
inputFile=inputFile.replaceFirst("<GenePatternURL>", gpServer+"/");
}
final String filenameWithExtension=filenameWithExt(inputFile);
final URL fileURL = downloadInputFile(inputFile);
final String inputFile = inputFiles.getString(i);
final String inputFileUrlStr=initInputFileUrlStr(inputFile);
final String filenameWithExtension=filenameWithExt(inputFileUrlStr);
final URL fileURL = downloadInputFile(inputFileUrlStr);
map.put(fileURL.toString(), filenameWithExtension);
}
jobInfo.setInputURLToFilePathMap(map);
}

protected String initInputFileUrlStr(final String inputFile) {
if (inputFile.startsWith("<GenePatternURL>")) {
return inputFile.replaceFirst("<GenePatternURL>", gpServer+"/");
}
else if (inputFile.startsWith("/gp/")) {
// e.g. gpServer=http://127.0.0.1:8080/gp
return inputFile.replaceFirst("/gp", gpServer);
}
else {
return inputFile;
}
}

protected String filenameWithExt(final String inputFile) {
final int slashIndex = inputFile.lastIndexOf('/');
final String filenameWithExtension = inputFile.substring(slashIndex + 1);
Expand Down

0 comments on commit 82999ff

Please sign in to comment.