Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions buildScript/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ dependencies {
implementation 'org.asdf-format:asdf-core:0.1-alpha-10'
implementation 'edu.stsci:roman-datamodels:0.1-alpha-3'

// tomcat for standalone
implementation 'org.apache.tomcat.embed:tomcat-embed-core:11.0.21'
implementation 'org.apache.tomcat.embed:tomcat-embed-websocket:11.0.21'
implementation 'org.apache.tomcat.embed:tomcat-embed-jasper:11.0.21'

}


Expand Down
23 changes: 0 additions & 23 deletions config/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,29 +89,6 @@
<url-pattern>/CmdSrv/async/*</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>H2Console</servlet-name>
<servlet-class>org.h2.server.web.WebServlet</servlet-class>
<init-param>
<param-name>-webAllowOthers</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>H2Console</servlet-name>
<url-pattern>/admin/db/*</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>alertviewer</servlet-name>
<jsp-file>/alertviewer.html</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>alertviewer</servlet-name>
<url-pattern>/alertviewer/*</url-pattern>
</servlet-mapping>

<!-- Resources -->

<resource-ref>
Expand Down
3 changes: 2 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
rootProject.name = 'firefly_root'

include 'firefly', 'firefly_data'
include 'firefly', 'firefly_data', "firefly_standalone"

project(":firefly").projectDir = file('src/firefly')
project(":firefly_data").projectDir = file('src/firefly_data')
project(":firefly_standalone").projectDir = file('src/firefly_standalone')

Original file line number Diff line number Diff line change
Expand Up @@ -64,32 +64,35 @@ public static void initVersion(ServletContext context) {
}

public static void ingestVersion(ServletContext context) {

_version.setAppName(context.getServletContextName());
_version.setConfigLastModTime(ServerContext.getConfigLastModTime());

File confDir = ServerContext.getWebappConfigDir();
Properties props = new Properties();
try {
_version.setAppName(context.getServletContextName());
_version.setConfigLastModTime(ServerContext.getConfigLastModTime());

File confDir = ServerContext.getWebappConfigDir();
Properties props = new Properties();
props.load(new FileInputStream(new File(confDir, VERSION_FILE)));
_version.setMajor(getNum(props.getProperty(MAJOR)));
_version.setMinor(getNum(props.getProperty(MINOR)));
_version.setRev(props.getProperty(REV));
_version.setVersionType(Version.convertVersionType(props.getProperty(TYPE)));
_version.setBuild(getNum(props.getProperty(BUILD_NUMBER)));
_version.setBuildDate(props.getProperty(BUILD_DATE));
_version.setBuildTime(props.getProperty(BUILD_TIME));
_version.setBuildTag(props.getProperty(BUILD_TAG));
_version.setBuildCommit(props.getProperty(BUILD_COMMIT));
_version.setBuildCommitFirefly(props.getProperty(BUILD_COMMIT_FIREFLY));
_version.setBuildFireflyTag(props.getProperty(BUILD_FIREFLY_TAG));
_version.setBuildFireflyBranch(props.getProperty(BUILD_FIREFLY_BRANCH));
_version.setDevCycleTag(props.getProperty(DEV_CYCLE_TAG));
ingestVersion(props);
} catch (IOException e) {
// just ignore
}
}

public static void ingestVersion(Properties props) {
_version.setMajor(getNum(props.getProperty(MAJOR)));
_version.setMinor(getNum(props.getProperty(MINOR)));
_version.setRev(props.getProperty(REV));
_version.setVersionType(Version.convertVersionType(props.getProperty(TYPE)));
_version.setBuild(getNum(props.getProperty(BUILD_NUMBER)));
_version.setBuildDate(props.getProperty(BUILD_DATE));
_version.setBuildTime(props.getProperty(BUILD_TIME));
_version.setBuildTag(props.getProperty(BUILD_TAG));
_version.setBuildCommit(props.getProperty(BUILD_COMMIT));
_version.setBuildCommitFirefly(props.getProperty(BUILD_COMMIT_FIREFLY));
_version.setBuildFireflyTag(props.getProperty(BUILD_FIREFLY_TAG));
_version.setBuildFireflyBranch(props.getProperty(BUILD_FIREFLY_BRANCH));
_version.setDevCycleTag(props.getProperty(DEV_CYCLE_TAG));
}

public static Version getAppVersion() { return _version; }

private static int getNum(String s) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public class VisContext {

static public void init() {
if (_initialized) return;
System.setProperty("java.awt.headless", "true");
// System.setProperty("java.awt.headless", "true");
boolean desktop= AppProperties.getBooleanProperty("runAsDesktopApplication", false);
System.setProperty("java.awt.headless", desktop ? "false" : "true"); //todo make this smart depending on context, no PR until it is done!!!!
initFootprints();
initCounters();
_initialized = true;
Expand Down
3 changes: 0 additions & 3 deletions src/firefly/java/edu/caltech/ipac/util/StringUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package edu.caltech.ipac.util;

import edu.caltech.ipac.firefly.core.Util;
import edu.caltech.ipac.firefly.server.util.Logger;

import javax.validation.constraints.NotNull;
import java.net.MalformedURLException;
Expand Down Expand Up @@ -45,8 +44,6 @@ public static enum Align {LEFT, RIGHT, MIDDLE}
public static final long GIG_HUNDREDTH= GIG / 100;
public static final long K = 1024;

private static final Logger.LoggerImpl logger = Logger.getLogger();

public static String[] groupMatch(String regex, String val) {
return groupMatch(regex, val, 0);
}
Expand Down
72 changes: 47 additions & 25 deletions src/firefly/java/edu/caltech/ipac/util/download/URLDownload.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@

public class URLDownload {
private static final int BUFFER_SIZE = FileUtil.BUFFER_SIZE;
private static final Logger.LoggerImpl _log = Logger.getLogger();
private static final int MAX_REDIRECT= 2;

static {
Expand All @@ -83,7 +82,7 @@ public void checkServerTrusted(X509Certificate[] arg0, String arg1) { }
sc.init(null, trustAllCerts, null);
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
} catch (KeyManagementException | NoSuchAlgorithmException e) {
_log.error(e);
loggerError(e);
}
}

Expand Down Expand Up @@ -200,11 +199,13 @@ public static Map<String, String> buildReqHeaders(URL url, Map<String, String> r
if (requestHeaders== null) requestHeaders= Collections.emptyMap();
Map<String, String> h = new HashMap<>(requestHeaders);
if (ops==null || ops.useCredentials) {
var inputs= new HttpServiceInput(url.toString());
var credentials= inputs.getHeaders();
if (credentials!=null && !credentials.isEmpty()) {
if (!credentials.keySet().stream().allMatch(h::containsKey)) h.putAll(credentials);
}
try {
var inputs= new HttpServiceInput(url.toString());
var credentials= inputs.getHeaders();
if (credentials!=null && !credentials.isEmpty()) {
if (!credentials.keySet().stream().allMatch(h::containsKey)) h.putAll(credentials);
}
} catch (NoClassDefFoundError ignore) { }
}
return h;
}
Expand Down Expand Up @@ -247,7 +248,11 @@ private static String sendHeadersToCompactStr(Map<String,List<String>> sendHeade
}
}
else {
workBuff.append(sanitizeHeader(se.getKey(), String.valueOf(se.getValue())));
try {
workBuff.append(sanitizeHeader(se.getKey(), String.valueOf(se.getValue())));
} catch (NoClassDefFoundError e) {
workBuff.append(se.getKey()+"="+se.getValue());
}
}
outStr.append(workBuff.toString());
}
Expand Down Expand Up @@ -306,7 +311,7 @@ public static URLConnection makeConnection(URL url,
}
return conn;
} catch (IOException e) {
logError(url,null,e);
loggerError(url,null,e);
throw e;
}
}
Expand Down Expand Up @@ -390,10 +395,10 @@ public static HttpResultInfo getDataFromURL(URL url,
if (!ops.logErrorsOnly) logSuccess(result,url,dlSeconds,reqProp, postData);
return result;
} catch (SSLException | SocketTimeoutException | UnknownHostException e) {
logError(url, postData, e);
loggerError(url, postData, e);
return exceptionToResponse(e,requestHeaders);
} catch (IOException e) {
logError(url, postData, e);
loggerError(url, postData, e);
throw new FailedRequestException(ResponseMessage.getNetworkCallFailureMessage(e), e, getResponseCode(conn));
}
}
Expand All @@ -418,7 +423,7 @@ public static HttpResultInfo getHeader(URL url,
} catch (SSLException | SocketTimeoutException | UnknownHostException e) {
return exceptionToResponse(e,h);
} catch (IOException e) {
logError(url, null, e);
loggerError(url, null, e);
throw new FailedRequestException(ResponseMessage.getNetworkCallFailureMessage(e), e, -1);
}
}
Expand Down Expand Up @@ -476,10 +481,10 @@ private static HttpResultInfo getHeaderFromConnection(HttpURLConnection conn,
}
return result;
} catch (SSLException | SocketTimeoutException | UnknownHostException e) {
logError(conn.getURL(), null , e);
loggerError(conn.getURL(), null , e);
return exceptionToResponse(e,requestHeaders);
} catch (IOException e) {
logError(conn.getURL(), null, e);
loggerError(conn.getURL(), null, e);
throw new FailedRequestException(ResponseMessage.getNetworkCallFailureMessage(e), e, getResponseCode(conn));
}
}
Expand All @@ -505,7 +510,7 @@ public static FileInfo getDataToFileUsingPost(URL url, Map<String,?> postData,
Options ops= new Options(true, true, 0L, false, false, timeoutInSec, dl, false, false);
return getDataToFile(makeURLConnection(url, cookies, requestHeader), outfile, ops, postData,0);
} catch (IOException e) {
logError(url, postData, e);
loggerError(url, postData, e);
throw new FailedRequestException(ResponseMessage.getNetworkCallFailureMessage(e), e);
}
}
Expand Down Expand Up @@ -636,7 +641,7 @@ public static FileInfo getDataToFile(HttpURLConnection conn,
} catch (SSLException | SocketTimeoutException | UnknownHostException e) {
return exceptionToFileInfo(e);
} catch (IOException e) {
logError(conn.getURL(), null, e);
loggerError(conn.getURL(), null, e);
throw new FailedRequestException(ResponseMessage.getNetworkCallFailureMessage(e),e, getResponseCode(conn));
}
}
Expand Down Expand Up @@ -760,7 +765,7 @@ private static FileInfo checkAlreadyDownloaded(HttpURLConnection urlConn, File o
urlConn.setIfModifiedSince(outfile.lastModified());
if (getResponseCode(urlConn) == HttpURLConnection.HTTP_NOT_MODIFIED) {
String urlStr= urlConn.getURL().toString();
_log.info(outfile.getName() + ": Not downloading, already have current version, from "+urlStr);
loggerInfo(outfile.getName() + ": Not downloading, already have current version, from "+urlStr);
retval = new FileInfo(outfile, getSuggestedFileName(urlConn), HttpURLConnection.HTTP_NOT_MODIFIED,
ResponseMessage.getHttpResponseMessage(HttpURLConnection.HTTP_NOT_MODIFIED));
retval.putAttribute(FileInfo.FILE_DOWNLOADED,false+"");
Expand All @@ -774,7 +779,7 @@ private static FileInfo checkAlreadyDownloaded(HttpURLConnection urlConn, File o
}


private static void logError(URL url, Map<String,?> postData, Exception e) {
private static void loggerError(URL url, Map<String,?> postData, Exception e) {
List<String> strList = new ArrayList<>(6);
strList.add("----------Network Error-----------");
if (url != null) {
Expand All @@ -788,7 +793,7 @@ private static void logError(URL url, Map<String,?> postData, Exception e) {
strList.add(StringUtils.pad(20,"----------Exception "));
strList.add(e.toString());
}
_log.warn(strList.toArray(new String[0]));
loggerInfo(strList.toArray(new String[0]));
}

private static void logHeaderForError(String originalUrl, Map<String,?> postData, HttpURLConnection conn, Map<String,List<String>> sendHeaders) {
Expand Down Expand Up @@ -861,9 +866,9 @@ private static void logHeaderForError(String originalUrl, Map<String,?> postData
else {
outStr.add("No headers or status received, invalid http response, using work around");
}
_log.info(outStr.toArray(new String[0]));
loggerInfo(outStr.toArray(new String[0]));
} catch (Exception e) {
_log.info(e.getMessage() + ":" + " url=" + (conn.getURL()!=null ? conn.getURL().toString() : "none"));
loggerInfo(e.getMessage() + ":" + " url=" + (conn.getURL()!=null ? conn.getURL().toString() : "none"));
}
}

Expand All @@ -880,7 +885,7 @@ private static void logSuccess(FileInfo fileInfo, File outfile, URL url, double
"more response headers: "+otherHeadersToStr(fileInfo)
));
if (postData!=null) strList.add("post data: " +postDataLogString(postData));
_log.info(strList.toArray(new String[0]));
loggerInfo(strList.toArray(new String[0]));
}

private static void logSuccess(HttpResultInfo r, URL url, double dSeconds, Map<String,List<String>> sendHeaders, Map<String, ?> postData) {
Expand All @@ -889,7 +894,7 @@ private static void logSuccess(HttpResultInfo r, URL url, double dSeconds, Map<S
String postStr= (postData==null || postData.isEmpty()) ? "" : "\n Post Data :" + postDataLogString(postData);
String send= "send headers: "+sendHeadersToCompactStr(sendHeaders) + postStr;

_log.info(
loggerInfo(
String.format( "DOWNLOAD to memory (%.1f sec, %s, response: %d): Content-Type: %s, Content-Length: %s%s",
dSeconds, formatedSize, r.getResponseCode(), r.getContentType(), r.getContentLength(), lastMod),
"url: "+ url.toString(),
Expand Down Expand Up @@ -960,14 +965,14 @@ private static DataInputStream makeEncodedInStream(HttpURLConnection conn) throw
} else if (encodeType.toLowerCase().endsWith("deflate")) {
return new DataInputStream(new InflaterInputStream(makeInStream(conn)));
} else {
_log.warn("unrecognized Content-encoding: " + encodeType, "cannot uncompress");
loggerInfo("unrecognized Content-encoding: " + encodeType, "cannot uncompress");
return makeDataInStream(conn);
}
}

private static DataInputStream makeDataInStream(HttpURLConnection conn) throws IOException {
if (getResponseCode(conn)==-1) {
_log.warn("Http Response Code is -1, invalid http protocol, " +
loggerInfo("Http Response Code is -1, invalid http protocol, " +
"probably no status line in response headers- trying anyway");
return new DataInputStream(makeInStream(conn));
}
Expand Down Expand Up @@ -1000,6 +1005,23 @@ private static String combineValues(List<String> values) {
return workBuff.toString();
}

private static void loggerInfo(String ...msgs) {
try {
Logger.getLogger().info(msgs);
} catch (NoClassDefFoundError t) {
Arrays.stream(msgs).forEach(System.out::println);
}
}

private static void loggerError(Throwable t, String ...msgs) {
try {
Logger.getLogger().error(t, msgs);
} catch (NoClassDefFoundError e) {
System.out.println(t.getMessage());
Arrays.stream(msgs).forEach(System.out::println);
}
}

public static class Options {
private boolean onlyIfModified;
private boolean uncompress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ public static void setDefaultFutureStretch(RangeValues defaultRangeValues) {
* @param lsstMasks mask array
* @deprecated
*/
@Deprecated
public synchronized void doStretchMask(
byte[] pixelData,
int startPixel,
Expand Down
Binary file added src/firefly_standalone/assets/fireflyDockIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/firefly_standalone/assets/fireflySplash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading